Skip to content

Instantly share code, notes, and snippets.

@atomize
Created March 15, 2019 19:13
Show Gist options
  • Save atomize/f15f9757a6f135bdb08405cd50aa181d to your computer and use it in GitHub Desktop.
Save atomize/f15f9757a6f135bdb08405cd50aa181d to your computer and use it in GitHub Desktop.
reminder for Prism
function loadFile(src, cb) {
var xhr = new XMLHttpRequest();
var s = [];
xhr.open("GET", src, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status < 400 && xhr.responseText) {
s = [src,xhr.responseText]
} else if (xhr.status >= 400) {
s = [src, "✖ Error " + xhr.status + " while fetching file: " + xhr.statusText]
} else {
s = [src, "✖ Error: File does not exist or is empty"]
}
cb(s)
}
};
xhr.send(null);
}
function callerbacker(a){
console.log(a)
}
loadFile("plugins/file-highlight/index.html", callerbacker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment