forked from conradoqg/naivecoin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
748 lines (678 loc) · 27.4 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
<!--
WARNING - WARNING - WARNING
This file is very disorganized and has mixed-styling
as this project was started prior to me learning
styleguides, eventually this will be entire styled
under the Standard JS Styleguide and is automatically
linted per-commit or push.
This project was mostly programmed by JSKitty, Creator
and Lead Developer of Concord (Doesn't mean this is perfect
by any means!) and is based on Naivecoin/Naivechain, by two
amazing open-source GitHub developers.
Contributions done by FabiClawZ (Fabian Felix Selbach) have
kept the project alive and functional in it's most important
algorithms.
THANK YOU!~ <3
-->
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
<title>Concord Core</title>
<link rel="stylesheet" href="styles.css">
</head>
<div class="topnav" id="menu" style="display:none">
<a draggable="false" type="button" onclick="loadCore();">Core</a>
<a draggable="false" type="button" onclick="loadSend();">Send</a>
<a draggable="false" type="button" onclick="loadRecieve();">Receive</a>
<a draggable="false" type="button" onclick="loadMessage();">Message</a>
</div>
<img class="coreImg" id="titleImg" src="img/concordCore.gif" alt="Concord" draggable="false" style="display:none">
<ul id="upgradeGrid" class="ch-grid" style="display:none">
<li>
<div class="ch-item ch-img-1">
<div class="ch-info">
<p><a id="upgradeButton" onclick="upgradeToMasternode();">Upgrade to Masternode</a></p>
</div>
</div>
</li>
</ul>
<body class="mainBody" oncontextmenu="return false">
<img class="exit" oncontextmenu="return false" id="exit" onclick="exitCore();" class="exit" src="img/x.png" alt="x" draggable="false">
<img class="settings" oncontextmenu="return false" id="settings" style="display:none" onclick="loadSettings();" class="settings" src="img/settingsCog.png" alt="Settings" draggable="false">
<div id="recieveMenu" style="display:none" class="centerText">
<h3 readonly="" id="ID" class="ID">Unknown</h3><button class="copyID" style="vertical-align:top;">Copy Identity</button>
<script>
document.getElementById("upgradeGrid").style.display = "none";
var address
var walletID
var imageLocation = 'img/'
var balanceDecimals = 6
var lastBlockHashes = 0
var hashrate = 0
var connResponded = 0
const clipboardy = require('clipboardy')
const req = require('requestify')
const fs = require('fs')
var x11 = require('x11-hash-js')
const genRString = require('crypto-random-string');
var coreImgOffline = imageLocation+"concordLogoOffline.png"
var coreImgOnline = imageLocation+"concordLogo.png"
var coreImgConnecting = imageLocation+"concordLogoConnecting.png"
var coreImgSpin = imageLocation+"concordCore.gif"
var copyTextareaBtn = document.querySelector('.copyID')
var stopStatus = 0
copyTextareaBtn.addEventListener('click', function(event) {
if(document.getElementById("ID").innerHTML != 'Identity Copied!'){
try {
clipboardy.writeSync(address);
document.getElementById("ID").innerHTML = 'Identity Copied!';
setTimeout(function(){document.getElementById("ID").innerHTML = address},2500)
} catch (err) {
console.log('Error, Couldn\'t copy Identity');
document.getElementById("ID").innerHTML = 'Identity couldn\'t copy';
setTimeout(function(){document.getElementById("ID").innerHTML = address},2500)
}
}
});
document.getElementById("recieveMenu").style.visibility = 'hidden'
document.getElementById("recieveMenu").style.display = "none"
</script>
</div>
<div id="messageMenu" style="display:none">
<h3 id="msgInfo" class="centerText">Broadcast an ID-Message</h3>
<h3 class="centerText">Chat History:</h3>
<div id="lastMessages"></div>
<div class="chatBoxInput">
<input oncontextmenu="return false" id="ipBox" name="msgBox" type="msgBox" class="ipBox" placeholder="ID" color="#4CAF50" autofocus="autofocus"><input oncontextmenu="return false" id="msgBox" name="msgBox" type="msgBox" class="msgBox" placeholder="Message" color="#4CAF50" autofocus="autofocus"><button class="sendMsg" style="vertical-align:bottom;" onclick="broadcastMsg();">Broadcast</button>
</div>
<script>
const Discord = require('discord.js')
var bot = new Discord.Client()
</script>
</div>
<div id="optionsMenu" style="display:none" class="centerText">
<h3 id="optionInfo">Options and Preferences</h3>
<h5>Seconds between mining sessions</h5>
<input id="miningBreakInput" type="text" value="0" placeholder="Time in Seconds" class="miningBreakInput">
<br>
<br>
<br>
<h6 id="changelogButton" class="changelogButton" onclick="openChangelog()">Changelog</h6>
<script>
fs.readFile("pref3.pref", 'utf8', function(err, contents) {
if(!err){
console.log('Masternode Enabled');
document.getElementById("upgradeButton").innerHTML = 'Downgrade to Lightnode'
nodeType = 1;
setTimeout(function(){stopStatus = 0;},2500)
}else{
console.log('Lightnode Enabled')
nodeType = 0
}
})
document.getElementById("optionsMenu").style.display = "none"
</script>
</div>
<div id="sendMenu" style="display:none" class="centerText">
<h3 id="sendInfo">Send Concord to an Identity (ID)</h3>
<input oncontextmenu="return false" id="sendBox" name="amountBox" type="amountBox" class="sendBox" placeholder="ID" color="#4CAF50" autofocus="autofocus"><input oncontextmenu="return false" id="amountBox" name="amountBox" type="amountBox" class="amountBox" placeholder="0" color="#4CAF50" autofocus="autofocus"><button class="sendMsg" style="vertical-align:bottom;" onclick="sendTransaction();" href="#">Send</button>
<br>
<!--<input oncontextmenu="return false" id="sendPassword" name="sendPassword" type="sendPassword" class="sendBox" placeholder="Wallet Password" color="#4CAF50" autofocus="autofocus"> -->
<script>
document.getElementById("sendMenu").style.display = "none";
const amtEnter = document.getElementsByClassName("amountBox")[0];
amtEnter.addEventListener("keydown", function(event) {
if (event.key === "Enter"){
sendTransaction()
}
});
function sendTransaction () {
var amount = Number(Number(document.getElementById('amountBox').value).toFixed(8))
var to = document.getElementById('sendBox').value
var password = '' //document.getElementById('sendPassword').value // NOTE: Will be enabled once password-based transactions are finished, for now, local and automatic authentication
if (password === '') {
fs.readFile(appdataPath + "1/key.priv", 'utf8', function(err, contents) {
if (err) {
walletNotify('Private Key Error', 'Your private key couldn\'t be found locally. Please double-check your files!', coreImgOffline)
return
} else {
password = contents
if (password === '') {
walletNotify('Private Key Error', 'Your private key couldn\'t be found locally. Please double-check your files!', coreImgOffline)
return
}
}
})
}
setTimeout(function(){
if (password.length > 0) {
console.log("Transaction authentication\nHeader: '"+password)
req.request(hostUrl+'operator/wallets/'+walletID+'/transactions', {
method: 'POST',
headers: {
"password": password
},
body: {
"fromAddress": address,
"toAddress": to,
"amount": amount,
"changeAddress": address
},
dataType: 'json'
}).then(function(response) {
console.log("Blockchain: "+response.body)
connResponded++
if (JSON.stringify(response.body).includes("transaction")) {
let receiver = to
if (receiver === address) {
receiver = "yourself"
} else {
receiver = 'an outside Identity'
}
walletNotify('Transaction Sent', amount+' CXD was sent to '+receiver, coreImgOnline)
}
getBalance()
}).fail(function(response) {
console.log("Error "+response.getCode()+" on POST "+hostUrl+'operator/wallets/'+to+'/transactions\n'+response.body)
if (response.body.includes("Invalid password")) {
walletNotify('Authentication Error', 'Your transaction failed due to an incorrect private key', coreImgOffline)
return
}
if (response.body.includes("The sender does not have enough to pay")) {
walletNotify('Not Enough Funds', 'You don\'t have enough funds to fulfill your transaction', coreImgOffline)
return
}
})
}
},250)
}
</script>
</div>
</body>
<body oncontextmenu="return false" style="-webkit-app-region: drag">
<div id="changelogModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<span class="closeChangelog">×</span>
<h2 id="changelogVer">Changelog for Version </h2>
</div>
<div class="modal-body">
<h4 id="changelogContent">Update stuff</h4>
</div>
</div>
</div>
<div oncontextmenu="return false" id="coreMenu" class="centerText">
<script>
var modal = document.getElementById('changelogModal')
var span = document.getElementsByClassName("closeChangelog")[0]
span.onclick = function() {
modal.style.display = "none"
}
function openChangelog(){
modal.style.display = "block"
document.getElementById("changelogContent").innerHTML = currentChangelog
document.getElementById("changelogVer").innerHTML = "Changelog for "+nodeVer
}
document.getElementById("settings").style.display = "none";
document.getElementById("messageMenu").style.display = "none";
var xShutdown = 0;
window.onbeforeunload = (e) => {
if(xShutdown == 0){
e.returnValue = false;
}
}
var msgList = [];
setInterval(function(){xShutdown = 0; document.getElementById("lastMessages").innerHTML = msgList.join("<br>") + '<br><br><br><br><br>';},750);
// CONCORD NODE STARTUP DATA
const ipc = require('electron').ipcRenderer;
const windowsToaster = require('node-notifier').WindowsToaster
var notifier = new windowsToaster({
withFallback: false,
customPath: void 0
})
var exitButton = document.getElementById('exit');
exitButton.addEventListener('click', function(){
ipc.once('actionReply', function(event, response){
exitCore();
})
ipc.send('invokeAction', 'exit');
});
var notification;
var path = require('path');
var desktopPath = require('path').join(require('os').homedir(), 'Desktop');
desktopPath = desktopPath.replace(/\\/g,'/')
console.log(desktopPath);
const { DownloaderHelper } = require('node-downloader-helper');
var userName = process.env['USERPROFILE'].split(path.sep)[2];
var loginId = path.join("domainName",userName);
var appdata = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + 'Library/Preferences' : '/var/local');
var appdataPath = appdata.replace(/\\/g,'/') + '/Concord Core/';
var host = 'localhost'
var port = '3001'
var hostUrl
function connectToBackend () {
hostUrl = 'http://' + host + ':' + port + "/"
console.log("Connecting to " + hostUrl + " for REST Wallet GUI Control")
testBackendConnection()
if (connResponded > 0) {
checkWallet()
} else {
console.log("Failed to connect, retrying in 1 second")
setTimeout(connectToBackend, 1000)
}
}
// Start initial connection attempt
connectToBackend()
console.log(appdataPath);
if (fs.existsSync(appdataPath)) {
console.log(appdataPath+' has already been created');
} else {
try{
fs.mkdirSync(appdataPath);
console.log('Created AppData directory');
} catch(err) {
console.log('Couldn\'t create AppData directory');
}
}
document.getElementById("menu").style.visibility = 'hidden';
var lastMsg;
const swal = require('sweetalert');
const DiscordRPC = require('discord-rpc');
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();
var nodeList = [];
var nodeVer = 'Concord Core 0.2';
var nodeVerNum = '20';
var currentChangelog = 'WILL BE UPDATED SOON!'
var myLastMsg;
var d;
var term = 0;
var updateNeeded = 0;
var titleImgSrc = document.getElementById('titleImg')
if(titleImgSrc && titleImgSrc.style) {
titleImgSrc.style.height = '250px';
titleImgSrc.style.width = '250px';
}
async function setActivity() {
var networkType = 'Core Chain'
var nodeName = ''
if (nodeType === 0) {
nodeName = 'Lightnode'
} else if (nodeType === 2) {
nodeName = 'Miner'
}
rpc.setActivity({
details: nodeName,
state: 'Network: ' + networkType,
startTimestamp,
largeImageKey: 'concordcore',
largeImageText: 'Concord Core',
smallImageKey: 'concordcore',
smallImageText: nodeName,
instance: false,
})
}
rpc.login({clientId: '581806156977274908'}).catch(console.error)
rpc.on('ready', () => {
setActivity()
rpcLogged = 1
// activity can only be set every 15 seconds
setInterval(() => {
setActivity()
}, 16)
})
//CORE CONNECTIVITY CHECK
function testBackendConnection () {
try {
req.get(hostUrl + 'ping').then(res => {
console.log(JSON.stringify(res))
if (res.body === "pong") {
connResponded++
return true
} else return false
})
} catch (err) {
return false
}
}
setInterval
//CORE TERMINATION
function terminate(){
setTimeout(function(){
document.getElementById("titleImg").src=coreImgOffline;
document.getElementById("nodeStatus").innerHTML = 'Node Terminated';
document.getElementById("menu").style.visibility = 'hidden';
document.getElementById("peersBox").style.visibility = 'hidden';
setInterval(function(){
terminate();
},500);
term = 1;
},500);
}
function exitCore(){
console.log('Shutting down Core Safely')
req.request(hostUrl + 'stop', {method: 'POST'}).then(function(response) {
console.log(response)
xShutdown = 1
app.quit()
process.exit()
}).fail(function(response) {
console.log("Error " + response.getCode() + " on POST " + hostUrl + 'stop\n\nDetails: ' + response.body)
xShutdown = 1
app.quit()
process.exit()
})
setTimeout(function(){
// Just incase the backend doesn't respond, we'll suicide
xShutdown = 1
app.quit()
process.exit()
}, 1000)
}
//CONCORD NODE API --> GUI FUNCTIONS
function checkWallet () {
fs.exists(appdataPath + '1/wallet.json', (exists) => {
if (exists) {
console.log("Wallet.json found, reading and importing")
fs.readFile(appdataPath + "1/wallet.json", 'utf8', function(err, contents) {
if (err) {
console.log("ERROR reading wallet.json")
return
} else {
contents = JSON.parse(contents)
walletID = contents.id
console.log("Wallet '"+walletID+"' loaded, searching for addresses")
fs.readFile(appdataPath + "1/addresses.json", 'utf8', function(err, contents) {
if (err) {
console.log("ERROR reading addresses.json")
return
} else {
contents = JSON.parse(contents)
address = contents.address
console.log("Address '"+address+"' loaded as default address")
getBalance()
}
})
}
})
} else {
console.log('No wallet found, generating new one')
var key = genRString(64)
console.log('Key: ' + key)
req.post(hostUrl+'operator/wallets', {password: key}).then(function(response) {
console.log("Blockchain: "+response.body)
connResponded++
fs.writeFile(appdataPath + '1/wallet.json', response.body, function(err) {
if (err) {
console.log("ERROR saving WalletID: "+err)
return
} else {
response.body = JSON.parse(response.body)
if (response.body.id && response.body.id.length === 64) {
if (response.body.addresses && response.body.addresses.length === 0) {
var newWalletID = response.body.id
walletID = newWalletID
console.log("Generating new wallet address")
req.request(hostUrl+'operator/wallets/'+newWalletID+'/addresses', {
method: 'POST',
headers: {
'password': key
},
dataType: 'json'
}).then(function(response) {
console.log("Blockchain: "+response.body)
connResponded++
fs.writeFile(appdataPath + '1/addresses.json', response.body, function(err) {
if (err) {
console.log("ERROR saving Address: "+err)
return
} else {
response.body = JSON.parse(response.body)
address = response.body.address
fs.writeFile(appdataPath + '1/key.priv', key, function(err) {
if (err) {
walletNotify('Private Key Error', 'Your newly generated Private Key had a saving issue. This means authenticating transactions will fail, please delete your local wallet files and restart', coreImgOffline, 'wait')
} else {
walletNotify('First Address Generated', 'Congrats, Welcome to Concord Core!', coreImgSpin)
}
})
}
})
}).fail(function(response) {
console.log("Error "+response.getCode()+" on POST "+hostUrl+'operator/wallets/'+newWalletID+'/addresses')
})
} else {
console.log("Wallet address already exists")
}
} else {
console.log("WalletID not 64 characters long, invalid.")
}
}
})
}).fail(function(response) {
console.log("Error "+response.getCode()+" on POST "+hostUrl+'operator/wallets')
})
}
})
}
function getBalance () {
req.get(hostUrl+'operator/'+address+'/balance').then(function(response) {
console.log("Blockchain Balance: "+response.body)
connResponded++
response = JSON.parse(response.body)
if(response.balance){
document.getElementById("nodeStatus").innerHTML = Number(parseFloat(response.balance).toFixed(balanceDecimals)).toPrecision()+' CXD';
}
}).fail(function(response) {
console.log("Error "+response.getCode()+" on GET "+hostUrl+'operator/'+address+'/balance')
})
}
var miningBreakTime = Number(document.getElementById("miningBreakInput").value) * 1000
function toggleMining () {
req.request(hostUrl + 'miner/toggle', {method: 'POST', body: {rewardAddress: address, feeAddress: address}, dataType: 'json'}).then(function(response) {
console.log(response)
}).fail(function(response) {
console.log("Error " + response.getCode() + " on POST " + hostUrl + 'miner/toggle\n\nDetails: ' + response.body)
getBalance()
})
}
//CONCORD NODE GUI UPDATING
function checkNodeStatus(){
if(updateNeeded == 0){
if(stopStatus == 0){
if(term == 0){
document.getElementById("titleImg").src=coreImgOnline;
document.getElementById("settings").style.display = "block";
getBalance()
req.get(hostUrl+'node/peers').then(function(response) {
connResponded++
response = JSON.parse(response.body)
document.getElementById("peersAmount").innerHTML = '<small><img class="peersImage" src="img/concordNodes.png"></img>' + response.length + '</small>';
}).fail(function(response) {
console.log("Error "+response.getCode()+" on GET "+hostUrl+'node/peers')
})
//if(updateNeeded == 0){
document.getElementById("peersBox").style.visibility = 'visible';
//} else {
// document.getElementById("peersBox").style.visibility = 'hidden';
//}
}else if(term == 1){
terminate();
}
}
}
}
function walletNotify (title, message, icon, shouldWait) {
if (shouldWait && shouldWait === 'wait') {
notifier.notify({
title: title,
message: message,
sound: true,
icon: icon,
wait: true
},
function(error, response) {
console.log(response)
})
} else {
notifier.notify({
title: title,
message: message,
sound: true,
icon: icon,
wait: false
},
function(error, response) {
console.log(response)
})
}
}
function loadCore(){
document.getElementById("coreMenu").style.display = "block";
document.getElementById("recieveMenu").style.display = "none";
document.getElementById("messageMenu").style.display = "none";
document.getElementById("sendMenu").style.display = "none";
document.getElementById("optionsMenu").style.display = "none";
document.getElementById("menu").style.display = "block";
document.getElementById("menu").style.visibility = "visible";
document.getElementById("peersBox").style.display = "block";
miningBreakTime = Number(document.getElementById("miningBreakInput").value) * 1000
stopStatus = 0;
}
function loadSend(){
if(updateNeeded == 0){
document.getElementById("coreMenu").style.display = "none";
document.getElementById("recieveMenu").style.display = "none";
document.getElementById("messageMenu").style.display = "none";
document.getElementById("optionsMenu").style.display = "none";
document.getElementById("sendMenu").style.display = "block";
document.getElementById("sendInfo").innerHTML = 'Send Concord to an Identity (ID)';
}
}
function loadRecieve(){
if(updateNeeded == 0){
document.getElementById("coreMenu").style.display = "none";
document.getElementById("messageMenu").style.display = "none";
document.getElementById("sendMenu").style.display = "none";
document.getElementById("optionsMenu").style.display = "none";
document.getElementById("recieveMenu").style.display = "block";
document.getElementById("recieveMenu").style.visibility = "visible";
document.getElementById("ID").innerHTML = address;
}
}
function loadMessage(){
if(updateNeeded == 0){
document.getElementById("coreMenu").style.display = "none";
document.getElementById("recieveMenu").style.display = "none";
document.getElementById("sendMenu").style.display = "none";
document.getElementById("optionsMenu").style.display = "none";
document.getElementById("messageMenu").style.display = "block";
document.getElementById("messageMenu").style.visibility = "visible";
document.getElementById("msgInfo").innerHTML = 'Broadcast an ID-Message';
}
}
function loadSettings(){
if(updateNeeded == 0){
document.getElementById("coreMenu").style.display = "none";
document.getElementById("recieveMenu").style.display = "none";
document.getElementById("sendMenu").style.display = "none";
document.getElementById("messageMenu").style.display = "none";
document.getElementById("optionsMenu").style.display = "block";
document.getElementById("optionsMenu").style.visibility = "visible";
document.getElementById("optionInfo").innerHTML = 'Options and Preferences';
}
}
function updateCore(){
document.getElementById("coreMenu").style.display = "block";
document.getElementById("recieveMenu").style.display = "none";
document.getElementById("peersBox").style.display = "none";
document.getElementById("menu").style.display = "none";
document.getElementById("messageMenu").style.display = "none";
document.getElementById("messageMenu").style.visibility = "hidden";
document.getElementById("coreMenu").style.visibility = "visible";
document.getElementById("titleImg").src=coreImgSpin;
console.log('Updating Concord Core');
const dl = new DownloaderHelper('https://www.euphmail.com/downloads/Concord%20Core%20Installer.exe', require('path').join(require('os').homedir(), 'Desktop'));
dl.on('end', () => completedUpdate())
dl.on('progress', (stats) => document.getElementById("nodeStatus").innerHTML = 'Update Progress: '+(Number(stats.progress)).toFixed(0)+'%')
dl.on('start', () => document.getElementById("nodeStatus").innerHTML = 'Download Started')
dl.on('error', () => retryUpdate())
dl.start();
document.getElementById("update").style.display = "none";
document.getElementById("nodeStatus").innerHTML = 'Starting Download';
}
function retryUpdate(){
document.getElementById("nodeStatus").innerHTML = 'Download Failed, retrying';
document.getElementById("titleImg").src=coreImgOffline;
setTimeout(function(){
updateCore();
},2500);
}
function completedUpdate(){
document.getElementById("nodeStatus").innerHTML = 'Download Completed<br>Core will shutdown in 10 seconds<br><small>The updated installer was downloaded to your Desktop*</small>';
document.getElementById("titleImg").src=coreImgOnline;
fs.renameSync(desktopPath+'/Concord%20Core%20Installer.exe',desktopPath+'/Concord Core Installer.exe');
setTimeout(function(){
//var exec = require('child_process').execFile;
//var fun = function(){
// console.log("Unloading "+nodeVer);
// exec(desktopPath+'/Concord Core Installer.exe', function(err, data) {
// console.log(err)
// console.log(data.toString());
// setTimeout(function(){exitCore();},1000);
// });
//}
//fun();
exitCore();
},10000);
}
function systemMessage(sysMsg){
var sysMsgProcessed = 'System: '+sysMsg;
msgList.push(sysMsgProcessed);
}
</script>
<div class="updateCenter">
<button id="update" class="update" onclick="updateCore();">Update</button>
</div>
<div class="introMaster" id="introMaster">
<div id="introText" class="introText"><p oncontextmenu="return false" id="introTextText"></p></div>
<div oncontextmenu="return false" id="introBg" class="bgImg"></div>
</div>
<p oncontextmenu="return false" id="nodeStatus"></p>
<br>
<h5 id="miningStatus">Mining<br></h5>
<label class="switch">
<input id="miningSwitch" onclick="toggleMining()" type="checkbox" title="Toggle Automining">
<span class="slider round"></span>
</label>
<script>
var introText = document.getElementById("introTextText");
setTimeout(function(){introText.innerHTML += 'W';},2700);
setTimeout(function(){introText.innerHTML += 'e';},2750);
setTimeout(function(){introText.innerHTML += 'l';},2800);
setTimeout(function(){introText.innerHTML += 'c';},2850);
setTimeout(function(){introText.innerHTML += 'o';},2900);
setTimeout(function(){introText.innerHTML += 'm';},2950);
setTimeout(function(){introText.innerHTML += 'e';},3000);
setTimeout(function(){
document.getElementById("introText").style.display = "none";
document.getElementById("titleImg").style.display = "block";
}, 11950);
setTimeout(function(){
document.getElementById("introMaster").style.display = "none";
document.getElementById("nodeStatus").style.display = "block";
document.getElementById("menu").style.display = "block";
loadCore();
setInterval(checkNodeStatus, 1000)
}, 15250);
document.getElementById("update").style.display = "none";
</script>
</div>
<div class="footer">
<div id="peersBox" class="peersBox">
<p id="peersAmount" class="peersAmount"> <small><img class="peersImage" src="img/concordNodes.png"></img>0</small></p>
</div>
<script>document.getElementById("peersBox").style.visibility = 'hidden';</script>
</div>
</body>
</html>