-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhome.html
805 lines (710 loc) · 24 KB
/
home.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
<div class="row">
<div class="col-sm-12 col-md-6">
<div class="panel panel-default" id="network-stats">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-tasks fa-fw" aria-hidden="true"></i> Stats</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-6 col-md-6">
<ul class="nav nav-pills nav-stacked">
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Blockchain height, total amount of blocks starting from zero."><i class="fa fa-bars"></i> Height: <span id="networkHeight"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="The number of transactions in the network (excluding coinbase, i.e. reward for mined blocks)."><i class="fa fa fa-exchange"></i> Transactions: <span id="networkTransactions"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Current Base Reward (for last mined block)."><i class="fa fa-certificate"></i> Reward: <span id="currentReward"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Total CBC supply in circulation."><i class="fa fa-money"></i> Supply: <span id="totalCoins"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="bottom" data-original-title="Percent of already emitted coins related to Initial supply before Tail emission."><i class="fa fa-percent" aria-hidden="true"></i> Emission: <span id="emissionPercent"></span> %</a></li>
</ul>
</div>
<div class="col-sm-6 col-md-6">
<ul class="nav nav-pills nav-stacked">
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Difficulty for next block. Ratio at which at the current hashing speed blocks will be mined with 4 minutes interval."><i class="fa fa-unlock-alt"></i> Difficulty: <span id="networkDifficulty"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Average difficulty by last 30 blocks."><i class="fa fa-lock"></i> Average Difficulty: <span id="avgDifficulty"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Current estimated network hash rate. Calculated by current difficulty."><i class="fa fa-tachometer"></i> Hash Rate: <span id="networkHashrate"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Average estimated network hash rate. Calculated by average difficulty."><i class="fa fa-clock-o"></i> Average Hash Rate: <span id="avgHashrate"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="bottom" data-original-title="Estimated block solve time at estimated network speed and current difficulty."><i class="fa fa-circle-o-notch" aria-hidden="true"></i> Solve time: <span id="blockSolveTime"></span></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-area-chart" aria-hidden="true"></i> Charts
<span class="text-default" data-toggle="tooltip" data-placement="right" data-original-title="Difficulty based on last blocks from the list below. Block size, transactions count. Load more blocks to enlarge chart range."><i class="fa fa-question-circle"></i></span>
</h3>
</div>
<div class="panel-body chart-wrapper">
<canvas id="difficultyChart" height="210"></canvas>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-exchange fa-fw" aria-hidden="true"></i> Transaction pool
<span id="mempool_count" class="badge"></span>
<span class="text-default" data-toggle="tooltip" data-placement="right" data-original-title="Recent transactions waiting to be included into a block. Once it happens a transaction gets into the blockchain and becomes confirmed."><i class="fa fa-question-circle"></i></span>
</h3>
</div>
<div class="panel-body">
<div>
<div class="table-responsive">
<table class="table table-hover" id="mem_pool_table">
<thead>
<tr>
<th width="30%"><i class="fa fa-clock-o"></i> Date & time</th>
<th width="10%"><i class="fa fa-money"></i> Amount</th>
<th width="10%"><i class="fa fa-tag"></i> Fee</th>
<th width="10%"><i class="fa fa-archive"></i> Size</th>
<th width="40%"><i class="fa fa-paw"></i> Hash</th>
</tr>
</thead>
<tbody id="mem_pool_rows">
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Recent blocks</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-8 col-md-6 col-lg-5">
<div class="input-group">
<a id="prev-page" href="#" class="btn btn-default input-group-addon"><i class="fa fa-arrow-left" aria-hidden="true"></i> Older</a>
<span class="input-group-addon">№</span>
<input id="goto-height" type="text" class="form-control" placeholder="Height">
<a id="goto-height-go" href="#" class="btn btn-default input-group-addon">Go</a>
<a id="next-page" href="#" class="btn btn-default input-group-addon disabled">Newer <i class="fa fa-arrow-right" aria-hidden="true"></i></a>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th><i class="fa fa-bars"></i> Height</th>
<th><i class="fa fa-clock-o"></i> Date & time</th>
<th><i class="fa fa-archive"></i> Size</th>
<th><i class="fa fa-paw"></i> Block Hash</th>
<th><i class="fa fa-unlock-alt"></i> Difficulty</th>
<th><i class="fa fa-bars"></i> Transactions</th>
</tr>
</thead>
<tbody id="blocks_rows">
</tbody>
</table>
</div>
<p class="text-center">
<button type="button" class="btn btn-default" id="loadMoreBlocks">Load More</button>
</p>
</div>
</div>
<script>
var block,
Difficulties = [],
Blocks = [],
Rewards = [],
Txses = [],
Sizes = [],
Timestamps = [],
diffChart;
currentPage = {
destroy: function(){
if (xhrGetBlocks) xhrGetBlocks.abort();
},
init: function(){
$.when(
renderInitialBlocks()
).then(function() {
setTimeout(function(){
displayDiffChart();
refreshChart();
}, 500)
});
},
update: function(){
renderLastBlock();
updateText('networkHeight', lastStats.height.toString());
updateText('networkTransactions', lastStats.tx_count.toString());
updateText('networkHashrate', getReadableHashRateString(lastStats.difficulty / blockTargetInterval));
updateText('networkDifficulty', getReadableDifficultyString(lastStats.difficulty, 0).toString());
$("time.timeago").timeago();
getPoolTransactions();
var currHeight = $('#blocks_rows').children().first().data('height');
if((currHeight + 31) > lastStats.last_known_block_index){
$.when(
renderInitialBlocks()
).then(function() {
setTimeout(function(){
refreshChart();
}, 100)
});
}
if((currHeight + 31) < lastStats.last_known_block_index){
$('#next-page').removeClass('disabled');
}
}
};
function renderLastBlock(){
$.ajax({
url: api + '/json_rpc',
method: "POST",
data: JSON.stringify({
jsonrpc:"2.0",
id: "test",
method:"getlastblockheader",
params: {
}
}),
dataType: 'json',
cache: 'false',
success: function(data){
last_block_hash = data.result.block_header.hash;
$.ajax({
url: api + '/json_rpc',
method: "POST",
data: JSON.stringify({
jsonrpc:"2.0",
id: "test",
method:"f_block_json",
params: {
hash: last_block_hash
}
}),
dataType: 'json',
cache: 'false',
success: function(data){
block = data.result.block;
updateText('totalCoins', getReadableCoins(block.alreadyGeneratedCoins,6));
updateText('emissionPercent', (block.alreadyGeneratedCoins / 3000000000000000 * 100).toFixed(6));
updateText('currentReward', getReadableCoins(block.baseReward,6));
}
});
}
});
}
var xhrGetBlocks;
$('#loadMoreBlocks').click(function(){
if (xhrGetBlocks) xhrGetBlocks.abort();
xhrGetBlocks = $.ajax({
url: api + '/json_rpc',
method: "POST",
data: JSON.stringify({
jsonrpc:"2.0",
id: "test",
method:"f_blocks_list_json",
params: {
height: $('#blocks_rows').children().last().data('height')
}
}),
dataType: 'json',
cache: 'false',
success: function(data){
$.when(
renderBlocks(data.result.blocks)
).then(function() {
setTimeout(function(){
loadMoreChart();
}, 100)
});
}
});
});
$('#prev-page').click(function(e){
if (xhrGetBlocks) xhrGetBlocks.abort();
var currHeight = $('#blocks_rows').children().first().data('height');
var openHeight = (currHeight - 31 < 0) ? 0 : currHeight - 31;
xhrGetBlocks = $.ajax({
url: api + '/json_rpc',
method: "POST",
data: JSON.stringify({
jsonrpc:"2.0",
id: "test",
method:"f_blocks_list_json",
params: {
height: openHeight
}
}),
dataType: 'json',
cache: 'false',
success: function(data){
$('#blocks_rows').children().remove();
$.when(
renderBlocks(data.result.blocks)
).then(function() {
setTimeout(function(){
refreshChart();
}, 100)
});
}
});
e.preventDefault();
if((currHeight + 31) > lastStats.last_known_block_index){
$('#next-page').removeClass('disabled');
}
if((currHeight - 61) < 0){
$('#prev-page').addClass('disabled');
}
});
$('#next-page').click(function(e){
if (xhrGetBlocks) xhrGetBlocks.abort();
var currHeight = $('#blocks_rows').children().first().data('height');
var openHeight = (currHeight + 31 > lastStats.last_known_block_index) ? (lastStats.last_known_block_index) : currHeight + 31;
xhrGetBlocks = $.ajax({
url: api + '/json_rpc',
method: "POST",
data: JSON.stringify({
jsonrpc:"2.0",
id: "test",
method:"f_blocks_list_json",
params: {
height: openHeight
}
}),
dataType: 'json',
cache: 'false',
success: function(data){
$('#blocks_rows').children().remove();
$.when(
renderBlocks(data.result.blocks)
).then(function() {
setTimeout(function(){
refreshChart();
}, 100)
});
}
});
e.preventDefault();
if((currHeight + 61) > lastStats.last_known_block_index){
$('#next-page').addClass('disabled');
}
$('#prev-page').removeClass('disabled');
});
$('#goto-height-go').click(function() {
var height = document.getElementById('goto-height').value;
var newUrl = "/?height="+height;
window.location = newUrl;
});
$('#goto-height').keyup(function(e){
if(e.keyCode === 13)
$('#goto-height-go').click();
});
function renderInitialBlocks(){
if (xhrGetBlocks) xhrGetBlocks.abort();
var loadHeight;
if (urlParam('height'))
loadHeight = parseInt(urlParam('height'));
else
loadHeight = lastStats.last_known_block_index;
if((loadHeight - 31) < 0){
$('#prev-page').addClass('disabled');
$('#next-page').removeClass('disabled');
}
xhrGetBlocks = $.ajax({
url: api + '/json_rpc',
method: "POST",
data: JSON.stringify({
jsonrpc:"2.0",
id: "test",
method:"f_blocks_list_json",
params: {
height: loadHeight
}
}),
dataType: 'json',
cache: 'false',
success: function(data){
renderBlocks(data.result.blocks);
}
});
};
function getBlockRowElement(block, jsonString){
var row = document.createElement('tr');
row.setAttribute('data-json', jsonString);
row.setAttribute('data-height', block.height);
row.setAttribute('id', 'blockRow' + block.height);
row.setAttribute('title', block.hash);
var dateTime = new Date(block.timestamp * 1000).toISOString();
row.setAttribute('data-dt', dateTime);
var columns =
'<td>' + block.height + '</td>' +
'<td class="date-time">' + formatDate(block.timestamp) + ' (<time class="timeago" datetime="'+dateTime+'"></time>)</td>' +
'<td>' + block.cumul_size + '</td>' +
'<td>' + formatBlockLink(block.hash) + '</td>' +
'<td class="blk-diff">' + block.difficulty + '</td>' +
'<td>' + block.tx_count + '</td>';
Difficulties.push(parseInt(block.difficulty));
Blocks.push(parseInt(block.height));
Txses.push(parseInt(block.tx_count));
Sizes.push(parseInt(block.cumul_size));
Timestamps.push(dateTime);
row.innerHTML = columns;
return row;
}
function renderBlocks(blocksResults){
var $blocksRows = $('#blocks_rows');
for (var i = 0; i < blocksResults.length; i ++){
var block = blocksResults[i];
var blockJson = JSON.stringify(block);
var existingRow = document.getElementById('blockRow' + block.height);
if (existingRow && existingRow.getAttribute('data-json') !== blockJson){
$(existingRow).replaceWith(getBlockRowElement(block, blockJson));
}
else if (!existingRow){
var blockElement = getBlockRowElement(block, blockJson);
var inserted = false;
var rows = $blocksRows.children().get();
for (var f = 0; f < rows.length; f++) {
var bHeight = parseInt(rows[f].getAttribute('data-height'));
if (bHeight < block.height){
inserted = true;
$(rows[f]).before(blockElement);
break;
}
}
if (!inserted) {
$blocksRows.append(blockElement);
}
}
}
$("time.timeago").timeago();
calcAvgHashRate();
}
function calcAvgHashRate(){
var sum = Difficulties.reduce(add, 0);
function add(a, b) {
return a + b;
}
var avgDiff = Math.round(sum / Difficulties.length);
var avgHashRate = avgDiff / blockTargetInterval;
updateText('avgDifficulty', getReadableDifficultyString(avgDiff, 0).toString());
updateText('avgHashrate', getReadableHashRateString(avgDiff / blockTargetInterval));
updateText('blockSolveTime', getReadableTime(lastStats.difficulty / avgHashRate));
}
// Cobitcoin MemPool Transactions
function getPoolTransactions(){
var xhrGetPool = $.ajax({
url: api + '/json_rpc',
method: "POST",
data: JSON.stringify({
jsonrpc:"2.0",
id: "test",
method:"f_pool_json",
params: {
}
}),
dataType: 'text',
cache: 'false',
success: function(data){
var txsRows = document.getElementById('mem_pool_rows');
while (txsRows.firstChild) {
txsRows.removeChild(txsRows.firstChild);
}
var rawTxs = data.split('"transactions":"').pop();
rawTxs = rawTxs.split('"}}')[0];
var txsArray = [];
txsArray = rawTxs.split('\n\n');
txsArray.forEach(function(tx, i) {
var arrayOfLines = tx.split('\n');
var hash = arrayOfLines[0].split(': ').pop();
if(hash != "") {
var timestamp = arrayOfLines[10].split(':').pop();
var amount = arrayOfLines[8].split(':').pop();
var fee = arrayOfLines[9].split(':').pop();
var size = arrayOfLines[1].split(':').pop();
var row = document.createElement('tr');
var columns =
'<td>' + formatDate(timestamp) + ' (<span class="mtx-ago"></span>)' + '</td>' +
'<td>' + getReadableCoins(amount, 4, true) + '</td>' +
'<td>' + getReadableCoins(fee, 4, true) + '</td>' +
'<td>' + size + '</td>' +
'<td>' + formatPaymentLink(hash) + '</td>';
row.innerHTML = columns;
$(txsRows).append(row);
$(row).find('.mtx-ago').timeago('update', new Date(timestamp * 1000).toISOString());
}
});
updateText('mempool_count', document.querySelectorAll('#mem_pool_rows tr').length);
}
});
};
// Difficulty chart
function displayDiffChart() {
var ctx = document.getElementById("difficultyChart");
var chartData = {
//labels: [].concat(Blocks).reverse(),
labels: [].concat(formatDate(Timestamps)).reverse(),
datasets: [
{
data: [].concat(Blocks).reverse(),
yAxisID: "Height",
label: "Height",
backgroundColor: "rgba(0,0,0,0)",
borderColor: 'rgba(0,0,0,0)',
borderWidth: 0,
pointBorderWidth: 0,
pointRadius: 0,
pointHoverRadius: 0,
pointHitRadius: 0,
display: false
},{
data: [].concat(Difficulties).reverse(),
yAxisID: "Difficulty",
label: "Difficulty",
backgroundColor: "rgba(220,220,220,0.2)",
borderColor: '#2FA4E7',
borderWidth: 2,
pointColor : "#2FA4E7",
pointBorderColor : "#2FA4E7",
pointHighlightFill: "#2FA4E7",
pointBackgroundColor: "#2FA4E7",
pointBorderWidth: 2,
pointRadius: 1,
pointHoverRadius: 3,
pointHitRadius: 20
},{
data: [].concat(Txses).reverse(),
yAxisID: "Transactions",
label: "Transactions",
backgroundColor: "rgba(255,242,0,0.1)",
borderColor: '#B5E61D',
borderWidth: 1,
pointColor : "#B5E61D",
pointBorderColor : "#B5E61D",
pointHighlightFill: "#B5E61D",
pointBackgroundColor: "#B5E61D",
pointBorderWidth: 1,
pointRadius: 1,
pointHoverRadius: 3,
pointHitRadius: 20
},{
data: [].concat(Sizes).reverse(),
yAxisID: "Sizes",
label: "Size",
backgroundColor: "rgba(65,172,0,0.1)",
borderColor: '#99D9EA',
borderWidth: 1,
pointColor : "#99D9EA",
pointBorderColor : "#99D9EA",
pointHighlightFill: "#99D9EA",
pointBackgroundColor: "#99D9EA",
pointBorderWidth: 1,
pointRadius: 1,
pointHoverRadius: 3,
pointHitRadius: 20
}
]
};
var options = {
responsive: true,
maintainAspectRatio: false,
elements: {
line: {
tension: 0
}
},
title: {
display: false
},
legend: {
display: false
},
scales: {
yAxes: [{
id: 'Height',
type: 'linear',
position: 'left',
scaleLabel: {
display: false,
labelString: 'Height'
},
gridLines: {
display:false
},
ticks: {
fontSize: 9,
display:false
},
display: false
},{
id: 'Difficulty',
type: 'linear',
position: 'left',
scaleLabel: {
display: false,
labelString: 'Difficulty'
},
gridLines: {
display:false
},
ticks: {
fontSize: 9,
display:false
},
display: false
},{
id: 'Transactions',
type: 'linear',
position: 'right',
scaleLabel: {
display: false,
labelString: 'Transactions'
},
gridLines: {
display:false
},
ticks: {
fontSize: 9,
display:false
},
display: false
},{
id: 'Sizes',
type: 'linear',
position: 'right',
scaleLabel: {
display: false,
labelString: 'Size'
},
gridLines: {
display:false
},
ticks: {
fontSize: 9,
display:false
},
display: false
}
],
xAxes: [{
type: "time",
time: {
parser: false,
unit: 'minute',
unitStepSize: 60,
round: 'second',
displayFormats: {
'millisecond': 'SSS [ms]',
'second': 'HH:mm:ss', // 11:20:01 AM
'minute': 'HH:mm', // 11:20:01 AM
'hour': 'HH:mm', // Sept 4, 5PM
'day': 'MMM Do', // Sep 4 2015
'week': 'll', // Week 46, or maybe "[W]WW - YYYY" ?
'month': 'MMM YYYY', // Sept 2015
'quarter': '[Q]Q - YYYY', // Q3
'year': 'YYYY', // 2017
},
},
gridLines: {
display:false
},
ticks: {
fontSize: 9,
fontColor: "#CCC",
autoSkip: true,
//maxRotation: 90,
//minRotation: 90
//display:false
}
//display: false
}]
},
tooltips: {
mode: 'index',
//displayColors: false,
callbacks: {
title: function(tooltipItem, data) {
var height = data.datasets[3].data[tooltipItem[0].index];
var time = new Date(data.labels[tooltipItem[0].index]).toLocaleString();
//return 'Блок №: ' + height + ' - ' + time + '';
return time + '';
},/*
label: function(tooltipItem, data) {
var diff = data.datasets[0].data[tooltipItem.index];
var txcount = data.datasets[1].data[tooltipItem.index];
var size = data.datasets[2].data[tooltipItem.index];
var diff_swatch_color = data.datasets[0].borderColor;
console.log(diff_swatch_color);
var diff_swatch = '<span style="color="'+ diff_swatch_color +'">•</span>';
var multistringText = [];
var str1 = diff_swatch + 'Складність: ' + diff + '';
var str2 = 'Розмір: ' + size + '';
var str3 = 'Транзакції: ' + txcount + '';
multistringText.push(str1);
multistringText.push(str2);
multistringText.push(str3);
return multistringText;
}*/
}
}
};
diffChart = new Chart(ctx,{
type: 'line',
data: chartData,
options: options
});
}
function refreshChart() {
var brows = $('#blocks_rows').children(),
labels = [],
diffs = [],
sizes = [],
times = [],
heights = [],
txsnr = [];
for (var i = 0; i < brows.length; i++) {
var row = $(brows[i]);
var label = parseInt(row.find('td:first').text());
var diff = parseInt(row.find('td.blk-diff').text());
var txses = parseInt(row.find('td:last').text());
var size = parseInt(row.find('td:nth-child(3)').text());
var time = row.attr('data-dt');
labels.push(label);
diffs.push(diff);
txsnr.push(txses);
sizes.push(size);
times.push(time);
}
//diffChart.data.labels = labels.reverse();
diffChart.data.labels = times.reverse();
diffChart.data.datasets[0].data = labels.reverse();
diffChart.data.datasets[1].data = diffs.reverse();
diffChart.data.datasets[2].data = txsnr.reverse();
diffChart.data.datasets[3].data = sizes.reverse();
diffChart.update();
}
function loadMoreChart() {
//diffChart.data.labels = [].concat(Blocks).reverse();
diffChart.data.labels = [].concat(Timestamps).reverse();
diffChart.data.datasets[0].data = [].concat(Blocks).reverse();
diffChart.data.datasets[1].data = [].concat(Difficulties).reverse();
diffChart.data.datasets[2].data = [].concat(Txses).reverse();
diffChart.data.datasets[3].data = [].concat(Sizes).reverse();
diffChart.update();
}
$(function() {
$('[data-toggle="tooltip"]').tooltip();
});
function getReadableTime(seconds){
var units = [ [60, 's.'], [60, 'min.'], [24, 'h.'],
[7, 'd.'], [4, 'w.'], [12, 'м.'], [1, 'y.'] ];
function formatAmounts(amount, unit){
var rounded = Math.round(amount);
return '' + rounded + ' ' + unit + (rounded > 1 ? '' : '');
}
var amount = seconds;
for (var i = 0; i < units.length; i++){
if (amount < units[i][0])
return formatAmounts(amount, units[i][1]);
amount = amount / units[i][0];
}
return formatAmounts(amount, units[units.length - 1][1]);
}
</script>
<script src="../js/Chart.bundle.min.js"></script>