-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
282 lines (234 loc) · 11.5 KB
/
index.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>課表產生器</title>
<meta name="description" content="幫你產生漂亮的課表">
<meta name="keywords" content="成大,課程,課表">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:url" content="http://ccns.github.io/classtable-generator/" />
<meta property="og:title" content="課表產生器" />
<meta property="og:description" content="幫你產生漂亮的課表" />
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/f/f8/NCKU_Logo_2011.png" />
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.3/js.cookie.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>
<link rel="stylesheet" href="css/main.min.css" media="screen" title="no title" charset="utf-8">
<!-- detect mobile -->
<script type="text/javascript">
var isMobile = false; //initiate as false
// device detection
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) isMobile = true;
</script>
</head>
<body>
<nav class="grey darken-3 pinned" role="navigation">
<div class="nav-wrapper container">
<h4 class="brand-logo center">課表產生器</h4>
<ul class="right hide-on-med-and-down">
<li><a href="https://github.com/ccns/classtable-generator">Github</a></li>
<li><a href="https://github.com/ccns/ncku-classtable-parser">Crawler</a></li>
<li><a href="https://ccns.github.io/">CCNS</a></li>
</ul>
<a href="#" data-activates="nav-mobile" class="button-collapse"><i class="material-icons">menu</i></a>
</div>
</nav>
<ul id="nav-mobile" class="side-nav">
<li><a href="https://github.com/ccns/classtable-generator">Github</a></li>
<li><a href="https://github.com/ccns/ncku-classtable-parser">Crawler</a></li>
<li><a href="http://web.ccns.ncku.edu.tw/">CCNS</a></li>
</ul>
<div class="container" id="login-field">
<div class="row">
<h5 class="col s12 center-align">
幫你產生漂亮的課表
</h5>
<p class="col s12 center-align">
帳號密碼僅擷取課表資料用,不會有任何紀錄
</p>
<p class="col s12 center-align">
伺服器狀態: <font id="status"></font>
</p>
</div>
<div class="row">
<form class="col s6 offset-s3" id="login-form">
<div class="row">
<div class="input-field col s12">
<input placeholder="成功入口帳號" id="stn_no" type="text" onkeypress="return enterHandler(event)">
<label for="user">帳號</label>
</div>
<div class="input-field col s12">
<input placeholder="成功入口密碼" id="passwd" type="password" onkeypress="return enterHandler(event)">
<label for="password">密碼</label>
</div>
<!-- <div class="input-field col s12">
<select id="device">
<option value="" disabled>請選擇</option>
<option value="1">Mobile</option>
<option value="2" selected>Desktop</option>
</select>
<label>選擇您的裝置</label>
</div> -->
</div>
</form>
</div>
<div class="row">
<div id="options">
<div>
<input type="checkbox" class="filled-in" id="remember" />
<label for="remember">記住帳密</label>
</div>
<div>
<input type="checkbox" class="filled-in" id="disp-more" />
<label for="disp-more">顯示A~E節</label>
</div>
<div>
<input type="checkbox" class="filled-in" id="disp-room" disabled/>
<label for="disp-room">顯示上課教室(查詢教室的伺服器暫時無法使用)</label>
</div>
</div>
</div>
<div class="row">
<div class="center-align" id="generate-btn">
<button class="btn waves-effect waves-light" type="button" onclick="generate();">產生課表</button>
</div>
</div>
<div class="row" id="loading-gif" style="display:none">
<div class="col s12 center-align">
<img src="img/spinner.gif" height="80px"/>
</div>
</div>
</div>
<div class="container" id="classtable-container" hidden>
<div class="row">
<p class="col s12 center-align" id="hint">
hint:「右鍵→另存影像」可下載圖片
</p>
</div>
<div class="row">
<div class="col s12 center-align" id="canvas-container">
<canvas id="table">
Your browser does not support this.
</canvas>
<img id="rasis" src="img/rasis.jpg" style="display:none" />
</div>
</div>
</div>
<div class="container" id="ics-container" hidden>
<div class="row">
<p class="col s12 center-align" id="ics-description">
下載 ICS 檔,可以匯入至 Google Calendar, Outlook, iCalendar 等行事曆軟體。
</p>
</div>
<div class="row">
<div class="center-align" id="ics-download">
<button class="btn waves-effect waves-light" type="button" onclick="downloadICS();">下載 ICS 檔</button>
</div>
</div>
</div>
<script src="js/ics.deps.min.js" charset="utf-8"></script>
<script src="js/generator.js" charset="utf-8"></script>
<script src="js/sha1.js" charset="utf-8"></script>
<script src="js/sha256.js" charset="utf-8"></script>
<!-- Materialize initializations -->
<script type="text/javascript">
$(document).ready(function() {
$('select').material_select();
$('.button-collapse').sideNav();
$('.pinned').pushpin({
top: 0
});
});
</script>
<!-- Initial functions -->
<script type="text/javascript">
(function($){
// if (isMobile) {
// var select = $("#device");
// select.children("option[selected]").removeAttr("selected");
// select.children(":nth-child(2)").addAttr("selected");
// }
if(Cookies.get("stn_no")) $("#stn_no").val(Cookies.get("stn_no"));
if(Cookies.get("passwd")) $("#passwd").val(Cookies.get("passwd"));
if(Cookies.get("remember")) $("#remember").prop("checked", Cookies.get("remember"));
console.log('在學號後面加上"/img:url"可以為你的課表加上背景唷');
console.log('另外也可以在學號後面加上"/mgc"試試!');
})(jQuery);
</script>
<!-- Function declare -->
<script type="text/javascript">
async function generate() {
$("#loading-gif").fadeIn("slow");
if ( $("#remember").prop("checked") ) {
Cookies.set("stn_no", $("#stn_no").val());
Cookies.set("passwd", $("#passwd").val());
Cookies.set("remember", true);
} else {
Cookies.remove("stn_no");
Cookies.remove("passwd");
Cookies.remove("remember");
}
var stn_no = $("#stn_no").val();
var sp = stn_no.split(/\/(.+)/);
if ( sp.length > 1 ) stn_no = sp[0];
var passwd = CryptoJS.SHA256($("#passwd").val()) + "";
var room = "false";
if ( $("#disp-room").prop("checked") ) room = "true";
var result = await getTable(stn_no, passwd, room);
window.table = result.table;
if (result.status == 0) {
var canvas = document.getElementById("table");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
var option = {
more: $("#disp-more").prop("checked")
}
clear( canvas, ctx );
drawTable( canvas, ctx, result.table, option);
if ( sp[1] == "mgc" ) {
rasis(canvas, ctx);
console.log("MGC stand for Music Game Club");
console.log("歡迎加入成大音樂遊戲社!");
} else if( sp[1] ) {
var sp2 = sp[1].split(/:(.+)/);
if (sp2[0] == "img") img(canvas, ctx, sp2[1]);
}
$("#loading-gif").hide();
$("#classtable-container").fadeIn("slow");
$("#ics-container").fadeIn("slow");
}
$("#download-ics").show();
} else {
alert(result.message);
$("#loading-gif").hide();
}
}
function enterHandler(e) {
if (e.keyCode == 13) {
generate();
}
}
function downloadICS() {
var begin = "2019-02-18";
var end = "2019-06-23";
var ics = generateICS(window.table, begin, end);
ics.download("classtable");
}
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-91760550-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-91760550-2');
</script>
</body>
</html>