Compare commits
6 Commits
8cb9b62b9d
...
c1bed6e2cd
Author | SHA1 | Date | |
---|---|---|---|
c1bed6e2cd | |||
10a7cf9301 | |||
6ef9ac2df1 | |||
eaa3ce9d5d | |||
9478c6c8dd | |||
dc7bf44576 |
@ -20,8 +20,7 @@ class Finder{
|
|||||||
let fileView = new FileView("/kek", newWindow.querySelector(".FileTileView"), Finder.Click)
|
let fileView = new FileView("/kek", newWindow.querySelector(".FileTileView"), Finder.Click)
|
||||||
if (!WebDesktopEnvironment.isMobile){
|
if (!WebDesktopEnvironment.isMobile){
|
||||||
let scrollBar = new WdeScrollBar(newWindow.children[1].children[1], newWindow.children[1].children[0])// TODO to querry selector
|
let scrollBar = new WdeScrollBar(newWindow.children[1].children[1], newWindow.children[1].children[0])// TODO to querry selector
|
||||||
let closeButton = newWindow.children[0].children[0] //TODO to query selector
|
newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) {
|
||||||
closeButton.addEventListener('click', function (params) {
|
|
||||||
WebDesktopEnvironment.CloseWindow(newWindow)
|
WebDesktopEnvironment.CloseWindow(newWindow)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,13 @@ class ImgViewer{
|
|||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((html) => {
|
.then((html) => {
|
||||||
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 450,400 )
|
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 450,400 )
|
||||||
|
|
||||||
newWindow.innerHTML = html
|
newWindow.innerHTML = html
|
||||||
|
|
||||||
let closeButton = newWindow.children[0].children[0]
|
if (!WebDesktopEnvironment.isMobile){
|
||||||
|
newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) {
|
||||||
closeButton.addEventListener('click', function (params) {
|
WebDesktopEnvironment.CloseWindow(newWindow)
|
||||||
WebDesktopEnvironment.CloseWindow(newWindow)
|
})
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
WebDesktopEnvironment.Alert(error);
|
WebDesktopEnvironment.Alert(error);
|
||||||
|
@ -22,11 +22,10 @@ class PersonalProperties{
|
|||||||
|
|
||||||
newWindow.innerHTML = html
|
newWindow.innerHTML = html
|
||||||
|
|
||||||
let closeButton = newWindow.querySelector("closeWindowButton")
|
let scrollBar = new WdeScrollBar(newWindow.querySelector('.ScrollBarScrollElement'), newWindow.querySelector('.ScrollContent'))
|
||||||
let scrollDiv = newWindow.children[1]
|
|
||||||
let scrollBar = new WdeScrollBar(scrollDiv.children[1].children[0], scrollDiv.children[0])
|
|
||||||
|
|
||||||
closeButton.addEventListener('click', function (params) {
|
newWindow.querySelector("#closeWindowButton").addEventListener('click', () => {
|
||||||
|
console.log("qewqweqweqweqwe")
|
||||||
WebDesktopEnvironment.CloseWindow(newWindow)
|
WebDesktopEnvironment.CloseWindow(newWindow)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//TODO Delete this file
|
||||||
;(function(root, factory) {
|
;(function(root, factory) {
|
||||||
if (typeof exports === 'object') {
|
if (typeof exports === 'object') {
|
||||||
module.exports = factory(window, document)
|
module.exports = factory(window, document)
|
||||||
|
101
resources/wde.js
101
resources/wde.js
@ -3,6 +3,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
wde = new WebDesktopEnvironment
|
wde = new WebDesktopEnvironment
|
||||||
if (!WebDesktopEnvironment.isMobile){
|
if (!WebDesktopEnvironment.isMobile){
|
||||||
WebDesktopEnvironment.Open("finder", ["kek"])
|
WebDesktopEnvironment.Open("finder", ["kek"])
|
||||||
|
WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -13,9 +14,8 @@ class WebDesktopEnvironment{
|
|||||||
static Applications = {};
|
static Applications = {};
|
||||||
static isMobile = false
|
static isMobile = false
|
||||||
constructor(){
|
constructor(){
|
||||||
this.wc = new WindowsCompositor
|
|
||||||
WebDesktopEnvironment.isMobile = WebDesktopEnvironment.CheckMobile()
|
WebDesktopEnvironment.isMobile = WebDesktopEnvironment.CheckMobile()
|
||||||
|
|
||||||
let applications = document.createElement("div")
|
let applications = document.createElement("div")
|
||||||
applications.setAttribute('id', 'applications')
|
applications.setAttribute('id', 'applications')
|
||||||
document.body.appendChild(applications)
|
document.body.appendChild(applications)
|
||||||
@ -26,40 +26,36 @@ class WebDesktopEnvironment{
|
|||||||
let mobileDesktop = document.createElement("div")
|
let mobileDesktop = document.createElement("div")
|
||||||
mobileDesktop.setAttribute('id', 'mobile-desktop')
|
mobileDesktop.setAttribute('id', 'mobile-desktop')
|
||||||
document.body.appendChild(mobileDesktop)
|
document.body.appendChild(mobileDesktop)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// let windowsLayer = document.createElement("div")
|
|
||||||
// windowsLayer.setAttribute('id', 'windows-layer')
|
|
||||||
|
|
||||||
// mobileDesktop.appendChild(windowsLayer)
|
|
||||||
|
|
||||||
fetch(`${window.location.origin}/system/wde/renderMobileDesktop` )
|
fetch(`${window.location.origin}/system/wde/renderMobileDesktop` )
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((html) => {
|
.then((html) => {
|
||||||
mobileDesktop.innerHTML = html
|
mobileDesktop.innerHTML = html
|
||||||
WebDesktopEnvironment.LoadApp("finder", () =>{
|
WebDesktopEnvironment.LoadApp("finder", () =>{
|
||||||
console.log("lel")
|
|
||||||
new FileView("/kek", mobileDesktop.querySelector(".FileTileView"), Finder.Click)
|
new FileView("/kek", mobileDesktop.querySelector(".FileTileView"), Finder.Click)
|
||||||
|
|
||||||
mobileDesktop.querySelector('#about-me').addEventListener('click', (event) => {
|
mobileDesktop.querySelector('#about-me').addEventListener('click', (event) => {
|
||||||
|
//TODO Do not allow launch second instance
|
||||||
WebDesktopEnvironment.Open("personal-properties", [])
|
WebDesktopEnvironment.Open("personal-properties", [])
|
||||||
})
|
})
|
||||||
|
mobileDesktop.querySelector('#mobile-dekstop-close').addEventListener('click', (event) => {
|
||||||
|
// console.log('close')
|
||||||
|
WebDesktopEnvironment.CloseFocusedWindow()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}).then(()=>{
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
WebDesktopEnvironment.Alert(error);
|
WebDesktopEnvironment.Alert(error);
|
||||||
})
|
})
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
document.body.style.setProperty('--zoom', 1)
|
document.body.style.setProperty('--zoom', 1)
|
||||||
|
|
||||||
let windowsLayer = document.createElement("div")
|
let windowsLayer = document.createElement("div")
|
||||||
windowsLayer.setAttribute('id', 'windows-layer')
|
windowsLayer.setAttribute('id', 'windows-layer')
|
||||||
document.body.appendChild(windowsLayer)
|
document.body.appendChild(windowsLayer)
|
||||||
}
|
}
|
||||||
|
this.wc = new WindowsCompositor
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -68,18 +64,13 @@ class WebDesktopEnvironment{
|
|||||||
* @returns {Application | undefined}
|
* @returns {Application | undefined}
|
||||||
*/
|
*/
|
||||||
static LoadApp(appId, func){
|
static LoadApp(appId, func){
|
||||||
console.log(`Load application ${appId}`)
|
// console.log(`Load application ${appId}`)
|
||||||
|
|
||||||
// let appDiv = document.createElement("application")
|
|
||||||
// appDiv.setAttribute("id", `application-${appId}`)
|
|
||||||
// document.getElementById("applications").appendChild(appDiv)
|
|
||||||
|
|
||||||
let script = document.createElement("script")
|
let script = document.createElement("script")
|
||||||
script.setAttribute("appId", appId)
|
script.setAttribute("appId", appId)
|
||||||
script.setAttribute("src", `${window.location.origin}/system/applications/${appId}/app.js`)
|
script.setAttribute("src", `${window.location.origin}/system/applications/${appId}/app.js`)
|
||||||
script.setAttribute("async", "false")
|
script.setAttribute("async", "false")
|
||||||
document.getElementById("applications").appendChild(script)
|
document.getElementById("applications").appendChild(script)
|
||||||
// let appElem = document.getElementById("applications").appendChild(script)
|
|
||||||
|
|
||||||
script.addEventListener('load', (event) =>{
|
script.addEventListener('load', (event) =>{
|
||||||
switch (appId) {
|
switch (appId) {
|
||||||
@ -127,7 +118,6 @@ class WebDesktopEnvironment{
|
|||||||
* @returns {HTMLElement}
|
* @returns {HTMLElement}
|
||||||
*/
|
*/
|
||||||
static CreateNewWindow(appId, width, height) {
|
static CreateNewWindow(appId, width, height) {
|
||||||
// let appElem = document.getElementById(`application-${appId}`)
|
|
||||||
let newWindow = document.createElement("div")
|
let newWindow = document.createElement("div")
|
||||||
if (WebDesktopEnvironment.isMobile){
|
if (WebDesktopEnvironment.isMobile){
|
||||||
newWindow.setAttribute("class", "MobileApplicationWindow")
|
newWindow.setAttribute("class", "MobileApplicationWindow")
|
||||||
@ -148,13 +138,13 @@ class WebDesktopEnvironment{
|
|||||||
* @param {HTMLElement} window
|
* @param {HTMLElement} window
|
||||||
*/
|
*/
|
||||||
static CloseWindow(window) {
|
static CloseWindow(window) {
|
||||||
let app = window.parentElement
|
|
||||||
window.remove()
|
window.remove()
|
||||||
// console.log(app.childElementCount)
|
}
|
||||||
// if (app.childElementCount < 2){
|
|
||||||
// console.log(app)
|
static CloseFocusedWindow() {
|
||||||
// app.remove()
|
if (document.body.querySelector('#windows-layer').childElementCount > 1){
|
||||||
// }
|
document.body.querySelector('#windows-layer').lastElementChild.remove()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +158,6 @@ class WebDesktopEnvironment{
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
static GetBasicWindow(){
|
static GetBasicWindow(){
|
||||||
// console.log(this.basicWindow)
|
|
||||||
return this.basicWindow
|
return this.basicWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,34 +191,53 @@ var getJSON = function(url, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class WindowsCompositor{
|
class WindowsCompositor{
|
||||||
|
windowLayer = undefined
|
||||||
movingElement = null
|
movingElement = null
|
||||||
|
xPosInit = 0
|
||||||
|
yPosInit = 0
|
||||||
|
|
||||||
|
//TODO refactor this to dynamic add/remove listeners
|
||||||
constructor(){
|
constructor(){
|
||||||
console.log("Windows Compositor is online :)");
|
this.windowLayer = document.body.querySelector('#windows-layer')
|
||||||
addEventListener("mousedown", (event) => {
|
if (!WebDesktopEnvironment.isMobile) {
|
||||||
this.catchClick(event)
|
addEventListener("mousedown", (event) => {
|
||||||
})
|
this.xPosInit = event.offsetX
|
||||||
addEventListener("mouseup", (event) => {
|
this.yPosInit = event.offsetY
|
||||||
this.movingElement = null
|
|
||||||
})
|
this.bringWindowToFront(event.target.closest('.StandartApplicationWindow'))
|
||||||
addEventListener("mousemove", (event) => {
|
|
||||||
if (this.movingElement != null) {
|
this.catchClick(event)
|
||||||
this.dragElement(this.movingElement, event.clientX, event.clientY)
|
|
||||||
} else {
|
})
|
||||||
|
addEventListener("mouseup", (event) => {
|
||||||
}
|
this.movingElement = null
|
||||||
})
|
this.xPosInit = 0
|
||||||
|
})
|
||||||
|
addEventListener("mousemove", (event) => {
|
||||||
|
|
||||||
|
if (this.movingElement != null) {
|
||||||
|
this.dragElement(this.movingElement, event.clientX - this.xPosInit, event.clientY - this.yPosInit)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {HTMLElement} window
|
||||||
|
*/
|
||||||
|
bringWindowToFront(window){
|
||||||
|
this.windowLayer.insertBefore(this.windowLayer.lastChild, window)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MouseEvent} event
|
* @param {MouseEvent} event
|
||||||
*/
|
*/
|
||||||
catchClick(event){
|
catchClick(event){
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case event.target.className == "WindowFrameTopBar":
|
case event.target.className == "WindowFrameTopBar":
|
||||||
this.movingElement = event.target.parentElement
|
this.movingElement = event.target.parentElement
|
||||||
// console.log(this.movingElement)
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -242,8 +250,7 @@ class WindowsCompositor{
|
|||||||
* @param {number} posY
|
* @param {number} posY
|
||||||
*/
|
*/
|
||||||
dragElement(element, posX, posY) { //TODO
|
dragElement(element, posX, posY) { //TODO
|
||||||
console.log()
|
element.style.left = `${posX}px`
|
||||||
element.style.left = (posX - element.clientWidth*0.5)+ "px";
|
element.style.top = `${posY}px`
|
||||||
element.style.top = (posY - element.children[0].clientHeight*0.5) + "px";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/desktop.png');"></div>
|
<div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/desktop.png');"></div>
|
||||||
<div class="FileTileTitle NoClick">Home</div>
|
<div class="FileTileTitle NoClick">Home</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="Home" class="FileTile">
|
<div id="mobile-dekstop-close" class="FileTile">
|
||||||
<div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/trash.png');"></div>
|
<div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/trash.png');"></div>
|
||||||
<div class="FileTileTitle NoClick">Close</div>
|
<div class="FileTileTitle NoClick">Close</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user