@zhennann/markdown
Advanced tools
Comparing version 1.0.3 to 1.0.4
34
index.js
@@ -38,7 +38,7 @@ const markdown_it = require('markdown-it'); | ||
// element | ||
const id = `aplayer-${(new Date()).getTime()}`; | ||
const id = `aplayer-${(new Date()).getTime()}${idx}`; | ||
// opening tag | ||
return `<p><div id="${id}"> | ||
<script type="text/javascript"> | ||
function loadScript(src, callback) { | ||
function __aplayerLoadScript(src, callback) { | ||
if (!(typeof callback === 'function')) { | ||
@@ -74,3 +74,3 @@ callback = function() {}; | ||
} | ||
function loadLink(src, callback) { | ||
function __aplayerLoadLink(src, callback) { | ||
if (!(typeof callback === 'function')) { | ||
@@ -102,6 +102,6 @@ callback = function() {}; | ||
} | ||
function loadAplayer(callback){ | ||
function __aplayerLoadResource(callback){ | ||
if(window.APlayer) return callback(); | ||
loadLink('https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.css',function(){ | ||
loadScript('https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js', function() { | ||
__aplayerLoadLink('https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.css',function(){ | ||
__aplayerLoadScript('https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js', function() { | ||
return callback(); | ||
@@ -111,6 +111,6 @@ }) | ||
} | ||
loadAplayer(function(){ | ||
var options = ${content}; | ||
function __aplayerLoad(id,options){ | ||
// options | ||
if(!options.audio) return; | ||
options.container = document.getElementById('${id}'); | ||
options.container = document.getElementById(id); | ||
if(options.audio.concat){ | ||
@@ -123,4 +123,16 @@ for(var i=0;i<options.audio.length;i++){ | ||
} | ||
new window.APlayer(options); | ||
}); | ||
// queue | ||
if(!window.__aplayerLoadQueue){ | ||
window.__aplayerLoadQueue=[options]; | ||
__aplayerLoadResource(function(){ | ||
for(var i=0;i<window.__aplayerLoadQueue.length;i++){ | ||
new window.APlayer(window.__aplayerLoadQueue[i]); | ||
} | ||
window.__aplayerLoadQueue=null; | ||
}); | ||
}else{ | ||
window.__aplayerLoadQueue.push(options); | ||
} | ||
} | ||
__aplayerLoad('${id}',${content}); | ||
</script> | ||
@@ -127,0 +139,0 @@ `; |
{ | ||
"name": "@zhennann/markdown", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "markdown", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16483
182