mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 21:06:15 -08:00
添加运行代码
This commit is contained in:
1 parent
d8e1e597e2
commit
8d52cf8bba
4 files changed
+57
-598
No files matched your search
@@ -0,0 +1,23 @@
|
||||
window.runCode = function(hook) {
|
||||
hook.ready(function() {
|
||||
Array.from(document.querySelectorAll('.markdown-section a'))
|
||||
.filter(function(item) {
|
||||
return item.innerHTML === 'Run Code';
|
||||
})
|
||||
.forEach(item => {
|
||||
item.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
var codeElement = item.parentElement.nextElementSibling;
|
||||
if (
|
||||
codeElement.tagName === 'PRE' &&
|
||||
codeElement.dataset.lang === 'js'
|
||||
) {
|
||||
var code = window.encodeURIComponent(codeElement.innerText);
|
||||
window.open(
|
||||
'https://blog.zhw-island.com/ArtPlayer/lab/?code=' + code
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user