Add files via upload

This commit is contained in:
Last 2018-11-15 17:35:02 +08:00 committed by GitHub
parent 48d2a16d5f
commit c80e5180f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 443 additions and 0 deletions

10
z_post/conf.json Normal file
View File

@ -0,0 +1,10 @@
{
"name": "楼中楼",
"brief": "热点讨论,已经是大势所趋",
"version": "1.0",
"bbs_version": "4.0",
"installed": 1,
"enable": 0,
"hooks_rank": [],
"dependencies": []
}

View File

@ -0,0 +1,159 @@
<!-- 独立的
<div class="test">这是test</div>
<p>这是p</p>
<button onclick="afterText()">在图片后面添加文本</button>
<br>
<br>
<br>
<script>
//确认上面已经引用过JQ库文件
function afterText(){
var txt1=$("<i></i>").text("love "); // 通过 jQuery 创建元素
$(".test").after(txt1); // 在 img 之后插入新元素
}
</script>
-->
<!-- 正式回复 -->
<!--script src="//www-static.diyidan.net/static/addface/js/main.js?v=f9faff63b439fec824edbde022b77397"></script-->
<script src="plugin/z_post/main.js?v=f9faff63b439fec824edbde022b77397"></script>
<!-- 二级回复中的一段 -->
<script type="text/javascript">
/*二级回复*/
function send_comment(item) {
do_l2commit(item);
/*if(getCookie('token_id') != null && getCookie('token_id')!=''){
do_l2commit(item);
}else{
onlyLogin()
}*/
//var p_inner_value = $('div.edit_container p.p_emoji_content')
//发送Ajax请求
}
function do_l2commit(item) {
var comment_id = $(item).closest('.reply_right').find('.comment_id_hidden').val();
var reply = getPcontentText($(item).closest('.write_reply').find('#write_container').get(0));
var ajax_url = "/main/post/l2comment";
var louzhu_id = "6293877835964134301";
$.ajax({
url: ajax_url, //登陆页面
type: "POST",
async: true,
timeout: 3000,
data: {
"l1CommentId": comment_id,
"comment": reply,
"commentPage": parseInt('1', 10),
},
dataType: "json",
error: function() {},
success: function(data, status) { //如果调用成功
// var jsonObject = JSON.parse(data);
var code = data.code;
if (code != 200) {
if (data.message != null) {
showMessagePopup(data.message);
}
} else {
//TODO:后台会回传有多少二层回复的页数的
var totalCount = data.data.totalCommentCount;
var page_total_num = parseInt((totalCount - 1) / 10) + 1;
$.ajax({
url: "/main/post/l2comment",
type: "GET",
data: {
"l1CommentId": comment_id,
"page": page_total_num
},
async: true,
timeout: 3000,
dataType: "json",
error: function() {},
success: function(data, status) { //如果调用成功
// var jsonObject = JSON.parse(data);
var code = data.code;
if (code != 200) {
if (data.message != null) {
showMessagePopup(data.message)
}
} else {
displayAjaxL2commentList(item, $('script[type="text/template"]').html(), data.data, page_total_num, page_total_num, ajax_url, comment_id, louzhu_id);
$(item).closest('.write_reply').remove();
}
}
});
}
}
});
}
</script>
<!-- 底部js -->
<script type="text/template">
<li class="clr" {display_str}>
<div class="user_ti f1">
<img src="{avatar}" onclick="{url_to_user}">
</div>
<div class="more_reply_right f1">
<div class="l2_comment user_name">
<span class="user_reply_name" onclick="{url_to_user}">{nickName}</span>
<span class="user_reply_level">Lv{level}</span> {louzhu_span}
<p>:&nbsp;&nbsp; {commentContent}</p>
<!--safe咋办-->
</div>
<div class="user_reply_time">
<span>{commentTime}</span>
<span class="to_reply f2" onclick="showReply(this)">回复</span>
</div>
</div>
</li>
</script>
<script type="text/templateCommentItem">
{anchor_str}
<li class="clr" style="margin-left:70px;position: relative">
<div class="user_ti f1">
<img src="{avatar}" onclick="{url_to_user}">
</div>
<div class="reply_right f1 " >
<input type="hidden" name="comment_id_hidden" class="comment_id_hidden" value="{commentId}" data-floor-num="{commentFloorNum}" />
<div class="user_name">
<span onclick="{url_to_user}">{nickName}</span>
<span class="user_reply_level">Lv{level}</span> {louzhu_span}
<span class="f2 ie2">{commentFloorNum}楼</span>
</div>
{pic_or_music_container_div}
<ul class="more_user_reply">
<div class="user_reply_time">
{commentJudge_judgerRecommendStmt_div} {commentReward_rewardAmount_div}
<span>{commentTime}</span>
<span class="to_reply f2" onclick="showReply(this)">回复</span>
<!--<span class="to_hide_reply f2" onclick="hidel2comments(this)">收起回复({commentl2TotalCount})</span>-->
</div>
{reply_li_container_div}
</ul>
{l2_comment_page_nav_div}
</div>
{commentJudge_judgeStampUrl_span} {commentReward_rewardStampUrl_span}
</li>
</script>

View File

@ -0,0 +1,41 @@
<!-- 一级回复 -->
<div class="reply_right f1 " >
<div class="user_reply_time">
<span>03-14</span>
<span class="to_reply f2" onclick="showReply(this)">回复</span>
<!--<span class="to_hide_reply f2" onclick="hidel2comments(this)">收起回复(1)</span>-->
</div>
</div>
<?php
//创建回复信息 直接从表中读取本次post的ID有多少回复
$postreply = db_find('post_reply', array('pid'=>$_post['pid']), array('create_date'=>1));
if($postreply) { foreach($postreply as $_posts) {
//创建回复人的信息,每条回复都会被查询一遍似乎很消耗资源
$userz = user_read_cache($_posts['uid']);
$postz['username'] = array_value($userz, 'username');
$postz['user_avatar_url'] = array_value($userz, 'avatar_url');
$postz['user'] = $userz ? $userz : user_guest();
!isset($postz['floor']) AND $postz['floor'] = '';
?>
<!-- 剩下的就是细化UI了 -->
<br>
<a href="<?php echo url("user-$_posts[uid]");?>" tabindex="-1">
<img class="avatar" src="<?php echo $postz['user_avatar_url'];?>">
</a>
<?php echo $postz['username'];?>
<span class="user_reply_level">Lv7</span>
<?php echo $_posts['message'];?>
<!-- 二级回复 -->
<div class="reply_right f1 " >
<div class="user_reply_time">
<span>03-14</span>
<span class="to_reply f2" onclick="showReply(this)">回复</span>
<!--<span class="to_hide_reply f2" onclick="hidel2comments(this)">收起回复(1)</span>-->
</div>
</div>
<?php }} ?>

46
z_post/install.php Normal file
View File

@ -0,0 +1,46 @@
<?php
/*
Xiuno BBS 4.0 插件:楼中楼 插件安装
创建posts表,用于回复楼层的时候多读取一遍楼层
/ 2017-09-16 05:11
*/
!defined('DEBUG') AND exit('Forbidden');
$tablepre = $db->tablepre;
$sql = "CREATE TABLE IF NOT EXISTS {$tablepre}post_reply (
pid int(11) unsigned NOT NULL DEFAULT '0',
rid int(11) unsigned NOT NULL AUTO_INCREMENT,
uid int(11) unsigned NOT NULL DEFAULT '0',
isfirst int(11) unsigned NOT NULL DEFAULT '0',
create_date int(11) unsigned NOT NULL DEFAULT '0',
userip int(11) unsigned NOT NULL DEFAULT '0',
message text NOT NULL DEFAULT '',
PRIMARY KEY (pid),
KEY (rid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
$r = db_exec($sql);
/*
目前不使用缓存
// 缓存 tagid 10000,10000,10000,10000
$sql = "ALTER TABLE {$tablepre}thread ADD COLUMN tagids char(32) NOT NULL DEFAULT ''";
$r = db_exec($sql);
// 缓存的时间,用来和 setting('tag_update_time') 对比
$sql = "ALTER TABLE {$tablepre}thread ADD COLUMN tagids_time int(11) unsigned NOT NULL DEFAULT '0'";
$r = db_exec($sql);
// tag 缓存的时间
setting_set('tag_update_time', $time);
//$r === FALSE AND message(-1, '创建表结构失败');
*/
?>

171
z_post/main.js Normal file
View File

@ -0,0 +1,171 @@
/*表情添加*/
function showEmoji(ele){
var the_face=$(ele).closest('.face_top').next()
if(the_face.hasClass('emoji_section')){
$(ele).removeClass("to_show");
the_face.removeClass('emoji_section').find('ul').remove()
}else{
$(ele).addClass("to_show").siblings().removeClass("to_show")
the_face.find('ul').remove()
the_face.removeClass('face_section emoji_section').addClass('emoji_section').append(show_emojis())
}
}
function showFace(ele){
var the_face=$(ele).closest('.face_top').next()
if(the_face.hasClass('face_section')){
$(ele).removeClass("to_show");
the_face.removeClass('face_section').find('ul').remove()
}else{
$(ele).addClass("to_show").siblings().removeClass("to_show")
the_face.find('ul').remove()
the_face.removeClass('face_section emoji_section').addClass('face_section').append(show_faces())
}
}
function show_emojis(){
var faceList = [" (๑• . •๑) ", " ˋ( ° ▽、° ) ", " (^人^) ", " _(:3」∠)_ ", " →_→ ", " ←_← ", " (*^^*) ", " ٩(๑`^´๑)۶ ", " ╮(╯_╰)╭ ",
" ヾ(′▽`*)ゝ ", " o(≧v≦)o~~ ", " ↖(^ω^)↗ ", " ヽ( ^∀^)ノ ", " (*∩_∩*) ", " (/≧▽≦)/~ ", " ㄟ( ▔, ▔ )ㄏ ",
" ~( ̄▽ ̄~) ", " (~ ̄▽ ̄)~ ", " /(ㄒoㄒ)/~~ ", " (*/ω\*) ", " ≧▽≦蛤蛤蛤 ", " (°ー°〃) ", " ヾ( ̄▽ ̄) ",
" (╯°Д°)╯︵ ", " (☆ω☆) ", " \@_\@ ", " (*´艸`)、 ", " QAQ ", " (⊙o⊙) ", " (×_×)昏倒 ", " ( ˘•㉨•˘ ) ",
" ヾ(´(エ)`ノ゙ ", " ฅ( ̳• ◡ • ̳)ฅ ", " ⊙﹏⊙‖∣ ", " (。•ˇ‸ˇ•。) ", " ╭(╯^╰)╮ ", " ( •̀∀•́ ) ", " o(&gt;&lt;)o ",
" (ˉ▽ ̄~) 切~~ ", " ⊙ω⊙ ", " =。=b ", " =3333= ", " (ง •̀_•́)ง ", " &lt;(_ _)&gt; ", " o( ̄ヘ ̄o) ", " ヽ( ̄д ̄;) ",
" ヽ(=^・ω・^=)丿 ", " ( ^_^ )/~~拜 ", " Orz ", " ♪(^∇^*) ", " (ฅ´ω`ฅ)留爪 ", " ( ´◔ ‸◔') ", " (*^^*) ", " p(^_^)q ",
" ┗( TT )┛ ", " (ˉ▽ˉ;) ", " Õ_Õ ", " 눈_눈 ", " o(一︿一+)o ", " (〃 ̄︶ ̄)人( ̄︶ ̄〃) "]
var reply_display_emoji ='';
var emoji_li='';
var len_emoji=faceList.length;
for (var i=0; i<len_emoji; i++) {
emoji_li += "<li onclick=\"addEmoji(this, '"+faceList[i]+"');\">"+faceList[i]+ "</li>";
}
reply_display_emoji ='<ul>'+emoji_li+'</ul>';
return reply_display_emoji
}
function addFace(item, imgUlr) {
var $write_reply=$(item).closest('.add_icons').parent();
var img_str = "<img src='"+imgUlr+"'></img>";
$write_reply.find('.in_write').append(img_str).focus()
$write_reply.find('.add_icons').removeClass('face_section').find('ul').remove()
$write_reply.find('.face_top li').removeClass()
placeCaretAtEnd($write_reply.find('.in_write').get(0));
}
function addEmoji(item, str) {
var $write_reply=$(item).closest('.add_icons').parent();
$write_reply.find('.in_write').append(str).focus()
$write_reply.find('.add_icons').removeClass('emoji_section').find('ul').remove()
$write_reply.find('.face_top li').removeClass('to_show')
placeCaretAtEnd($write_reply.find('.in_write').get(0));
}
function placeCaretAtEnd(el) {
el.focus();
if (typeof window.getSelection != "undefined"
&& typeof document.createRange != "undefined") {
var range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (typeof document.body.createTextRange != "undefined") {
var textRange = document.body.createTextRange();
textRange.moveToElementText(el);
textRange.collapse(false);
textRange.select();
}
}
//这是增加回复输入框的调用按钮触发
function showReply(ele){
var toReply=null
if ($(ele).closest('.more_reply_right').length>0) {
toReply="回复 @"+$(ele).closest('.more_reply_right').find('.user_reply_name').html()+""
}else{
toReply=''
}
var replyDiv="<div class='write_reply'>"+
"<div>"+
"<div id='write_container' class='in_write' contenteditable='true'>"+toReply+"</div>"+
"</div>"+
"<div id='face_top' class='face_top'>"+
"<ul id='face_btn' class='clr'>"+
"<li onclick='showEmoji(this)'>(・ω・)颜文字</li>"+
"<li onclick='showFace(this)'><img src='/static/image/face_01.png'></li>"+
"</ul>"+
"<div class='f2'><span onclick='cancelReply(this)' style='margin-right:10px;'>取消</span><span class='ie2' onclick='send_comment(this)'>发送</span></div>"+
"</div>"+
"<div id='add_icons' class='add_icons'></div>"+
"</div>"
if ($(ele).parents().find('.write_reply').length>0) {
if ($(ele).closest('.user_reply_time').siblings('.write_reply').length>0) {
$(ele).parents().find('.write_reply').detach()
}else{
$(ele).parents().find('.write_reply').detach()
$(replyDiv).insertAfter($(ele).closest('.user_reply_time'))
}
}else{
$(replyDiv).insertAfter($(ele).closest('.user_reply_time'))
placeCaretAtEnd($(ele).closest('.reply_right').find('.in_write').get(0));
}
$('[contenteditable]').each(function() {
// 干掉IE http之类地址自动加链接
try {
document.execCommand("AutoUrlDetect", false, false);
} catch (e) {}
$(this).on('paste', function(e) {
e.preventDefault();
var text = null;
if(window.clipboardData && clipboardData.setData) {
// IE
text = window.clipboardData.getData('text');
} else {
text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在这里输入文本');
}
if (document.body.createTextRange) {
if (document.selection) {
textRange = document.selection.createRange();
} else if (window.getSelection) {
sel = window.getSelection();
var range = sel.getRangeAt(0);
// 创建临时元素使得TextRange可以移动到正确的位置
var tempEl = document.createElement("span");
tempEl.innerHTML = "&#FEFF;";
range.deleteContents();
range.insertNode(tempEl);
textRange = document.body.createTextRange();
textRange.moveToElementText(tempEl);
tempEl.parentNode.removeChild(tempEl);
}
textRange.text = text;
textRange.collapse(false);
textRange.select();
} else {
// Chrome之类浏览器
document.execCommand("insertText", false, text);
}
});
// 去除Crtl+b/Ctrl+i/Ctrl+u等快捷键
$(this).on('keydown', function(e) {
// e.metaKey for mac
if (e.ctrlKey || e.metaKey) {
switch(e.keyCode){
case 66: //ctrl+B or ctrl+b
case 98:
case 73: //ctrl+I or ctrl+i
case 105:
case 85: //ctrl+U or ctrl+u
case 117: {
e.preventDefault();
break;
}
}
}
});
});
}
function cancelReply(ele){
$(ele).closest('.write_reply').detach()
}

16
z_post/unstall.php Normal file
View File

@ -0,0 +1,16 @@
<?php
/*
Xiuno BBS 4.0 插件实例TAG 插件卸载
admin/plugin-unstall-xn_tag.htm
*/
!defined('DEBUG') AND exit('Forbidden');
$tablepre = $db->tablepre;
$sql = "DROP TABLE IF EXISTS {$tablepre}post_reply;";
$r = db_exec($sql);
$r === FALSE AND message(-1, '卸载表失败');
?>