forked from siunus/duco-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
855 lines (735 loc) · 28.3 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
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
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<meta http-equiv='X-UA-Compatible' content='IE=edge'/>
<title>DUCO Monitor | by siunusdev.com</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'/>
<link rel='shortcut icon' href='favicon.ico'/>
<link rel='stylesheet' href='plugins/bootstrap/dist/css/bootstrap.min.css'/>
<link rel='stylesheet' href='plugins/font-awesome/css/font-awesome.min.css'/>
<link rel='stylesheet' href='dist/css/AdminLTE.min.css'/>
<link rel='stylesheet' href='dist/css/skins/skin-yellow.min.css'/>
<link rel='stylesheet' href='dist/css/axkjfkdfhk.css?v=1.0'/>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic'/>
</head>
<body class='hold-transition skin-yellow layout-top-nav'>
<div class='wrapper'>
<div style="padding: 20px 30px; background: #00a65a; z-index: 999999; font-size: 16px; font-weight: 600; text-align: center;">
<a href="v2023" style="color: rgba(255, 255, 255, 0.9); display: inline-block; margin-right: 10px; text-decoration: none;">
<span style="font-size: 20pt;">🥳</span> We have a new look.
</a>
<a class="btn btn-default btn-sm" href="v2023" style="margin-top: -5px; border: 0px; box-shadow: none; color: rgb(243, 156, 18); font-weight: 600; background: rgb(255, 255, 255);">
Try it now!
</a>
</div>
<header class="main-header">
<nav class="navbar navbar-static-top">
<div class="container">
<div class="navbar-header">
<a href="" class="navbar-brand"><b>DUCO</b>Monitor</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
<i class="fa fa-bars"></i>
</button>
</div>
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="">Monitor <span class="sr-only">(current)</span></a></li>
<li><a href="https://wallet.duinocoin.com/" target='_blank'>Web Wallet</a></li>
<li><a href="https://server.duinocoin.com/webminer.html" target='_blank'>Web Miner</a></li>
<li><a href="https://exchange.duinocoin.com/" target='_blank'>DUCO Exchange</a></li>
</ul>
</div>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle">
<i class="fa fa-clock-o"></i> <span id='time-bar'>00:00:00</span>
</a>
</li>
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
<span class="hidden-xs" id="duco-user"> </span>
</a>
<ul class="dropdown-menu">
<li class="user-header">
<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
<p>
<small>Change duco username by adding hash #username to the end of URL</small>
</p>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="content-wrapper">
<div class="container">
<section class="content-header hidden-lg hidden-md hidden-sm">
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-database"></i> CPU: <span id='stat-cpu'>-</span></a></li>
<li><a href="#">RAM: <span id='stat-ram'>-</span></a></li>
<li><a href="#">Active Connections: <span id='stat-conn'>-</span></a></li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-aqua"><i class="fa fa-sitemap"></i></span>
<div class="info-box-content">
<span class="info-box-text">Active Workers</span>
<span class="info-box-number"><span id='counter-worker'>-</span></span>
</div>
<!-- /.info-box-content -->
</div>
<!-- /.info-box -->
</div>
<!-- /.col -->
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-teal"><i class="fa fa-bolt"></i></span>
<div class="info-box-content">
<span class="info-box-text">Total Hashrate</span>
<span class="info-box-number"><span id='counter-hashrate'>-</span></span>
</div>
<!-- /.info-box-content -->
</div>
<!-- /.info-box -->
</div>
<!-- /.col -->
<div class="clearfix visible-sm-block"></div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green"><i class="fa fa-money"></i></span>
<div class="info-box-content">
<span class="info-box-text">Estimated Profit</span>
<span class="info-box-number"><span id='counter-estprofit'>-</span></span>
<span class="info-box-text">in 24 Hours</span>
</div>
<!-- /.info-box-content -->
</div>
<!-- /.info-box -->
</div>
<!-- /.col -->
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-red"><i class="fa fa-money"></i></span>
<div class="info-box-content">
<span class="info-box-text">DUCO Balance</span>
<span class="info-box-number"><span id='counter-balance'>-</span></span>
<span class="info-box-text"><span id='counter-dollar'></span></span>
</div>
<!-- /.info-box-content -->
</div>
<!-- /.info-box -->
</div>
<!-- /.col -->
</div>
<div class='row'>
<div class='col-md-12'>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title"><i class='fa fa-line-chart fa-fw'></i> Mined Coins</h3>
</div>
<div class="box-body">
<!--div class='row'>
<div class='col-md-10'></div>
<div class='col-md-2'>
<i class='fa fa-fw fa-caret-up text-green'></i> Max: <span id='coins-max'>-</span><br/>
<i class='fa fa-fw fa-caret-down text-red'></i> Min: <span id='coins-min'>-</span><br/>
<i class='fa fa-fw fa-arrows-h text-yellow'></i> Avg: <span id='coins-avg'>-</span><br/>
</div>
</div-->
<br/>
<canvas id='coinsChart' style='height:200px;width:100%;'></canvas>
</div>
</div>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title"><i class='fa fa-line-chart fa-fw'></i> Price Chart</h3>
</div>
<div class="box-body">
<canvas id='priceChart' style='height:200px;width:100%;'></canvas>
</div>
<div class='box-footer'>
<div class='row'>
<div class='col-sm-3 col-xs-6'>
<div class='description-block border-right'>
<span class='description-text'>DUCO PRICE</span>
<h5 class='description-header'><span id='counter-price'>-</span></h5>
<span class='description-percentage' id='counter-price-change'>-</span>
</div>
</div>
<div class='col-sm-3 col-xs-6'>
<div class='description-block border-right'>
<span class='description-text'>MAX</span>
<h5 class='description-header'><span id='price-max'>-</span></h5>
<span class='description-percentage'> </span>
</div>
</div>
<div class='col-sm-3 col-xs-6'>
<div class='description-block border-right'>
<span class='description-text'>MIN</span>
<h5 class='description-header'><span id='price-min'>-</span></h5>
<span class='description-percentage'> </span>
</div>
</div>
<div class='col-sm-3 col-xs-6'>
<div class='description-block'>
<span class='description-text'>AVERAGE</span>
<h5 class='description-header'><span id='price-avg'>-</span></h5>
<span class='description-percentage'> </span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title"><i class='fa fa-diamond fa-fw'></i> My Miners</h3>
</div>
<!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<table class='table' id='table-miners'>
<thead>
<tr>
<th width='20px'>#</th>
<th>Software</th>
<th>Algorithm</th>
<th>Sharetime</th>
<th>Accepted</th>
<th>Rejected</th>
<th>Hashrate</th>
<th>Diff</th>
<th>Identifier</th>
<th>Pool</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
<!-- /.footer -->
</div>
<!-- /.box -->
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title"><i class='fa fa-fw fa-trophy'></i> Top 10</h3>
</div>
<!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<table class='table' id='table-top10'>
<thead>
<tr>
<th width='20px'>#</th>
<th>Username</th>
<th>Balance</th>
<th>Price</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- /.footer -->
</div>
</div>
<div class='col-md-6'>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title"><i class='fa fa-fw fa-retweet'></i> Last Transactions</h3>
</div>
<!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<table class='table' id='table-transactions'>
<thead>
<tr>
<th width='20px'>#</th>
<th>Date/Time</th>
<th>Sender</th>
<th>Recipient</th>
<th>Amount</th>
<th>Note</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- /.footer -->
</div>
<!-- /.box -->
</div>
</div>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="utterances utterances-frame"></div>
<script src="https://utteranc.es/client.js"
repo="siunus/duco-monitor"
issue-number="4"
label="comment"
theme="github-light"
crossorigin="anonymous"
async>
</script>
</div>
</div>
<div style="text-align: center">
<a href="https://www.buymeacoffee.com/siunusdev" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
</div>
</section>
</div>
</div>
<footer class="main-footer">
<div class="container">
<div class="pull-right hidden-xs">
<a href="https://github.com/siunus/duco-monitor" title='Github' target='_blank'><i class='fa fa-github text-black'></i></a>
<a href="https://www.instagram.com/siunus_id" title='Follow me on Instagram' target='_blank'><i class='fa fa-instagram text-red'></i></a>
<!-- Default Statcounter code for Duco Monitor
https://siunus.github.io/duco-monitor/ -->
<script type="text/javascript">
var sc_project=12655032;
var sc_invisible=0;
var sc_security="f40e0cbb";
var scJsHost = "https://";
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><span class="statcounter"><a title="Web Analytics" href="https://statcounter.com/" target="_blank"><img class="statcounter" src="https://c.statcounter.com/12655032/0/f40e0cbb/0/" alt="Web Analytics" referrerPolicy="no-referrer-when-downgrade"></a></span></noscript>
<!-- End of Statcounter Code -->
</div>
<a href="https://www.siunusdev.com" title='My Website' target='_blank'>SIUNUSDEV</a> ·
<a href="https://duinocoin.com" title='Duino-Coin' target='_blank'>Duinocoin.com</a> ·
<a href="https://adminlte.io" title='Theme' target='_blank'>AdminLTE.io</a>
<span class='badge bg-yellow' id='siunusdev-online-counter' title='Count since 2021-10-15' style='display:hidden'>Online: <span id='counter-online'>0</span></span>
</div>
</footer>
</div>
<script src='plugins/jquery/dist/jquery.min.js'></script>
<script src='plugins/bootstrap/dist/js/bootstrap.min.js'></script>
<script src='plugins/chart.js/Chart.min.js'></script>
<script src='dist/js/adminlte.min.js'></script>
<script src='dist/js/siunusdev.counter.js?v=2.0'></script>
<script defer>
const log = console.log;
const refresh_interval = 5; // seconds, faster interval may increase server load
const counter_worker = $('#counter-worker');
const counter_hashrate = $('#counter-hashrate');
const counter_price = $('#counter-price');
const counter_price_change = $('#counter-price-change');
const counter_estprofit = $('#counter-estprofit');
const counter_balance = $('#counter-balance');
const counter_dollar = $('#counter-dollar');
const table_miners = $('#table-miners');
const table_top10 = $('#table-top10 tbody');
const table_transactions = $('#table-transactions tbody');
let username = 'siunusdev'; // set default duco username
let intervalUserData, intervalServerInfo;
let workers, balance, lastBalance, lastBalanceChangeTime, ducoPrice, lastDucoPrice, ducoDollar;
let totalSharetime, totalAccepted, totalRejected, totalHashrate, totalDiff;
let maxChartData, priceData, coinsData, chartPriceConfig, chartCoinsConfig;
if(location.hash != "") {
username = location.hash.replaceAll("#", "");
} else {
location.hash = username;
}
window.onhashchange = function() {
if(location.hash != "") {
username = location.hash.replaceAll("#", "");
start();
getUserData();
getServerInfo();
}
}
start = function() {
workers = balance = lastBalance = lastBalanceChangeTime = ducoPrice = lastDucoPrice = ducoDollar = 0;
priceData = coinsData = [];
maxChartData = 15;
setUsername(username);
clearTimeout(intervalUserData);
clearTimeout(intervalServerInfo);
intervalUserData = intervalServerInfo = null;
counter_worker.text('-');
counter_hashrate.text('-');
counter_price.text('-');
counter_price_change.text('-');
counter_estprofit.text('-');
counter_balance.text('-');
counter_dollar.text('-');
table_miners.find('tbody').html("<tr><td></td><td colspan='9'>Loading...</td></tr>");
table_top10.html("<tr><td></td><td colspan='3'>Loading...</td></tr>");
table_transactions.html("<tr><td></td><td colspan='5'>Loading...</td></tr>");
if(window.innerWidth < 500) {
maxChartData = 10;
}
if(localStorage.getItem('priceData') != null) {
priceData = JSON.parse(localStorage.getItem('priceData'));
}
if(localStorage.getItem('coinsData') != null) {
coinsData = JSON.parse(localStorage.getItem('coinsData'));
}
}
addZero = function(n) {
if(n < 10) {
return "0" + n;
} else {
return n;
}
}
setTimebar = function() {
let date = new Date();
let h = date.getHours();
let m = date.getMinutes();
let s = date.getSeconds();
$('#time-bar').text(addZero(h) + ":" + addZero(m) + ":" + addZero(s));
setTimeout(setTimebar, 1000);
}
setUsername = function(name) {
$('#duco-user').text(name);
}
setPriceChart = function() {
chartPriceConfig = {
type: 'line',
data: {
labels: [],
datasets: [
{
label: '$',
backgroundColor : 'rgba(221, 75, 57, 0.1)',
borderColor : '#dd4b39',
borderWidth : 2,
pointRadius : 1,
pointHoverRadius : 6,
pointHitRadius : 10,
data: []
}
]
},
options: {
animation: false,
responsive: true,
legend: {
display: false
}
}
};
let chartPriceContext = document.getElementById('priceChart').getContext('2d');
window.priceChart = new Chart(chartPriceContext, chartPriceConfig);
}
setCoinsChart = function() {
chartCoinsConfig = {
type: 'line',
data: {
labels: [],
datasets: [
{
label: 'ᕲ',
backgroundColor : 'rgba(0, 166, 90, 0.1)',
borderColor : '#00a65a',
borderWidth : 2,
pointRadius : 1,
pointHoverRadius : 6,
pointHitRadius : 10,
data: []
}
]
},
options: {
animation: false,
responsive: true,
legend: {
display: false
}
}
};
let chartCoinsContext = document.getElementById('coinsChart').getContext('2d');
window.coinsChart = new Chart(chartCoinsContext, chartCoinsConfig);
}
hashrateConvert = function(val) {
let hashrate = val;
let hashrate_unit = ' H/s';
if(hashrate > 1000) {
hashrate = hashrate / 1000;
hashrate_unit = ' KH/s';
}
if(hashrate > 1000) {
hashrate = hashrate / 1000;
hashrate_unit = ' MH/s';
}
if(hashrate > 1000) {
hashrate = hashrate / 1000;
hashrate_unit = ' GH/s';
}
return hashrate.toFixed(2) + hashrate_unit;
}
getUserData = function() {
$.ajax({
dataType: "json",
url: "https://server.duinocoin.com/users/" + username
})
.done(function(data) {
//log(data);
if(data.success) {
let date = new Date();
let result = data.result;
workers = result.miners.length;
balance = result.balance.balance;
counter_worker.text(workers);
counter_balance.html(balance.toFixed(8) + ' <small>ᕲ</small>');
ducoDollar = balance * ducoPrice;
counter_dollar.text('~ $' + ducoDollar.toFixed(8));
setMiners(result.miners);
setTransations(result.transactions);
if(balance > lastBalance) {
let balanceChangeTime = (date.getTime() - lastBalanceChangeTime) / 1000;
let mined = balance - lastBalance;
let minedInSec = mined / balanceChangeTime;
let minedInHour = minedInSec * 3600;
let minedInDay = minedInHour * 24;
if(lastBalance == 0) {
counter_estprofit.html("<small>Calculating...</small>");
if(coinsData.length > 0) {
updateCoinsChart(coinsData);
}
} else {
counter_estprofit.html("~" + minedInDay.toFixed(8) + " <small>ᕲ</small>");
updateCoinsData(addZero(date.getHours()) + ":" + addZero(date.getMinutes()) + ":" + addZero(date.getSeconds()), +mined.toFixed(8));
}
lastBalanceChangeTime = date.getTime();
lastBalance = balance;
}
}
})
.fail(function(error) {
log(error);
})
.always(function() {
intervalUserData = setTimeout(getUserData, refresh_interval * 1000);
});
}
getServerInfo = function() {
$.ajax({
dataType: "json",
url: "https://server.duinocoin.com/api.json"
})
.done(function(data) {
//log(data);
if(data != '') {
let date = new Date();
ducoPrice = data["Duco price"];
counter_price.text('~ $' + ducoPrice.toFixed(8));
ducoDollar = balance * ducoPrice;
counter_dollar.text('~ $' + ducoDollar.toFixed(8));
setTopMiners(data["Top 10 richest miners"]);
if(ducoPrice != lastDucoPrice) {
if(lastDucoPrice != 0) {
let ducoPriceChange = (ducoPrice - lastDucoPrice);
if(ducoPriceChange != 0) {
if(ducoPriceChange > 0) {
counter_price_change.html("<span class='text-green'><i class='fa fa-caret-up'></i> $" + ducoPriceChange.toFixed(8) + "</span>");
} else {
counter_price_change.html("<span class='text-red'><i class='fa fa-caret-down'></i> $" + ducoPriceChange.toFixed(8) + "</span>");
}
}
}
updatePriceData(addZero(date.getHours()) + ":" + addZero(date.getMinutes()), +ducoPrice.toFixed(8));
lastDucoPrice = ducoPrice;
}
}
})
.fail(function(error) {
log(error);
})
.always(function() {
intervalServerInfo = setTimeout(getServerInfo, refresh_interval * 1000);
});
}
setMiners = function(miners) {
totalSharetime = totalAccepted = totalRejected = totalHashrate = totalDiff = 0;
table_miners.find('tbody').text('');
table_miners.find('tfoot').text('');
if(miners.length == 0 || typeof miners != 'object') {
table_miners.find('tbody').html("<tr><td></td><td colspan='8'>No active miner.</td></tr>");
}
else {
miners.forEach(function(miner, i) {
let tblHTML = "<tr>";
tblHTML += "<td>" + (+i+1) + "</td>";
tblHTML += "<td>" + miner["software"] + "</td>";
tblHTML += "<td>" + miner["algorithm"] + "</td>";
tblHTML += "<td class='text-info'>" + miner["sharetime"] + "</td>";
tblHTML += "<td class='text-green'>" + miner["accepted"] + "</td>";
tblHTML += "<td class='text-red'>" + miner["rejected"] + "</td>";
tblHTML += "<td>" + hashrateConvert(miner["hashrate"]) + "</td>";
tblHTML += "<td>" + miner["diff"] + "</td>";
tblHTML += "<td>" + miner["identifier"] + "</td>";
tblHTML += "<td>" + miner["pool"] + "</td>";
tblHTML += "</tr>";
table_miners.find('tbody').append(tblHTML);
totalSharetime += miner['sharetime'];
totalAccepted += miner['accepted'];
totalRejected += miner['rejected'];
totalHashrate += miner['hashrate'];
totalDiff += miner['diff'];
});
}
let tblHTML = "<tr>";
tblHTML += "<td></td>";
tblHTML += "<td></td>";
tblHTML += "<td>TOTAL</td>";
tblHTML += "<td class='text-info'>" + totalSharetime.toFixed(4) + "</td>";
tblHTML += "<td class='text-green'>" + totalAccepted + "</td>";
tblHTML += "<td class='text-red'>" + totalRejected + "</td>";
tblHTML += "<td>" + hashrateConvert(totalHashrate) + "</td>";
tblHTML += "<td>" + totalDiff + "</td>";
tblHTML += "<td></td>";
tblHTML += "<td></td>";
tblHTML += "</tr>";
table_miners.find('tfoot').append(tblHTML);
counter_hashrate.text(hashrateConvert(totalHashrate));
}
setTransations = function(transactions) {
table_transactions.text('');
if(transactions.length == 0 || typeof transactions != 'object') {
table_transactions.html("<tr><td></td><td colspan='5'>No transaction yet.</td></tr>");
}
else {
transactions.forEach(function(val, i) {
let dateTime = val["datetime"];
let sender = val["sender"];
let recipient = val["recipient"];
let amount = val["amount"];
let note = val["memo"];
table_transactions.append("<tr><td>" + (i+1) + "</td><td><small>" + dateTime + "</small></td><td><a href='#" + sender + "'>" + sender + "</a></td><td><a href='#" + recipient + "'>" + recipient + "</a></td><td>" + amount + "</td><td>" + note + "</td></tr>");
});
}
}
setTopMiners = function(data) {
table_top10.text('');
data.forEach(function(val, i) {
let position = val.split("-");
let topUsername = position[1].trim();
let topBalance = position[0].trim().split(' ');
let topBalanceNum = +topBalance[0];
let topBalanceStr = topBalanceNum.toFixed(8) + " <small>ᕲ</small>";
let topBalancePrice = ducoPrice * topBalanceNum;
let topBalancePriceStr = "~ $" + topBalancePrice.toFixed(8);
table_top10.append("<tr><td>" + (+i+1) + "</td><td><a href='#" + topUsername + "'>" + topUsername + "</a></td><td>" + topBalanceStr + "</td><td>" + topBalancePriceStr + "</td></tr>");
});
}
updatePriceData = function(newLabel, newValue) {
let maxData = maxChartData - priceData.length;
let lastData = 0;
if(priceData.length > 0) {
lastData = priceData[priceData.length - 1].val;
}
if(lastData != newValue) {
for(i = 0; i < maxData; i++) {
priceData.push({label: '--:--', val: 0});
}
priceData.shift();
priceData.push({label: newLabel, val: newValue});
}
updatePriceChart(priceData);
updatePriceMinMax(priceData);
updatePriceAverage(priceData);
localStorage.setItem('priceData', JSON.stringify(priceData));
}
updatePriceChart = function(d) {
let dataLabel = [], dataValue = [];
d.forEach(function(v, i) {
dataLabel.push(v.label);
dataValue.push(v.val);
});
chartPriceConfig.data.labels = dataLabel;
chartPriceConfig.data.datasets[0].data = dataValue;
window.priceChart.update();
}
updatePriceMinMax = function(d) {
priceMax = priceMin = ducoPrice;
d.forEach(function(v, i) {
if(v.val != 0) {
if(v.val > priceMax) {
priceMax = v.val;
}
if(v.val < priceMin) {
priceMin = v.val;
}
}
});
$('#price-max').text('$' + priceMax);
$('#price-min').text('$' + priceMin);
}
updatePriceAverage = function(data) {
let sum = 0, div = 0, avg = 0;
data.forEach(function(v, i) {
sum += v.val;
if(v.val != 0) {
div++;
}
});
if(div != 0) {
avg = sum / div;
avg = avg.toFixed(8);
}
$('#price-avg').text('$' + avg);
}
updateCoinsData = function(newLabel, newValue) {
let maxData = maxChartData - coinsData.length;
let lastData = 0;
if(coinsData.length > 0) {
lastData = coinsData[coinsData.length - 1].val;
}
if(lastData != newValue) {
for(i = 0; i < maxData; i++) {
coinsData.push({label: '--:--', val: 0});
}
coinsData.shift();
coinsData.push({label: newLabel, val: newValue});
}
updateCoinsChart(coinsData);
//updatePriceMinMax(priceData);
//updatePriceAverage(priceData);
localStorage.setItem('coinsData', JSON.stringify(coinsData));
}
updateCoinsChart = function(d) {
let dataLabel = [], dataValue = [];
d.forEach(function(v, i) {
dataLabel.push(v.label);
dataValue.push(v.val);
});
chartCoinsConfig.data.labels = dataLabel;
chartCoinsConfig.data.datasets[0].data = dataValue;
window.coinsChart.update();
}
$(document).ready(function() {
start();
setTimebar();
setPriceChart();
setCoinsChart();
getUserData();
getServerInfo();
});
</script>
</body>
</html>