-
Notifications
You must be signed in to change notification settings - Fork 14
/
index1.html
2127 lines (1965 loc) · 89.8 KB
/
index1.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
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="assets/img/logo-fav.png">
<title>头号玩家——资本游戏</title>
<link rel="stylesheet" type="text/css" href="assets/lib/perfect-scrollbar/css/perfect-scrollbar.min.css"/>
<link rel="stylesheet" type="text/css" href="assets/lib/material-design-icons/css/material-design-iconic-font.min.css"/>
<link rel="stylesheet" type="text/css" href="assets/lib/jquery.vectormap/jquery-jvectormap-1.2.2.css"/>
<link rel="stylesheet" type="text/css" href="assets/lib/jqvmap/jqvmap.min.css"/>
<link rel="stylesheet" type="text/css" href="assets/lib/select2/css/select2.min.css">
<link rel="stylesheet" type="text/css" href="assets/lib/bootstrap-slider/css/bootstrap-slider.min.css">
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="assets/lib/datetimepicker/css/bootstrap-datetimepicker.min.css"/>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="assets/lib/jquery.gritter/css/jquery.gritter.css"/>
<link rel="stylesheet" href="assets/css/app.css" type="text/css"/>
<!-- <script src="assets/js/nebulas.js"></script> -->
<!-- <script src="assets/js/nebPay.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/nebulas.js"></script>
<script src="https://cdn.jsdelivr.net/gh/nebulasio/nebPay@60c65f8a7e26015bb31c56d56f3a638a33ea3c8e/dist/nebPay.min.js"></script>
<script src="assets/js/mustache.min.js"></script>
<script src="assets/js/bignumber.min.js"></script>
<script src="assets/js/config.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="assets/js/ga.js"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-119584347-3');
</script>
</head>
<body>
<div class="be-wrapper be-offcanvas-menu be-fixed-sidebar">
<nav class="navbar navbar-expand fixed-top be-top-header">
<div class="container-fluid">
<div class="be-navbar-header"><a href="#" class="nav-link be-toggle-left-sidebar"><span class="icon mdi mdi-menu"></span></a><a href="index.html" class="navbar-brand"></a>
</div>
<div class="be-right-navbar">
<ul class="nav navbar-nav float-right be-user-nav">
<li class="nav-item dropdown"><a href="#" data-toggle="dropdown" role="button" aria-expanded="false" class="nav-link dropdown-toggle"><img src="assets/img/avatar0.png" alt="Avatar" id="avatarImg"><span class="user-name">Player #</span></a>
<div role="menu" class="dropdown-menu">
<div class="user-info">
<div class="user-name"> Player #</div>
<div class="user-position offline" id="showWalletStatus">未检测到星云插件钱包</div>
</div>
<a class="dropdown-item"><span class="icon mdi mdi-money"></span> 账户NAS余额<b id="accountBalance"></b></a>
<a class="dropdown-item"><span class="icon mdi mdi-money"></span> 账户CGT余额<b id="accountTokenBalance"></b></a>
<a class="dropdown-item"><span class="icon mdi mdi-money-box"></span> 合约储备金<b id="contractBalance"></b></a>
<a class="dropdown-item"><span class="icon mdi mdi-money-box"></span> 合约保证金<b id="contractInsureBalance"></b></a>
<a class="dropdown-item"><span class="icon mdi mdi-money-box"></span> 合约CGT余额<b id="contractTokenBalance"></b></a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" id="playerData"><span class="icon mdi mdi-account"></span>账户游戏数据</a>
<a class="dropdown-item" onclick="login()" id="loginbtn"><span class="icon mdi mdi-key"></span> 登陆</a>
</div>
</li>
</ul>
<div class="page-title"><span>头号玩家——资本游戏</span></div>
<ul class="nav navbar-nav float-right be-icons-nav">
<li class="nav-item dropdown"><a href="en/index.html?lang=en" role="button" aria-expanded="false" class="nav-link be-toggle-right-sidebar">English</a></li>
</ul>
</div>
</div>
</nav>
<div class="be-left-sidebar">
<div class="left-sidebar-wrapper"><a href="#" class="left-sidebar-toggle">Menu</a>
<div class="left-sidebar-spacer">
<div class="left-sidebar-scroll">
<div class="left-sidebar-content">
<ul class="sidebar-elements">
<li class="divider">Menu</li>
<li><a href="index.html"><i class="icon mdi mdi-home"></i><span>Dashboard</span></a>
</li>
<li class="parent"><a><i class="icon mdi mdi-8tracks"></i><span>相关资源</span></a>
<ul class="sub-menu">
<li><a href="assets/file/一种基于分布式总账技术的去中心化自治银行构建方法.pdf" target="_blank">项目白皮书</a>
</li>
<li><a href="https://nebulas.io/" target="_blank">星云官方网站</a>
</li>
<li><a href="https://explorer.nebulas.io/#/" target="_blank">星云区块浏览器</a>
</li>
<li><a href="https://github.com/nebulasio/WebExtensionWallet" target="_blank">星云钱包插件</a>
</li>
<li><a href="https://nano.nebulas.io" target="_blank">NAS nano</a>
</li>
<li><a href="https://github.com/dabdevelop/capitalgame" target="_blank">项目GitHub源码</a>
</li>
<li><a href="#" target="_blank" id="contract">合约地址</a>
</li>
</ul>
</li>
<li class="parent"><a href="http://foxythemes.net/preview/products/beagle/charts.html"><i class="icon mdi mdi-email"></i><span>联系我们</span></a>
<ul class="sub-menu">
<li><a href="mailto:[email protected]">邮箱</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="progress-widget">
<div class="progress-data"><span class="progress-value">0%</span><span class="name">游戏进度</span></div>
<div class="progress mb-4">
<div role="progressbar" style="width: 0%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-primary progress-bar-striped progress-bar-animated" id="progressCirculation"></div>
<div role="progressbar" style="width: 0%" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-danger progress-bar-striped" id="progressTotalSupply"></div>
</div>
<!--<div class="progress">-->
<!--<div style="width: 0%;" class="progress-bar progress-bar-primary"></div>-->
<!--</div>-->
</div>
</div>
</div>
<div class="be-content">
<div class="main-content container-fluid">
<div class="row">
<div class="col-12 col-lg-6 col-xl-3">
<div class="widget widget-tile">
<div id="spark1" class="chart sparkline"><canvas width="85" height="35" style="display: inline-block; width: 85px; height: 35px; vertical-align: top;"></canvas></div>
<div class="data-info">
<div class="desc">玩家数量</div>
<div class="value"><span class="indicator indicator-positive mdi mdi-chevron-up"></span><span data-toggle="counter" data-start="0" data-end="0" class="number" id="playerNum">0</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 col-xl-3">
<div class="widget widget-tile">
<div id="spark2" class="chart sparkline"><canvas width="81" height="35" style="display: inline-block; width: 81px; height: 35px; vertical-align: top;"></canvas></div>
<div class="data-info">
<div class="desc">CGT流通量</div>
<div class="value"><span class="indicator indicator-positive mdi mdi-chevron-up"></span><span data-toggle="counter" data-start="0" data-end="0" class="number" id="circulation">0</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 col-xl-3">
<div class="widget widget-tile">
<div id="spark3" class="chart sparkline"><canvas width="85" height="35" style="display: inline-block; width: 85px; height: 35px; vertical-align: top;"></canvas></div>
<div class="data-info">
<div class="desc">CGT成交量</div>
<div class="value"><span class="indicator indicator-positive mdi mdi-chevron-up"></span><span data-toggle="counter" data-start="0" data-end="0" class="number" id="volume">0</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 col-xl-3">
<div class="widget widget-tile">
<div id="spark4" class="chart sparkline"><canvas width="85" height="35" style="display: inline-block; width: 85px; height: 35px; vertical-align: top;"></canvas></div>
<div class="data-info">
<div class="desc">CGT总市值(NAS)</div>
<div class="value"><span class="indicator indicator-positive mdi mdi-chevron-up"></span><span data-toggle="counter" data-start="0" data-end="0" class="number" id="marketCap">0</span>
</div>
</div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="col-md-12">
<div class="widget widget-fullwidth be-loading">
<div class="widget-head">
</div>
<div class="widget-chart-container">
<div class="widget-chart-info">
<ul class="chart-legend-horizontal">
<li><span data-color="main-chart-color1" style="background-color: rgb(66, 133, 244);"></span>买入价格(10 ^ -6 NAS)</li>
</ul>
</div>
<div id="main-chart" style="height: 260px; padding: 0px; position: relative;"><canvas class="flot-base" width="1904" height="520" style="direction: ltr; position: absolute; left: 0px; top: 0px; width: 952px; height: 260px;"></canvas><canvas class="flot-overlay" width="1904" height="520" style="direction: ltr; position: absolute; left: 0px; top: 0px; width: 952px; height: 260px;"></canvas></div>
</div>
<div class="be-spinner">
<svg width="40px" height="40px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle fill="none" stroke-width="4" stroke-linecap="round" cx="33" cy="33" r="30" class="circle"></circle>
</svg>
</div>
</div>
</div>
</div> -->
<div class="row">
<div class="col-12 col-lg-3">
<div class="card card-border-color card-border-color-infor">
<div class="widget be-loading">
<div class="widget-head">
<div class="title">合约金额构成</div>
</div>
<div class="widget-chart-container">
<div id="top-sales" style="height: 120px; padding: 0px; position: relative;"><canvas class="flot-base" width="514" height="356" style="direction: ltr; position: absolute; left: 0px; top: 0px; width: 257.328px; height: 178px;"></canvas><canvas class="flot-overlay" width="514" height="356" style="direction: ltr; position: absolute; left: 0px; top: 0px; width: 257.328px; height: 178px;"></canvas></div>
<div class="chart-pie-counter text-sm-center"></div>
</div>
<div class="chart-legend">
<table>
<tbody><tr>
<td class="chart-legend-color"><span data-color="top-sales-color1" style="background-color: rgb(52, 168, 83);"></span></td>
<td>合约储备金</td>
<td class="chart-legend-value" id="balance">0</td>
</tr>
<tr>
<td class="chart-legend-color"><span data-color="top-sales-color2" style="background-color: rgb(251, 188, 5);"></span></td>
<td>合约保证金</td>
<td class="chart-legend-value" id="insureBalance">0</td>
</tr>
</tbody></table>
</div>
<div class="be-spinner">
<svg width="40px" height="40px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle fill="none" stroke-width="4" stroke-linecap="round" cx="33" cy="33" r="30" class="circle"></circle>
</svg>
</div>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="card card-border-color card-border-color-danger">
<div class="card-header card-header-divider">销毁<span class="card-subtitle" id="burnPrice">销毁价格</span></div>
<div class="card-body">
<div class="form-group input-group-sm">
<label for="burnAmount" class="col-form-label text-right">销毁数量</label><br><br>
<input id="burnAmount" type="number" step="0.01" placeholder="数量" class="form-control">
</div>
<div class="row pt-3">
<button type="submit" onclick="getBurnOrder()" class="btn btn-rounded btn-block btn-danger md-trigger" style="float: right;" data-modal="form-burn">销毁</button>
</div>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="card card-border-color card-border-color-success">
<div class="card-header card-header-divider">买入<span class="card-subtitle" id="buyPrice">买入价格</span></div>
<div class="card-body">
<div class="form-group input-group-sm">
<label for="buyValue" class="col-form-label text-right">买入金额</label><br><br>
<input id="buyValue" type="number" step="0.001" placeholder="金额" class="form-control">
</div>
<div class="row pt-3">
<button type="submit" onclick="getBuyOrder()" class="btn btn-rounded btn-block btn-success md-trigger" data-modal="form-buy">买入</button>
</div>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="card card-border-color card-border-color-danger">
<div class="card-header card-header-divider">卖出<span class="card-subtitle" id="sellPrice">卖出价格</span></div>
<div class="card-body">
<div class="form-group input-group-sm">
<label for="sellAmount" class="col-form-label text-right">卖出数量</label><br><br>
<input id="sellAmount" type="number" step="0.01" placeholder="数量" class="form-control">
</div>
<div class="row pt-3">
<button type="submit" onclick="getSellOrder()" class="btn btn-rounded btn-block btn-danger md-trigger" data-modal="form-sell">卖出</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-6">
<div class="card card-table">
<div class="card-header">
<div class="title">买入</div>
</div>
<div class="card-body table-responsive">
<table class="table table-striped table-borderless">
<thead>
<tr>
<th style="width:30%;">玩家</th>
<th class="number">数量</th>
<th class="number">价格(NAS)</th>
<th style="width:30%;">时间</th>
<th style="width:5%;" class="actions"></th>
</tr>
</thead>
<tbody class="no-border-x" id="buyOrder">
</tbody>
</table>
</div>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="card card-table">
<div class="card-header">
<div class="title">卖出</div>
</div>
<div class="card-body table-responsive">
<table class="table table-striped table-borderless">
<thead>
<tr>
<th style="width:30%;">玩家</th>
<th class="number">数量</th>
<th class="number">价格(NAS)</th>
<th style="width:30%;">时间</th>
<th style="width:5%;" class="actions"></th>
</tr>
</thead>
<tbody class="no-border-x" id="sellOrder">
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Nifty Modal-->
<div id="form-burn" class="modal-container colored-header colored-header-danger custom-width modal-effect-9">
<div class="modal-content">
<div class="modal-header modal-header-colored">
<h3 class="modal-title">请确认订单</h3>
<button type="button" data-dismiss="modal" aria-hidden="true" class="close modal-close"><span class="mdi mdi-close"></span></button>
</div>
<div class="modal-body form">
<div class="form-group">
<label id="burnLabel">销毁CGT</label>
<input type="number" class="form-control" disabled="disabled" id="burnAmountConfirm">
</div>
<div class="form-group">
<label>获得NAS</label>
<input type="number" class="form-control" disabled="disabled" id="burnValueConfirm">
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-secondary modal-close" onclick="burnCancel()" id="burnBtnCancel">取消</button>
<button type="button" data-dismiss="modal" class="btn btn-success modal-close" disabled="disabled" onclick="burn()" id="burnBtnConfirm">确定</button>
</div>
</div>
</div>
<!-- Nifty Modal-->
<div id="form-sell" class="modal-container colored-header colored-header-danger custom-width modal-effect-9">
<div class="modal-content">
<div class="modal-header modal-header-colored">
<h3 class="modal-title">请确认订单</h3>
<button type="button" data-dismiss="modal" aria-hidden="true" class="close modal-close"><span class="mdi mdi-close"></span></button>
</div>
<div class="modal-body form">
<div class="form-group">
<label id="sellLabel">卖出CGT</label>
<input type="number" class="form-control" disabled="disabled" id="sellAmountConfirm">
</div>
<div class="form-group">
<label>获得NAS</label>
<input type="number" class="form-control" disabled="disabled" id="sellValueConfirm">
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-secondary modal-close" onclick="sellCancel()" id="sellBtnCancel">取消</button>
<button type="button" data-dismiss="modal" class="btn btn-success modal-close" disabled="disabled" onclick="sell()" id="sellBtnConfirm">确定</button>
</div>
</div>
</div>
<!-- Nifty Modal-->
<div id="form-buy" class="modal-container colored-header colored-header-success custom-width modal-effect-9">
<div class="modal-content">
<div class="modal-header modal-header-colored">
<h3 class="modal-title">请确认订单</h3>
<button type="button" data-dismiss="modal" aria-hidden="true" class="close modal-close"><span class="mdi mdi-close"></span></button>
</div>
<div class="modal-body form">
<div class="form-group">
<label id="buyLabel">买入CGT</label>
<input type="number" class="form-control" disabled="disabled" id="buyAmountConfirm">
</div>
<div class="form-group">
<label>花费NAS</label>
<input type="number" class="form-control" disabled="disabled" id="buyValueConfirm">
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-secondary modal-close" onclick="buyCancel()" id="buyBtnCancel">取消</button>
<button type="button" data-dismiss="modal" class="btn btn-success modal-close" disabled="disabled" onclick="buy()" id="buyBtnConfirm">确定</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="assets/lib/jquery/jquery.min.js" type="text/javascript"></script>
<script src="assets/lib/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js" type="text/javascript"></script>
<script src="assets/lib/bootstrap/dist/js/bootstrap.bundle.min.js" type="text/javascript"></script>
<script src="assets/lib/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="assets/lib/jquery.nestable/jquery.nestable.js" type="text/javascript"></script>
<script src="assets/lib/moment.js/min/moment.min.js" type="text/javascript"></script>
<script src="assets/lib/datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<script src="assets/lib/select2/js/select2.min.js" type="text/javascript"></script>
<script src="assets/lib/select2/js/select2.full.min.js" type="text/javascript"></script>
<script src="assets/lib/bootstrap-slider/bootstrap-slider.min.js" type="text/javascript"></script>
<script src="assets/js/app.js" type="text/javascript"></script>
<script src="assets/lib/jquery-flot/jquery.flot.js" type="text/javascript"></script>
<script src="assets/lib/jquery-flot/jquery.flot.pie.js" type="text/javascript"></script>
<script src="assets/lib/jquery-flot/jquery.flot.time.js" type="text/javascript"></script>
<script src="assets/lib/jquery-flot/jquery.flot.resize.js" type="text/javascript"></script>
<script src="assets/lib/jquery-flot/plugins/jquery.flot.orderBars.js" type="text/javascript"></script>
<script src="assets/lib/jquery-flot/plugins/curvedLines.js" type="text/javascript"></script>
<script src="assets/lib/jquery-flot/plugins/jquery.flot.tooltip.js" type="text/javascript"></script>
<script src="assets/lib/jquery.sparkline/jquery.sparkline.min.js" type="text/javascript"></script>
<script src="assets/lib/countup/countUp.min.js" type="text/javascript"></script>
<script src="assets/lib/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="assets/lib/jqvmap/jquery.vmap.min.js" type="text/javascript"></script>
<script src="assets/lib/jqvmap/maps/jquery.vmap.world.js" type="text/javascript"></script>
<script src="assets/lib/prettify/prettify.js" type="text/javascript"></script>
<script src="assets/lib/jquery.gritter/js/jquery.gritter.js" type="text/javascript"></script>
<script src="assets/lib/jquery.niftymodals/dist/jquery.niftymodals.js" type="text/javascript"></script>
<script type="text/javascript">
'use strict';
var Nebulas = require("nebulas");
var Account = Nebulas.Account;
var Transaction = Nebulas.Transaction;
var Utils = Nebulas.Utils;
var Unit = Nebulas.Unit;
// var rpcURL = "https://testnet.nebulas.io";
// var dappAddress = 'n235Bs9WMYYQAuo7w3F8XrhX5DCtWbSQ6cY';
// var chainId = 1001;
// var rpcURL = "http://localhost:8685";
var rpcURL = "https://mainnet.nebulas.io";
var chainId = 1;
var dappAddress = 'n1sr4JA4e9QPB4opLk2Kjmp8NkP6GGoAmnt';
if(chainId == 1){
$("#contract").prop('href','https://explorer.nebulas.io/#/address/'+ dappAddress +'#/').prop('target', '_blank_');
} else {
$("#contract").prop('href','https://explorer.nebulas.io/#/testnet/address/'+ dappAddress +'#/').prop('target', '_blank_');
}
var neb = new Nebulas.Neb();
neb.setRequest(new Nebulas.HttpRequest(rpcURL));
var needCheckNASWallet = localStorage.getItem('needCheckNASWallet') || '1';
needCheckNASWallet = parseInt(needCheckNASWallet);
var invoker = null;
function checkNASWallet(_invoker) {
invoker = _invoker;
//to check if the extension is installed
//if the extension is installed, var "webExtensionWallet" will be injected in to web page
if (needCheckNASWallet && (typeof (webExtensionWallet) === "undefined")) {
$(document).ready(function () {
if(window.mobileAndTabletcheck()){
$.gritter.add({
title: "新消息",
text: "在移动端请安装使用NAS nano!",
time: "",
class_name: "warning clean"
});
disableCheckNASWallet();
return true;
} else{
$.gritter.add({
title: "新消息",
text: "未检测到星云钱包插件, 请安装星云钱包插件!",
time: "",
class_name: "warning clean"
});
}
return false;
});
}
return true;
}
function disableCheckNASWallet() {
needCheckNASWallet = false;
localStorage.setItem('needCheckNASWallet', 0);
if(invoker != null){
invoker.click();
}
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var receiptGot = [];
function getTransactionReceipt(hash, callback){
$.post(rpcURL + '/v1/user/getTransactionReceipt', JSON.stringify({
"hash": hash
}), function (resp) {
callback && callback(resp)
})
}
function recheckTransactionReceipt(hash, callback) {
var retry = 8;
var retry2 = 32;
var task = setInterval(function () {
getTransactionReceipt(hash, function (resp) {
retry --;
if(retry < 0){
try{
neb.api.getTransactionReceipt({hash: hash}).then(function(receipt){
if (receipt.status == 0) //not in pending
{
console.log(receipt);
clearInterval(task);
$.gritter.add({
title: "新消息",
text: "交易失败, 请将GasLimit手动设置为2M wei 或者进行小额度的买卖, 错误提示: " + receipt.execute_error,
time: "",
class_name: "danger clean"
});
} else if (receipt.status == 2) {
retry2 --;
if(retry2 < 0){
clearInterval(task);
$.gritter.add({
title: "新消息",
text: "查询交易状态超时, 请您手动查询交易!",
time: "",
class_name: "warning clean"
});
}
} else {
clearInterval(task);
callback && callback(resp.result);
}
});
} catch(err){
console.log(err);
}
}
var status = resp.result.status;
if(status == 1){
clearInterval(task);
if(!receiptGot.includes(resp.result.hash)){
receiptGot.push(resp.result.hash);
callback && callback(resp.result);
}
}
})
}, 5000);
}
function innerCall(fun, args, value, callback) {
let params = {};
var account = Account.NewAccount();
account.setPrivateKey(faucets[getRandomInt(0, 100)]);
params.from = account;
params.to = dappAddress;
params.gasPrice = Utils.toBigNumber(1000000);
params.gasLimit = Utils.toBigNumber(20000000);
params.value = value;
// prepare contract
params.contract = {
"function": fun,
"args": JSON.stringify(args)
};
// console.log(params.from.getAddressString() + ' call ' + params.to + ' @ ' + fun + ": " + JSON.stringify(args) + ' with value: ' + value);
callback(params);
}
window.mobileAndTabletcheck = function() {
var check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
return check;
};
function refresh(){
$.gritter.add({
title: "新消息",
text: "交易数据将在几秒内自动更新",
time: "",
class_name: "primary clean"
});
address = localStorage.getItem('address') || '';
checkWallet();
getPrice();
loadPlayerAccount();
getContractTokenBalance();
}
function getMobileTransactionReceipt(serialNumber, callback){
$.get("https://pay.nebulas.io/api/mainnet/pay/query?payId=" + serialNumber, function (resp) {
callback && callback(resp)
})
}
var retryQueryTime = 10;
function recheckMobileTransactionReceipt(serialNumber, callback) {
retryQueryTime --;
getMobileTransactionReceipt(serialNumber, function (resp) {
if(resp instanceof Object){
if(retryQueryTime <= 0){
clearInterval(intervalQuery);
if(resp.code == 1){
clearInterval(intervalQuery);
$.gritter.add({
title: "新消息",
text: "查询交易状态超时, 请您手动查询交易!",
time: "",
class_name: "warning clean"
});
return;
}
}
if (resp.code == 0 && (resp.data.status == 1 || resp.data.status == 0)) {
clearInterval(intervalQuery);
if(!receiptGot.includes(resp.data.hash)){
receiptGot.push(resp.data.hash);
callback && callback(resp.data);
}
}
}
})
}
var NebPay = require("nebpay"); //https://github.com/nebulasio/nebPay
var nebPay = new NebPay();
var intervalQuery;
function callNebPay(fun, args, value, callback) {
if(isWx){
$.gritter.add({
title: "新消息",
text: "微信浏览器可能不支持NAS nano调用, 请点击右上方的三个小点, 并选择用浏览器打开!",
time: "",
class_name: "warning clean"
});
}
var wait;
function clearWait() {
clearInterval(wait);
refresh();
}
var inQuery = false;
$.gritter.add({
title: "新消息",
text: "正在调用钱包, 请将GasLimit手动设置为2M wei 或者进行小额度的买卖并确认操作!",
time: "",
class_name: "primary clean"
});
var serialNumber;
innerCall(fun, args, value, function (params) {
serialNumber = nebPay.call(params.to, params.value, params.contract.function, params.contract.args, {
qrcode: {
showQRCode: false
},
callback:"https://pay.nebulas.io/api/mainnet/pay",
listener: function (resp) {
if(window.mobileAndTabletcheck()){
if(!inQuery){
inQuery = true;
retryQueryTime = 10;
$.gritter.add({
title: "新消息",
text: "正在查询交易状态!",
time: "",
class_name: "primary clean"
});
intervalQuery = setInterval(function () {
recheckMobileTransactionReceipt(serialNumber, function(resp){
if(resp.status == 1){
$.gritter.add({
title: "新消息",
text: "交易成功!",
time: "",
class_name: "success clean"
});
callback && callback(resp);
} else if(resp.status == 0){
$.gritter.add({
title: "新消息",
text: "交易失败, 请将GasLimit手动设置为2M wei 或者进行小额度的买卖, 错误提示: " + resp.execute_error,
time: "",
class_name: "danger clean"
});
wait = setInterval(clearWait, 2000);
}
});
}, 5000);
}
return;
}
if (resp !== 'Error: Transaction rejected by user') {
$.gritter.add({
title: "新消息",
text: "交易已提交, 正在为您查询交易状态, 请等待约15秒钟!",
time: "",
class_name: "primary clean"
});
var hash = resp.txhash;
recheckTransactionReceipt(hash, function (resp) {
$.gritter.add({
title: "新消息",
text: "交易成功!",
time: "",
class_name: "success clean"
});
callback && callback(resp);
})
} else {
$.gritter.add({
title: "新消息",
text: "您已取消!",
time: "",
class_name: "warning clean"
});
}
}
});
var wait2;
function clearWait2() {
clearInterval(wait2);
if(window.mobileAndTabletcheck() && !inQuery){
inQuery = true;
retryQueryTime = 15;
$.gritter.add({
title: "新消息",
text: "正在查询交易状态!",
time: "",
class_name: "primary clean"
});
intervalQuery = setInterval(function () {
recheckMobileTransactionReceipt(serialNumber, function(resp){
if(resp.status == 1){
$.gritter.add({
title: "新消息",
text: "交易成功!",
time: "",
class_name: "success clean"
});
callback && callback(resp);
} else if(resp.status == 0){
$.gritter.add({
title: "新消息",
text: "交易失败, 请将GasLimit手动设置为2M wei 或者进行小额度的买卖, 错误提示: " + resp.execute_error,
time: "",
class_name: "danger clean"
});
wait = setInterval(clearWait, 2000);
}
});
}, 5000);
}
}
wait2 = setInterval(clearWait2, 10000);
var wait3;
function clearWait3() {
clearInterval(wait3);
if (window.mobileAndTabletcheck() && inQuery) {
$.gritter.add({
title: "新消息",
text: "正在查询交易状态!",
time: "",
class_name: "primary clean"
});
}
}
wait3 = setInterval(clearWait3, 18000);
});
}
function getPlayerNum(callback){
var fun = 'playerNum';
var args = [];
innerCall(fun, args, 0, function(params){
neb.api.call(params.from.getAddressString(), params.to, params.value, 0, params.gasPrice, params.gasLimit, params.contract).then(function (resp) {
var result = resp.result;
if(result === 'null' || result === '""'){
return;
}
try{
result = JSON.parse(result);
callback(result);
}catch (err){
//result is the error message
console.log("error:" + err.message)
}
}).catch(function (err) {
console.log("error:" + err.message)
});
});
}
function getCirculation(callback){
var fun = 'circulation';
var args = [];
innerCall(fun, args, 0, function(params){
neb.api.call(params.from.getAddressString(), params.to, params.value, 0, params.gasPrice, params.gasLimit, params.contract).then(function (resp) {
var result = resp.result;
if(result === 'null' || result === '""'){
return;
}
try{
result = JSON.parse(result);
callback(result);
}catch (err){
//result is the error message
console.log("error:" + err.message)
}
}).catch(function (err) {
console.log("error:" + err.message)
});
});
}
function getBuyVolumeByIndex(index, callback){
var fun = 'getBuyOrder';
var args = [];
args.push(index);
innerCall(fun, args, 0, function(params){
neb.api.call(params.from.getAddressString(), params.to, params.value, 0, params.gasPrice, params.gasLimit, params.contract).then(function (resp) {
var result = resp.result;
if(result === 'null' || result === '""'){
return;
}
try{
result = JSON.parse(result);
buyOrder = buyOrder.concat(result);
for(var r in result){
volume += result[r].amount;
buyPriceTrend.push([result[r].orderId, parseInt(result[r].price.toFixed(8) * 1000000)]);
}
callback();
}catch (err){
//result is the error message
console.log("error:" + err.message)
}
}).catch(function (err) {
console.log("error:" + err.message)
});
});
}
function getBuyVolume(callback){
var fun = 'buyOrderIndex';
var args = [];
innerCall(fun, args, 0, function(params){
neb.api.call(params.from.getAddressString(), params.to, params.value, 0, params.gasPrice, params.gasLimit, params.contract).then(function (resp) {
var result = resp.result;
if(result === 'null' || result === '""'){
return;
}
try{
var index = JSON.parse(result);
var i = index;
// var f = function(){
// i ++;
// if(i < index){
// getBuyVolumeByIndex(i, f);
// } else {
// callback()
// }
// };
getBuyVolumeByIndex(i, callback);
}catch (err){
//result is the error message
console.log("error:" + err.message)
}
}).catch(function (err) {
console.log("error:" + err.message)
});
});
}
function getSellVolumeByIndex(index, callback){
var fun = 'getSellOrder';
var args = [];
args.push(index);
innerCall(fun, args, 0, function(params){
neb.api.call(params.from.getAddressString(), params.to, params.value, 0, params.gasPrice, params.gasLimit, params.contract).then(function (resp) {
var result = resp.result;
if(result === 'null' || result === '""'){
return;
}
try{
result = JSON.parse(result);
for(var r in result){
volume += result[r].amount;
}
sellOrder = sellOrder.concat(result);
callback();
}catch (err){
//result is the error message
console.log("error:" + err.message)
}
}).catch(function (err) {
console.log("error:" + err.message)
});
});
}
function getSellVolume(callback){
var fun = 'sellOrderIndex';
var args = [];
innerCall(fun, args, 0, function(params){
neb.api.call(params.from.getAddressString(), params.to, params.value, 0, params.gasPrice, params.gasLimit, params.contract).then(function (resp) {
var result = resp.result;
if(result === 'null' || result === '""'){
return;
}
try{
var index = JSON.parse(result);
var i = index;
// var f = function(){
// i ++;
// if(i <= index){
// getSellVolumeByIndex(i, f);
// } else {
// callback();
// }
// };
getSellVolumeByIndex(i, callback);
}catch (err){
//result is the error message
console.log("error:" + err.message)
}
}).catch(function (err) {
console.log("error:" + err.message)
});
});
}
function getBurnVolumeByIndex(index, callback){
var fun = 'getBurnOrder';
var args = [];
args.push(index);
innerCall(fun, args, 0, function(params){
neb.api.call(params.from.getAddressString(), params.to, params.value, 0, params.gasPrice, params.gasLimit, params.contract).then(function (resp) {
var result = resp.result;
if(result === 'null' || result === '""'){
return;
}
try{
result = JSON.parse(result);
for(var r in result){
volume += result[r].amount;
buyPriceTrend.push([result[r].orderId, parseInt(result[r].price.toFixed(8) * 1000000)]);
}
burnOrder = burnOrder.concat(result);
callback();
}catch (err){
//result is the error message
console.log("error:" + err.message)
}
}).catch(function (err) {
console.log("error:" + err.message)
});
});
}