-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (56 loc) · 1.32 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
<!Doctype html>
<html>
<head>
<title>CariAyat</title>
<link rel="stylesheet" href="assets/style.css" type="text/css"/>
</head>
<body>
<div class="wrap">
<h1>Cari Ayat</h1>
<hr/>
<div id="response"></div>
<input type="text" id="keyword"/><input type="submit" id="go">
<div class="result"></div>
</div>
</body>
</html>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function(){
var index;
var response = '';
$('#go').attr('disabled', 'disabled');
//load index, bila dah success baru enable submission
$.get('./assets/json.txt', function(data){
index = JSON.parse(data);
$('#go').prop('disabled', false);
// capture event
$('#go').on('click', function(){
search_and_display();
});
$('#keyword').on('keyup', function(e){
if(e.keyCode == 13){
search_and_display();
}
});
});
////// FUNCTIONS ///////
function search_and_display(){
$('#response').html('');
// capture text
var keyword = $('#keyword').val();
if(keyword != ''){ // kalau ada keyword baru carik
// carik kat sinih
console.log(index);
}else{
response = '<p class="error">isikan perkataan yang mahu dicari:</p>';
}
shout();
}
function shout(){
if(response != ''){
$('#response').html(response);
}
}
});
</script>