-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
154 lines (147 loc) · 5.79 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>UVA Easy Viewer</title>
<script src="//code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
var probnum,probid,probtitle;
var userId;
var uvaUrl,lcatUrl;
var hasLcat = true;
window.onload = function() {
var urlGet = decodeURIComponent(window.location.search.substring(1)).split("/");
probnum = (urlGet[0].match(/[0-9]+/g) || [0])[0];
userId = urlGet[1];
$.getJSON("https://uhunt.onlinejudge.org/api/p/num/"+probnum, loadProb);
$.get("lcat.csv", loadLcatDetail);
$("title").text(probnum+" - UVA Easy Viewer");
$("#google").attr("href","https://www.google.com/search?q=uva+"+probnum);
if(userId) $("#myUhunt").attr("href","https://uhunt.onlinejudge.org/id/"+userId);
$("#myUdebug").attr("href","https://www.udebug.com/UVa/"+probnum);
$(window).resize(windowSizeChange);
windowSizeChange();
}
function loadProb(probdata) {
probtitle = probdata.title;
probid = probdata.pid;
uvaUrl = "https://onlinejudge.org/external/"+probnum.substring(0,probnum.length-2)+"/"+probnum+".html";
if(hasLcat) lcatUrl = "http://web.kshs.kh.edu.tw/academy/luckycat/homework/q"+probnum+".htm";
lcat_mUrl = "http://www3.tcgs.tc.edu.tw/~sagit/luckycat/q"+probnum+".htm";
$("#uva").attr("href","https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem="+probid);
if(hasLcat) view("lcat");
else view("uva");
setInterval(function(){
$("#keepLogin").attr("src","https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=25");
},10*60*1000);
if(userId)
refreshVerdict();
}
function windowSizeChange(){
$("#content").height( $(window).height() - $("#content").position().top - 10 );
}
function view(type) {
$("#contentFrame").attr("src",this[type+"Url"]);
if (type == "lcat") {
$("#note").show("slow");
} else {
$("#note").hide();
}
}
function showzj() {
$("#zjsearch").attr("value",probnum);
$("#zjform").submit();
}
function setOpenPage() {
$("#openPage").attr("href", $("#contentFrame").attr("src") );
}
function submit() {
//$("#contentFrame").attr("src","submit.html?"+probnum+"&"+encodeURI(probtitle));
$("#contentFrame").attr("src","https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=submit_problem&problemid="+probid+"&category=");
}
function loadLcatDetail(data) {
data = data.split("\n");
for(var i in data) {
var line = data[i].split(",");
if(line[0] == probnum) {
var starcount = line[1];
var star = "";
for(var j=0;j<starcount;j++)
star += "★";
$("#star").html(star); $("#star_hide").hide()
$("#hint").hide().html(line[2]);
$("#way").hide().html(line[3]);
hasLcat = true;
return;
}
}
hasLcat = false;
lcatUrl = "nolcat.html";
view("uva");
}
function showHide(type) {
if($("#"+type).is(':visible')) {
$("#"+type).hide("slow");
$("#"+type+"_hide").show("slow");
} else {
$("#"+type).show("slow");
$("#"+type+"_hide").hide("slow");
}
}
function refreshVerdict() {
console.log("refresh");
var verdict = {0: " - In queue - ", 10: "Submission error", 15: "Can't be judged", 20: "In queue", 30: "Compile error", 35: "Restricted function", 40: "Runtime error", 45: "Output limit", 50: "Time limit", 60: "Memory limit", 70: "Wrong answer", 80: "PresentationE", 90: '<span style="color:#00AA00; font-weight:bold;">Accepted</span>'};
$.getJSON("https://uhunt.onlinejudge.org/api/subs-pids/"+userId+"/"+probid+"/0?nocache="+Math.random(),function(data){
data = data[userId].subs;
if(data.length > 0) {
var lastsub = data[0];
for(var i in data)
if(data[i][4]>lastsub[4])
lastsub = data[i];
var change = ($("#verdict").html() != verdict[lastsub[2]] && $("#verdict").html() != "" && lastsub[2] != 0);
$("#verdict").html(verdict[lastsub[2]]);
if(change) {
$("#verdict").css({background:"red","font-size":"30pt",width:"300"});
$("#verdict").effect("bounce",{distance:1000,direction:"right"} , 3000, function(){
$("#verdict").css({background:"","font-size":"",width:""});
});
}
verdictCount = data.length;
}
setTimeout(refreshVerdict,1000);
});
}
</script>
</head>
<body>
<div id="header">
<button onclick="view('uva');">UVa</button>
<button onclick="view('lcat');">Lucky Cat</button>
<button onclick="view('lcat_m');">Lucky Cat (Mirror)</button>
<button onclick="showzj();">Zero Judge</button>
<button onclick="submit();">Submit</button>
<a id="openPage" onclick="setOpenPage();" href="#">開啟此頁</a>
<a id="google" href="">Google搜尋</a>
<a id="uva" href="">UVa</a>
<a id="myUhunt" href="https://uhunt.onlinejudge.org/">uHunt</a>
<a id="myUdebug" href="https://www.udebug.com/">uDebug</a>
<a href="https://sites.google.com/site/domenprg/uva-easy-viewer">About</a>
<span id="star" style="color:red;" ondblclick="showHide('star');"></span><span id="star_hide" onclick="showHide('star');">難度</span>
<span id="hint" style="color:red;" ondblclick="showHide('hint');"></span><span id="hint_hide" onclick="showHide('hint');">提示</span>
<span id="way" style="color:red;" ondblclick="showHide('way');"></span><span id="way_hide" onclick="showHide('way');">解題方向</span>
<span id="note" style="color:red; display:none;">如果 Lucky Cat 沒有回應,請嘗試點擊 Lucky Cat (Mirror)。</span>
<span id="verdict" style="display:inline-block;width:auto;"></span>
</div>
<div id="content">
<iframe id="contentFrame" name="contentFrame" frameborder="1" height="100%" width="100%"></iframe>
</div>
<div hidden>
<iframe id="keepLogin" width="0" height="0"></iframe>
<form id="zjform" method="post" target="contentFrame" action="https://zerojudge.tw/Problems">
<input id="zjsearch" type="hidden" name="searchword"></input>
</form>
</div>
</body>
</html>