Created
March 15, 2019 19:13
-
-
Save atomize/f15f9757a6f135bdb08405cd50aa181d to your computer and use it in GitHub Desktop.
reminder for Prism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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