new docs init

This commit is contained in:
Harvey Zack committed 2019-04-20 12:46:15 +08:00
1 parent f04493a8fa
commit f2947edacb
36 files changed
+14 -4651

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
(function () {
window.runCode = function(hook) {
hook.ready(function() {
Array.from(document.querySelectorAll('.markdown-section a'))
.filter(function(item) {
return item.innerHTML === 'Run Code';
})
.forEach(function(item) {
item.addEventListener('click', function(event) {
event.preventDefault();
var codeElement = item.parentElement.nextElementSibling;
if (
codeElement.tagName === 'PRE' &&
codeElement.dataset.lang === 'js'
) {
var libs = item.href.split('/lib=')[1] || '';
var code = encodeURIComponent(codeElement.innerText);
var url = 'https://artplayer.org/lab/?libs=' + libs + '&code=' + code;
window.open(url);
}
});
});
});
};
})();