-
Notifications
You must be signed in to change notification settings - Fork 3
/
discuss.php
executable file
·154 lines (149 loc) · 5.32 KB
/
discuss.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=1200">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Discuss -- <?php echo $OJ_NAME ?></title>
<?php include("template/semantic-ui/css.php"); ?>
<?php include("template/semantic-ui/extra_css.php") ?>
<?php include("template/semantic-ui/js.php"); ?>
<?php include("template/semantic-ui/extra_js.php") ?>
<script src="/js/dist/g2.min.js"></script>
<script src="/js/dist/data-set.min.js"></script>
<script src="/js/dayjs.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php include("template/$OJ_TEMPLATE/nav.php") ?>
<!-- Main component for a primary marketing message or call to action -->
<div class="ui container padding">
<contest-mode v-if="contest_mode"></contest-mode>
<h2 class="ui dividing header" v-if="!contest_mode">Discuss</h2>
<div class="ui grid" v-if="!contest_mode">
<div class="row">
<div class="thirteen wide column">
<div class="ui search">
<div class="ui icon input">
<input class="prompt" type="text" placeholder="搜索标题" v-model="search">
<i class="search icon"></i>
</div>
<div class="results"></div>
</div>
</div>
<div class="three wide right aligned column">
<a href="/newdiscusspost.php" target="_blank" class="ui labeled icon blue mini button">
<i class="write icon"></i>
Post
</a>
</div>
</div>
<div class="row">
<div id="word-cloud">
</div>
</div>
</div>
<table class="ui very basic center aligned table" v-if="!contest_mode" v-cloak>
<thead>
<th width="5%">ID</th>
<th width="40%">Title</th>
<th>Author</th>
<th>Create Time</th>
<th>Modify Time</th>
<th>Latest Post</th>
</thead>
<tbody>
<tr v-for="row in table">
<td>{{row.article_id}}</td>
<td><a :href="'discusscontext.php?id='+row.article_id" target='_blank'>{{row.title}}</a></td>
<td><a :href="'userinfo.php?user='+row.user_id" target='_blank'>{{row.user_id}}</a></td>
<td>{{dayjs(row.create_time).format("YYYY-MM-DD HH:mm:ss")}}</td>
<td>{{dayjs(row.edit_time).format("YYYY-MM-DD HH:mm:ss")}}</td>
<td>{{dayjs(row.last_post).format("YYYY-MM-DD HH:mm:ss")}}</td>
</tr>
</tbody>
</table>
</div> <!-- /container -->
<script>
window.discussTable = new Vue({
el:".ui.container.padding",
data:function(){
var query_string = parseQueryString(window.location.hash.substring(1));
return {
page:parseInt(query_string.page)||0,
table_val:[],
total:0,
search:"",
contest_mode:false
}
},
watch:{
search:function(newVal,oldVal) {
var that = this;
var page = this.page * 20;
var url = "/api/discuss/";
if(newVal && newVal.length > 0) {
url += "search/" + newVal;
}
url += "?page=" + page;
$.get(url,function(data){
if(data.contest_mode) {
that.contest_mode = true;
return;
}
if(data.discuss) {
that.table = data;
}
else {
that.table = {
discuss:data.data
}
}
})
}
},
created:function(){
},
mounted:function(){
var page = this.page * 20;
var that = this;
$.get("/api/discuss?page="+page,function(data){
if(data.contest_mode) {
that.contest_mode = true;
return;
}
that.table = data;
});
$.get("/api/discuss?page="+page,function(data){
if(data.contest_mode) {
that.contest_mode = true;
return;
}
that.table = data;
});
},
methods:{
},
computed:{
table:{
get:function(){
return this.table_val;
},
set:function(data){
this.total = parseInt(data.total);
this.table_val = data.discuss;
}
}
}
})
</script>
<?php include("template/semantic-ui/bottom.php") ?>
</body>
</html>