Skip to content

Commit

Permalink
add width and height option
Browse files Browse the repository at this point in the history
  • Loading branch information
dixyes committed Sep 19, 2016
1 parent d4c3037 commit 4446e99
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ hexo.extend.filter.register('after_post_render', function(data) {

// {% dplayer key=value ... %}
hexo.extend.tag.register('dplayer', function(args) {
let url, api, loop, autoplay, theme, pic, did, token, screenshot, lang, maximum, hotkey, preload;
var id = 'dplayer' + (counter++),
raw = '<div id="'+ id + '" class="dplayer" style="margin-bottom: 20px;"></div>';
let url, api, loop, autoplay, theme, pic, did, token, screenshot, lang, maximum, hotkey, preload, width, height;
var id = 'dplayer' + (counter++);
for (var i = 0; i < args.length; ++i) {
var arg=args[i];
if(arg.split('=').length<2)
Expand Down Expand Up @@ -114,9 +113,15 @@ hexo.extend.tag.register('dplayer', function(args) {
case 'maximum':
maximum = arg.slice(arg.indexOf("=")+1);
break;
case 'width':
width = arg.slice(arg.indexOf("=")+1);
break;
case 'height':
height = arg.slice(arg.indexOf("=")+1);
break;
}
}

var raw = '<div id="'+ id + '" class="dplayer" style="margin-bottom: 20px;'+(height?" width:"+width+";":"")+(height?" height:"+height+";":"")+'"></div>';
if(url != undefined)
raw += '<script>var '+ id + ' = new DPlayer('+
JSON.stringify({
Expand Down

0 comments on commit 4446e99

Please sign in to comment.