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
/
user.html
521 lines (307 loc) · 13.6 KB
/
user.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
<!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 charset="utf-8">
<meta name="description" content="User.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Peer Query">
<meta property="og:title" content="Account: Peer Query">
<meta property="og:description" content="User.">
<meta property="og:image" content="https://www.peerquery.com/assets/img/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>User profile</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 stackable grid">
<div class="four wide column">
<div class="ui cards">
<div class="card">
<div class="image">
<img id="userImg" src="/assets/img/image.png">
</div>
<div class="content">
<div class="header" id="name"></div>
<div class="meta">
<a><span id="username"></span><span id="rep"></span></a>
</div>
<div class="description" id="bio">
</div>
</div>
<div class="extra content">
<i class="marker icon"></i>
<span id="location">
..
</span>
</div>
<div class="extra content">
<span class="right floated">
<i class="history icon"></i>
<span class="timeago" id="created"></span>
</span>
<span>
<i class="user icon"></i>
<span id="followers"></span>
</span>
</div>
<div class="ui compact selection dropdown">
<i class="dropdown icon"></i>
<div class="text">View details</div>
<div class="menu">
<a class="item" id="feed_btn">Feed</a>
<a class="item" id="community_btn">Community</a>
<a class="item" id="wallet_btn">Wallet</a>
<a class="item" target="_blank" id="website_btn">Website</a>
</div>
</div>
</div>
</div>
</div>
<div class="twelve wide column">
<div class="ui pointing below label">
<span id="blog-label"></span>
<span id="post_count"></span>
</div>
<div class="ui relaxed divided items" id="item-container">
</div>
<div class="ui active centered inline loader" id="spinner" style=""></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>
</div>
</div>
<br/><br/>
<!-- mounting div -->
<div id="temp" style="display:none"></div>
<!-- end of mounting div -->
<div id="footer"></div>
<script>
$("#navbar").load("/navbar.html"); //load the navbar!!!
$("#footer").load("/footer.html"); //load the footer!!!
$("#response-toggle").click(function(){
$("#response-form").slideToggle("slow");
});
var converter = new showdown.Converter();
steem.api.setOptions({ url: 'https://api.steemit.com' });
let p_URL = window.location.pathname;
let str = p_URL.substr(p_URL.indexOf("@") + 1);
let user = str.substring((str.indexOf("@") + 1));
//console.log(author);
document.title = "@" + user + " - Peer Query";
document.getElementById("more-btn").dataset.tag = user;
document.getElementById("wallet_btn").href = "/@" + user + "/wallet";
document.getElementById("community_btn").href = "/@" + user + "/community";
document.getElementById("feed_btn").href = "/@" + user + "/feed";
document.getElementById("userImg").src = "https://img.busy.org/@" + user + "?height=500&width=500";
document.getElementById("blog-label").innerText = "Blog of @" + user;
document.getElementById("username").innerText = "@" + user;
steem.api.getFollowCount(user, function(err, result) {
//console.log(err, result);
document.getElementById("followers").innerText = result.follower_count.toLocaleString() + " followers";
});
//let account = account;
steem.api.getAccounts([user], function(err, response){
//console.log(err, response);
if (response == "" || response[0] == "") {
alert("Account does not exist!");
return;
}
var response = response[0];
document.getElementById("created").title = response.created;
document.getElementById("rep").innerText = "(" + steem.formatter.reputation(response.reputation) + ")";
document.getElementById("post_count").innerText = "(" + Number(response.post_count).toLocaleString() + " total posts and comments)";
if (response.json_metadata) {
metaData = JSON.parse(response.json_metadata);
if (metaData.profile) {
if(metaData.profile.name != undefined || "") document.getElementById("name").innerText = metaData.profile.name;
if(metaData.profile.about != undefined || "") document.getElementById("bio").innerText = metaData.profile.about;
if(metaData.profile.website != undefined || "") document.getElementById("website_btn").href = metaData.profile.website;
if(metaData.profile.location != undefined || "") document.getElementById("location").innerText = metaData.profile.location;
}
}
});
function loadMore() {
//console.log("WORKING!!!");
document.getElementById("spinner").style.display = "block";
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.getDiscussionsByBlog(query, function(err, result) {
//console.log(err, result);
document.getElementById("spinner").style.display = "none";
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 > 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();};
}
}
});
}
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.style.height = "124px";
post_image.style.width = "150px";
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 = "/tag/" + 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);
}
</script>
</body>
</html>