Skip to content

Instantly share code, notes, and snippets.

@esironal
Created October 1, 2018 21:58
Show Gist options
  • Save esironal/4c1ae4a55ab431680712d57d80992658 to your computer and use it in GitHub Desktop.
Save esironal/4c1ae4a55ab431680712d57d80992658 to your computer and use it in GitHub Desktop.
Trying to make a script loder for LingerUI
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Code Mirror CDN</title>
<link rel="stylesheet" href="lib/codemirror.css">
<link rel="stylesheet" href="addon/hint/show-hint.css">
<script src="lib/codemirror.js"></script>
<script src="addon/hint/show-hint.js"></script>
<script src="addon/hint/xml-hint.js"></script>
<script src="addon/hint/html-hint.js"></script>
<script src="mode/xml/xml.js"></script>
<script src="mode/javascript/javascript.js"></script>
<script src="mode/css/css.js"></script>
<script src="mode/htmlmixed/htmlmixed.js"></script>
<script src="addon/selection/active-line.js"></script>
<script src="addon/edit/matchbrackets.js"></script>
<link rel="stylesheet" href="theme/neonsyntax.css">
<style type="text/css">.CodeMirror {font-size:15px; width: 100%,; height: 100%;}</style>
</head>
<body>
<!-- This is an awsome comment -->
<div id="code"></div>
<script type="text/javascript">
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
CodeMirror.commands.autocomplete = function(cm) {
CodeMirror.showHint(cm, CodeMirror.hint.html);
};
window.onload = function() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200)
xhttp.open("GET", '../' + getUrlParameter('src'), true);
xhttp.send();
editor = CodeMirror(document.getElementById("code"), {
mode: "text/html",
theme: "neonsyntax",
lineWrapping: true,
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
extraKeys: {
"Ctrl-Space": "autocomplete"
},
value: xhttp.responseText,
});
};
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment