-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
229 lines (201 loc) · 9.15 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
<!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>Voting for 2020 President of United States</title>
<link rel="stylesheet" href="lib/bootstrap-4.0.0-dist/css/bootstrap.min.css">
<style>
.header-flag {
width: 100%;
height: 500px;
}
.header-title {
margin-left: 80px;
margin-right: 80px;
height: 140px;
background: white;
margin-top: -80px;
text-align: center;
}
.candicate-table {
margin-left: 80px;
margin-right: 80px;
margin-top: 40px;
}
.vertical-align {
vertical-align: inherit !important;
}
.noExtension {
position: fixed;
bottom: 0;
width: 100%;
height: 40px;
background: orange;
}
.hide{
display: none;
}
</style>
</head>
<body>
<img src="./img/american_flag_matrix_by_chrisdiontewalker-d954qoe-777x437.jpg" class='header-flag'></img>
<div class="card header-title">
<div class="card-body">
<h3 class='mt-4'>Voting for 2020 President of United States.</h3>
</div>
</div>
<div class="candicate-table">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Name</th>
<th scope="col">Born</th>
<th scope="col">Current or previous position</th>
<th scope="col">State</th>
<th scope="col">Votes</th>
<th scope="col">#</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<img alt="Donald Trump official portrait.jpg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Donald_Trump_official_portrait.jpg/237px-Donald_Trump_official_portrait.jpg" width="118" height="135" class="thumbborder" data-file-width="2250" data-file-height="2850">
<br />
<b>Donald Trump</b>
</th>
<td class='vertical-align'>June 14, 1946</td>
<td class='vertical-align'>President of the United States since 2017</td>
<td class='vertical-align'>New York</td>
<td class='vertical-align' id='donaldTrump-vote'>0</td>
<td class='vertical-align'><button data-vote="donaldTrump" type="button" class="btn btn-primary vote">Vote</button></td>
</tr>
<tr>
<th scope="row">
<img alt="Jack Fellure official portrait.jpg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Jack_Fellure.jpg/300px-Jack_Fellure.jpg" width="118" height="135" class="thumbborder" data-file-width="2250" data-file-height="2850">
<br />
<b>Jack Fellure</b>
</th>
<td class='vertical-align'>October 3, 1931</td>
<td class='vertical-align'>
<b>Retired engineer</b>
<br/>
<span>Prohibition nominee for President in 2012
Candidate for President in 1988, 1992, 1996, 2000, 2004, 2008, and 2016</span>
</td>
<td class='vertical-align'>West Virginia</td>
<td class='vertical-align' id='jackFellure-vote'>0</td>
<td class='vertical-align'><button data-vote="jackFellure" type="button" class="btn btn-primary vote">Vote</button></td>
</tr>
<tr>
<th scope="row">
<img alt="Jeff Boss official portrait.jpg" src="https://upload.wikimedia.org/wikipedia/commons/e/e2/Jeff_Boss.jpg" width="118" height="135" class="thumbborder" data-file-width="2250" data-file-height="2850">
<br />
<b>Jeff Boss</b>
</th>
<td class='vertical-align'>May 20, 1963</td>
<td class='vertical-align'>
<b>Conspiracy theorist</b>
<br/>
<span>Candidate for U.S. Representative from New York in 2018
Candidate for Mayor of New York City in 2013 and 2017
Candidate for Governor of New Jersey in 2009, 2013, and 2017
Candidate for President in 2008, 2012, and 2016
Candidate for U.S. Representative in 2010 and 2016
Candidate for U.S. Senate in 2008 and 2014</span>
</td>
<td class='vertical-align'>New York</td>
<td class='vertical-align' id='jeffBoss-vote'>0</td>
<td class='vertical-align'><button data-vote="jeffBoss" type="button" class="btn btn-primary vote">Vote</button></td>
</tr>
<tr>
<th scope="row">
<img alt="John Delaney official portrait.jpg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/John_Delaney_113th_Congress_official_photo.jpg/186px-John_Delaney_113th_Congress_official_photo.jpg" width="118" height="135" class="thumbborder" data-file-width="2250" data-file-height="2850">
<br />
<b>John Delaney</b>
</th>
<td class='vertical-align'>April 16, 1963</td>
<td class='vertical-align'>
<b>U.S. Representative from Maryland since 2013</b>
</td>
<td class='vertical-align'>Maryland</td>
<td class='vertical-align' id='johnDelaney-vote'>0</td>
<td class='vertical-align'><button data-vote="johnDelaney" type="button" class="btn btn-primary vote">Vote</button></td>
</tr>
<tr>
<th scope="row">
<img alt="Andrew Yang official portrait.jpg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Andrew_Yang_talking_about_urban_entrepreneurship_at_Techonomy_Conference_2015_in_Detroit%2C_MI_%28cropped%29.jpg/157px-Andrew_Yang_talking_about_urban_entrepreneurship_at_Techonomy_Conference_2015_in_Detroit%2C_MI_%28cropped%29.jpg" width="118" height="135" class="thumbborder" data-file-width="2250" data-file-height="2850">
<br />
<b>Andrew Yang</b>
</th>
<td class='vertical-align'>January 13, 1975</td>
<td class='vertical-align'>
<b>Entrepreneur</b>
</td>
<td class='vertical-align'>New York</td>
<td class='vertical-align' id='andrewYang-vote'>0</td>
<td class='vertical-align'><button data-vote="andrewYang" type="button" class="btn btn-primary vote">Vote</button></td>
</tr>
<tr>
<th scope="row">
<img alt="Kanye West official portrait.jpg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Kanye_West_at_the_2009_Tribeca_Film_Festival.jpg/194px-Kanye_West_at_the_2009_Tribeca_Film_Festival.jpg" width="118" height="135" class="thumbborder" data-file-width="2250" data-file-height="2850">
<br />
<b>Kanye West</b>
</th>
<td class='vertical-align'>June 8, 1977</td>
<td class='vertical-align'>
<b>Rapper, singer, songwriter, record producer, fashion designer, and entrepreneur</b>
</td>
<td class='vertical-align'>California</td>
<td class='vertical-align' id='kanyeWest-vote'>0</td>
<td class='vertical-align'><button data-vote="kanyeWest" type="button" class="btn btn-primary vote">Vote</button></td>
</tr>
</tbody>
</table>
</div>
<div class="noExtension hide" id="noExtension">
NOTE: Please install <a target="_blank" href="https://github.com/ChengOrangeJu/WebExtensionWallet">WebExtensionWallet</a> to use the application.
</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/
var nebPay = new NebPay();
const dappAddress = "n1tjxkC4a2fttaXMcPbAaYMGaKhqPzet7Ps";
// if(typeof(webExtensionWallet) === "undefined"){
// $("#noExtension").removeClass("hide")
// }
$('.vote').click(function() {
var to = dappAddress;
var value = "0";
var callFunction = "save";
var callArgs = "[\"" + this.dataset.vote + "\"]"; //in the form of ["args"]
nebPay.call(to, value, callFunction, callArgs, { //使用nebpay的call接口去调用合约,
listener: function(resp) {console.log("response of vote: " + resp)}
});
})
$(document).ready(function(){
const CANDIDATES = ['donaldTrump', 'jackFellure', 'jeffBoss', 'johnDelaney', 'andrewYang', 'kanyeWest'];
CANDIDATES.map(candidate => {
var to = dappAddress;
var value = "0";
var callFunction = "get";
var callArgs = "[\"" + candidate + "\"]"; //in the form of ["args"]
nebPay.simulateCall(to, value, callFunction, callArgs, { //使用nebpay的simulateCall接口去执行get查询, 模拟执行.不发送交易,不上链
listener: function(response) {
if(response.result === "null") {
return 0;
} else {
var {name, vote} = JSON.parse(response.result)
console.log( name + ' : ' + vote );
$('#'+name+'-vote').text(vote)
}
}
});
})
})
</script>
</body>
</html>