-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrontend.js
105 lines (89 loc) · 2.75 KB
/
frontend.js
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
const {
shell
} = require('electron');
const remote = require('electron').remote,
electron = require('electron'),
save = require('save-file'),
app = remote.app;
var fs = require('fs'),
fullpath = app.getPath("appData");
/*
MAIN FRAME BUTTONS
*/
document.getElementsByClassName("minimize")[0].addEventListener("click", function(e) {
var window = remote.getCurrentWindow();
window.minimize();
});
document.getElementsByClassName("close")[0].addEventListener("click", function(e) {
var window = remote.getCurrentWindow();
window.close();
});
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('LOCATOR => No data')
return;
}
if(!filename) filename = 'locator_export.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
}
})(console)
$(function() {
var allFound = false;
$('#start').on('click', function() {
$('#step1').hide();
$('#step2').show();
$('#block8').val(IP_PART1);
$('#block16').val(IP_PART2);
$('#block24').val(IP_PART3);
});
$('#continue').on('click', function() {
$('#step2').hide();
$('#step3').show();
IP_PART1 = $('#block8').val();
IP_PART2 = $('#block16').val();
IP_PART3 = $('#block24').val();
// Find all device
if (IP_PART3.toString().includes("X")) {
// searching /17 with 32,766 ip address. (around 1-5 minute search time)
WAITING_LIST(IP_PART1 + "." + IP_PART2 + "." + IP_PART3 + ".X".replace(/X/gi, "0") + "/17");
} else {
// searching /24 as it is defined 254 ip. (really fast method)
WAITING_LIST(IP_PART1 + "." + IP_PART2 + "." + IP_PART3 + ".0" + "/24");
}
setTimeout(discovery, 1 * 1000);
});
$('#export').on('click', function() {
// Download JSON export
if (Export > 0) {
console.save(ExportArr);
} else {
Export = 0;
ipArr = [];
ExportArr = [];
$('#step1').hide();
$('#step3').hide();
$('#step4').hide();
$('#step2').show();
}
});
$('#scanAgain').on('click', function() {
Export = 0;
ipArr = [];
ExportArr = [];
$('#step1').hide();
$('#step3').hide();
$('#step4').hide();
$('#step2').show();
});
});