|
|
@ -22,12 +22,13 @@ |
|
|
|
// Given a array of URIs, load them in order |
|
|
|
// Given a array of URIs, load them in order |
|
|
|
function loadLanguages(uris, callback) { |
|
|
|
function loadLanguages(uris, callback) { |
|
|
|
uris.forEach(function(uri) { |
|
|
|
uris.forEach(function(uri) { |
|
|
|
var sc=document.createElement('script'); |
|
|
|
var sc = document.createElement('script'); |
|
|
|
sc.src=uri; sc.async=false; // critical? |
|
|
|
sc.src = uri; |
|
|
|
if( uris.indexOf(uri) == uris.length-1) { |
|
|
|
sc.async = false; // critical? |
|
|
|
sc.onload = callback; |
|
|
|
if (uris.indexOf(uri) == uris.length-1) { |
|
|
|
} |
|
|
|
sc.onload = callback; |
|
|
|
document.head.appendChild(sc); |
|
|
|
} |
|
|
|
|
|
|
|
document.head.appendChild(sc); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -44,10 +45,10 @@ |
|
|
|
// Check what we need to load |
|
|
|
// Check what we need to load |
|
|
|
for (i=0; i < lb.length; i++) { |
|
|
|
for (i=0; i < lb.length; i++) { |
|
|
|
lang = lb[i].className.replace('language-',''); |
|
|
|
lang = lb[i].className.replace('language-',''); |
|
|
|
lurl = hlbaseUri + "languages/" + lang + ".min.js"; |
|
|
|
lurl = hlbaseUri + "languages/" + lang + ".min.js"; |
|
|
|
if (!(langs.includes(lang) || jss.includes(lurl))) { |
|
|
|
if (!(langs.includes(lang) || jss.includes(lurl))) { |
|
|
|
jss.push(lurl); |
|
|
|
jss.push(lurl); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Load files in order, higlight on last load |
|
|
|
// Load files in order, higlight on last load |
|
|
|
loadLanguages(jss, () => {highlight(lb)}); |
|
|
|
loadLanguages(jss, () => {highlight(lb)}); |
|
|
|