From ce864034669b54bc6db2ed3101104316481e9eba Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 2 Oct 2016 10:50:15 -0400 Subject: [PATCH] Toolbar stuff --- css/main.css | 15 ++++++- js/type.js | 76 ++++++++++++++++++++--------------- type.html | 109 ++++++++++++++++++++++++++------------------------- 3 files changed, 114 insertions(+), 86 deletions(-) diff --git a/css/main.css b/css/main.css index e5f89b4..c5cdc0d 100644 --- a/css/main.css +++ b/css/main.css @@ -8,7 +8,7 @@ font-family: "Helvetica", Arial, sans-serif; } -/* Editor */ +/* Type */ .invalid { background-color: red; color: white !important; @@ -24,6 +24,19 @@ height: 100%; } +#toolbar { + position: absolute; + left: 0; + top: 0; + width: 100%; + padding: 7px; + height: 20px; +} + +.CodeMirror { + margin-top: 33px; +} + /* Index */ .prev-list { padding: 0px; diff --git a/js/type.js b/js/type.js index 21fd193..d6424e1 100644 --- a/js/type.js +++ b/js/type.js @@ -5,42 +5,10 @@ var focused = false; let invalids = []; var fileLines; -// fetch file and setup let hash = window.location.hash.substring(1); let hashBits = hash.split("/"); let repo = hashBits.slice(0, 3).join("/"); let filePath = hashBits.slice(3, hashBits.length).join("/"); -$.get({ - url: `https://raw.githubusercontent.com/${repo}/${filePath}`, - success: (code) => { - fileLines = code.split("\n"); - getChunk(code) - .then((chunk) => { - let lang = getLanguageByExtension(getFileExtension()); - console.log(`Detected language as ${lang.mime}`); - if (Array.isArray(lang.file)) { - if (lang.file.length != 0) { - var req = req = $.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file[0]}/${lang.file[0]}.min.js`); - for (var i = 1; i < lang.file.length; i++) { - req = req.then($.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file[i]}/${lang.file[i]}.min.js`)); - } - req.then(() => { - setup(chunk, lang.mime); - }); - } else { - setup(chunk, lang.mime); - } - } else { - $.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file}/${lang.file}.min.js`, () => { - setup(chunk, lang.mime); - }); - } - }) - .catch((e) => { - throw e; - }) - } -}); // language selector let langaugeSelector = $("#language"); @@ -83,6 +51,44 @@ $("#restart").click(() => { }); }); +// back button +$("#back").click(() => { + window.location.href = `/repo.html#${repo}`; +}); + +// fetch file and setup +$.get({ + url: `https://raw.githubusercontent.com/${repo}/${filePath}`, + success: (code) => { + fileLines = code.split("\n"); + getChunk(code) + .then((chunk) => { + let lang = getLanguageByExtension(getFileExtension()); + console.log(`Detected language as ${lang.mime}`); + if (Array.isArray(lang.file)) { + if (lang.file.length != 0) { + var req = req = $.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file[0]}/${lang.file[0]}.min.js`); + for (var i = 1; i < lang.file.length; i++) { + req = req.then($.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file[i]}/${lang.file[i]}.min.js`)); + } + req.then(() => { + setup(chunk, lang.mime); + }); + } else { + setup(chunk, lang.mime); + } + } else { + $.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file}/${lang.file}.min.js`, () => { + setup(chunk, lang.mime); + }); + } + }) + .catch((e) => { + throw e; + }) + } +}); + // setup function setup(data, mime) { let el = document.getElementById("editor"); @@ -536,3 +542,9 @@ function removeAllInvalids() { invalids = []; }); } + +function goToEnd() { + editor.setCursor(getEndPos()); + updateIncompleteMark(); + save(); +} diff --git a/type.html b/type.html index 6f5abee..3bce600 100644 --- a/type.html +++ b/type.html @@ -15,59 +15,62 @@
- - - +
+ + + + +