mirror of https://github.com/shadowfacts/type.git
Toolbar stuff
This commit is contained in:
parent
ce5f66413e
commit
ce86403466
15
css/main.css
15
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;
|
||||
|
|
76
js/type.js
76
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();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
<br>
|
||||
</noscript>
|
||||
|
||||
<div id="toolbar">
|
||||
<button id="back">‹ Back</button>
|
||||
<button id="restart">Restart</button>
|
||||
<select id="language">
|
||||
<option value="auto-detect">Auto-Detect</option>
|
||||
|
@ -68,6 +70,7 @@
|
|||
<option value="yeti">Yeti</option>
|
||||
<option value="zenburn">Zenburn</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<textarea id="editor"></textarea>
|
||||
|
||||
|
|
Loading…
Reference in New Issue