-
Notifications
You must be signed in to change notification settings - Fork 34
/
memos.php
193 lines (169 loc) · 8.85 KB
/
memos.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
/**
* Memos
*
* @package custom
*/
?>
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('compoment/head.php');?>
<link rel="stylesheet" href="https://staticfile.typecho.co.uk/fancybox/fancybox.min.css">
<?php if(Bsoptions('Emoji') == true) :?>
<link href="<?php AssetsDir();?>assets/vendors/bs-emoji/bs-emoji.css" rel="stylesheet" type="text/css">
<?php endif; ?>
<div class="pure-g" id="layout">
<div class="pure-u-1 pure-u-md-<?php if(Bsoptions('site_style') == '1' || Bsoptions('site_style') == ''):?>3<?php endif;?><?php if(Bsoptions('site_style') == '2'):?>4<?php endif;?>-4">
<div class="content_container">
<?php if(Bsoptions('Diy') == true): ?><div class="ui <?php if(Bsoptions('postType') == "1"): ?>raised<?php endif; ?><?php if(Bsoptions('postType') == "2"): ?>stacked<?php endif; ?><?php if(Bsoptions('postType') == "3"): ?>tall stacked<?php endif; ?><?php if(Bsoptions('postType') == "4"): ?>piled<?php endif; ?> segment" <?php if(Bsoptions('postradius')): ?>style="border-radius:<?php echo Bsoptions('postradius'); ?>px"<?php endif; ?>><?php endif; ?>
<h2><i class="lightbulb outline icon"></i> <?php $this->title() ?></h2>
<div class="memos-container">
<!-- memos list -->
<div id="memos_list"></div>
<!-- memos loading -->
<div class="ui basic segment" id="memo-loading" style="display:none">
<div class="ui active blue elastic loader"></div>
<br>
<br>
<br>
<br>
</div>
<!-- memos next -->
<div id="memos_next"></div>
</div>
</div></div>
<script>
$(document).ready(function(){
$("#memo-loading").show();
var number = 5;
var stin = 'first';
var numberx = '';
getData();
function getData() {
$.ajax({
type: "POST",
async:true,
url: "<?php getMemosAction(); ?>",
data: {
"action":'getmemo',
'number':number,
'stin':stin,
'numberx':numberx
},
dateType: "json",
success: function(json) {
json = JSON.parse(json);
total = json.total;
number = json.number;
stin = json.stin;
numberx = json.numberx;
if(stin == 'first'){
content(json.list,json.hiddenagree);
}
else{
content(json.list,json.hiddenagree,'next');
}
},
complete: function() {
pageList();
getLike();
<?php if(Bsoptions('Lazyload') == true) :?>
lazyLoad();
<?php endif; ?>
$("#memo-loading").hide();
},
error: function() {
}
});
};
function pageList() {
if(number < total){
number = parseInt(number) + 5;
var html = "<center><div class=\"ui icon tiny button\" id=\"#memo-click\" data-number="+number+"><i class=\"hand point right outline icon\"></i> 加载更多</div></center>";
var $html = $(html);
$html.find("div").click(function() {
$("#memo-loading").show();
$html.find("div").css("pointer-events","none");
number = $(this).attr("data-number");
stin = 'next';
getData();
});
$("#memos_next").html($html);
}
else{
$("#memos_next").hide();
}
}
function content(list,hidden,type = 'first') {
var str = " ";
for(var i in list) {
if(hidden == true){
str += '<li class="memo-li-' + list[i]['memos_id'] + '" data-memoid="' + list[i]['memos_id'] + '"><div class="memo-main-level" id="memos-' + list[i]['memos_id'] + '"><div class="memo-avatar"><img <?php echo lazyload('auto');?>src="<?php echo imgravatarq($this->author->mail); ?>"></div><div class="memo-box"><div class="memo-head"><h6 class="memo-name by-author">' + list[i]['memos_name'] + '</h6> <span>' + list[i]['memos_time'] + '</span> </div><div class="memo-content">' + list[i]['memos_content'] +'<div class="memo-attachment">'+list[i]['resource']+'</div> <emoji-reaction theme="light" endpoint="<?php getEmactionAction();?>" reacttargetid="memos-' + list[i]['memos_id'] + '" style="flex-wrap: nowrap; max-width: 100%; display: flex; gap: 0.375rem;height: 1.5rem;"></emoji-reaction> </div></div></div> </li>';
}
else{
str += '<li class="memo-li-' + list[i]['memos_id'] + '" data-memoid="' + list[i]['memos_id'] + '"><div class="memo-main-level" id="memos-' + list[i]['memos_id'] + '"><div class="memo-avatar"><img <?php echo lazyload('auto');?>src="<?php echo imgravatarq($this->author->mail); ?>"></div><div class="memo-box"><div class="memo-head"><h6 class="memo-name by-author">' + list[i]['memos_name'] + '</h6> <span>' + list[i]['memos_time'] + '</span> </div><div class="memo-content">' + list[i]['memos_content'] +'<div class="memo-attachment">'+list[i]['resource']+'</div><?php if(Bsoptions('emaction_Openplace') && in_array('3',Bsoptions('emaction_Openplace'))):?><emoji-reaction theme="light" endpoint="<?php getEmactionAction();?>" reacttargetid="memos-' + list[i]['memos_id'] + '" style="flex-wrap: nowrap; max-width: 100%; display: flex; gap: 0.375rem;height: 1.5rem;"></emoji-reaction><?php endif; ?></div></div></div> <div class="ui tertiary button like" style="margin-top:10px;float:right;" data-memoid="' + list[i]['memos_id'] + '">点赞(<span id="memo-' + list[i]['memos_id'] + '">' + list[i]['memos_agree'] + '</span>)</div></li>';
}
str = str.replace(RegExp('" data-memo-image>,', "g"),'">');
str = str.replace(RegExp('</a>,', "g"),'</a>');
}
if(type == 'first'){
$("#memos_list").html('<ul id="memos-list" class="memos-list memos-list-front">'+str+'</ul>');
}
else{
$("#memos-list").append(str);
}
};
function getLike(){
$('.ui.tertiary.button.like').off('click').on('click',function(){
$(this).css("pointer-events","none").addClass('loading');
$.ajax({
type: "POST",
async:true,
url: "<?php getMemosAction(); ?>",
data: {
"action":'getmemolike',
'memoid':$(this).attr('data-memoid'),
},
success: function(json) {
jsonx = $.trim(json);
result = JSON.parse(jsonx);
switch(result.code){
case 1:
$('body').toast({
title:'点赞成功',
class: 'green',
message: '您已经点赞成功啦~',
showIcon: 'grin beam outline',
showProgress: 'top',
});
$('#memo-'+result.memo_id).html(result.memo_agree); $('.ui.tertiary.button.like').css("pointer-events","auto").removeClass('loading');
break;
case 0:
$('body').toast({
title:'点赞失败',
class: 'warning',
message: result.message,
showIcon: 'flushed outline',
showProgress: 'top',
});
$('.ui.tertiary.button.like').css("pointer-events","auto").removeClass('loading');
break;
}
},
error: function() {
$('body').toast({
title:'点赞失败',
class: 'warning',
message: '呜呜呜,可能是网络出现了问题,请稍后再试~',
showIcon: 'flushed outline',
showProgress: 'top',
});
$('.ui.tertiary.button.like').css("pointer-events","auto").removeClass('loading');
}
});
})
}
});
</script>
<?php if(Bsoptions('Diy') == true): ?></div><?php endif; ?>
<?php $this->need('compoment/sidebar.php'); ?>
<?php $this->need('compoment/foot.php'); ?>