Compare commits

...

5 Commits

Author SHA1 Message Date
24a7f2c937 delete obsolete url 2023-03-21 15:38:58 +03:00
fa6ecea0f0 add scroll calculations 2023-03-21 15:38:51 +03:00
c5f55c807a change url to right var 2023-03-21 15:38:36 +03:00
c05f542e71 add body absolute pos 2023-03-21 15:38:20 +03:00
1175cf3e98 add dockerfile 2023-03-21 15:38:03 +03:00
7 changed files with 53 additions and 85 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
### STAGE 1: build ###
FROM golang:1.18-alpine AS build
WORKDIR /usr/app
COPY . .
RUN go build .
RUN ls -a
### STAGE 2: Run ###
FROM golang:1.18-alpine
WORKDIR /usr/app
COPY --from=build /usr/app/personalwebsite /usr/app/personalwebsite
COPY ./templates /usr/app/templates
COPY ./resources /usr/app/resources
EXPOSE 8080
CMD [ "/usr/app/personalwebsite" ]

View File

@ -28,7 +28,6 @@ import (
// } // }
func main() { func main() {
// hostUrl := "http://localhost:8080/"
router := gin.New() router := gin.New()
router.LoadHTMLGlob("templates/**/*") router.LoadHTMLGlob("templates/**/*")

View File

@ -17,6 +17,9 @@
} }
body{ body{
position: absolute;
width: 100%;
height: 100%;
margin: 0px; margin: 0px;
/* font: normal 14px Summer Pixel 22, "res/SummerPixel22Regular.ttf"; */ /* font: normal 14px Summer Pixel 22, "res/SummerPixel22Regular.ttf"; */
-webkit-touch-callout: none; /* iOS Safari */ -webkit-touch-callout: none; /* iOS Safari */

View File

@ -11,7 +11,7 @@ class Finder{
Init(){ Init(){
console.log("Init") console.log("Init")
fetch(`http://localhost:8080/application/${this.appId}/render`) //TODO Move to wde func fetch(`${window.location.origin}/application/${this.appId}/render`) //TODO Move to wde func
.then((response) => response.text()) .then((response) => response.text())
.then((html) => { .then((html) => {
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, "Finder", 600, 500) let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, "Finder", 600, 500)

View File

@ -12,28 +12,18 @@ class PersonalProperties{
Init(){ Init(){
console.log("Init") console.log("Init")
fetch("http://localhost:8080/application/personal-properties/render") //TODO Move to wde func fetch(`${window.location.origin}/application/personal-properties/render`) //TODO Move to wde func. Or Not?
.then((response) => response.text()) .then((response) => response.text())
.then((html) => { .then((html) => {
//TODO Get ~70% of user screen height // console.log(document.body)
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, "Personal Properties", 300, 500) // let heigth = Math.max(document.body.clientHeight*0.8, scrollDiv.children[0].scrollHeight) //TODO
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, "Personal Properties", 360, document.body.clientHeight*0.8 )
newWindow.innerHTML = html newWindow.innerHTML = html
let closeButton = newWindow.children[0].children[0] let closeButton = newWindow.children[0].children[0]
let scrollDiv = newWindow.children[1] let scrollDiv = newWindow.children[1]
// console.log(scrollDiv) let scrollBar = new WdeScrollBar(scrollDiv.children[1].children[0], scrollDiv.children[0])
let scrollBar = new WdeScrollBar(scrollDiv.children[1].children[0])
console.log(scrollBar)
// scrollBar.BindHandler(scrollDiv.children[1].children[0])
// scrollBar.BindHandler(scrollDiv.children[1].children[0])
// SimpleScrollbar.initEl(scrollDiv)
// console.log("SimpleBar" + SimpleScrollbar)
// SimpleScrollbar.initAll();
closeButton.addEventListener('click', function (params) { closeButton.addEventListener('click', function (params) {
WebDesktopEnvironment.CloseWindow(newWindow) WebDesktopEnvironment.CloseWindow(newWindow)
@ -43,13 +33,4 @@ class PersonalProperties{
WebDesktopEnvironment.Alert(error); WebDesktopEnvironment.Alert(error);
}); });
} }
CloseWindow(id){
console.log(id+"Close")
}
}
function reply_click(){
console.log("QQQQQQQQQQQQQQQQQQQ")
} }

View File

@ -1,83 +1,49 @@
class WdeScrollBar{ class WdeScrollBar{
// max = 0
// isDragged = false
/** /**
* @param {HTMLElement} handler * @param {HTMLElement} handler
* @param {HTMLElement} content
*/ */
constructor(handler){ constructor(handler, content){
console.log( handler.clientHeight) let nonNativeScroll = false
handler.style.height = (content.clientHeight /content.scrollHeight)* handler.parentElement.clientHeight + 'px'
let max = handler.parentElement.clientHeight - handler.clientHeight let max = handler.parentElement.clientHeight - handler.clientHeight
let yOffset = null
let yPosInit = 0 let yPosInit = 0
handler.addEventListener('mousedown', (event) => { handler.addEventListener('mousedown', (event) => {
// yOffset = event.offsetY nonNativeScroll = true
yPosInit = event.clientY - Number(handler.style.top.replace('px','' )) yPosInit = event.clientY - Number(handler.style.top.replace('px','' ))
// console.log()
document.addEventListener('mousemove', drag); document.addEventListener('mousemove', drag);
document.addEventListener('mouseup', stop) document.addEventListener('mouseup', stop)
//TODO Document dissallow select })
content.addEventListener('scroll', (event) =>{
if (!this.nonNativeScroll){
let handlerPathLength = handler.parentElement.clientHeight - handler.clientHeight //TODO recalculate only on resize event
let coefficient = (content.scrollHeight - content.clientHeight) /handlerPathLength
handler.style.top = content.scrollTop/coefficient + 'px'
}
}) })
function drag() { function drag() {
// console.log(event.clientY - yPosInit, Number(handler.style.top.replace('px','' )))
console.log(event.clientY - yPosInit, Number(handler.style.top.replace('px','' )))
let pos = event.clientY - yPosInit let pos = event.clientY - yPosInit
let clampPos = Math.min(Math.max(pos, 0), max) let clampPos = Math.min(Math.max(pos, 0), max)
handler.style.top = clampPos + "px"; handler.style.top = clampPos + "px";
let handlerPathLength = handler.parentElement.clientHeight - handler.clientHeight //TODO recalculate only on resize event
let coefficient = (content.scrollHeight - content.clientHeight) /handlerPathLength
// console.log(clampPos, coefficient, content.clientHeight, clampPos* coefficient)
// let yPos = Number(handler.style.top.replace('px', 0)) content.scrollTop = clampPos* coefficient
// console.log(event)
// console.log(yOffset)
// console.log(event.movementY)
// let pos = event.clientY - handler.clientHeight
// console.log(pos)
// let pos2 = yPos + event.movementY
// console.log(event.clientY - yPosInit)
// console.log(event.offsetY)
// yPos += event.yOffset
// handler.style.top = event.clientY - yPosInit + 'px'
// console.log(handler.Y)
// let pos = yPosInit - event.clientY
// let newPos = Math.min(Math.max(pos, 0), max)
// console.log(handler.style.top , event.offsetY)
// handler.style.top = event.clientY+ "px";
} }
function stop() { function stop() {
console.log("stop") // console.log("stop")
document.removeEventListener('mousemove', drag); document.removeEventListener('mousemove', drag);
document.removeEventListener('mouseup', stop) document.removeEventListener('mouseup', stop)
nonNativeScroll = false
} }
} }
// /**
// * @param {HTMLElement} element
// */
// BindHandler(element) {
// element.addEventListener('mousedown', (event) => {
// this.isDragged =
// element.addEventListener('mouseup', this.stop);
// });
// element.removeEventListener
// }
// drag(){
// }
// stop(doc){
// console.log("stop")
// doc.removeEventListener('mouseup', (event) => {
// this.stop(document)
// });
// }
// MoveHandler(param) {
// console.log("Move")
// }
} }

View File

@ -4,10 +4,11 @@ document.addEventListener('DOMContentLoaded', function() {
class WebDesktopEnvironment{ class WebDesktopEnvironment{
constructor(){ constructor(){
// console.log(window)
this.wc = new WindowsCompositor this.wc = new WindowsCompositor
//Get basic window ready frame //Get basic window ready frame
fetch("http://localhost:8080/system/wde/getbasicwindow") //TODO Move to wde func fetch(`${window.location.origin}/system/wde/getbasicwindow`) //TODO Move to wde func
.then((response) => response.text()) .then((response) => response.text())
.then((html) => { .then((html) => {
WebDesktopEnvironment.SetBasicWindow(html) WebDesktopEnvironment.SetBasicWindow(html)
@ -31,7 +32,7 @@ class WebDesktopEnvironment{
let script = document.createElement("script") let script = document.createElement("script")
script.setAttribute("src", `http://localhost:8080/system/applications/${appId}/app.js`) script.setAttribute("src", `${window.location.origin}/system/applications/${appId}/app.js`)
script.setAttribute("async", "false") script.setAttribute("async", "false")
appElem.appendChild(script) appElem.appendChild(script)
script.addEventListener("load", function () { script.addEventListener("load", function () {
@ -92,6 +93,7 @@ class WebDesktopEnvironment{
static Alert(alertText){ static Alert(alertText){
console.log(alertText) console.log(alertText)
} }
} }
var getJSON = function(url, callback) { var getJSON = function(url, callback) {