var directorio='raiz'; var util = util || {}; util.toArray = function(list) { return Array.prototype.slice.call(list || [], 0); }; function delay(milisegundos){ for(i=0;i<=milisegundos;i++){ setTimeout('return 0',1); } } var Terminal = Terminal || function(cmdLineContainer, outputContainer) { window.URL = window.URL || window.webkitURL; window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; var cmdLine_ = document.querySelector(cmdLineContainer); var output_ = document.querySelector(outputContainer); const VERSION_ = 'Mundo Viejuno v2.0b'; const CMDS_ = [ 'help', 'dir', 'ver', 'who', 'cd', 'type' ]; const THEMES_ = ['default', 'cream']; var fs_ = null; var cwd_ = null; var history_ = []; var histpos_ = 0; var histtemp_ = 0; window.addEventListener('click', function(e) { cmdLine_.focus(); }, false); // Always force text cursor to end of input line. cmdLine_.addEventListener('click', inputTextClick_, false); // Handle up/down key presses for shell history and enter for new command. cmdLine_.addEventListener('keydown', historyHandler_, false); cmdLine_.addEventListener('keydown', processNewCommand_, false); function inputTextClick_(e) { this.value = this.value; } function historyHandler_(e) { // Tab needs to be keydown. if (history_.length) { if (e.keyCode == 38 || e.keyCode == 40) { if (history_[histpos_]) { history_[histpos_] = this.value; } else { histtemp_ = this.value; } } if (e.keyCode == 38) { // up histpos_--; if (histpos_ < 0) { histpos_ = 0; } } else if (e.keyCode == 40) { // down histpos_++; if (histpos_ > history_.length) { histpos_ = history_.length; } } if (e.keyCode == 38 || e.keyCode == 40) { this.value = history_[histpos_] ? history_[histpos_] : histtemp_; this.value = this.value; // Sets cursor to end of input. } } } function processNewCommand_(e) { if (e.keyCode == 9) { // tab e.preventDefault(); // TODO(ericbidelman): Implement tab suggest. } else if (e.keyCode == 13) { // enter // Save shell history. if (this.value) { history_[history_.length] = this.value; histpos_ = history_.length; } // Duplicate current input and append to output section. var line = this.parentNode.parentNode.cloneNode(true); line.removeAttribute('id') line.classList.add('line'); var input = line.querySelector('input.cmdline'); input.autofocus = false; input.readOnly = true; output_.appendChild(line); // Parse out command, args, and trim off whitespace. // TODO(ericbidelman): Support multiple comma separated commands. if (this.value && this.value.trim()) { var args = this.value.split(' ').filter(function(val, i) { return val; }); var cmd = args[0].toLowerCase(); args = args.splice(1); // Remove cmd from arg list. } switch (cmd) { case 'version': case 'ver': output(VERSION_); break; case 'who': output(document.title + '

- Original HTML5 console demo By: Eric Bidelman <ericbidelman@chromium.org> '); output('Modified by JoJo <jojo@vieju.net>
'); output('- Pong game by ^Misato^ <misato@vieju.net>
'); break; case 'help': output('Available commands:
'); output('
' + CMDS_.join('
') + '
'); output('
Tips:

'); output('- To enter the blog type \'cd blog\', press enter, and then type \'blog\'
'); output('- To read the FAQ type \'cd info\', press enter, and then type \'type faq.txt\'
'); output('- To enter the old mundoviejuno page type \'cd old\', press enter, and then type \'mviejuno\'
'); break; case 'autoexec': case 'autoexec.bat': if (directorio=='raiz'){ output('

To see a list of commands, please type "help" and press enter.

'); output('

'); } else output('Illegal command: ' + cmd); break; case 'command.com': if (directorio=='raiz'){ output('ViejunoDos v2.0b
'); output('Copyright 2007,2008,2009,2010,2011,2012 ViejuNET Enterprises LTD.
'); output('
'); } else output('Illegal command: ' + cmd); break; case 'pong': case 'pong.exe': if (directorio=='games'){ window.location='pong.htm'; } else output('Illegal command: ' + cmd); break; case 'blog': case 'blog.exe': if (directorio=='blog'){ window.location='blog.htm'; } else output('Illegal command: ' + cmd); break; case 'mviejuno': case 'mviejuno.exe': if (directorio=='old'){ window.location='http://www.vieju.net/pub/mirror/mundoviejuno_v1'; } else output('Illegal command: ' + cmd); break; case 'dir': switch(directorio){ case 'raiz': { output('Directory of C:/.
'); output('INFO           <DIR>          07-02-2012 15:34
'); output('BLOG           <DIR>          07-02-2012 15:34
'); output('GAMES          <DIR>          07-02-2012 15:34
'); output('OLD            <DIR>          07-02-2012 15:34
'); output('AUTOEXEC BAT               93 07-02-2012 15:34
'); output('CONFIG   SYS               24 07-02-2012 15:34
'); output('COMMAND  COM            74736 07-02-2012 15:34
'); output('    3 File(s)           74853 Bytes.
'); output('    3 Dir(s)            0 Bytes free.
'); break; } case 'old': { output('Directory of C:/OLD.
'); output('.              <DIR>          07-02-2012 15:34
'); output('..             <DIR>          07-02-2012 15:34
'); output('MVIEJUNO EXE               93 15-11-2007 19:25
'); output('    1 File(s)           74853 Bytes.
'); output('    2 Dir(s)            0 Bytes free.
'); break; } case 'games': { output('Directory of C:/GAMES.
'); output('.              <DIR>          07-02-2012 15:34
'); output('..             <DIR>          07-02-2012 15:34
'); output('PONG EXE           93 15-11-2007 19:25
'); output('    1 File(s)           74853 Bytes.
'); output('    2 Dir(s)            0 Bytes free.
'); break; } case 'blog': { output('Directory of C:/BLOG.
'); output('.              <DIR>          07-02-2012 15:34
'); output('..             <DIR>          07-02-2012 15:34
'); output('BLOG EXE           93 15-11-2007 19:25
'); output('    1 File(s)           74853 Bytes.
'); output('    2 Dir(s)            0 Bytes free.
'); break; } case 'info': { output('Directory of C:/INFO.
'); output('.              <DIR>          07-02-2012 15:34
'); output('..             <DIR>          07-02-2012 15:34
'); output('FAQ     TXT         93 15-11-2007 19:25
'); output('    1 File(s)           74853 Bytes.
'); output('    2 Dir(s)            0 Bytes free.
'); break; } } break; case 'type': if (directorio=='raiz') switch(args[0].toLowerCase()){ case 'autoexec.bat': output('@ECHO OFF
'); output('ECHO To see a list of commands, please type "help" and press enter.
'); output('PROMPT $N$G
'); break; case 'config.sys': output('FILES=40
'); output('BUFFERS=30
'); break; case 'command.com': output('MZ/ #ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍ��(��(��(��(��(��(��(�ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ��(��(��(��(��(��(��(��(ï
'); output('(ҟ9����۟�T˯�n���x>�*�H>���cJ������T��f=��
'); break; default: output('File not found: ' + args); break; } else if (directorio=='games') switch(args[0].toLowerCase()){ case 'pong.exe': output('MZ/ #ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍ��(��(��(��(��(��(��(�ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ��(��(��(��(��(��(��(��(ï
'); output('(ҟ9����۟�T˯�n���x>�*�H>���cJ������T��f=��
'); break; default: output('File not found: ' + args); break; } else if (directorio=='blog') switch(args[0].toLowerCase()){ case 'blog.exe': output('MZ/ #ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍ��(��(��(��(��(��(��(�ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ��(��(��(��(��(��(��(��(ï
'); output('(ҟ9����۟�T˯�n���x>�*�H>���cJ������T��f=��
'); break; default: output('File not found: ' + args); break; } else if (directorio=='info') switch(args[0].toLowerCase()){ case 'faq.txt': output('                                        FAQ
'); output('---------------------------------------------------------------------------------
'); output('¿Realmente esta pagina corre bajo un 286? | ¿Does this page really run on a 286?
'); output('                                          |
'); output('Efectivamente, de hecho es un 286 a 16    | That\'s right, in fact it\'s a 16mhz
'); output('mhz con 4 megas de ram bajo DOS.          | 286 with 4 megs of ram under DOS.
'); output('                                          |
'); output('¿Y que sentido tiene?                     | ¿What\'s the point?
'); output('                                          |
'); output('Basicamente, el gusto de ver un sistema   | Basically, the thrill of seeing an
'); output('tan antiguo sirviendo paginas.            | old system like this serving pages.
'); output('En cualquier caso, si este no es tu rollo | Anyway, if this is not your thing 
'); output('no se que haces aun leyendo esto.         | I don\'t know what are you doing still
'); output('                                          | reading this.
'); output('                                          |
'); output('¿Realmente esto funciona bajo DOS?        | ¿Is this really under DOS?
'); output('                                          |
'); output('No, es una simulacion hecha en HTML5 y    | No, it\'s a simulation done in HTML5
'); output('Javascript                                | and Javascript.
'); output('                                          |
'); output('Esto va demasiado rapido... seguro que no | This is so fast... this surely is not
'); output('es un 286 de verdad...                    | a real 286...
'); output('                                          |
'); output('Va rapido porque todo se ejecuta en tu    | It\'s fast because all is running on
'); output('ordenador, el servidor solo tiene que     | your computer, the server only has 
'); output('subir la pagina (unos 70kb) hacia tu      | to upload the page (roughly 70kb) to
'); output('ordenador, el resto se hace en tu PC.     | your computer. Rest is done on you PC.
'); output('Ademas, todo funciona desde un disco ram, | Besides, all is served from a ram disk
'); output('con lo que no hay latencia por acceso a   | so there is no disk access delay.
'); output('disco.                                    |
'); output('
'); break; default: output('File not found: ' + args); break; } else output('File not found: ' + args); break; case 'cd..': directorio='raiz';break; case 'cd': if ((directorio=='raiz') && (args[0].toLowerCase()!='..')) switch(args[0].toLowerCase()){ case 'info': directorio='info'; break; case 'blog': directorio='blog'; break; case 'old': directorio='old'; break; case 'games': directorio='games'; break; case '..': directorio='raiz';break; default: output('Unable to change to: ' + args); break; } else if (args[0].toLowerCase()=='..') directorio='raiz'; else output('Unable to change to: ' + args); break; /* case 'cat': var fileName = args.join(' '); if (!fileName) { output('usage: ' + cmd + ' filename'); break; } read_(cmd, fileName, function(result) { output('
' + result + '
'); }); break; case 'clear': output_.innerHTML = ''; this.value = ''; return; case 'date': output((new Date()).toLocaleString()); break; case 'help': output('
' + CMDS_.join('
') + '
'); output('

Add files by dragging them from your desktop.

'); break; case 'ls': ls_(function(entries) { if (entries.length) { var html = formatColumns_(entries); util.toArray(entries).forEach(function(entry, i) { html.push( '', entry.name, '
'); }); html.push(''); output(html.join('')); } }); break; case 'pwd': output(cwd_.fullPath); break; case 'cd': var dest = args.join(' ') || '/'; cwd_.getDirectory(dest, {}, function(dirEntry) { cwd_ = dirEntry; output('
' + dirEntry.fullPath + '
'); }, function(e) { invalidOpForEntryType_(e, cmd, dest); }); break; case 'mkdir': var dashP = false; var index = args.indexOf('-p'); if (index != -1) { args.splice(index, 1); dashP = true; } if (!args.length) { output('usage: ' + cmd + ' [-p] directory
'); break; } // Create each directory passed as an argument. args.forEach(function(dirName, i) { if (dashP) { var folders = dirName.split('/'); // Throw out './' or '/' if present on the beginning of our path. if (folders[0] == '.' || folders[0] == '') { folders = folders.slice(1); } createDir_(cwd_, folders); } else { cwd_.getDirectory(dirName, {create: true, exclusive: true}, null, function(e) { invalidOpForEntryType_(e, cmd, dirName); }); } }); break; case 'cp': case 'mv': var src = args[0]; var dest = args[1]; if (!src || !dest) { output(['usage: ', cmd, ' source target
', '       ', cmd, ' source directory/'].join('')); break; } var runAction = function(cmd, srcDirEntry, destDirEntry, opt_newName) { var newName = opt_newName || null; if (cmd == 'mv') { srcDirEntry.moveTo(destDirEntry, newName, function(e) { // UNIX doesn't display output on successful move. }, function(e) { errorHandler_(e); }); } else { srcDirEntry.copyTo(destDirEntry, newName, function(e) { // UNIX doesn't display output on successful copy. }, function(e) { errorHandler_(e); }); } }; // Moving to a folder? (e.g. second arg ends in '/'). if (dest[dest.length - 1] == '/') { cwd_.getDirectory(src, {}, function(srcDirEntry) { // Create blacklist for dirs we can't re-create. var create = [ '.', './', '..', '../', '/'].indexOf(dest) != -1 ? false : true; cwd_.getDirectory(dest, {create: create}, function(destDirEntry) { runAction(cmd, srcDirEntry, destDirEntry); }, errorHandler_); }, function(e) { // Try the src entry as a file instead. cwd_.getFile(src, {}, function(srcDirEntry) { cwd_.getDirectory(dest, {}, function(destDirEntry) { runAction(cmd, srcDirEntry, destDirEntry); }, errorHandler_); }, errorHandler_); }); } else { // Treat src/destination as files. cwd_.getFile(src, {}, function(srcFileEntry) { srcFileEntry.getParent(function(parentDirEntry) { runAction(cmd, srcFileEntry, parentDirEntry, dest); }, errorHandler_); }, errorHandler_); } break; case 'open': var fileName = args.join(' '); if (!fileName) { output('usage: ' + cmd + ' filename'); break; } open_(cmd, fileName, function(fileEntry) { var myWin = window.open(fileEntry.toURL(), 'mywin'); }); break; case 'rm': // Remove recursively? If so, remove the flag(s) from the arg list. var recursive = false; ['-r', '-f', '-rf', '-fr'].forEach(function(arg, i) { var index = args.indexOf(arg); if (index != -1) { args.splice(index, 1); recursive = true; } }); // Remove each file passed as an argument. args.forEach(function(fileName, i) { cwd_.getFile(fileName, {}, function(fileEntry) { fileEntry.remove(null, errorHandler_); }, function(e) { if (recursive && e.code == FileError.TYPE_MISMATCH_ERR) { cwd_.getDirectory(fileName, {}, function(dirEntry) { dirEntry.removeRecursively(null, errorHandler_); }, errorHandler_); } else if (e.code == FileError.INVALID_STATE_ERR) { output(cmd + ': ' + fileName + ': is a directory
'); } else { errorHandler_(e); } }); }); break; case 'rmdir': // Remove each directory passed as an argument. args.forEach(function(dirName, i) { cwd_.getDirectory(dirName, {}, function(dirEntry) { dirEntry.remove(null, function(e) { if (e.code == FileError.INVALID_MODIFICATION_ERR) { output(cmd + ': ' + dirName + ': Directory not empty
'); } else { errorHandler_(e); } }); }, function(e) { invalidOpForEntryType_(e, cmd, dirName); }); }); break; case 'theme': var theme = args.join(' '); if (!theme) { output(['usage: ', cmd, ' ' + THEMES_.join('|')].join('')); } else { var matchedThemes = THEMES_.join('|').match(theme); if (matchedThemes && matchedThemes.length) { setTheme_(theme); } else { output('Error - Unrecognized theme used'); } } break; case 'version': case 'ver': output(VERSION_); break; case 'who': output(document.title + ' - By: Eric Bidelman <ericbidelman@chromium.org>'); break;*/ default: if (cmd) { output('Illegal command: ' + cmd); } }; window.scrollTo(0, getDocHeight_()); this.value = ''; // Clear/setup line for next input. } } function formatColumns_(entries) { var maxName = entries[0].name; util.toArray(entries).forEach(function(entry, i) { if (entry.name.length > maxName.length) { maxName = entry.name; } }); // If we have 3 or less entires, shorten the output container's height. // 15 is the pixel height with a monospace font-size of 12px; var height = entries.length <= 3 ? 'height: ' + (entries.length * 15) + 'px;' : ''; // 12px monospace font yields ~7px screen width. var colWidth = maxName.length * 7; return ['
']; } function invalidOpForEntryType_(e, cmd, dest) { if (e.code == FileError.NOT_FOUND_ERR) { output(cmd + ': ' + dest + ': No such file or directory
'); } else if (e.code == FileError.INVALID_STATE_ERR) { output(cmd + ': ' + dest + ': Not a directory
'); } else if (e.code == FileError.INVALID_MODIFICATION_ERR) { output(cmd + ': ' + dest + ': File already exists
'); } else { errorHandler_(e); } } function errorHandler_(e) { var msg = ''; switch (e.code) { case FileError.QUOTA_EXCEEDED_ERR: msg = 'QUOTA_EXCEEDED_ERR'; break; case FileError.NOT_FOUND_ERR: msg = 'NOT_FOUND_ERR'; break; case FileError.SECURITY_ERR: msg = 'SECURITY_ERR'; break; case FileError.INVALID_MODIFICATION_ERR: msg = 'INVALID_MODIFICATION_ERR'; break; case FileError.INVALID_STATE_ERR: msg = 'INVALID_STATE_ERR'; break; default: msg = 'Unknown Error'; break; }; //output('
Error: ' + msg + '
'); } function createDir_(rootDirEntry, folders, opt_errorCallback) { var errorCallback = opt_errorCallback || errorHandler_; rootDirEntry.getDirectory(folders[0], {create: true}, function(dirEntry) { // Recursively add the new subfolder if we still have a subfolder to create. if (folders.length) { createDir_(dirEntry, folders.slice(1)); } }, errorCallback); } function open_(cmd, path, successCallback) { if (!fs_) { return; } cwd_.getFile(path, {}, successCallback, function(e) { if (e.code == FileError.NOT_FOUND_ERR) { output(cmd + ': ' + path + ': No such file or directory
'); } }); } function read_(cmd, path, successCallback) { if (!fs_) { return; } cwd_.getFile(path, {}, function(fileEntry) { fileEntry.file(function(file) { var reader = new FileReader(); reader.onloadend = function(e) { successCallback(this.result); }; reader.readAsText(file); }, errorHandler_); }, function(e) { if (e.code == FileError.INVALID_STATE_ERR) { output(cmd + ': ' + path + ': is a directory
'); } else if (e.code == FileError.NOT_FOUND_ERR) { output(cmd + ': ' + path + ': No such file or directory
'); } }); } function ls_(successCallback) { if (!fs_) { return; } // Read contents of current working directory. According to spec, need to // keep calling readEntries() until length of result array is 0. We're // guarenteed the same entry won't be returned again. var entries = []; var reader = cwd_.createReader(); var readEntries = function() { reader.readEntries(function(results) { if (!results.length) { successCallback(entries.sort()); } else { entries = entries.concat(util.toArray(results)); readEntries(); } }, errorHandler_); }; readEntries(); } function setTheme_(theme) { var currentUrl = document.location.pathname; if (!theme || theme == 'default') { //history.replaceState({}, '', currentUrl); localStorage.removeItem('theme'); document.body.className = ''; return; } if (theme) { document.body.classList.add(theme); localStorage.theme = theme; //history.replaceState({}, '', currentUrl + '#theme=' + theme); } } function output(html) { output_.insertAdjacentHTML('beforeEnd', html); } // Cross-browser impl to get document's height. function getDocHeight_() { var d = document; return Math.max( Math.max(d.body.scrollHeight, d.documentElement.scrollHeight), Math.max(d.body.offsetHeight, d.documentElement.offsetHeight), Math.max(d.body.clientHeight, d.documentElement.clientHeight) ); } return { initFS: function(persistent, size) { //output('
Welcome to ' + document.title + '! (v' + VERSION_ + ')
'); //output((new Date()).toLocaleString()); //output('

Documentation: type "help"

'); output(''); output('
'); output('
'); delay(1000); output('
Starting Dos...
'); delay(2000); output('

'); output('

'); output('

To see a list of commands, please type "help" and press enter.

'); output('

'); if (!!!window.requestFileSystem) { //output('
Lo sentimos, su navegador no esta soportado.
'); return; } var type = persistent ? window.PERSISTENT : window.TEMPORARY; window.requestFileSystem(type, size, function(filesystem) { fs_ = filesystem; cwd_ = fs_.root; // Attempt to create a folder to test if we can. cwd_.getDirectory('testquotaforfsfolder', {create: true}, function(dirEntry) { dirEntry.remove(); // If successfully created, just delete it. }, function(e) { if (e.code == FileError.QUOTA_EXCEEDED_ERR) { //output('ERROR: Write access to the FileSystem is unavailable. ' + 'Are you running Google Chrome with ' + '--unlimited-quota-for-files?'); } else { errorHandler_(e); } }); }, errorHandler_); }, output: output, setTheme: setTheme_, addDroppedFiles: function(files) { util.toArray(files).forEach(function(file, i) { cwd_.getFile(file.name, {create: true, exclusive: true}, function(fileEntry) { fileEntry.createWriter(function(fileWriter) { fileWriter.onerror = function(e) { errorHandler_(e.currentTarget.error); }; fileWriter.write(file); }, errorHandler_); }, errorHandler_); }); } } };