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('
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' + result + ''); }); break; case 'clear': output_.innerHTML = ''; this.value = ''; return; case 'date': output((new Date()).toLocaleString()); break; case 'help': 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, 'Documentation: type "help"
'); output('To see a list of commands, please type "help" and press enter.
'); output(''); if (!!!window.requestFileSystem) { //output('