Support source queryparam. Fix space.

This commit is contained in:
Joshua Bell 2013-05-02 22:53:08 -04:00
parent 9504df54ca
commit 7f1e5e57ef
2 changed files with 18 additions and 3 deletions

View File

@ -233,6 +233,15 @@ window.onload = function () {
}
}
function parseQueryParams() {
var params = {};
var query = document.location.search.substring(1);
query.split(/&/g).forEach(function(pair) {
pair = pair.replace(/\+/g, " ").split(/=/).map(decodeURIComponent);
params[pair[0]] = pair.length === 1 ? pair[0] : pair[1];
});
return params;
}
function loadFile(filename, callback) {
var req = new XMLHttpRequest();
@ -250,7 +259,12 @@ window.onload = function () {
}
// load default
loadFile('samples/sample.default.txt', setSource);
var params = parseQueryParams();
if ('source' in params) {
setSource(params.source);
} else {
loadFile('samples/sample.default.txt', setSource);
}
// Show change history
atomToHtml('feed.xml?' + Math.random(), $('#feed'));

5
tty.js
View File

@ -738,7 +738,7 @@ function TTY(screenElement, keyboardElement, bell) {
}
// Symbol and Punctuation
case 'Spacebar': return ord(' ');
case 'Space': return ord(' ');
case 'Semicolon': return e.shiftKey ? ord(':') : ord(';');
case 'Equal': return e.shiftKey ? ord('+') : ord('=');
case 'Comma': return e.shiftKey ? ord('<') : ord(',');
@ -751,7 +751,8 @@ function TTY(screenElement, keyboardElement, bell) {
case 'BracketRight': return e.ctrlKey ? 29 : e.shiftKey ? ord('}') : ord(']');
case 'Quote': return e.shiftKey ? ord('"') : ord('\'');
// not present on Apple II keyboard
// Apple IIgs Keyboard
case 'NumpadClear': return 24;
case 'NumpadAdd': return ord('+');
case 'NumpadSubtract': return ord('-');
case 'NumpadMultiply': return ord('*');