Browse Source

Fix syntax-highlighting

ace
Shadowfacts 6 years ago
parent
commit
0ade2dcfbc
No known key found for this signature in database
GPG Key ID: A7A3BA2CFC135F32
  1. 1
      index.html
  2. 16
      main.js

1
index.html

@ -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

@ -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…
Cancel
Save