@@ -98,67 +98,57 @@ var app = {
98
98
setup : {
99
99
runs : false ,
100
100
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
+ }
162
152
}
163
153
} ,
164
154
files : {
@@ -570,9 +560,10 @@ var app = {
570
560
var recepient = tk . c ( "input" , win . main , "i1" )
571
561
recepient . required = true
572
562
var send = tk . cb ( "b1" , "Start" , async function ( ) {
563
+ console . log ( 'Initializing' )
573
564
var conn = peer . connect ( recepient . value )
574
565
conn . on ( 'open' , async function ( ) {
575
- // Receive messages
566
+ console . log ( 'Connected' )
576
567
577
568
// Send messages
578
569
var castpeer = new Peer ( await fs . read ( '/system/deskid' ) + "-cast" )
@@ -585,15 +576,15 @@ var app = {
585
576
conn2 . on ( 'data' , async function ( data ) {
586
577
console . log ( data )
587
578
if ( data == "connAccept" ) {
588
- if ( navigator . userAgent . toLowerCase ( ) . includes ( 'firefox' ) ) {
579
+ if ( navigator . userAgent . toLowerCase ( ) . includes ( 'firefox' ) ) {
589
580
var w = tk . mbw ( "Stupid confirmation because firefox sucks" , "300px" , "auto" , false , true , true , "ncast" , './assets/img/systemIcons/cast.svg' )
590
581
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 )
591
582
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 ( ) {
593
584
castpeer . call ( recepient . value + "-cast" , await navigator . mediaDevices . getDisplayMedia ( displayMediaOptions ) )
594
585
} , w . main ) ;
595
586
}
596
- else {
587
+ else {
597
588
castpeer . call ( recepient . value + "-cast" , await navigator . mediaDevices . getDisplayMedia ( displayMediaOptions ) )
598
589
}
599
590
}
@@ -606,51 +597,70 @@ var app = {
606
597
stop . style . display = "none"
607
598
console . log ( id )
608
599
} ,
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
+ } ,
609
606
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 ) ;
629
616
} ) ;
630
617
618
+ // Send messages
619
+ c . send ( 'connAccept' ) ;
631
620
} ) ;
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 ] )
651
644
} ) ;
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
+ }
654
664
}
655
665
}
656
666
} ,
@@ -667,4 +677,11 @@ window.installApp = function (appn, appid, appscripts, appico) {
667
677
fs . write ( `/system/apps/${ appid } /${ script . name } ` , script . script )
668
678
} )
669
679
}
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
+ }
0 commit comments