mirror of https://github.com/shadowfacts/type.git
Fix syntax-highlighting
This commit is contained in:
parent
64da38254d
commit
0ade2dcfbc
|
@ -9,7 +9,6 @@
|
|||
<body>
|
||||
|
||||
<script src="codemirror/codemirror.js"></script>
|
||||
<script src="codemirror/mode/javascript/javascript.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
|
|
16
main.js
16
main.js
|
@ -13,19 +13,25 @@ let extensions = {
|
|||
let file = window.location.hash.substring(1);
|
||||
$.get({
|
||||
url: `https://raw.githubusercontent.com/${file}`,
|
||||
success: (data) => {
|
||||
success: (code) => {
|
||||
let parts = file.split(".");
|
||||
let fileExtension = parts[parts.length - 1];
|
||||
let extension = extensions.hasOwnProperty(fileExtension) ? extensions[fileExtension] : fileExtension;
|
||||
setup(data, extension);
|
||||
let mode = extensions.hasOwnProperty(fileExtension) ? extensions[fileExtension] : fileExtension;
|
||||
$.get({
|
||||
url: `/codemirror/mode/${mode}/${mode}.js`,
|
||||
success: (data) => {
|
||||
eval(data);
|
||||
setup(code, mode);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// setup
|
||||
function setup(data, extension) {
|
||||
function setup(data, mode) {
|
||||
editor = new CodeMirror(document.body, {
|
||||
value: data,
|
||||
mode: extension,
|
||||
mode: mode,
|
||||
readOnly: true,
|
||||
autofocus: true,
|
||||
extraKeys: {
|
||||
|
|
Loading…
Reference in New Issue