-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_old.html
309 lines (283 loc) · 11.2 KB
/
index_old.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
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html>
<html lang="en">
<head>
<title>NebVoter</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vee-validate@latest/dist/vee-validate.js"></script>
<style>
/* Remove the navbar's default margin-bottom and rounded borders */
body {
font-family: "Verdana", sans-serif;
}
.navbar {
margin-bottom: 0;
border-radius: 0;
background-color: #2cc185;
padding: 5px 40px 2px 0;
}
.navbar-inverse a.navbar-brand {
color: #FFFFFF;
font-size: 2.2rem;
font-weight: 600;
}
.navbar-brand.brand-discription {
color: #FFFFFF;
font-size: 1.5rem;
}
.navbar-nav > .active > a.nav-link, .navbar-nav > .active > a.nav-link:hover, .navbar-nav > .active > a.nav-link:visited {
background-color: #FFFFFF;
color: #2cc185;
}
.navbar-nav> li > a.nav-link {
color: #FFFFFF;
font-size: 1.6rem;
font-weight: 600;
line-height: 54px;
min-width: 85px;
padding: 0 17px;
text-align: center;
}
.nav-link .glyphicon {
margin-right: 6px;
font-size: 1.2em;
}
.navbar-nav > li > a.nav-link:hover {
background-color: transparent;
color: #337f61;
}
.main-poll label.control-label {
text-align: left;
padding-top: 0;
}
.poll-answer-header {
margin-bottom: 10px;
}
/* Set height of the grid so .sidenav can be 100% (adjust as needed) */
.row.content {height: 450px}
footer {
background-color: #2cc185;
color: #FFFFFF;
padding: 5px;
}
.bold {
font-weight: 600;
}
.remove-poll-variant {
margin-top: 7px;
margin-left: -22px;
color: red;
cursor: pointer;
font-size: 1.3em;
}
.poll-save-button {
text-align: right;
}
.poll-buttons {
margin-top: 25px;
}
.form-subtitle {
padding-bottom: 15px;
border-bottom: 1px solid #e6e6e6;
margin-bottom: 15px;
}
.alert-margin {
margin-top: 20px;
font-size: 1.4em;
}
/* On small screens, set height to 'auto' for sidenav and grid */
@media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {height:auto;}
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">NebVoter</a><span class="navbar-brand brand-discription">Voting tool on Nebulas blockchain</span>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right" >
<li class="active"><a href="#" class="nav-link"><span class="glyphicon glyphicon-home"></span>Home</a></li>
<li><a href="#" class="nav-link"><span class="glyphicon glyphicon-list-alt"></span>Work with poll</a></li>
<li><a href="#" class="nav-link"><span class="glyphicon glyphicon-question-sign"></span>Help</a></li>
<li><a href="#" class="nav-link"><span class="glyphicon glyphicon-envelope"></span>Contact</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid text-center">
<div class="row content">
<div class="col-sm-5 col-sm-offset-1 text-left">
<h2>Welcome to NebVoter</h2>
<p><span class="bold">NebVoter</span> is a voting tool based on the Nebulas blockchain. Using blockchain we can guarantee transperancy of the voting.</p>
<p>There are another voting sites and tools, but NebVoter has several key advanages:</p>
<ul>
<li>voting is processed on Nebulas blockchain</li>
<li>every Nebulas address could vote only once</li>
<li>every Nebulas user can create his one voting polls for free</li>
<li>while creating poll you can set voting price - to prevent scum voting from empty addresses or to use poll for some crowd funding</li>
<li>you can set maximum numbers of voters and final date of voting</li>
<li>when the poll is closed, the poll creator could withdraw funds received from voters</li>
</ul>
<p class="bold">To create your own poll on NebVoter please use the form on the right!</p>
<p>You must have Nebulas Web Extension wallet installed to use NebVoter.</p>
<p>To use existing poll - Work with poll</p>
</div>
<div class="col-sm-4 col-sm-offset-1 text-left" id="app">
<div v-if="!checkNebulasExtensionWallet()" class="alert alert-warning alert-margin">Please install <a href="https://github.com/ChengOrangeJu/WebExtensionWallet">Nebulas Web Extension wallet.</a></div>
<div v-if="checkNebulasExtensionWallet() && !createdPollId">
<h2>Create your poll</h2>
<div class="form-subtitle">Fill all poll details in form and click "Create poll" button!</div>
<div v-if="contractError" class="alert alert-danger alert-margin">{{contractError}}</div>
<form class="form-horizontal main-poll" @submit.prevent="savePoll">
<div class="form-group" :class="{'has-error': errors.has('pollName') }">
<label for="pollName" class="control-label col-sm-4">Poll name</label>
<div class="col-sm-8">
<input id="pollName" name="pollName" type="text" placeholder="Enter poll name" maxlength="50"
class="form-control" v-model="pollName" v-validate="{required: true}" >
<p class="text-danger" v-if="errors.has('pollName')">The Poll Name field is required.</p>
</div>
</div>
<div class="form-group" :class="{'has-error': errors.has('pollMaxVoters') }">
<label for="pollMaxVoters" class="control-label col-sm-4">Maximum number of voters</label>
<div class="col-sm-8">
<input id="pollMaxVoters" name="pollMaxVoters" type="number" min="1" class="form-control"
v-model="pollMaxVoters" v-validate="{required: true, min_value: 1, numeric: true}">
<p class="text-danger" v-if="errors.has('pollMaxVoters')">The Poll Maximum Voters field is required and should be integer</p>
</div>
</div>
<div class="form-group" :class="{'has-error': errors.has('pollPrice') }">
<label for="pollPrice" class="control-label col-sm-4">Voting price (NAS)</label>
<div class="col-sm-8">
<input id="pollPrice" type="number" step="0.001" class="form-control" name="pollPrice"
v-model="pollPrice" v-validate="{required: true, min_value: 0, decimal: true}">
<p class="text-danger" v-if="errors.has('pollPrice')">The Poll Price field is required.</p>
</div>
</div>
<div class="form-group" :class="{'has-error': errors.has('pollEndDate') }">
<label for="pollEndDate" class="control-label col-sm-4">Poll end date</label>
<div class="col-sm-8">
<input id="pollEndDate" type="date" class="form-control" name="pollEndDate"
v-model="pollEndDate" v-validate="{required: true}">
<p class="text-danger" v-if="errors.has('pollEndDate')">The Poll End Date field is required.</p>
</div>
</div>
<div class="poll-answer-header bold">Poll answer options:</div>
<div v-for="(variant, index) in pollOptions">
<div class="form-group" :class="{'has-error': errors.has('name_' + index) }">
<div class="col-sm-11">
<input type="text" class="form-control" placeholder="Enter poll option"
v-model="pollOptions[index]" v-validate="{required: true}"
:name="'name_' + index">
<p class="text-danger" v-if="errors.has('name_' + index)">Poll option field is required.</p>
</div>
<div class="col-sm-1">
<span class="glyphicon glyphicon-minus-sign remove-poll-variant" @click="removePollOption(index)" v-if='pollOptions.length > 2 '></span>
</div>
</div>
</div>
<div class="form-group poll-buttons">
<div class="col-sm-4">
<button class="btn btn-space btn-primary" type="button" @click="addPollOption">
Add poll answer
</button>
</div>
<div class="col-sm-offset-4 col-sm-4 poll-save-button">
<button class="btn btn-space btn-success"
v-bind:disabled="errors.any()">Create poll</button>
</div>
</div>
</form>
</div>
<div v-if="createdPollId" class="alert alert-success alert-margin">
Your poll was successfully created! Poll ID is {{createdPollId}}
</div>
</div>
</div>
</div>
<footer class="container-fluid text-center">
<p>Footer Text</p>
</footer>
<script src=nebPay.min.js></script>
<script type="text/javascript">
var contract_address = "n1xcCKoVJYmN83iZA6PeAs79stGQNJjGSvV";
var NebPay = require("nebpay");
var nebPay = new NebPay();
Vue.use(VeeValidate);
var app = new Vue({
el: "#app",
data: {
pollOptions: ["", ""],
pollName: "",
pollMaxVoters: 1,
pollPrice: 0,
pollEndDate: "",
contractError: "",
createdPollId: null
},
methods: {
savePoll: function() {
this.$validator.validateAll().then(function(result) {
if (result) {
nebPay.simulateCall(contract_address, 0, "createPoll", app.getPollArgumets(),
{
listener: app.onCreatePoll
});
}
});
},
addPollOption: function() {
this.pollOptions.push("");
},
removePollOption: function(index) {
this.pollOptions.splice(index, 1);
},
checkNebulasExtensionWallet: function() {
return typeof(webExtensionWallet) !== "undefined";
},
getPollArgumets: function() {
var pollVariants = app.pollOptions.filter(function(opt) {
return opt !== "";
});
var args = [];
args.push(pollName.value, pollVariants, pollPrice.value,
pollMaxVoters.value, pollEndDate.value);
return JSON.stringify(args);
},
onCreatePoll: function(response) {
if (response.execute_err !== "") {
app.contractError = response.result;
console.log(app.contractError);
} else {
app.contractError = null;
nebPay.call(contract_address, 0, "createPoll", app.getPollArgumets(),
{
listener: function(resp) {
console.log(response);
app.createdPollId = JSON.parse(response.result);
}
});
}
}
}
});
//https://github.com/hardlydifficult/HardlySocialNebulas/blob/master/index.html
//https://cryptopoll.herokuapp.com/lib/crypto-poll.js
</script>
</body>
</html>