This repository has been archived by the owner on May 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed.html
671 lines (370 loc) · 16.1 KB
/
feed.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
<!DOCTYPE html>
<html>
<head>
<!-- Standard Meta -->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<!-- Site Properties -->
<meta name="description" content="">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Peer Query">
<meta property="og:title" content="Peer Query">
<meta property="og:description" content="">
<meta property="og:image" content="https://www.peerquery.com/assets/images/peerquery.png">
<meta property="fb:app_id" content="384491628645652">
<link rel="icon" type="image/x-icon" href="/assets/img/favicon.ico">
<meta name="application-name" content="Peer Query">
<title>Feed - Peer Query</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css" />
<link rel="stylesheet" href="/assets/css/custom.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/components/visibility.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/components/sidebar.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/components/transition.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.8.6/showdown.min.js"></script>
<script src="/assets/scripts/timeago.js"></script>
<script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
<script src="https://steemit.github.io/sc2-angular/sc2.min.js"></script>
</head>
<body>
<div id="navbar"></div>
<br/><br/>
<br/><br/>
<br/><br/>
<div class="ui container">
<div class="ui feed">
<div class="event">
<div class="label">
<img id="account_img" src="">
</div>
<div class="content">
<div class="summary">
<a id="user_account"></a>
<div class="date">
Feed
</div>
<div class="ui active inline tiny loader" id="spinner"></div>
</div>
</div>
</div>
</div>
<div class="ui dropdown">
<i class="sidebar icon"></i>
<div class="text">View</div>
<i class="dropdown icon"></i>
<div class="menu">
<a class="item" id="account_btn">
<i class="user icon"></i>
Account
</a>
<a class="item" id="community_btn">
<i class="users icon"></i>
Community
</a>
<a class="item" id="wallet_btn">
<i class="dollar icon"></i>
Wallet
</a>
</div>
</div>
</div>
<br/>
<div class="ui divider"></div>
<br/><br/>
<div class="ui stackable grid container">
<div class="row">
<div class="ten wide column">
<br/>
<!-- top questions -->
<div class="ui container">
<div class="ui relaxed divided items" id="item-container">
</div>
<div class="ui active centered inline loader" id="post-loader" style="display:none"></div>
</div>
</div>
<!-- end of top questions -->
<div class="six wide desktop-only right floated column">
<!-- Top earners -->
<div class="ui container">
<br/>
<div class="ui active centered inline loader" id="responses-loader" style="display:none"></div>
<br/>
<div class="ui left pointing label grid" style="visibility:hidden" id="responses-label">
<div class="ui grid">
<div class="two wide column"><i class="big comments icon"></i></div>
<div class="fourteen wide column" id="responses-title"></div>
</div>
</div>
<div class="ui comments" id="responses-container">
</div>
</div>
<!-- end of top earners -->
</div>
</div>
<div class="row">
<div class="center aligned column">
<br/><br/>
<a class="ui huge button" id="more-btn" style="visibility:hidden" data-href="" data-author="" data-tag="" data-type="" onClick="loadMore(this)">Load more</a>
</div>
</div>
</div>
<!-- mounting div -->
<div id="temp" style="display:none"></div>
<!-- end of mounting div -->
<div id="footer"></div>
<script>
//
$("#navbar").load("/navbar.html"); //load the footer!!!
$("#footer").load("/footer.html"); //load the footer!!!
var converter = new showdown.Converter();
steem.api.setOptions({ url: 'https://api.steemit.com' });
var pth = window.location.pathname;
account = pth.substr(pth.indexOf("@") + 1, pth.indexOf("/feed") -2);
//console.log(account);
document.getElementById("wallet_btn").href = "/@" + account + "/wallet";
document.getElementById("account_btn").href = "/@" + account;
document.getElementById("community_btn").href = "/@" + account + "/community";
document.getElementById("more-btn").dataset.tag = account;
document.getElementById("user_account").innerText = account.toUpperCase();
document.getElementById("user_account").href = "/@" + account;
document.getElementById("account_img").src = "https://img.busy.org/@" + account;
function loadMore() {
document.getElementById("post-loader").style.visibility = "visible";
document.getElementById("more-btn").style.visibility = "hidden";
var element = document.getElementById("more-btn");
var limt = 11;
var last_permlink = element.dataset.href;
var last_author = element.dataset.author;
if (element.dataset.href == "") {
query = { tag: element.dataset.tag, limit: limt };
} else {
query = { tag: element.dataset.tag, limit: limt, start_author : last_author, start_permlink : last_permlink };
}
//console.log(query);
steem.api.getDiscussionsByFeed(query, function(err, result) {
//console.log(err, result);
document.getElementById("post-loader").style.visibility = "hidden";
document.getElementById("spinner").style.visibility = "hidden";
if (result.length <= 1) return;
if (result.length > 10) document.getElementById("more-btn").style.visibility = "visible";
var n = result.length -1;
//console.log(n);
element.dataset.href = result[n].permlink;
element.dataset.author = result[n].author;
if (result.length <= 1) return;
if (result.length > 10 ) {
for (x in result) {
if ( x == result.length -1 ) { timeAgo(); break; };
create_post_card(result[x]);
}
}
//console.log(result.length);
if (result.length < 10 ) {
for (x in result) {
//console.log(x);
create_post_card(result[x]);
if ( x == result.length -1 ) { timeAgo();};
}
}
get_responses_to_top(result[0]);
});
}
loadMore();
function create_post_card(result) {
var resteem_state = "hidden";
if (result.first_reblogged_on) resteem_state = "visible";
var html = converter.makeHtml(result.body);
document.getElementById("temp").innerHTML = html;
body_raw = $("#temp").text();
body1 = body_raw.replace(/ *\([^)]*\) */g, ""); //removes () and all content in it
body2 = body1.replace(/ *\[[^\]]*\] */g, ""); //removes [] and all content in it
body3 = body2.replace(/(?:https?|ftp):\/\/[\S\n]+/g, ''); //removes all links - targetted at image links
var summary = body3.substr(0, 150) + " ...";
summary = summary.replace(/\n/g, "");
var src = "/assets/img/image.png";
src = $('#temp img').attr('src');
document.getElementById("temp").innerHTML = "";
var item = document.createElement("div");
item.className = "item";
var image_div = document.createElement("div");
image_div.className = "ui small image";
var post_image = document.createElement("img");
post_image.onerror = function() {this.src='/assets/img/image.png'; this.onerror='';};
post_image.src = src;
image_div.appendChild(post_image);
var content_div = document.createElement("div");
content_div.className = "content";
var header_a = document.createElement("a");
header_a.className = "header";
header_a.href = "/" + result.parent_permlink + "/@" + result.author + "/" + result.permlink;
header_a.innerText = result.title + " ";
var i_resteem = document.createElement("i");
i_resteem.title = "Resteemed";
i_resteem.style.visibility = resteem_state;
i_resteem.className = "tiny circular pink inverted fitted refresh icon";
header_a.appendChild(i_resteem);
var extra_div = document.createElement("div");
extra_div.className = "extra";
var author_a = document.createElement("a");
author_a.className = "ui blue image label";
author_a.href = "/@" + result.author;
var author_img = document.createElement("img");
author_img.onerror = function() {this.src='/assets/img/image.png'; this.onerror='';};
author_img.src = "https://img.busy.org/@" + result.author;
var author_span = document.createElement("span");
author_span.innerText = result.author;
var author_rep_div = document.createElement("div");
author_rep_div.className = "detail";
author_rep_div.title = "User's reputation";
author_rep_div.innerText = steem.formatter.reputation(result.author_reputation);
author_a.appendChild(author_img);
author_a.appendChild(author_span);
author_a.appendChild(author_rep_div);
var time_span = document.createElement("span");
var time_span_icon = document.createElement("i");
time_span_icon.className = "wait icon";
var time = document.createElement("span");
time.className = "timeago";
time.title = result.created;
time.innerText = result.created;
time_span.appendChild(time_span_icon);
time_span.appendChild(time);
extra_div.appendChild(author_a);
extra_div.appendChild(time_span);
var description_div = document.createElement("div");
description_div.className = "description";
description_div.innerText = summary;
var extra_label_div = document.createElement("div");
extra_label_div.className = "extra";
var a_category = document.createElement("a");
a_category.className = "ui label";
a_category.title = "Category";
a_category.href = "/tags/" + result.parent_permlink;
var i_category = document.createElement("i");
i_category.className = "tag icon";
var span_category = document.createElement("span");
span_category.innerText = result.parent_permlink;
a_category.appendChild(i_category);
a_category.appendChild(span_category);
var a_earned = document.createElement("a");
a_earned.className = "ui label";
a_earned.title = "Earned";
var i_earned = document.createElement("i");
i_earned.className = "dollar icon";
var span_earned = document.createElement("span");
span_earned.innerText = Math.max(Number(result.pending_payout_value.split(' ')[0]), Number(result.total_payout_value.split(' ')[0]) + Number(result.curator_payout_value.split(' ')[0])).toLocaleString();
a_earned.appendChild(i_earned);
a_earned.appendChild(span_earned);
var a_votes = document.createElement("a");
a_votes.className = "ui label";
a_votes.title = "Votes";
var i_votes = document.createElement("i");
i_votes.className = "heart icon";
var span_votes = document.createElement("span");
span_votes.innerText = Number(result.active_votes.length).toLocaleString();
a_votes.appendChild(i_votes);
a_votes.appendChild(span_votes);
var a_responses = document.createElement("a");
a_responses.className = "ui label";
a_responses.title = "Responses";
var i_responses = document.createElement("i");
i_responses.className = "comments icon";
var span_responses = document.createElement("span");
span_responses.innerText = result.children.toLocaleString();
a_responses.appendChild(i_responses);
a_responses.appendChild(span_responses);
extra_label_div.appendChild(a_category);
extra_label_div.appendChild(a_earned);
extra_label_div.appendChild(a_votes);
extra_label_div.appendChild(a_responses);
content_div.appendChild(header_a);
content_div.appendChild(extra_div);
content_div.appendChild(description_div);
content_div.appendChild(extra_label_div);
item.appendChild(image_div);
item.appendChild(content_div);
document.getElementById("item-container").appendChild(item);
}
function get_responses_to_top(result) {
document.getElementById("responses-title").innerText = result.title;
steem.api.getContentReplies(result.author, result.permlink, function(err, result) {
//console.log(err, result);
if(err) { alert(err); return }
document.getElementById("responses-label").style.visibility = "visible";
document.getElementById("responses-loader").style.display = "none";
for(x in result) {
if(x == result.length -1) timeAgo();
if(x == "25") return;
create_comment(result[x]);
}
});
}
function create_comment(cmt) {
var md = cmt.body;
var html = converter.makeHtml(md);
var tmp = document.createElement('div');
tmp.innerHTML = html;
var img = tmp.getElementsByTagName('img')[0];
var src = "/img/thumbnail-placeholder.png";
if (img !== undefined || null) src = img.src;
var summary = tmp.innerText.replace(/\W+/g, " ");
summary = summary.substr(0, 100) + " ...";
var comment = document.createElement("div");
comment.className = "comment";
var a_avatar = document.createElement("a");
a_avatar.className = "avatar";
var img_avatar = document.createElement("img");
img_avatar.onerror = function() {this.src='/assets/img/image.png'; this.onerror='';};
img_avatar.src = "https://img.busy.org/@" + cmt.author;
a_avatar.appendChild(img_avatar);
var div_content = document.createElement("div");
div_content.className = "content";
var a_author = document.createElement("a");
a_author.className = "author";
a_author.href = "/@" + cmt.author;
a_author.innerText = "@" + cmt.author + "(" + steem.formatter.reputation(cmt.author_reputation) + ")";
var div_meta = document.createElement("div");
div_meta.className = "metadata";
var div_date = document.createElement("div");
div_date.className = "date";
var i_date = document.createElement("i");
i_date.className = "wait icon";
var span_date = document.createElement("span");
span_date.className = "timeago";
span_date.title = cmt.created;
div_date.appendChild(i_date);
div_date.appendChild(span_date);
var div_votes = document.createElement("div");
div_votes.className = "rating";
var i_votes = document.createElement("i");
i_votes.className = "heart icon";
var span_votes = document.createElement("span");
span_votes.innerText = Number(cmt.net_votes).toLocaleString();
div_votes.appendChild(i_votes);
div_votes.appendChild(span_votes);
var div_earned = document.createElement("div");
div_earned.className = "earned";
var i_earned = document.createElement("i");
i_earned.className = "dollar icon";
var span_earned = document.createElement("span");
span_earned.innerText = Math.max(Number(cmt.pending_payout_value.split(' ')[0]), Number(cmt.total_payout_value.split(' ')[0]) + Number(cmt.curator_payout_value.split(' ')[0])).toLocaleString();
div_earned.appendChild(i_earned);
div_earned.appendChild(span_earned);
div_comment = document.createElement("div");
div_comment.className = "text";
div_comment.innerText = summary;
div_meta.appendChild(div_date);
div_meta.appendChild(div_votes);
div_meta.appendChild(div_earned);
div_content.appendChild(a_author);
div_content.appendChild(div_meta);
div_content.appendChild(div_comment);
comment.appendChild(a_avatar);
comment.appendChild(div_content);
document.getElementById("responses-container").appendChild(comment);
}
</script>
</body>
</html>