-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
377 lines (356 loc) · 12.9 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
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AskWeave</title>
<meta name="description" content="AskWeave">
<meta name="author" content="shenwilly">
<script src="https://use.fontawesome.com/2aaa3d49d4.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="
sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.0/dist/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-url/2.5.3/url.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="
sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://unpkg.com/arweave/bundles/web.bundle.min.js"></script>
<script src="./js/get_username.js"></script>
<script src="./js/view.js"></script>
<script src="./js/login.js"></script>
<script src="./js/get_questions.js"></script>
<script src="./js/get_question.js"></script>
<script src="./js/get_answers.js"></script>
<script src="./js/get_comments.js"></script>
<script src="./js/ask_question.js"></script>
<script src="./js/answer_question.js"></script>
<script src="./js/tip_answer.js"></script>
<script src="./js/post_comment.js"></script>
<style type="text/css">
.file-input{
height: 200px;
border: 2px dashed #62666f;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
position: relative;
margin: auto;
max-width: 300px;
}
.file-input input[type=file]{
opacity: 0;
position: absolute;
background: none;
width: 100%;
height: 100%;
}
.card-header {
padding-top: 5px;
padding-bottom: 5px;
}
.question-card {
cursor: pointer;
}
.card-body {
padding-top: 15px;
padding-bottom: 15px;
}
.form-group {
margin-bottom: 0;
}
.clickable {
cursor: pointer;
}
.error {
color: red;
}
.wait {
cursor: wait !important;
}
.color-arweave {
color: #7cbcd8;
}
.btn-arweave {
color: #fff;
background-color: #7cbcd8;
border-color: #7cbcd8;
}
.btn-arweave:hover {
color:#fff;
background-color:#68a8c4;
}
.btn-arweave.active {
background-color:#68a8c4;
}
.limited-height {
display: block;
text-overflow: ellipsis;
overflow: hidden;
max-height: 3.6em;
line-height: 1.8em;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.pre-wrap {
white-space: pre-wrap;
}
.icon-frame {
width: 30px;
height: 30px;
}
.btn-small-text {
font-size: 13px;
}
.btn-small-text:hover {
background: #7cbcd8;
color: white;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container flex">
<a class="navbar-brand clickable" style="color: white" id="home-icon" onclick="get_questions()">AskWeave</a></button>
<span class="navbar-text" id="public-address">
</span>
<span class="navbar-item">
<button type="button" class="btn btn-success not-logged-in" data-toggle="modal" data-target="#loginModal">Login to Ask Question</button>
<button type="button" class="btn btn-primary logged-in" data-toggle="modal" data-target="#askQuestionModal" style="display: none">Ask a Question</button>
</span>
</div>
</nav>
<div class="container" id="index-page">
<div class="row my-2">
<div class="col-lg-12 mt-5 loading-question" style="text-align: center">
<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
</div>
<div class="col-lg-12" id="question-card-list">
</div>
</div>
<div class="row mt-2 mb-4">
<div class="col-lg-12">
<hr>
<span class="clickable" data-toggle="modal" data-target="#aboutModal">About</span>
<span class="pull-right">
<a href="https://www.arweave.org/" target="_blank" class="mr-1">
<img class="icon-frame" src="./img/arweave.png">
</a>
<a href="https://github.com/shenwilly/askweave" target="_blank">
<img class="icon-frame" src="./img/github.png">
</a>
</span>
</div>
</div>
</div>
<div class="container" id="detail-page" style="display: none">
<div class="col-lg-12 mt-5 loading-answer" style="text-align: center">
<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
</div>
<div class="detail-container" style="display: none;">
<div class="row mt-4">
<div class="col-lg-12">
<p class="pull-right text-muted" style="font-size: 0.75rem">
<i><span class="question-author"></span> - <span class="question-datetime"></span></i>
</p>
<h3 class="question-title">[title]</h3>
<p class="question-description pre-wrap">[description]</p>
<hr>
</div>
</div>
<div class="row">
<div class="col-lg-12 no-answer" style="text-align: center">
<h5>No Answers Yet</h5>
</div>
<div class="col-lg-12" id="answer-card-list">
</div>
</div>
<div class="row mb-4">
<div class="col-lg-12 not-logged-in">
<hr>
<button type="button" class="btn btn-success login-btn" data-toggle="modal" data-target="#loginModal">Login to Answer</button>
</div>
<div class="col-lg-12 logged-in" style="display: none">
<hr>
<h5>Have an answer?</h5>
<form id="answer-form">
<div class="form-group">
<textarea class="form-control" rows="3" style="min-width: 100%" id="input_answer" required="true"></textarea>
</div>
<button type="button" class="btn btn-success mt-3" id="answer-btn">Post Answer!</button>
</form>
</div>
</div>
</div>
</div>
<div id="question-card-template" style="display: none">
<div class="card mt-2 question-card" card-id="[id]" author-id="[author]">
<div class="card-body">
<i>
<p class="pull-right text-muted" style="font-size: 0.75rem">
<span class="card-is-owner"></span><span class="card-datetime">[datetime]</span>
</p>
</i>
<h5 class="card-title">[question]</h5>
<p class="card-description mb-0 limited-height pre-wrap">[description]</p>
</div>
</div>
</div>
<div id="answer-card-template" style="display: none">
<div class="card mt-2 answer-card" card-id="[id]" author-id="[author_id]">
<div class="card-header">
<span class="font-weight-light font-italic text-muted"><span class="card-author">[author]</span> - </span>
<span class="card-points">
<span class="has-value">
<strong><span class="card-value">[tip_amount]</span> <span style="color: #53aac7">AR</span> tipped</strong>
</span>
</span>
<span class="font-weight-light font-italic text-muted pull-right">[datetime]</span>
</div>
<div class="card-body">
<p style="white-space: pre-wrap;" class="mb-0">[answer]</p>
<div class="d-flex flex-row justify-content-end">
<div>
<form class="tip-form">
<div class="input-group">
<i class="pt-2 fa fa-times fa-2x text-danger clickable tip-close" aria-hidden="true" style="display: none"></i>
<span class="input-group-btn mt-2 ml-2 pull-right">
<button type="button" class="btn btn-arweave pull-right tip-toggle logged-in" style="display: none;">Tip This Answer</button>
<div class="btn-group btn-group-toggle tip-radio-group mr-2" data-toggle="buttons" style="display: none;">
<label class="btn btn-arweave active clickable option-btn init">
<input type="radio" value="0.01" name="tip_options" autocomplete="off" checked>0.01
</label>
<label class="btn btn-arweave clickable option-btn">
<input type="radio" value="0.1" name="tip_options" autocomplete="off">0.1
</label>
<label class="btn btn-arweave clickable option-btn">
<input type="radio" value="1" name="tip_options" autocomplete="off">1
</label>
</div>
<button type="button" class="btn btn-arweave pull-right tip-btn" style="display: none">Tip!</button>
</span>
</div>
</form>
</div>
</div>
<div>
<span class="px-1 btn-small-text clickable badge comment-toggle">
<i class="fa fa-comments text-secondary" aria-hidden="true"></i>
<strong>[comments-count] Comments</strong>
</span>
<div class="comments-list" style="display: none">
<div class="row comments-container">
</div>
<div class="row comments-input">
<div class="col-lg-12 mt-2 logged-in" style="display: none">
<form name="comment-form">
<div class="form-group">
<textarea class="form-control" rows="2" style="min-width: 100%" name="input_comment" required="true"></textarea>
</div>
<button type="button" class="btn btn-success mt-2 comment-btn">Post Comment</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="comment-card-template" style="display: none">
<div class="col-lg-12 mt-2" card-id="[id]">
<div class="card">
<div class="card-body px-2 py-1">
<p style="white-space: pre-wrap;" class="mb-0">[comment]</p>
<div style="text-align: right; font-size: 80%" class="text-muted">
<i>[author] - [datetime]</i>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Login using Arweave
<a href="https://tokens.arweave.org/#/wallet" target="_blank">
<i class="fa fa-question-circle text-secondary" aria-hidden="true"></i>
</a>
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<div class="col-lg-12" style="text-align: center;">
<div class="file-input">
<input type="file" id="file" onchange="login(this.files)">
<div id="desc">Drop a keyfile to login</div>
</div>
<i class="fa fa-spinner fa-spin fa-3x fa-fw login-loading-indicator" style="display: none;"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="askQuestionModal" tabindex="-1" role="dialog" aria-labelledby="askQuestionModal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Ask Question</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="question-form">
<div class="form-group">
<label for="input_question">Question</label>
<input type="text" class="form-control" id="input_question" name="input_question" placeholder="Enter your question here" required="true">
</div>
<div class="form-group">
<label for="input_description" class="mt-4">Description</label>
<textarea class="form-control" rows="4" id="input_description" placeholder="Enter additional description here" style="min-width: 100%" required="true"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="ask_question()" id="question-btn">Submit Question</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="aboutModal" tabindex="-1" role="dialog" aria-labelledby="aboutModal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">About</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>
AskWeave is a permaweb Quora-like question & answer platform, where both answers are curated by users in a decentralized way.
<br>
Powered by Arweave, all questions and answers are forever stored and accessible anywhere!
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
var arweave = Arweave.init({host: 'arweave.net', port: 443, protocol: 'https'});
var versionNumber = '0.0.1';
var baseUrl = window.location;
</script>
</body>
</html>