Skip to content

Commit

Permalink
添加了插入按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
menhood authored and fghrsh committed Jun 12, 2018
1 parent 16e1dc4 commit 62691ee
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 2 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# [DPlayer_for_Z-BlogPHP](https://app.zblogcn.com/?id=1033)

## 2018-6-9更新

添加了插入按钮↙,不过只支持自带的UE编辑器,其他编辑器就得手动复制了😝

目前属于能用就行的阶段🤣

下上图:

![效果图](https://www.menhood.wang/iframe/dpplaylist/insertdemo.png)

Demo:https://www.fghrsh.net/post/57.html
效果截图
<img width="80%" src="https://fp1.fghrsh.net/2016/06/01/5dc96d3a7e157c883ea62e22339cee39.jpg" border="0" vspace="0"/>
Expand All @@ -18,4 +29,4 @@ Demo:https://www.fghrsh.net/post/57.html
更多说明见 Z-Blog 应用中心 https://app.zblogcn.com/?id=1033

## LICENSE
MIT &copy; [FGHRSH](https://www.fghrsh.net)
MIT &copy; [FGHRSH](https://www.fghrsh.net)
142 changes: 141 additions & 1 deletion include.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ function ActivePlugin_DPlayer() {
Add_Filter_Plugin('Filter_Plugin_ViewPost_Template', 'DPlayer_Filter_Plugin_ViewPost_Template');
Add_Filter_Plugin('Filter_Plugin_ViewList_Template', 'DPlayer_Filter_Plugin_ViewList_Template');
Add_Filter_Plugin('Filter_Plugin_Zbp_MakeTemplatetags', 'DPlayer_Filter_Plugin_Zbp_MakeTemplatetags');
Add_Filter_Plugin('Filter_Plugin_Edit_Response5','DPlayer_Edit_5');
Add_Filter_Plugin('Filter_Plugin_Admin_Header','SCP_frame_src');
Add_Filter_Plugin('Filter_Plugin_Other_Header','SCP_frame_src');
}

function DPlayer_Filter_Plugin_ViewPost_Template(&$template) {
Expand Down Expand Up @@ -34,6 +37,143 @@ function DPlayer_Filter_Plugin_Zbp_MakeTemplatetags() {
'<script type="text/javascript" src="'.$zbp->host.'zb_users/plugin/DPlayer/DPlayer.min.js?v=1.1.3"></script>'."\n".
'<script>function dpajaxload(){if(0<$(\'#dpajax\').length){var DPlayerOptions=[];eval($(\'#dpajax\').text());for(i=0;i<DPlayerOptions.length;i++)new DPlayer({element:document.getElementById(\'dp\'+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,video:DPlayerOptions[i].video,danmaku:DPlayerOptions[i].danmaku})}}dpajaxload();</script>';
}
function SCP_frame_src(){
echo '<meta http-equiv="Content-Security-Policy" content="child-src \'self\' https://api.menhood.wang;sandbox allow-forms allow-same-origin">'. "\r\n";
}
function DPlayer_Edit_5(){
echo <<<EOF
<input type="button" id="ShowButton_2" name="ShowButton_2" value="显示DP插入参数" class="button">
<style>
#dplayerinput{display:none;margin:5px;width:400px;height:100%;}
#iframechild{border-radius:10px;}
h4{display:inline}
#shortcode{display:none;margin:2px;}
#shortcodecopy{display:none;maigin:2px;}
#copysuccess{display:none;}
</style>
<div id="" style="display: flex;" >
<div id="dplayerinput" >
<br>
<h4>图片地址格式:</h4>http://ddns.menhood.wang/img.jpg
<br>
<h4>视频地址格式</h4>:http://ddns.menhood.wang/video.mp4
<br>
<h4>图片地址:</h4><input type="text" oninput="dplayerurls()" value="" width=100% id="dplayerpic">
<br>
<h4>视频地址:</h4><input type="text" oninput="dplayerurls()" value="" width=100% id="dplayerurl">
<br>
<h4>是否开启弹幕:</h4><input type="checkbox" id="danmucheck" >
<br>
<h4>是否开启自动播放:</h4><input type="checkbox" id="autoplaycheck" >
<br>
<h4>是否开启预加载:</h4><input type="checkbox" id="preloadcheck" >
<script>
$(function(){
$("#ShowButton_2").click(
function(){
if($("#dplayerinput").css("display")=='none'){
$("#dplayerinput").slideDown();
$("#ShowButton_2").val("隐藏DP插入参数");
}else{
$("#dplayerinput").slideUp();
$("#ShowButton_2").val("显示DP插入参数");
}
});
});
$(function(){
$("#dplisgenerate").click(
function(){
if($("#dplistiframe").css("display")=='none'){
window.open('https://api.menhood.wang/dpplaylist');
//$("#dplistiframe").slideDown();
//$("#dplisgenerate").val("隐藏列表生成页");
//$("#iframechild").attr("src","https://api.menhood.wang/dpplaylist/index.php");
}else{
//$("#dplistiframe").slideUp();
// $("#dplisgenerate").val("显示列表生成页");
}
});
});
var dplayerurl;
var dplayerpic;
var danmucheack;
var dpcode;
function dplayerurls(){
dplayerurl = document.getElementById("dplayerurl").value;
dplayerpic = document.getElementById("dplayerpic").value;
}//文本框参数处理
function dplayerinsert(){
if (document.getElementById("danmucheck").checked){
danmucheack="true";
}else {
danmucheack="false";
}//检查弹幕checkbox是否选中
if (document.getElementById("autoplaycheck").checked){
autoplaycheck="true";
}else {
autoplaycheck="false";
}
if (document.getElementById("preloadcheck").checked){
preloadcheck="true";
}else {
preloadcheck="false";
}
dpcode = '[dplayer url="' + dplayerurl + '" pic="' + dplayerpic + '"preload='+'"'+ preloadcheck +'"'+'"autoplay='+'"'+ autoplaycheck +'"'+'danmu='+'"'+danmucheack+'"'+' / ]';
if(editor_api.editor.content.obj.execCommand){
editor_api.editor.content.obj.execCommand('inserthtml',dpcode);
}else{
document.getElementById("shortcode").value=dpcode;
document.getElementById("shortcode").style.display="inline";
document.getElementById("shortcodecopy").style.display="inline";
document.getElementById("dpclear").style.display="none";
}
/* (document.getElementById("editor_content")){
document.getElementById("editor_content").innerHTML = dpcode;
}*/
}//插入单个视频代码
function dpclear(){
if(document.getElementById("carea")){
editor_api.editor.content.obj.setContent('',false);
}
if (document.getElementByName("carea-html-code")){
document.getElementByName("carea-html-code")[0].value = '';
}
}//清除输入代码
function disinfo(){document.getElementById("copysuccess").style.display="none";}
function copycode(){
document.getElementById("shortcode").select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
document.getElementById("copysuccess").style.display="inline";
setTimeout("disinfo()", 3000);
}//复制代码
</script>
<br>
<input type="button" onclick="dplayerinsert()" class="button" value="生成代码">
<input type="button" id="dplisgenerate" name="dplisgenerate" value="生成列表" class="button">
<input type="button" id="dpclear" onclick="dpclear()" class="button" value="清除输入" >
<hr>
<input type="text" id="shortcode" value="" ><input type="button"id="shortcodecopy" onclick="copycode()" class="button" value="复制" >
<br>
<span id="copysuccess">复制成功,请将短代码粘贴到编辑器内<span>
</div>
<div id="dplistiframe" style="display:none; ">
<iframe sandbox="allow-forms allow-same-origin allow-scripts" name="iframechild" id="iframechild" src="" border="0" frameborder="no" framespacing="0" allowfullscreen="true" width=768 height=350 > </iframe>
</div>
</div>
EOF;
}

function InstallPlugin_DPlayer() {
global $zbp,$obj,$bucket;
Expand Down Expand Up @@ -67,4 +207,4 @@ function UninstallPlugin_DPlayer() {
file_put_contents(dirname(__FILE__)."/DPlayer.min.js", $dpjs);
}
$zbp->DelConfig('DPlayer');
}
}

0 comments on commit 62691ee

Please sign in to comment.