This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mntool.html
476 lines (423 loc) · 20.8 KB
/
mntool.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Noso Exporer MNtool</title>
<link rel="icon" type="image/x-icon" href="img/favicon.ico">
<script src="js/search.js"></script>
<!---chart-->
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Add custom CSS here -->
<link href="css/sb-admin.css" rel="stylesheet">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
<!-- Page Specific CSS -->
<style>
.save-button {
display: none;
margin-top: 0px;
}
.mntool-spinner {
border: 2px solid rgba(0, 0, 0, 0.1);
border-left-color: #3498db;
border-radius: 50%;
width: 8px;
height: 8px;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
<!--style-->
</head>
<body color="#222222">
<div id="wrapper">
<!-- Sidebar -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header"> <button type="button" class="navbar-toggle"
data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">Toggle
navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> </button><a class="navbar-brand" href="index.html"><img
src="img/logo_clearbg.png" alt="nosologo" title="nosologo" style="width: 20px; height: 20px;">
NOSO <span class="navbar-logo">Explorer</span> <font size="1px">Beta</font>
</a> </div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav side-nav">
<!-- <li><a href="index.html"><i class="fa fa-dashboard"></i>
NosoStats</a></li> -->
<li><a href="index.html"><i class="fa fa-tachometer"></i> Overview</a></li>
<li><a href="blocks.html"> <i class="fa fa-th-large"></i> Blocks</a></li>
<li><a href="movements.html"><i class="fa fa-exchange"></i> Coin
Movements</a></li>
<li><a href="topaddresses.html"><i class="fa fa-star"></i> Top
Addresses </a></li>
<li><a href="masternodes.html"><i class="fa fa-globe"></i>
Masternodes</a></li>
<!-- <li><a href="chainstats.html"><i class="fa fa-bar-chart"></i>
Chain Statistics </a></li> -->
<li><a href="gvt.html"><i class="fa fa-gavel"></i> Governance</a></li>
</ul>
<!-- /.navbar-top-right -->
<div class="toprow">
<ul class="nav navbar-nav navbar-right navbar-user">
<li><a href="qr.html"> <img src="img/qr.png" style="width: 17px; height: 16px;"
alt="QR Scanner"></a> </li>
<li><a href="https://twitter.com/NosoCoin" target="_blank"> <img
src="img/twitter_bird.png" style="width: 20px; height: 16px;"
alt="Noso on Twitter"></a> </li>
<li><a href="https://discord.gg/weed5ePmfY" target="_blank"> <img
src="img/discord.png" style="width: 24px; height: 22px;" alt="Noso on Discord"></a></li>
<li><a href="https://t.me/nosocoin" target="_blank"> <img src="img/telegram.png"
style="width: 24px; height: 23px;" alt="Noso on telegram"></a></li>
<li><a href="https://github.com/Noso-Project/" target="_blank"> <img
src="img/gh.png" style="width: 28px; height: 17px;" alt="Noso on Github"></a></li>
<li><a href="https://nosocoin.com/"> <img src="img/nosoN.png" style="width: 24px; height: 23px;"
alt="Noso Website"></a></li>
<li><a href="https://docs.nosocoin.com/noso-developers-portal/rpc-connection/running-a-noso-json-rpc-node-for-development-utilizing-nosos-rest-api"
target="_blank"> <img src="img/doc.png" style="width: 14px; height: 16px;"
alt="Noso Developers"></a></li>
<li><a href="https://api.nosocoin.com/" target="_blank"> <img src="img/api.png"
style="width: 28px; height: 24px;" alt="Noso API"></a></li>
</ul>
</div>
</div>
<!-- /.navbar-collapse --> </nav>
<br>
<div class="row2">
<h3>Noso Node Monitor (MNTool)</h3>
<br>
<form id="addressForm"><br>
<textarea id="addresses" name="addresses" placeholder=" Enter Your Noso Node addresses (comma-separated)"></textarea><br>
<button type="submit2"></button> </form>
<br>
<label for="csvFile" class="page-action-button" title="Import from CSV File | address1,description1,address2,description2">Import
CSV File</label><input id="csvFile" name="csvFile" type="file"> <strong><a
id="customUrlLink" class="bookmark-link page-action-button" title="1: Save your addresses and custom description to CSV using the save icon below.... 2: Import your custom CSV using the import from CSV File button.... 3: Click Bookmark This Page to refresh the address URL.... 4: Bookmark this page in your browser.. "
href="javascript:void(0)" onclick="bookmarkPage()">Bookmark Page</a></strong>
<button id="clearFormButton" type="button" class="page-action-button"><b>Reset
Form</b></button> <br>
<br>
<div id="statusTable" class="custom-table">
<div class="custom-row header">
<div class="custom-cell priority-1">Address</div>
<div class="custom-cell priority-6">Status</div>
<div class="custom-cell priority-1">Description <button id="saveButton"
class="save-button fa fa-save" alt="save-button" title="Save changes to CSV File">
</button></div>
<div class="custom-cell priority-6">Consecutive Payments</div>
<div class="custom-cell priority-5">Uptime</div>
<div class="custom-cell priority-6">Monthly NOSO</div>
<div class="custom-cell priority-6">Monthly USDT</div>
</div>
</div>
</div>
<a id="customUrlLink" class="bookmark-link" href="javascript:void(0)" onclick="bookmarkPage()">
<script>
function bookmarkPage() {
var pageTitle = document.title;
var pageURL = window.location.href;
if (window.sidebar && window.sidebar.addPanel) { // Firefox
window.sidebar.addPanel(pageTitle, pageURL, '');
} else if (window.external && ('AddFavorite' in window.external)) { // Internet Explorer
window.external.AddFavorite(pageURL, pageTitle);
} else if (window.opera && window.print) { // Opera
var elem = document.createElement('a');
elem.setAttribute('href', pageURL);
elem.setAttribute('title', pageTitle);
elem.setAttribute('rel', 'sidebar');
elem.click();
} else { // Other browsers
alert('Please use your browser\'s bookmark feature to bookmark this page.');
}
}
let changesMade = false; // Flag to track changes made to the table
// Function to copy custom URL
function copyCustomUrl() {
const customUrl = generateCustomUrl();
const input = document.createElement('input');
input.setAttribute('value', customUrl);
document.body.appendChild(input);
input.select();
document.execCommand('copy');
document.body.removeChild(input);
alert('Custom URL copied to clipboard!');
}
// Function to generate custom URL
function generateCustomUrl() {
const rows = document.querySelectorAll('.custom-row:not(.header)');
let customUrl = window.location.href.split('?')[0]; // Get the base URL without parameters
customUrl += '?mynodes=';
rows.forEach(row => {
const address = row.children[0].textContent.trim();
const description = row.querySelector('.description').value.trim();
customUrl += `${address}:${description},`;
});
// Remove trailing comma
customUrl = customUrl.slice(0, -1);
return customUrl;
}
document.getElementById('addressForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent form submission
const addressesInput = document.getElementById('addresses').value.trim();
const csvFile = document.getElementById('csvFile').files[0];
// Check if there are addresses or a CSV file
if (addressesInput || csvFile) {
if (csvFile) {
// Read the CSV file
const reader = new FileReader();
reader.onload = function(event) {
const csvData = event.target.result;
// Process CSV data
processCSV(csvData);
};
reader.readAsText(csvFile);
} else {
// Clear the table before adding new data
clearTable();
// Fetch data for each address from manual input
const addresses = addressesInput.split(',').map(address => address.trim());
addresses.forEach(address => {
fetchDataForAddress(address);
});
}
} else {
alert('Please enter at least one address or upload a CSV file.');
}
});
// Fetch data for addresses provided in the URL parameters
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('mynodes')) {
const nodeAddresses = urlParams.get('mynodes').split(',');
nodeAddresses.forEach(pair => {
const [address, description] = pair.split(':');
fetchDataForAddress(address.trim(), description ? description.trim() : '');
});
}
function clearTable() {
const statusTable = document.getElementById('statusTable');
// Keep the header row and remove other rows
const rows = document.querySelectorAll('.custom-row:not(.header)');
rows.forEach(row => {
statusTable.removeChild(row);
});
}
function appendDataToTable(data) {
const statusTable = document.getElementById('statusTable');
// Create data row
const row = document.createElement('div');
row.classList.add('custom-row');
row.innerHTML = `
<div class="custom-cell-address ${data.status === 'online' ? 'online-address' : 'offline-address'} priority-1"> ${data.address}</div>
<div class="custom-cell priority-6"> ${data.status}</div>
<div class="custom-cell priority-1">
<textarea class="description" contenteditable="true"> ${data.description}</textarea>
</div>
<div class="custom-cell priority-6"> ${data.consecutive_payments}</div>
<div class="custom-cell priority-5"> ${data.uptime_percent}%</div>
<div class="custom-cell priority-6"> ${data.monthly_earning}</div>
<div class="custom-cell priority-6"> $${data.monthly_earning_usdt}</div>
`;
// Get the uptime element
const uptimeElement = row.querySelector('.custom-cell.priority-5:nth-child(5)');
// Determine font color based on uptime percentage range
const uptimePercent = parseInt(data.uptime_percent);
if (!isNaN(uptimePercent)) { // Check if uptimePercent is a valid number
if (uptimePercent >= 90) {
// Green for 90% and above
uptimeElement.style.color = '#16B13D';
} else if (uptimePercent >= 80) {
// Light green for 80-89%
uptimeElement.style.color = '#7BB11B';
} else if (uptimePercent >= 70) {
// Yellow for 70-79%
uptimeElement.style.color = '#B19719';
} else if (uptimePercent >= 60) {
// Red for 60-69%
uptimeElement.style.color = '#B1671E';
} else {
// Dark red for below 60%
uptimeElement.style.color = 'darkred';
}
} else {
// Handle the case where uptime_percent is not a valid number
// You can set a default color or handle the error as needed
uptimeElement.style.color = 'black'; // Default color
}
// Insert offline rows under the header
if (data.status === 'offline') {
const headerRow = statusTable.querySelector('.header');
statusTable.insertBefore(row, headerRow.nextSibling);
} else {
// For online rows, find the insertion index based on consecutive payments
const rows = Array.from(document.querySelectorAll('.custom-row:not(.header)'));
let insertionIndex = rows.findIndex(existingRow => {
if (existingRow.classList.contains('offline-address')) return false; // Skip offline rows
const existingConsecutivePayments = parseInt(existingRow.children[3].textContent);
const newConsecutivePayments = parseInt(row.children[3].textContent);
return newConsecutivePayments < existingConsecutivePayments;
});
if (insertionIndex === -1) insertionIndex = rows.length; // Insert at the end if no smaller value found
statusTable.insertBefore(row, rows[insertionIndex]);
}
// Attach event listener to track changes in the description cell
const descriptionCell = row.querySelector('.description');
descriptionCell.addEventListener('input', function() {
changesMade = true;
document.getElementById('saveButton').style.display = 'inline';
});
}
function processCSV(csvData) {
// Parse CSV data
const lines = csvData.split('\n');
const addresses = [];
lines.forEach(line => {
const parts = line.split(',');
const address = parts[0].trim(); // Assuming address is the first column
const description = parts.length > 1 ? parts[1].trim() : ''; // Check if description exists
addresses.push({ address, description });
});
// Clear the table before adding new data
clearTable();
// Fetch data for each address
addresses.forEach(addressData => {
fetchDataForAddress(addressData.address, addressData.description);
});
}
function fetchDataForAddress(address, description = '') {
fetch(`https://api.nosocoin.com/nodes/status?address=${address}`)
.then(response => response.json())
.then(data => {
// Append data to the table
appendDataToTable({ ...data, description });
countOfflineStatus();
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
function countOfflineStatus() {
const offlineCount = document.querySelectorAll('.offline-address').length;
const totalCount = document.querySelectorAll('.custom-row:not(.header)').length;
const addressHeader = document.querySelector('.header .custom-cell:nth-child(1)');
addressHeader.textContent = `Address (${totalCount}) ${offlineCount} offline`;
// Update custom URL link when status changes
document.getElementById('customUrlLink').setAttribute('href', generateCustomUrl());
}
document.getElementById('saveButton').addEventListener('click', function() {
saveToCSV();
});
function saveToCSV() {
const rows = Array.from(document.querySelectorAll('.custom-row')).slice(1); // Exclude the header row
let csvContent = '';
rows.forEach(row => {
const address = row.children[0].textContent.trim();
const description = row.querySelector('.description').value.trim();
csvContent += `${address},${description},\n`;
});
// Create a blob with the CSV data
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a');
if (link.download !== undefined) {
// Create a link element, hide it, direct it towards the blob, and then 'click' it programmatically
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', 'nodes.csv');
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// Reset changes made flag
changesMade = false;
document.getElementById('saveButton').style.display = 'none'; // Hide the Save button
}
}
// Add an event listener to the file input element
document.getElementById('csvFile').addEventListener('change', function(event) {
const file = event.target.files[0]; // Get the selected file
const reader = new FileReader(); // Create a new FileReader object
reader.onload = function(event) {
const csvData = event.target.result; // Get the CSV data from the FileReader
processCSV(csvData); // Process the CSV data
};
reader.readAsText(file); // Read the selected file as text
});
// Add event listener for the clear form button
document.getElementById('clearFormButton').addEventListener('click', function() {
clearForm();
});
// Function to clear the form
function clearForm() {
// Reset the form elements to their initial state
document.getElementById('addressForm').reset();
// Redirect to the base URL without any query parameters
window.location.href = window.location.href.split('?')[0];
}
// Function to calculate time until the next 10-minute interval
function calculateRefreshTime() {
const now = new Date();
const minutes = now.getMinutes();
const seconds = now.getSeconds();
const remainingSeconds = (10 - (minutes % 10) - 1) * 30 + (60 - seconds) + 30;
return remainingSeconds * 1000; // Convert to milliseconds
}
// Function to refresh the data periodically
function refreshData() {
setInterval(function () {
// Clear the table before fetching new data
clearTable();
// Fetch data for addresses provided in the URL parameters
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('mynodes')) {
const nodeAddresses = urlParams.get('mynodes').split(',');
nodeAddresses.forEach(pair => {
const [address, description] = pair.split(':');
fetchDataForAddress(address.trim(), description ? description.trim() : '');
});
}
// Check if there is data from the CSV file
const csvFile = document.getElementById('csvFile').files[0];
if (csvFile) {
const reader = new FileReader();
reader.onload = function (event) {
const csvData = event.target.result;
processCSV(csvData); // Process the CSV data
};
reader.readAsText(csvFile);
}
// Check if there is data from the form entry
const addressesInput = document.getElementById('addresses').value.trim();
if (addressesInput) {
const addresses = addressesInput.split(',').map(address => address.trim());
addresses.forEach(address => {
fetchDataForAddress(address);
});
}
}, calculateRefreshTime());
}
// Call the function to refresh the data periodically
refreshData();
// Function to update the browser tab title with countdown time
function updateTitleWithCountdown() {
setInterval(function() {
const remainingTime = calculateRefreshTime();
const seconds = Math.floor(remainingTime / 1000); // Calculate remaining seconds
document.title = `MNtool Refresh (${seconds}s) `; // Update the browser tab title with seconds
}, 1000);
}
// Call the function to update the browser tab title with countdown time
updateTitleWithCountdown();
</script>
<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.js"></script> </a></div>
<a id="customUrlLink" class="bookmark-link" href="javascript:void(0)" onclick="bookmarkPage()">
</a>
</body>
</html>