' +
'
' +
@@ -31,40 +31,38 @@ $(function () {
});
//ok
$(document).on('click', '#ok', function () {
- var DP_url = document.getElementById('DP-url').value,
- DP_pic = document.getElementById('DP-pic').value,
- DP_danmu = document.getElementById('DP-danmu').checked ? true : false,
- DP_autoplay = document.getElementById('DP-autoplay').checked ? true : false,
- DP_addition = document.getElementById('DP-addition').value;
- var tag = '[dplayer url="' + DP_url + '" pic="' + DP_pic + '" ';
- if (!DP_danmu) tag += 'danmu="' + DP_danmu + '" ';
- if (DP_autoplay) tag += 'autoplay="' + DP_autoplay + '" ';
- if (DP_addition) tag += 'addition="' + DP_addition + '" ';
+ var url = document.getElementById('DP-url').value,
+ pic = document.getElementById('DP-pic').value,
+ danmu = !!document.getElementById('DP-danmu').checked,
+ autoplay = !!document.getElementById('DP-autoplay').checked;
+ var tag = '[dplayer url="' + url + '" pic="' + pic + '" ';
+ if (!danmu) tag += 'danmu="' + danmu + '" ';
+ if (autoplay) tag += 'autoplay="' + autoplay + '" ';
tag += '/]\n';
- myField = document.getElementById('text');
+ var editor = document.getElementById('text');
if (document.selection) {
- myField.focus();
+ editor.focus();
sel = document.selection.createRange();
sel.text = tag;
- myField.focus();
+ editor.focus();
}
- else if (myField.selectionStart || myField.selectionStart == '0') {
- var startPos = myField.selectionStart;
- var endPos = myField.selectionEnd;
+ else if (editor.selectionStart || editor.selectionStart === '0') {
+ var startPos = editor.selectionStart;
+ var endPos = editor.selectionEnd;
var cursorPos = startPos;
- myField.value = myField.value.substring(0, startPos)
+ editor.value = editor.value.substring(0, startPos)
+ tag
- + myField.value.substring(endPos, myField.value.length);
+ + editor.value.substring(endPos, myField.value.length);
cursorPos += tag.length;
- myField.focus();
- myField.selectionStart = cursorPos;
- myField.selectionEnd = cursorPos;
+ editor.focus();
+ editor.selectionStart = cursorPos;
+ editor.selectionEnd = cursorPos;
}
else {
- myField.value += tag;
- myField.focus();
+ editor.value += tag;
+ editor.focus();
}
$('#DPlayer-Panel').remove();
diff --git a/assets/player.js b/assets/player.js
new file mode 100644
index 0000000..869946a
--- /dev/null
+++ b/assets/player.js
@@ -0,0 +1,16 @@
+var dPlayers = [];
+var loadDPlayer = function () {
+ var load = function (d, conf) {
+ conf.container = d;
+ dPlayers.push(new DPlayer(conf));
+ };
+ for (var i = 0; i < dPlayers.length; i++) {
+ dPlayers[i].destroy();
+ }
+ dPlayers = [];
+ for (var j = 0, k = document.querySelectorAll('.dplayer'); j < k.length; j++) {
+ load(k[j], JSON.parse(k[j].dataset.config));
+ }
+};
+
+document.addEventListener('DOMContentLoaded', loadDPlayer, !1);
\ No newline at end of file
diff --git a/assets/screenshot.png b/assets/screenshot.png
deleted file mode 100644
index d706191..0000000
Binary files a/assets/screenshot.png and /dev/null differ
diff --git a/assets/screenshot_editor.png b/assets/screenshot_editor.png
deleted file mode 100644
index a012f58..0000000
Binary files a/assets/screenshot_editor.png and /dev/null differ
diff --git a/dist/util.js b/dist/util.js
deleted file mode 100644
index 5e326f7..0000000
--- a/dist/util.js
+++ /dev/null
@@ -1,20 +0,0 @@
-var len = dPlayerOptions.length;
-var dPlayers = [];
-for (var i = 0; i < len; i++) {
- dPlayers.push(new DPlayer({
- container: document.getElementById('player' + dPlayerOptions[i]['id']),
- autoplay: dPlayerOptions[i]['autoplay'],
- theme: dPlayerOptions[i]['theme'],
- loop: dPlayerOptions[i]['loop'],
- lang: dPlayerOptions[i]['lang'],
- screenshot: dPlayerOptions[i]['screenshot'],
- hotkey: dPlayerOptions[i]['hotkey'],
- preload: dPlayerOptions[i]['preload'],
- logo: dPlayerOptions[i]['logo'],
- volume: dPlayerOptions[i]['volume'],
- mutex: dPlayerOptions[i]['mutex'],
- video: dPlayerOptions[i]['video'],
- subtitle: dPlayerOptions[i]['subtitle'],
- danmaku: dPlayerOptions[i]['danmaku'],
- }));
-}
\ No newline at end of file