Skip to content

Commit 9758747

Browse files
author
git@nova's optiplex
committed
uuwwuu
1 parent dc7aaf9 commit 9758747

File tree

7 files changed

+465
-144
lines changed

7 files changed

+465
-144
lines changed

assets/code/apps.js

Lines changed: 123 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -98,67 +98,57 @@ var app = {
9898
setup: {
9999
runs: false,
100100
init: async function () {
101-
const setupWin = tk.mbw('Setup', '300px', '300px', true, true, true)
102-
const main = document.querySelector("#setuparea")
103-
// const main = tk.c('div', setupWin.main, 'setupbox');
104-
// create setup menubar
105-
const bar = tk.c('div', main, 'setupbar');
106-
const tnav = tk.c('div', bar, 'tnav');
107-
const title = tk.c('div', bar, 'title');
108-
tk.cb('b4', 'Start Over', () => fs.erase('reboot'), tnav);
109-
tk.cb('b4 time', 'what', undefined, title);
110-
// first menu
111-
const first = tk.c('div', main, 'setb');
112-
tk.img('./assets/img/systemIcons/os.svg', 'setupi', first);
113-
tk.p('Welcome to NovaOS Deskop Next-Gen!', 'h2', first);
114-
tk.p('NovaOS is proudly powered by WebDesk!', 'h3', first);
115-
tk.cb('b1', `Login as Guest`, () => wd.desktop('Guest', gen(8)), first);
116-
tk.cb('b1', `Begin Setup`, () => ui.sw2(first, transfer), first);
117-
// migrate menu
118-
const transfer = tk.c('div', main, 'setb hide');
119-
tk.img('./assets/img/setup/quick.png', 'setupi', transfer);
120-
tk.p('Quick Start', 'h2', transfer);
121-
tk.p(`If you have used WebDesk or NovaOS-NG previously, you can migrate it's data to this device. To do so, open settings, choose Backup, then Migrate and enter the code below.`, undefined, transfer);
122-
tk.p('--------', 'h2 deskid', transfer);
123-
tk.cb('b1', 'No thanks', () => ui.sw2(transfer, warn), transfer);
124-
transfer.id = "quickstartwdsetup";
125-
// copying menu
126-
const copy = tk.c('div', main, 'setb hide');
127-
tk.img('./assets/img/setup/restore.svg', 'setupi', copy);
128-
tk.p('Restoring from other Device', 'h2', copy);
129-
tk.p('This might take a while depending on settings and file size.', undefined, copy);
130-
tk.p('Starting...', 'restpg', copy);
131-
tk.cb('b1', 'Cancel', function () { fs.erase('reboot'); }, copy);
132-
copy.id = "quickstartwdgoing";
133-
// warn menu
134-
const warn = tk.c('div', main, 'setb hide');
135-
tk.img('./assets/img/systemIcons/os.svg', 'setupi', warn);
136-
tk.p(`Online services`, 'h2', warn);
137-
tk.p('NovaOS makes an ID called a DeskID for you. Others using WebDesk, NovaOS-NG or compatible tools can use this ID to send you files or call you.', undefined, warn);
138-
tk.p('To recieve calls and files from others, NovaOS needs to be open. When not in use, NovaOS uses less resources', undefined, warn);
139-
tk.p('You can find your DeskID upon completion of setup.', undefined, warn);
140-
// tk.cb('b1', `What's my DeskID?`, function () {
141-
// const box = wm.cm();
142-
// tk.p(`Your DeskID is <span class="deskid med">unknown</span>. You'll need to finish setup to use this ID.`, undefined, box);
143-
// tk.cb('b1 rb', 'Got it', undefined, box);
144-
// }, warn);
145-
tk.cb('b1', 'Got it', function () { ui.sw2(warn, user) }, warn);
146-
// user menu
147-
const user = tk.c('div', main, 'setb hide');
148-
tk.img('./assets/img/setup/user.svg', 'setupi', user);
149-
tk.p('About You', 'h2', user);
150-
tk.p(`Set up a user for NovaOS to store all of your stuff in, and set up permissions. By default, your data is stored on-device, soon you will be able to opt-in to cloud sync..`, undefined, user);
151-
const input = tk.c('input', user, 'i1');
152-
input.placeholder = "Pick a username.";
153-
tk.cb('b1', 'Done!', function () { wd.finishsetup(input.value, user, sum) }, user);
154-
// summary
155-
const sum = tk.c('div', main, 'setb hide');
156-
tk.img('./assets/img/setup/check.svg', 'setupi', sum);
157-
tk.p('Setup is complete.', 'h2', sum);
158-
tk.p('Keep in mind, novaOS is still in early public alpha.', undefined, sum);
159-
tk.cb('b1 rb', 'Erase & restart', function () { fs.erase('reboot'); }, sum); tk.cb('b1', 'Complete setup', function () { wd.reboot(); }, sum);
160-
sum.id = "setupdone";
161-
fs.mkdir('/user/Documents/', 'opfs');
101+
if (!sys.isIOT) {
102+
const main = document.querySelector("#setuparea")
103+
// const main = tk.c('div', setupWin.main, 'setupbox');
104+
// create setup menubar
105+
const bar = tk.c('div', main, 'setupbar');
106+
const tnav = tk.c('div', bar, 'tnav');
107+
const title = tk.c('div', bar, 'title');
108+
tk.cb('b4', 'Start Over', () => fs.erase('reboot'), tnav);
109+
tk.cb('b4 time', 'what', undefined, title);
110+
// first menu
111+
const first = tk.c('div', main, 'setb');
112+
tk.img('./assets/img/systemIcons/os.svg', 'setupi', first);
113+
tk.p('Welcome to NovaOS Deskop Next-Gen!', 'h2', first);
114+
tk.p('NovaOS is proudly powered by WebDesk!', 'h3', first);
115+
tk.cb('b1', `Login as Guest`, () => wd.desktop('Guest', gen(8)), first);
116+
tk.cb('b1', `Begin Setup`, () => ui.sw2(first, warn), first);
117+
// warn menu
118+
const warn = tk.c('div', main, 'setb hide');
119+
tk.img('./assets/img/systemIcons/os.svg', 'setupi', warn);
120+
tk.p(`Online services`, 'h2', warn);
121+
tk.p('NovaOS makes an ID called a DeskID for you. Others using WebDesk, NovaOS-NG or compatible tools can use this ID to send you files or call you.', undefined, warn);
122+
tk.p('To recieve calls and files from others, NovaOS needs to be open. When not in use, NovaOS uses less resources', undefined, warn);
123+
tk.p('You can find your DeskID upon completion of setup.', undefined, warn);
124+
// tk.cb('b1', `What's my DeskID?`, function () {
125+
// const box = wm.cm();
126+
// tk.p(`Your DeskID is <span class="deskid med">unknown</span>. You'll need to finish setup to use this ID.`, undefined, box);
127+
// tk.cb('b1 rb', 'Got it', undefined, box);
128+
// }, warn);
129+
tk.cb('b1', 'Got it', function () { ui.sw2(warn, user) }, warn);
130+
// user menu
131+
const user = tk.c('div', main, 'setb hide');
132+
tk.img('./assets/img/setup/user.svg', 'setupi', user);
133+
tk.p('About You', 'h2', user);
134+
tk.p(`Set up a user for NovaOS to store all of your stuff in, and set up permissions. By default, your data is stored on-device, soon you will be able to opt-in to cloud sync..`, undefined, user);
135+
const input = tk.c('input', user, 'i1');
136+
input.placeholder = "Pick a username.";
137+
tk.cb('b1', 'Done!', function () { wd.finishsetup(input.value, user, sum) }, user);
138+
// summary
139+
const sum = tk.c('div', main, 'setb hide');
140+
tk.img('./assets/img/setup/check.svg', 'setupi', sum);
141+
tk.p('Setup is complete.', 'h2', sum);
142+
tk.p('Keep in mind, novaOS is still in early public alpha.', undefined, sum);
143+
tk.cb('b1 rb', 'Erase & restart', function () { fs.erase('reboot'); }, sum); tk.cb('b1', 'Complete setup', function () { wd.reboot(); }, sum);
144+
sum.id = "setupdone";
145+
fs.mkdir('/user/Documents/', 'opfs');
146+
} else{
147+
fs.mkdir('/user/Documents/', 'opfs');
148+
wd.finishsetup()
149+
wd.reboot()
150+
151+
}
162152
}
163153
},
164154
files: {
@@ -570,9 +560,10 @@ var app = {
570560
var recepient = tk.c("input", win.main, "i1")
571561
recepient.required = true
572562
var send = tk.cb("b1", "Start", async function () {
563+
console.log('Initializing')
573564
var conn = peer.connect(recepient.value)
574565
conn.on('open', async function () {
575-
// Receive messages
566+
console.log('Connected')
576567

577568
// Send messages
578569
var castpeer = new Peer(await fs.read('/system/deskid') + "-cast")
@@ -585,15 +576,15 @@ var app = {
585576
conn2.on('data', async function (data) {
586577
console.log(data)
587578
if (data == "connAccept") {
588-
if(navigator.userAgent.toLowerCase().includes('firefox')){
579+
if (navigator.userAgent.toLowerCase().includes('firefox')) {
589580
var w = tk.mbw("Stupid confirmation because firefox sucks", "300px", "auto", false, true, true, "ncast", './assets/img/systemIcons/cast.svg')
590581
tk.p("Firefox is a bad browser and needs you to hit the button below because the other button isn't direct enough.", "", w.main)
591582
tk.mkel("h1", [], "FUCK YOU MOZILLA", w.main)
592-
tk.cb("b1","Start cast forreallz", async function(){
583+
tk.cb("b1", "Start cast forreallz", async function () {
593584
castpeer.call(recepient.value + "-cast", await navigator.mediaDevices.getDisplayMedia(displayMediaOptions))
594585
}, w.main);
595586
}
596-
else{
587+
else {
597588
castpeer.call(recepient.value + "-cast", await navigator.mediaDevices.getDisplayMedia(displayMediaOptions))
598589
}
599590
}
@@ -606,51 +597,70 @@ var app = {
606597
stop.style.display = "none"
607598
console.log(id)
608599
},
600+
iot: async function () {
601+
const win = tk.mbw("iotapp", 'auto', 'auto', false, false, false, "ncast", "")
602+
var title = tk.mkel("h1", ["time"], "", win.main)
603+
var kb = tk.mkel("h2", [], "", win.main)
604+
kb.innerHTML = `Use '${await fs.read('/system/deskid')}' to connect`
605+
},
609606
connection: async function (id, username = "ffs, not a cast") {
610-
if (username !== "ffs, not a cast") {
611-
const win = tk.mbw('Cast', '300px', 'auto', false, true, true, "ncast", './assets/img/systemIcons/cast.svg');
612-
var ic = tk.mkel("div", ["notif"], "", win.main)
613-
ic.id = "ncastNotizone"
614-
tk.mkel('b', [], "Incoming Request<br>", ic)
615-
var req = tk.mkel('span', [], `ID: ${id.toString()}<br>Username: ${username.toString()}<br>`, ic)
616-
var ac = tk.cb("b1 smallb", "Accept", async function () {
617-
p = new Peer(await fs.read('/system/deskid') + "-cast");
618-
p.on('open', function (thisID) {
619-
console.log('My peer ID is: ' + thisID);
620-
var c = p.connect(id + "-cast");
621-
c.on('open', function () {
622-
// Receive messages
623-
c.on('data', function (data) {
624-
console.log('Received', data);
625-
});
626-
627-
// Send messages
628-
c.send('connAccept');
607+
async function acceptCast() {
608+
p = new Peer(await fs.read('/system/deskid') + "-cast");
609+
p.on('open', function (thisID) {
610+
console.log('My peer ID is: ' + thisID);
611+
var c = p.connect(id + "-cast");
612+
c.on('open', function () {
613+
// Receive messages
614+
c.on('data', function (data) {
615+
console.log('Received', data);
629616
});
630617

618+
// Send messages
619+
c.send('connAccept');
631620
});
632-
ui.dest(ic)
633-
const recv = tk.mbw(`Cast Reciever: ${username.toString()}#${id.toString()}`, '850px', '490px', false, true, true, './assets/img/systemIcons/cast.svg')
634-
win.title.children[0].children[0].click()
635-
const video = tk.c('video', recv.main)
636-
video.setAttribute("controls", "yes")
637-
video.style.width = "100%"
638-
video.style.height = "420px"
639-
p.on('call', function (call) {
640-
// Answer the call, providing our mediaStream
641-
call.answer(null);
642-
call.on('stream', function (stream) {
643-
// `stream` is the MediaStream of the remote peer.
644-
// Here you'd add it to an HTML video/canvas element.
645-
video.srcObject = stream;
646-
video.play()
647-
const stop = tk.cb('b4', "Stop", function () {
648-
p.disconnect()
649-
}, recv.title.children[0])
650-
});
621+
622+
});
623+
ui.dest(ic)
624+
const recv = tk.mbw(`Cast Reciever: ${username.toString()}#${id.toString()}`, '850px', '490px', false, true, true, './assets/img/systemIcons/cast.svg')
625+
if(!sys.isIOT){ win.title.children[0].children[0].click()
626+
}
627+
const video = tk.c('video', recv.main)
628+
video.setAttribute("controls", "yes")
629+
video.setAttribute("autoplay", "yes")
630+
video.style.width = "100%"
631+
video.style.height = "100%"
632+
video.style.id = "castvideo"
633+
p.on('call', function (call) {
634+
// Answer the call, providing our mediaStream
635+
call.answer(null);
636+
call.on('stream', function (stream) {
637+
// `stream` is the MediaStream of the remote peer.
638+
// Here you'd add it to an HTML video/canvas element.
639+
video.srcObject = stream;
640+
video.play()
641+
const stop = tk.cb('b4', "Stop", function () {
642+
p.disconnect()
643+
}, recv.title.children[0])
651644
});
652-
}, ic)
653-
var de = tk.cb("b1 smallb", "Deny", function () { ui.dest(ic) }, ic)
645+
call.on('close', function () {
646+
ui.dest(recv.win)
647+
})
648+
});
649+
}
650+
if (username !== "ffs, not a cast") {
651+
if(!sys.isIOT){
652+
const win = tk.mbw('Cast', '300px', 'auto', false, true, true, "ncast", './assets/img/systemIcons/cast.svg');
653+
var ic = tk.mkel("div", ["notif"], "", win.main)
654+
ic.id = "ncastNotizone"
655+
tk.mkel('b', [], "Incoming Request<br>", ic)
656+
var req = tk.mkel('span', [], `ID: ${id.toString()}<br>Username: ${username.toString()}<br>`, ic)
657+
var ac = tk.cb("b1 smallb", "Accept", acceptCast(), ic)
658+
var de = tk.cb("b1 smallb", "Deny", function () { ui.dest(ic) }, ic)
659+
}
660+
else{
661+
acceptCast()
662+
wm.notif("Cast Connection", `${username}#${id} connected to this reciever`)
663+
}
654664
}
655665
}
656666
},
@@ -667,4 +677,11 @@ window.installApp = function (appn, appid, appscripts, appico) {
667677
fs.write(`/system/apps/${appid}/${script.name}`, script.script)
668678
})
669679
}
670-
// app.cast.connection(30012)
680+
// app.cast.connection(30012)
681+
if(sys.isIOT){
682+
try{
683+
app[sys.iotApp].iot()
684+
}catch{
685+
app[sys.iotApp].init()
686+
}
687+
}

assets/code/core.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ var wd = {
126126
btn.classList.add("appItem");
127127
var $thisapp = app[key]
128128
btn.onclick = $thisapp.init
129+
btn.addEventListener('click', function () {
130+
if (document.querySelector(".tbmenu")) {
131+
ui.dest(document.querySelector(".tbmenu"), 150);
132+
}
133+
});
129134
} else {
130135
console.log(`<i> ${apps[key].name} is not launchable! :(`);
131136
}
@@ -138,6 +143,10 @@ var wd = {
138143
$(".contcent").fadeOut(150, function () { });
139144
}
140145
el.sm = tk.c('div', document.body, 'tbmenu');
146+
el.sm.addEventListener('mouseleave', function () {
147+
ui.dest(el.sm, 150);
148+
el.sm = undefined;
149+
});
141150
const btm = el.taskbar.getBoundingClientRect();
142151
el.sm.style.bottom = btm.height + btm.x + 4 + "px";
143152
tk.p(`Hello, ${name}!`, 'h2', el.sm);
@@ -246,11 +255,19 @@ var wd = {
246255
* Stores the user's name and sets parts of the filesystem
247256
*/
248257
finishsetup: function (name, div1, div2) {
249-
ui.sw2(div1, div2); ui.masschange('name', name);
250-
fs.mkdir('/user')
251-
fs.mkdir('/user/info')
252-
fs.mkdir('/user/Documents')
253-
fs.write('/user/info/name', name);
258+
if(sys.isIOT){
259+
ui.sw2(div1, div2); ui.masschange('name', "iotuser");
260+
fs.mkdir('/user')
261+
fs.mkdir('/user/info')
262+
fs.mkdir('/user/Documents')
263+
fs.write('/user/info/name', "iotuser");
264+
} else{
265+
ui.sw2(div1, div2); ui.masschange('name', name);
266+
fs.mkdir('/user')
267+
fs.mkdir('/user/info')
268+
fs.mkdir('/user/Documents')
269+
fs.write('/user/info/name', name);
270+
}
254271
},
255272
/**
256273
* Reboot NovaOS

assets/code/fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ var fs = {
127127
* @param {string} path - The path of the directory to create.
128128
* @param {string} [filesystem="opfs"] - The filesystem to use ("opfs" or "idbfs").
129129
* @returns {Promise<any>} A promise that resolves when the directory is created.
130-
*/
130+
*/
131131
mkdir: function (path, filesystem = "opfs") {
132132
if(filesystem == "opfs") {
133133
return this.askwfsOPFS('mkdir', path);

0 commit comments

Comments
 (0)