📄 正在查看:admin/view/default/comment_index.htm
大小:4,573 字节 · 修改:2014-01-24 01:15:24 · 行数:137
1{inc:header.htm}
2<style type="text/css">
3.tb2 .li .col{border-bottom:1px solid #D0E6EC}
4.tb2 .li i{margin-right:15px;color:#077AC7}
5</style>
6<div class="m">
7 <div class="head">
8 <dl>
9 <dt style="display:inline;float:left;margin-right:8px">
10 <select name="mid" id="mid">
11 {loop:$mod_name $v $k}<option value="{$k}"{if:$mid == $k} selected="selected"{/if}>{$v}评论</option>{/loop}
12 </select>
13 </dt>
14 </dl>
15 </div>
16 <div class="p c2">
17 <div class="cc">
18 {if:empty($comment_arr)}<div class="sky warning bnote"><i></i><b>暂无评论</b></div>{else}
19 <table class="tb2">
20 <tr class="tit">
21 <th class="th" width="25"><input type="checkbox" id="check_all"></th>
22 <th class="th" width="100">作者</th>
23 <th class="th">评论</th>
24 <th class="th" width="100">操作</th>
25 </tr>
26
27 {loop:$comment_arr $v}
28 <tr class="li">
29 <td class="col"><input type="checkbox" name="chk_row" _id="{$v[id]}" _commentid="{$v[commentid]}"></td>
30 <td class="col">{$v[author]}<br>({$v[ip]})</td>
31 <td class="col">发表于:<i>{$v[date]}</i> 标题:<a href="{$v[url]}" target="_blank">{$v[title]}</a><br>{$v[content]}</td>
32 <td class="col"><a class="but3" href="javascript:edit({$v[commentid]});">编辑</a> <a class="but3 del" href="javascript:del({$v[id]},{$v[commentid]});">删除</a></td>
33 </tr>
34 {/loop}
35 </table>
36 <div class="page cf"><span>共 <font color="red">{$total}</font> 条</span>{$pages}</div>
37 {/if}
38 </div>
39 </div>
40</div>
41
42<script id="edit_comment" type="text/html">
43 <table class="tb">
44 <tr>
45 <th class="th">昵称</th>
46 <td class="col"><input id="c_author" name="author" type="text" class="inp w1" /></td>
47 </tr>
48 <tr>
49 <th class="th">评论</th>
50 <td class="col"><textarea id="c_content" name="content" class="inp w3" style="width:98%"></textarea></td>
51 </tr>
52 </table>
53</script>
54
55<script type="text/javascript">
56var _mid = $("#mid").val();
57$("#mid").change(function(){
58 var mid = $(this).val();
59 location.href = 'index.php?u=comment-index-mid-'+ mid;
60});
61
62//全选
63$("#check_all").click(function(){
64 var bool = $(this)[0].checked;
65 var len = $("input[name='chk_row']").length;
66 for(var i=0; i<len; i++) {
67 $("input[name='chk_row']").eq(i)[0].checked = bool;
68 }
69 bool ? buttonDis() : $("#batch_del").remove();
70});
71
72//是否显示删除按钮
73$("input[name='chk_row']").click(function(){
74 var len = $("input[name='chk_row']:checked").length;
75 len ? buttonDis() : $("#batch_del").remove();
76});
77
78//显示删除按钮
79function buttonDis() {
80 if(!$("#batch_del").length) $(".head>dl").append('<input id="batch_del" onclick="batch_del()" type="button" value="批量删除" class="but1" />');
81}
82
83//批量删除
84function batch_del() {
85 twAjax.confirm("删除不可恢复,确定删除?", function(){
86 var id_arr = {};
87 var len = $("input[name='chk_row']").length;
88 for(var i=0; i<len; i++) {
89 var obj = $("input[name='chk_row']").eq(i);
90 if(obj[0].checked) {
91 id_arr[i] = [obj.attr("_id"), obj.attr("_commentid")];
92 }
93 }
94 twAjax.postd("index.php?u=comment-batch_del-ajax-1", {"mid":_mid, "id_arr":id_arr}, function(data){
95 twAjax.alert(data);
96 if(window.twData.err==0) setTimeout(function(){ window.location.reload(); }, 1000);
97 });
98 });
99}
100
101//编辑
102function edit(commentid) {
103 $.twDialog({content:$("#edit_comment").html(), resizable:true, open:true, modal:true, width:900, height:280, minW:500, minH:280});
104
105 //读取
106 twAjax.postd("index.php?u=comment-get_json-ajax-1", {"mid":_mid, "commentid":commentid}, function(data){
107 var json = toJson(data);
108 $("#c_author").val(json.author);
109 $("#c_content").val(json.content);
110 twAjax.remove();
111 });
112
113 //提交
114 $("#twdialog_button>.ok").click(function(){
115 var author = $("#c_author").val();
116 var content = $("#c_content").val();
117 twAjax.postd("index.php?u=comment-edit-ajax-1", {"mid":_mid, "commentid":commentid, "author":author, "content":content}, function(data){
118 twAjax.alert(data);
119 $.twDialog("remove");
120 if(window.twData.err==0) setTimeout(function(){ window.location.reload(); }, 1000);
121 });
122 });
123}
124
125//删除
126function del(id, commentid) {
127 twAjax.confirm("删除不可恢复,确定删除?", function(){
128 twAjax.postd("index.php?u=comment-del-ajax-1", {"mid":_mid, "id":id, "commentid":commentid}, function(data){
129 twAjax.alert(data);
130 if(window.twData.err==0) setTimeout(function(){ window.location.reload(); }, 1000);
131 });
132 });
133}
134</script>
135</body>
136</html>
137