Commit 44acc473 authored by Liang Ding's avatar Liang Ding

🔥 Fix #12336

parent 6d37999e
#
# Copyright (c) 2010-2016, b3log.org & hacpai.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Description: Language configurations(zh_CN) of plugin b3log broadcast.
# Version: 1.0.1.1, Sep 4, 2016
# Author: Liyuan Li
# Author: Liang Ding
#
userBroadcastLabel=User Broadcast
titleLabel1=Title:
linkLabel1=Link:
contentLabel1=Content:
noEmptyLabel=No Empty
submitLabel=Submit
submitErrorLabel=Error
chanceBroadcastLabel1=Time to post:
#
# Copyright (c) 2010-2016, b3log.org & hacpai.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Description: Language configurations(zh_CN) of plugin b3log broadcast.
# Version: 1.0.0.1, Apr 24, 2013
# Author: Liyuan Li
#
userBroadcastLabel=\u7528\u6237\u5e7f\u64ad
titleLabel1=\u6807\u9898\uff1a
linkLabel1=\u94fe\u63a5\uff1a
contentLabel1=\u5185\u5bb9\uff1a
noEmptyLabel=\u4e0d\u80fd\u4e3a\u7a7a
submitLabel=\u63d0\u4ea4
submitErrorLabel=\u63d0\u4ea4\u5f02\u5e38
chanceBroadcastLabel1=\u5e7f\u64ad\u5269\u4f59\u65f6\u95f4\uff1a
\ No newline at end of file
<link type="text/css" rel="stylesheet" href="${staticServePath}/plugins/b3log-broadcast/style.css"/>
<div id="b3logBroadcastPanel">
<div id="b3logBroadcast">
<div class="module-panel">
<div class="module-header">
<h2 class="left">
<a target="_blank" href="https://hacpai.com/tags/B3log%20Broadcast">
${userBroadcastLabel}
</a>
</h2>
<button class="none right msg"></button>
<span class="clear"></span>
</div>
<div class="module-body padding12">
<div id="b3logBroadcastList">
</div>
</div>
</div>
</div>
<div id="b3logBroadcastDialog" class="form">
<label>${titleLabel1}</label>
<span class="none msg">${noEmptyLabel}</span>
<input type="text" id="b3logBroadcastTitle">
<label>${linkLabel1}</label>
<input type="text" id="b3logBroadcastLink">
<label>${contentLabel1}</label>
<span class="none msg">${noEmptyLabel}</span>
<textarea id="b3logBroadcastContent"></textarea>
<button class="marginTop12">${submitLabel}</button><span class="none msg">${submitErrorLabel}</span>
</div>
</div>
<script type="text/javascript">
plugins.b3logBroadcast = {
init: function() {
$("#loadMsg").text("${loadingLabel}");
// dialog
$("#b3logBroadcastDialog").dialog({
width: 700,
height: 245,
"modal": true,
"hideFooter": true
});
// 打开广播窗口
$("#b3logBroadcast .module-header > button").click(function() {
$("#b3logBroadcastDialog").dialog("open");
});
// 广播提交
$("#b3logBroadcastDialog button").click(function() {
var data = {
"broadcast": {
"title": $("#b3logBroadcastTitle").val().replace(/(^\s*)|(\s*$)/g, ""),
"content": $("#b3logBroadcastContent").val().replace(/(^\s*)|(\s*$)/g, ""),
"link": $("#b3logBroadcastLink").val()
}
};
if (data.broadcast.title === "") {
$("#b3logBroadcastTitle").prev().show();
}
if (data.broadcast.content === "") {
$("#b3logBroadcastContent").prev().show();
}
if (data.broadcast.title === "" || data.broadcast.content === "") {
return;
}
$.ajax({
type: "POST",
url: latkeConfig.servePath + "/console/plugins/b3log-broadcast",
data: JSON.stringify(data),
success: function(result) {
if (result.sc) {
$("#b3logBroadcastTitle").val("");
$("#b3logBroadcastLink").val("");
$("#b3logBroadcastContent").val("");
$("#b3logBroadcastDialog").dialog("close");
$("#b3logBroadcastDialog > button").next().hide();
$("#b3logBroadcastTitle").prev().hide();
$("#b3logBroadcastContent").prev().hide();
broadcastChange();
} else {
$("#b3logBroadcastDialog > button").next().show();
}
}
});
});
// 获取广播
$.ajax({
type: "GET",
url: "https://hacpai.com/apis/broadcasts",
dataType: "jsonp",
jsonp: "callback",
beforeSend: function() {
$("#b3logBroadcastList").css("background",
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent");
},
error: function() {
$("#b3logBroadcastList").html("Loading Symphony broadcasts failed :-(").css("background", "none");
},
success: function(result) {
var articles = result.articles;
if (0 === articles.length) {
return;
}
var listHTML = "<ul>";
for (var i = 0; i < articles.length; i++) {
var article = articles[i];
var articleLiHtml = "<li>"
+ "<a target='_blank' href='" + article.articlePermalink + "'>"
+ article.articleTitle + "</a>&nbsp; <span class='date'>" + $.bowknot.getDate(article.articleCreateTime, 1);
+"</span></li>";
listHTML += articleLiHtml;
}
listHTML += "</ul>";
$("#b3logBroadcastList").html(listHTML).css("background", "none");
},
complete: function(XMLHttpRequest, textStatus) {
$("#loadMsg").text("");
}
});
// 广播机会
var interval;
var broadcastChange = function() {
$.ajax({
type: "GET",
url: latkeConfig.servePath + "/console/plugins/b3log-broadcast/chance",
cache: false,
success: function(result) {
if (result.sc) {
var showCountDown = function() {
var now = new Date();
var leftTime = result.broadcastChanceExpirationTime - now.getTime();
var leftsecond = parseInt(leftTime / 1000);
if (leftsecond < 0) {
$("#b3logBroadcast .module-header > button").hide();
clearInterval(interval);
interval = undefined;
return;
} else {
var minute = Math.floor(leftsecond / 60),
second = Math.floor(leftsecond - minute * 60);
$("#b3logBroadcast .module-header > button").text("${chanceBroadcastLabel1}" + minute + ":" + second).show();
}
};
if (!interval) {
interval = window.setInterval(function() {
showCountDown();
}, 1000);
}
} else {
$("#b3logBroadcast .module-header > button").hide();
clearInterval(interval);
interval = undefined;
}
}
});
};
setInterval(function() {
broadcastChange();
}, 10000);
broadcastChange();
}
};
/*
* 添加插件
*/
admin.plugin.add({
"id": "b3logBroadcast",
"path": "/main/panel2",
"content": $("#b3logBroadcastPanel").html()
});
// 移除现有内容
$("#b3logBroadcastPanel").remove();
</script>
\ No newline at end of file
#
# Copyright (c) 2010-2016, b3log.org & hacpai.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Description: Description of plugin b3log-broadcast.
# Version: 1.0.0.1, Apr 24, 2013
# Author: Liang Ding
#
rendererId=admin-main.ftl
author=<a href="http://88250.b3log.org">88250</a> & <a href="http://vanessa.b3log.org">Vanessa</a>
name=B3log Broadcast
version=0.0.1
types=ADMIN
classesDirPath=/WEB-INF/classes/
# TODO: libDirPath=/WEB-INF/lib/
pluginClass=
eventListenerClasses=
\ No newline at end of file
/*
* plugin style for b3log-broadcast
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.0.0.1, Apr 24, 2011
*/
#b3logBroadcastDialog input,
#b3logBroadcastDialog textarea {
width: 98%;
}
#b3logBroadcast .module-header > button {
height: 22px;
}
#b3logBroadcastDialog label {
line-height: 30px;
}
#b3logBroadcast .msg,
#b3logBroadcastDialog .msg {
color: #D54121;
}
#b3logBroadcastList ul {
list-style: none;
}
#b3logBroadcastList a {
text-decoration: none;
}
#b3logBroadcastList .date {
color: #686868;
font-size: 12px;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment