Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Commit

Permalink
some changes uwu
Browse files Browse the repository at this point in the history
  • Loading branch information
Nova committed May 7, 2024
1 parent d212d18 commit 214a493
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 32 deletions.
55 changes: 55 additions & 0 deletions libraries/foxyfs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// foxyfs.js
var currentStore = localStorage.getItem('fs');
function jsonPathToValue(jsonData, path) {
if (!(jsonData instanceof Object) || typeof path === 'undefined') {
throw 'InvalidArgumentException';
}
path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
path = path.replace(/^\./, ''); // strip a leading dot
var pathArray = path.split('.');
for (var i = 0, n = pathArray.length; i < n; ++i) {
var key = pathArray[i];
if (key in jsonData) {
if (jsonData[key] !== null) {
jsonData = jsonData[key];
} else {
return null;
}
} else {
return key;
}
}
return jsonData;
}
if (currentStore == null) {
localStorage.setItem(
'fs',
'{"d_home":{"d_Documents":{"f_README․html":"data:text/html;base64,PGgxIGlkPSJ3ZWxjb21lLXRvLW9ueXhvcyI+V2VsY29tZSB0byBPbnl4T1M8L2gxPg0KPHA+VGhpcyBpcyBhIHRlc3Qgb2YgdGhlIEZTPC9wPg0KDQo="},"d_Downloads":{},"d_Pics":{}}}'
);
}
export default function initFFS(){
window.foxyfs = {
save: function(path, content) {
currentStore = JSON.parse(localStorage.getItem('fs'));
path2 = "['" + path.replaceAll('.', "']['") + "']";
eval('currentStore' + path2 + " = '" + encodeURIComponent(content) + "'");
localStorage.fs = JSON.stringify(currentStore);
currentStore = localStorage.fs;
},
load: function(path) {
return jsonPathToValue(JSON.parse(localStorage.fs), path);
},
rm: function(path) {
var fs = JSON.parse(localStorage.fs);
if (path.split('')[0] == '.') {
eval('delete fs.' + path.slice(1) + '');
} else {
eval('delete fs.' + path + '');
}
console.log(fs);
localStorage.fs2 = fs;
}

}
}
initFFS()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Welcome to Nova OS",
"content": "Welcome to Nova OS Proto. Keep in mind that this is in early stages."
},
"bio": {
"bi2o": {
"title": "Who is Nova?",
"content": "piss to Nova OS Proto. Keep in mind that this is in early stages."
},
Expand Down
36 changes: 21 additions & 15 deletions libraries/foxywm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// foxywm.js
import defaults from './foxywm.config.json' assert { type: 'json' };
import defaults from './foxywm.default.json' with { type: 'json' };
import 'https://code.jquery.com/jquery-3.7.1.js';
import 'https://code.jquery.com/ui/1.13.3/jquery-ui.js';
var fwmStor = {};
var onEnter = function () { }
var onClose = function () { }
var onLeave = function () { }
window.memory = {}
fwmStor.memory = {}
var windowContainer = $("body")
var css = document.createElement("link")
css.rel = "stylesheet"
Expand All @@ -19,7 +20,7 @@ function handleMouseMove(event) {
window.x = event.pageX;
window.y = event.pageY;
}
export default function foxyWM() {
export default function fwmInit() {
console.log(defaults);

window.wm = {
Expand All @@ -30,19 +31,19 @@ export default function foxyWM() {
win.innerHTML = content;
win.title = title
win.dataset.title = title;
if(memory[id] !== undefined){
memory[id] = String(Number(memory[id]) + 1)
if(fwmStor.memory[id] !== undefined){
fwmStor.memory[id] = String(Number(fwmStor.memory[id]) + 1)
}
else{
memory[id] = "1";
fwmStor.memory[id] = "1";
}
win.id = id + "-" + memory[id];
win.id = id + "-" + fwmStor.memory[id];
document.body.appendChild(win);
if (instant) {
wm.windows.show(win.id);
}
win.parentElement.addEventListener("mouseleave", onLeave)
console.log(memory)
console.log(fwmStor.memory)
return win;
}

Expand All @@ -53,9 +54,9 @@ export default function foxyWM() {
$("#" + id).parent().draggable( "option", "containment", windowContainer);
$("#" + id).on('dialogclose', function (event) {
console.log(event.target)
wm.windows.close(event.target.id)
wm.windows.close(event.target.id)
});
$("#" + id)[0].previousElementSibling.onclick = wm.windows.restore
$("#" + id)[0].previousElementSibling.onclick =wm.windows.restore
document.querySelector("#" + id).parentElement.onmouseenter = function (e) {
console.log(e.target.children)
window.lastWin = { "el": e.target, "id": e.target.getAttribute("aria-describedby") }
Expand All @@ -64,18 +65,18 @@ export default function foxyWM() {
},
close: function close(id, destroy = true) {
$('[aria-describedby="' + id + '"]').hide();
if (destroy) { wm.windows.destroy(id) }
if (destroy) {wm.windows.destroy(id) }
onClose()
// id = id.split("-")[0]
// memory[id] = String(Number(memory[id]) - 1)
id = id.split("-")[0]
fwmStor.memory[id] = String(Number(fwmStor.memory[id]) - 1)
},
destroy: function destroy(id) {
$('[aria-describedby="' + id + '"]').fadeOut();
$('[aria-describedby="' + id + '"]').remove();
$('#' + id).remove();
},
default: function def(id) {
wm.windows.new(defaults[id].content, defaults[id].title, id, true);
wm.windows.new(defaults[id].content, defaults[id].title, id, true);
},
maximise: function max(id) {
$('[aria-describedby="' + id + '"]')[0].style.top = "40px"
Expand Down Expand Up @@ -138,8 +139,13 @@ export default function foxyWM() {
setWContainer: function (query){
windowContainer = $(query)
}
},
store: {
countAppWin: function (id){
return fwmStor.memory[id]
}
}
}
};

foxyWM()
fwmInit()
52 changes: 37 additions & 15 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import foxyWM from './libraries/foxywm.js';
import './libraries/foxywm.js';
import './libraries/foxyfs.js';
window.clickSfx = new (Audio)
clickSfx.src = "assets/click.mp3"
var topBar = $(".bar")
function appOpen(app) {
wm.windows.default(app)
}
Expand All @@ -12,32 +16,50 @@ wm.events.setOnEnter(
$("#WindowTitle")[0].innerText = wm.windows.getName("fwm.current");
$("#wb")[0].setAttribute("class", "");
clearTimeout(timeout);
})
})
wm.events.setOnClose(function () { $("#WindowTitle")[0].innerText = "NovaOS"; $("#wb")[0].setAttribute("class", "noWin") })
document.addEventListener("mousemove", function (e) {
document.querySelector(".cur").style.top = `${e.clientY}px`
console.log(e)
document.querySelector(".cur").style.left = `${e.clientX}px`
if(e.srcElement.classList.contains("clickable")){
document.querySelector(".cur").style.background = "#0000FF";
}
else{
document.querySelector(".cur").style.background = "#FFFFFF"
}
setTimeout(function () {
document.querySelector(".cur").style.top = `${e.clientY}px`
// console.log(e)
document.querySelector(".cur").style.left = `${e.clientX}px`
if (e.srcElement.classList.contains("clickable")) {
document.querySelector(".cur").style.background = "#0000FF";
}
else {
document.querySelector(".cur").style.background = "#FFFFFF"
}
}, 0)
})
wm.events.setOnLeave(function(){
wm.events.setOnLeave(function () {
timeout = setTimeout(() => {
$("#WindowTitle")[0].innerText = "NovaOS";
$("#wb")[0].setAttribute("class", "noWin")
}, 2000);
}, 2000);
})
$(".message")[0].addEventListener("click", function(){
$(".message")[0].addEventListener("click", function () {
appOpen("cvm")
})
document.onclick = function (e) {
if (e.target.classList.contains("clickable")) {
clickSfx.play()
}
}

// window.onbeforeunload = function() {
// var message = 'Do you want to leave this page?';
// return message;
// }
wm.config.setWContainer(".bgcover")
setInterval(function(){document.body.scrollTo(0,0)},100)
setInterval(function () { document.body.scrollTo(0, 0) }, 100)
topBar[0].addEventListener("mouseenter", function () {
$("#WindowTitle")[0].innerText = wm.windows.getName("fwm.current");
$("#wb")[0].setAttribute("class", "");
clearTimeout(timeout);
})
topBar[0].addEventListener("mouseleave", function () {
timeout = setTimeout(() => {
$("#WindowTitle")[0].innerText = "NovaOS";
$("#wb")[0].setAttribute("class", "noWin")
}, 2000);
})
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
font-style: normal;
font-size: 20px;
user-select: none;
transition: transform 0.1s ease;
transition: transform 0.15s ease;
-webkit-user-drag: none;
}
*:not(.ui-resizable-handle, .ui-draggable-handle, .ui-draggable-handle *){
Expand Down

0 comments on commit 214a493

Please sign in to comment.