forked from 15010159959/super-dictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
277 lines (226 loc) · 7.83 KB
/
index.html
File metadata and controls
277 lines (226 loc) · 7.83 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Super Dictionary</title>
<link rel="stylesheet" href="lib/bootstrap-4.0.0-dist/css/bootstrap.min.css">
<style>
.logo {
width: 60%;
height: 500px;
margin: auto;
}
.name {
text-align: center;
font-size: 66px;
text-shadow: 3px 5px grey, 1px 1px #333;
}
.img {
width: 48%;
height: 53%;
margin: auto;
margin-top: 38px;
}
.img img {
width: 100%;
height: 100%;
}
.search {
width: 60%;
height: 100px;
margin: auto;
}
.noExtension {
width: 60%;
height: 100px;
margin: auto;
font-size: 23px;
}
#search_value {
width: 80%;
height: 50px;
box-shadow: 3px 5px grey, 1px 1px #333;
}
.search button {
width: 18%;
height: 50px;
margin-left: 6px;
box-shadow: 3px 5px grey, 1px 1px #333;
}
@keyframes rotate {
0% { transform:rotateY(0deg);}
25% { transform:rotateY(180deg);}
50% { transform:rotateY(0deg);}
75% { transform:rotateY(180deg);}
100% { transform:rotateY(0deg);}
}
.logo_rotate {
/*
animation: rotate 10s infinite;
animation-fill-mode: forwards;
animation-timing-function: linear;
*/
/* 当动画结束时,让<div>元素保留上一个关键帧的样式值 */
}
.result_success {
width: 60%;
margin: auto;
}
.result_faile{
width: 60%;
margin: auto;
}
.add_banner{
width: 60%;
margin: auto;
}
.add_banner input{
width: 80%;
height: 50px;
box-shadow: 3px 5px grey, 1px 1px #333;
}
.add_banner button{
width: 18%;
height: 50px;
margin-left: 6px;
box-shadow: 3px 5px grey, 1px 1px #333;
}
#search_banner{
font-size: 40px;
border-bottom: 1px solid black;
}
p{
text-indent:2em;
font-size: 20px;
}
.hide{
display: none;
}
.contenner{
background: url("img/bg.jpg");
height: 900px;
}
.author{
text-align: right;
}
.author p{
display: inline-block;
font-size: 14px;
}
</style>
</head>
<body>
<div class="contenner">
<div class="logo">
<div class="name">SUPER DICTIONARY</div>
<div class="img logo_rotate">
<img src="img/logo.png" alt="">
</div>
</div>
<div class="noExtension hide" id="noExtension">
NOTE: Please install <a target="_blank" href="https://github.com/ChengOrangeJu/WebExtensionWallet">WebExtensionWallet</a> to use SUPER DICTIONARY
</div>
<div class="search">
<input id="search_value" type="text">
<button id=search>search</button>
</div>
<div class="result_success hide">
<div id=search_banner></div>
<p id=search_result> wait for content </p>
<div class="author">
<i><p> Author:</p> <p id=search_result_author> dasdajkajksdhjasdkjahdkjad</p></i>
</div>
</div>
<div class="result_faile hide">
Failed to find related information. Do you want to <button id="add">add</button> infromation for "<i id="result_faile_add">asd</i>"?
</div>
<div class="add_banner hide">
<input type="text" id="add_value" placeholder="input contents for your keyword">
<button id="push">submit</button>
</div>
</div>
<script src=lib/jquery-3.3.1.min.js></script>
<script src=lib/nebPay.js></script>
<script src=lib/bootstrap-4.0.0-dist/js/bootstrap.min.js></script>
<script>
var NebPay = require("nebpay"); //https://github.com/nebulasio/nebPay
var nebPay = new NebPay();
$("#search_value").attr("disabled",true)
$("#search").attr("disabled",true)
//to check if the extension is installed
//if the extension is installed, var "webExtensionWallet" will be injected in to web page
if(typeof(webExtensionWallet) === "undefined"){
//alert ("Extension wallet is not installed, please install it first.")
$("#noExtension").removeClass("hide")
}else{
$("#search_value").attr("disabled",false)
$("#search").attr("disabled",false)
}
var dappAddress = "n1oXdmwuo5jJRExnZR5rbceMEyzRsPeALgm";
// 搜索功能: 查找Super-Dictionary 中有没有该词条
$("#search").click(function(){
// $("#search_value").val() 搜索框内的值
var to = dappAddress;
var value = "0";
var callFunction = "get";
var callArgs = "[\"" + $("#search_value").val() + "\"]"; //in the form of ["args"]
nebPay.simulateCall(to, value, callFunction, callArgs, { //使用nebpay的simulateCall接口去执行get查询, 模拟执行.不发送交易,不上链
listener: cbSearch //指定回调函数
});
})
//return of search,
function cbSearch(resp) {
var result = resp.result
console.log("return of rpc call: " + JSON.stringify(result))
if (result === 'null'){
$(".add_banner").addClass("hide");
$(".result_success").addClass("hide");
$("#result_faile_add").text($("#search_value").val())
$(".result_faile").removeClass("hide");
} else{
//if result is not null, then it should be "return value" or "error message"
try{
result = JSON.parse(result)
}catch (err){
//result is the error message
}
if (!!result.key){ //"return value"
$(".add_banner").addClass("hide");
$(".result_faile").addClass("hide");
$("#search_banner").text($("#search_value").val())
$("#search_result").text(result.value)
$("#search_result_author").text(result.author)
$(".result_success").removeClass("hide");
} else { //"error message"
$(".add_banner").addClass("hide");
$(".result_faile").addClass("hide");
$("#search_banner").text($("#search_value").val())
$("#search_result").text(result)
$("#search_result_author").text("")
$(".result_success").removeClass("hide");
}
}
}
// 添加信息功能: 像super-dictionary 中添加词条
$("#add").click(function() {
$(".result_faile").addClass("hide");
$(".add_banner").removeClass("hide");
$("#add_value").val("")
})
$("#push").click(function() {
var to = dappAddress;
var value = "0";
var callFunction = "save"
var callArgs = "[\"" + $("#search_value").val() + "\",\"" + $("#add_value").val() + "\"]"
nebPay.call(to, value, callFunction, callArgs, { //使用nebpay的call接口去调用合约,
listener: cbPush
});
});
function cbPush(resp) {
console.log("response of push: " + resp)
}
</script>
</body>
</html>