diff --git a/clite/core.css b/clite/core.css index cfa065a..741478c 100644 --- a/clite/core.css +++ b/clite/core.css @@ -1,15 +1,16 @@ -html,body {margin:0; padding:0; overflow:auto; width:100%; height:100%; background-color:#000000; color:#FFFFFF; font-family:monospace; font-size:14px;} -body {display:flex; flex-direction: column;} +html,body {margin:0; padding:0; overflow:hidden; width:100%; height:100%; max-height:100%; background-color:#000000; color:#FFFFFF; font-family:monospace; font-size:14px;} +body {display:flex; flex-direction:column;} div, header, section, article, p, form, h1 {display:block; margin:0; padding:0;} header {padding:10px;} header h1 {line-height:40px; font-size:30px;} section {} -section.content {flex-grow:1;} -section.content div#terminal {width:100%; min-width: 500px; max-width:1000px; margin:0 auto; overflow:hidden; height:100%; min-height:100px;} -section.content article {unicode-bidi: embed; white-space: pre;} -section.content form {} -section.content form label, section.content form input, section.content form input:focus {display:block; float:left; border:none; margin:0; padding:0; font-family:monospace; font-size:14px; line-height:20px; background-color:#000000; color:#FFFFFF; outline:none;} +section.content {position:relative; overflow:hidden;} +section.content div#terminal {width:100%; min-width: 500px; max-width:1000px; margin:0 auto; overflow:hidden; overflow-y:auto; scrollbar-width:none;} +section.content article {unicode-bidi: embed; white-space: pre-wrap;} +section.content form {display:flex;} +section.content form label, section.content form input, section.content form input:focus {display:block; border:none; margin:0; padding:0; font-family:monospace; font-size:14px; line-height:20px; background-color:#000000; color:#FFFFFF; outline:none;} +section.content form input, section.content form input:focus {flex-grow:100;} div.vga {margin:auto; z-index:10; background-color:#000000;} div.io {position:absolute; top:0px; left:0px; width:100px; height:100px; z-index:3;} diff --git a/clite/core.js b/clite/core.js index f14e81d..182cf22 100644 --- a/clite/core.js +++ b/clite/core.js @@ -79,104 +79,130 @@ var clite = { this.core.execSafeAsync(function() { clite.term.clear(false); + var vfsapi = null; - // setup vfs - clite.log.write('Setting up VFS'); - clite.vfs.init(); - var vfsapi = clite.vfs.getApi(); - clite.log.init(vfsapi); - clite.log.write('Mounting wfs on /'); - // mount core (root) filesystem using data/filesys.txt - clite.core.load.file('data/filesys.txt',function(data) { + function init1() { + // setup vfs + clite.log.write('Setting up VFS'); + clite.vfs.init(); + vfsapi = clite.vfs.getApi(); + clite.log.init(vfsapi); + clite.log.write('Mounting wfs on /'); + // mount core (root) filesystem using data/filesys.txt + if (window.location.protocol == 'file:') { + // work around the file: problems by just not loading files, here's a temporary filesystem + var d = ` +clite/core.js:/usr/clite/core.js:0:0:-rw-r----- +clite/core.css:/usr/clite/web/core.css:0:0:-rw-r----- +data/intro:/usr/share/introduction:0:0:-rw-rw-r--`; + init2(d); + return; + } + clite.core.load.file('data/filesys.txt',init2); + } + function init2(data) { if (data == null) { clite.log.write('No Filesystem Found'); return; } - vfsapi.mkFile('/dev/wfs'); - var n = vfsapi.getNode('/dev/wfs'); - if (!n) { - clite.log.write('wfs device failure'); - return; - } - n.data.content = data; - n.perms = 'cr--r-----'; - n.isdev = true; - var fd = clite.io.open('/dev/wfs'); - var l; - while ((l = clite.io.readLine(fd)) != null) { - if (l.length <1 || l[0] == '#') - continue; - var parts = l.split(':'); - if (parts.length != 5) - continue; - var url = parts[0]; - var path = parts[1]; - var uid = parseInt(parts[2]); - var gid = parseInt(parts[3]); - var perms = parts[4]; + vfsapi.mkFile('/dev/wfs'); + var n = vfsapi.getNode('/dev/wfs'); + if (!n) { + clite.log.write('wfs device failure'); + return; + } + n.data.content = data; + n.perms = 'cr--r-----'; + n.isdev = true; + var fd = clite.io.open('/dev/wfs'); + var l; + while ((l = clite.io.readLine(fd)) != null) { + if (l.length <1 || l[0] == '#') + continue; + var parts = l.split(':'); + if (parts.length != 5) + continue; + var url = parts[0]; + var path = parts[1]; + var uid = parseInt(parts[2]); + var gid = parseInt(parts[3]); + var perms = parts[4]; - var fn = vfsapi.getNode(path); - // TODO: make the full path if needed - if (!fn) { - if (perms[0] == 'd') { - vfsapi.mkDir(path); - }else{ - vfsapi.mkFile(path); + var fn = vfsapi.getNode(path); + // TODO: make the full path if needed + if (!fn) { + if (perms[0] == 'd') { + vfsapi.mkDir(path); + }else{ + vfsapi.mkFile(path); + } + fn = vfsapi.getNode(path); } - fn = vfsapi.getNode(path); + if (!fn) + continue; + fn.perms = perms; + fn.uid = uid; + fn.gid = gid; + fn.name = clite.lib.basename(path); + fn.data.remote = url; + fn.data.content = null; } - if (!fn) - continue; - fn.perms = perms; - fn.uid = uid; - fn.gid = gid; - fn.name = clite.lib.basename(path); - fn.data.remote = url; - fn.data.content = null; - } - clite.io.close(fd); - // populate /dev (data/filesys.txt is /dev/wfs already) - clite.log.write('Populating /dev'); - // TODO: are there any other devices we need? - // populate /bin - clite.log.write('Populating /bin'); - // create a temporary function to load in commands - clite.commands = { - data:null, - load:function(name,fn) { - vfsapi.mkFile('/bin/'+name); - var f = vfsapi.getNode('/bin/'+name); - if (!f) - return; - f.perms = '-r-xr-xr-x'; - f.data.content = fn; + clite.io.close(fd); + // populate /dev (data/filesys.txt is /dev/wfs already) + clite.log.write('Populating /dev'); + // TODO: are there any other devices we need? + // populate /bin + clite.log.write('Populating /bin'); + // create a temporary function to load in commands + clite.commands = { + data:null, + load:function(name,fn) { + vfsapi.mkFile('/bin/'+name); + var f = vfsapi.getNode('/bin/'+name); + if (!f) + return; + f.perms = '-r-xr-xr-x'; + f.data.content = fn; + } } + clite.core.load.script('clite/commands.js',init3); } - clite.core.load.script('clite/commands.js',function() { + function init3(data) { clite.core.execSafe(clite.commands.data); clite.commands = null; - // check cookies for login - clite.log.write('Checking for user session'); - if (clite.user.init(vfsapi)) {// if logged in: - clite.log.write('found user session?'); - // create user session - }else{// if new user: - clite.log.write('Generating guest session'); - // read in /usr/share/introduction and write to shell - var fd = clite.io.open('/usr/share/introduction',function(fd) { - clite.user.genGuest(); - if (!fd) - return; - var d = clite.io.readAll(fd); - if (d != null) - clite.shell.writeLine(d); - clite.io.close(fd); + // check cookies for login + clite.log.write('Checking for user session'); + if (clite.user.init(vfsapi)) {// if logged in: + clite.log.write('found user session?'); + // create user session + }else{// if new user: + clite.log.write('Generating guest session'); + // read in /usr/share/introduction and write to shell + if (window.location.protocol == 'file:') { + clite.user.genGuest(); + clite.shell.writeLine(` + _____ _ _____ _ + / ____| | |_ _| | + | | | | | | | |_ ___ + | | | | | | | __/ _ \\ + | |____| |____ _| |_| || __/ + \\_____|______|_____|\\__\\___|`); + }else{ + var fd = clite.io.open('/usr/share/introduction',function(fd) { + clite.user.genGuest(); + if (!fd) + return; + var d = clite.io.readAll(fd); + if (d != null) + clite.shell.writeLine(d); + clite.io.close(fd); - }); + }); + } + } } - }); // end command load callback - }); // end filesys load callback + init1(); }); } @@ -661,6 +687,7 @@ clite.term = { if (!t) return; t.appendChild(a); + t.scrollTop = t.scrollHeight; }, genForm:function() { var f = document.getElementById('form'); diff --git a/index.html b/index.html index 13d6397..11a7610 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,14 @@
-