-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (71 loc) · 4.16 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Websites</title>
<style>
body {
background-attachment: fixed;
background-position:left top;
background:url(./image/background3.jpg)no-repeat ;
background-size:cover;
background-color: #ccc;
}
</style>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body >
<div class="container">
<div style="max-height:700px;min-height:200px;height:300px;position:relative" >
<div style="bottom:0px;position:absolute;width:100%;text-align:center;">
<div class="row" style=" ">
<div class="col-sm-12">
<input id="keyword" style="box-shadow:4px 4px 3px rgba(20%,20%,40%,0.5);font-size:15px;padding:13px 25px 15px 25px;background-color:rgba(225,225,225,0.5);border-radius:8px;max-width:300px;min-width:50px;width:30%" type="text">
<input id="num" style="box-shadow:4px 4px 3px rgba(20%,20%,40%,0.5);position:inherit;left:-2px;font-size:15px;padding:13px 25px 15px 25px;background-color:rgba(225,225,225,0.5);border-radius:8px;max-width:300px;min-width:50px;width:10%" type="number" value="10">
<select id="typesel" style="box-shadow:4px 4px 3px rgba(20%,20%,40%,0.5);position:inherit;left:-3px;font-size:15px;padding:13px 25px 15px 25px;background-color:rgba(225,225,225,0.5);border-radius:8px;max-width:300px;min-width:50px;width:10%">
<option value="http://api.udic.cs.nchu.edu.tw/api/kemApi/?keyword=" selected>KEM</option>
<option value="http://api.udic.cs.nchu.edu.tw/api/kcmApi/?keyword=">KCM</option>
</select>
<button id="submitbtn" style="box-shadow:4px 4px 3px rgba(20%,20%,20%,0.5);position:inherit;font-size:15px;left:-5px;padding:15px 25px 15px 25px;" class="btn btn-success">Search</button>
</div>
</div>
<div class="row" >
<div class="col-sm-12">
<input style="font-size:20px;" id="ischinese" type="radio" name="langsel" checked="checked">
<label style="font-size:20px;">中文</label>
<input style="font-size:20px;" type="radio" name="langsel">
<label style="font-size:20px;">英文</label>
</div>
</div>
</div>
</div>
<div style="position:relative;">
<div id="result" style="position:absolute;border-radius:20px;left:30%;background-color:Rgba(225,225,225,0.3);max-width:500px;max-height:500px;overflow-y:scroll;">
</div>
</div>
</div>
</body>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$('#submitbtn').click(function(){
document.getElementById("result").innerHTML = "";
if (document.getElementById("keyword").value != "" && document.getElementById("keyword").value != null) {
var keyword = (document.getElementById("ischinese").checked == true) ? encodeURI(document.getElementById("keyword").value) : document.getElementById("keyword").value;
var lang = (document.getElementById("ischinese").checked == true) ? 'cht' : 'eng';
var typesel = document.getElementById("typesel").value;
var num = (document.getElementById("num").value == 0 || document.getElementById("num").value == "") ? 10 : document.getElementById("num").value;
$.getJSON(typesel + keyword + "&lang=" + lang + "&num=" + num)
.done(function (json) {
console.log(json)
for (var prop in json) {
document.getElementById("result").innerHTML += "<h1>" + prop + ':' + json[prop] + "</h1>";
}
})
}
else {
alert("您尚未輸入要尋找的關鍵字!");
}
});
</script>