-
Notifications
You must be signed in to change notification settings - Fork 1
/
news.html
executable file
·179 lines (177 loc) · 7.51 KB
/
news.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<title>Northeastern University</title>
<link href="assets/styles/normalize.css" type="text/css" rel="stylesheet"/>
<link href="assets/styles/list.css" type="text/css" rel="stylesheet"/>
<link href="assets/styles/superfish.css" type="text/css" rel="stylesheet" />
<link href="assets/styles/iconfont.css" type="text/css" rel="stylesheet" />
<link href="assets/styles/ajax_control.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="libs/jquery.min.js"></script>
<script type="text/javascript" src="libs/superfish.min.js"></script>
<script type="text/javascript" src="libs/jquery.xdomainrequest.min.js"></script>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
<script type="text/javascript">
(function($){
$(document).ready(function(){
var example = $('.navbar').superfish({
//配置
hoverClass: 'sfHover',
popUpSelector: 'ul,.subnav',
pathLevels: 1,
cssArrows: false
});
});
})(jQuery);
</script>
</head>
<body>
<div id="top-banner">
<div class="wrapper">
<div id="search-box" style="display: inline-block;">
<!--<form style="padding:20px 0">
<input type="text" name="search" style="border:0;padding:3px;height:20px;width:140px;color:#FFF;background-color: #5376aa;"/><button type="submit" name="fff" style="border:0;height: 26px;background-color: #EEE;">search</button>
</form>-->
</div>
<div>
<img src="assets/img/logo.png" id="logo-img"/>
<img src="assets/img/uname.png" id="uname-img"/>
</div>
</div>
</div>
<div id="header">
<!--#include virtual="include/header.html" -->
<div id="banner-img"><img src="assets/img/detail_banner.png" style="width:100%;"/></div>
</div>
<div class="clearfix" id="main-body">
<div class="sidebar">
<div class="bottom-gradient-1"></div>
<div class="sidebar-content">
<ul>
</ul>
<div class="bottom-gradient-2"></div>
</div>
</div>
<div class="wrapper">
<div id="list">
<h1>News & Events</h1>
<div id="loading"><img src="./assets/img/loading.gif" alt="loading" /></div>
<div id="refresh"><img src="./assets/img/refresh.png" alt="refresh" /></div>
</div>
<div id="page_controller">
<a href="#" onclick="firstPage()"><i class="iconfont"></i> First Page</a><a href="#" id="previous_page" onclick="previousPage()"><i class="iconfont"></i> Previous Page</a><a href="#" id="next_page" onclick="nextPage()">Next Page <i class="iconfont"></i></a>
</div>
</div>
<!--<div style="height: 800px;margin-bottom: 20px;">-->
<!--</div>-->
</div>
<!--#include virtual="include/footer.html" -->
<script type="text/javascript" src="./mods/side_menu.js"></script>
<script type="text/javascript">
function init() {
$('#previous_page').hide();
$('#next_page').hide();
}
init();
var currentPage = 0;
$.support.cors = true;
var loading_icon = $('#loading');
var refresh_icon = $('#refresh');
$(refresh_icon).click(function() {
$(refresh_icon).hide();
fetch({
url: 'http://neunews.neu.edu.cn/api.php?action=lists&num=20&cid=7&page=' + currentPage
}, generate);
});
function fetch(params, generate) {
$("#news_list").remove();//防止内容溢出
$(loading_icon).show();
$.ajax({
url: params.url,
dataType: 'json',
async: true,
data: params.data || {},
type: 'GET',
success: function(ret) {
$(loading_icon).hide();
generate(ret);
},
error: function(err) {
$(loading_icon).hide();
$(refresh_icon).show();
console.log(err);
}
});
}
fetch({
url: 'http://neunews.neu.edu.cn/api.php?action=lists&num=20&cid=7&page=' + currentPage
}, generate);
function generate(ret) {
var container = $('#list');
var list = document.createElement("ul");
$(list).attr("id", "news_list");
//$("#news_list").remove();
if(ret.length < 20) {
$('#next_page').hide();
} else {
$('#next_page').show();
}
for(var i = 0; i < ret.length; i++) {
var data = ret[i];
var piece = document.createElement("li");
var date = document.createElement("span");
var link = document.createElement("a");
var url = "./detail.html?news#id=";
$(link).attr("href", url + data['id']);
$(link).attr("title", data['title']);
$(link).text(data['title']);
$(link).appendTo(piece);
var time = new Date(data['pubtime'] * 1000);
$(date).addClass("news_date");
$(date).text(time.getFullYear() + '-' + ((time.getMonth()+1) < 10 ? ('0' + (time.getMonth()+1)) : (time.getMonth()+1)) + '-' + (time.getDate() < 10 ? ('0' + time.getDate()) : time.getDate()));
$(date).appendTo(piece);
$(piece).addClass("news_piece");
$(piece).appendTo(list);
}
$(list).appendTo(container);
}
function addToList(data, list) {
}
function nextPage() {
currentPage++;
$('#previous_page').show();
// $("#news_list").remove();
fetch({
url: 'http://neunews.neu.edu.cn/api.php?action=lists&num=20&cid=7&page=' + currentPage
}, generate);
}
function previousPage() {
if (currentPage == 0) {
return;
} else {
currentPage--;
if (currentPage == 0) {
$('#previous_page').hide();
} else {
$('#previous_page').show();
}
// $("#news_list").remove();
fetch({
url: 'http://neunews.neu.edu.cn/api.php?action=lists&num=20&cid=7&page=' + currentPage
}, generate);
}
}
function firstPage() {
currentPage = 0;
$('#previous_page').hide();
// $('#news_list').remove();
fetch({
url: 'http://neunews.neu.edu.cn/api.php?action=lists&num=20&cid=7&page=' + currentPage
}, generate);
}
</script>
</body>
</html>