1
|
|
|
var whois = require('../common/whoiswrapper.js'), |
2
|
|
|
parseRawData = require('../common/parse-raw-data.js'); |
3
|
|
|
|
4
|
|
|
var { getDate } = require('../common/conversions.js'); |
5
|
|
|
window.$ = window.jQuery = require('jquery'); |
6
|
|
|
|
7
|
|
|
const { |
8
|
|
|
ipcRenderer |
9
|
|
|
} = require('electron'); |
10
|
|
|
|
11
|
|
|
var singleWhois = { |
12
|
|
|
'input': { |
13
|
|
|
'domain': null |
14
|
|
|
}, |
15
|
|
|
'results': null |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
// Single Whois, whois reply processing |
19
|
|
|
ipcRenderer.on('sw:results', function(event, domainResults) { |
20
|
|
|
const { |
21
|
|
|
isDomainAvailable |
22
|
|
|
} = whois; |
23
|
|
|
var domainStatus, domainResultsJSON; |
24
|
|
|
//ipcRenderer.send('app:debug', "Whois domain reply:\n {0}".format(domainResults)); |
25
|
|
|
|
26
|
|
|
domainResultsJSON = (function() { |
27
|
|
|
var result; |
28
|
|
|
if (typeof domainResults === 'object') { |
29
|
|
|
JSON.stringify(domainResults, null, 2); |
30
|
|
|
result = domainResults.map(function(data) { |
31
|
|
|
data.data = parseRawData(data.data); |
32
|
|
|
return data; |
33
|
|
|
}); |
34
|
|
|
} else { |
35
|
|
|
result = parseRawData(domainResults); |
36
|
|
|
} |
37
|
|
|
return result; |
38
|
|
|
})(); |
39
|
|
|
|
40
|
|
|
// Check domain status |
41
|
|
|
domainStatus = isDomainAvailable(domainResults); |
42
|
|
|
|
43
|
|
|
switch (domainStatus) { |
44
|
|
|
case 'querylimituniregistry': |
45
|
|
|
case 'error': |
46
|
|
|
$('#swMessageWhoisResults').text("Whois error: {0}\n{1}".format(domainStatus, domainResults)); |
47
|
|
|
$('#swMessageError').removeClass('is-hidden'); |
48
|
|
|
break; |
49
|
|
|
case 'unavailable': |
50
|
|
|
console.log(domainResultsJSON); |
|
|
|
|
51
|
|
|
$('#swMessageUnavailable').removeClass('is-hidden'); |
52
|
|
|
$('#swMessageWhoisResults').text(domainResults); |
53
|
|
|
|
54
|
|
|
$('#swTdDomain').attr('url', "http://" + domainResultsJSON['domainName'] || domainResultsJSON['domain']); |
55
|
|
|
$('#swTdDomain').text(domainResultsJSON['domainName'] || domainResultsJSON['domain']); |
56
|
|
|
|
57
|
|
|
console.log(domainResultsJSON['registrarRegistrationExpirationDate'] || domainResultsJSON['expires'] || domainResultsJSON['registryExpiryDate']); |
58
|
|
|
$('#swTdUpdate').text(getDate(domainResultsJSON['updatedDate'] || domainResultsJSON['lastUpdated'])); |
59
|
|
|
$('#swTdRegistrar').text(domainResultsJSON['registrar']); |
60
|
|
|
$('#swTdCreation').text(getDate(domainResultsJSON['creationDate'] || domainResultsJSON['createdDate'] || domainResultsJSON['created'])); |
61
|
|
|
$('#swTdCompany').text(domainResultsJSON['registrantOrganization'] || domainResultsJSON['registrant']); |
62
|
|
|
$('#swTdExpiry').text(getDate(domainResultsJSON['expires'] || domainResultsJSON['registryExpiryDate'] || domainResultsJSON['expiryDate'] || domainResultsJSON['registrarRegistrationExpirationDate'])); |
63
|
|
|
$('#swTableWhoisinfo.is-hidden').removeClass('is-hidden'); |
64
|
|
|
break; |
65
|
|
|
case 'available': |
66
|
|
|
$('#swMessageWhoisResults').text(domainResults); |
67
|
|
|
$('#swMessageAvailable').removeClass('is-hidden'); |
68
|
|
|
break; |
69
|
|
|
default: |
70
|
|
|
$('#swMessageWhoisResults').text("Whois default error\n{0}".format(domainResults)); |
71
|
|
|
$('#swMessageError').removeClass('is-hidden'); |
72
|
|
|
break; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$('#swSearchButtonSearch').removeClass('is-loading'); |
76
|
|
|
$('#swSearchInputDomain').removeAttr('readonly'); |
77
|
|
|
|
78
|
|
|
}); |
79
|
|
|
|
80
|
|
|
// Simple Whois, trigger search by using [ENTER] key |
81
|
|
|
$('#swSearchInputDomain').keyup(function(event) { |
82
|
|
|
// Cancel the default action, if needed |
83
|
|
|
event.preventDefault(); |
84
|
|
|
// Number 13 is the "Enter" key on the keyboard |
85
|
|
|
if (event.keyCode === 13) { |
86
|
|
|
// Trigger the button element with a click |
87
|
|
|
$('#swSearchButtonSearch').click(); |
88
|
|
|
} |
89
|
|
|
}); |
90
|
|
|
|
91
|
|
|
// Open URL in new Window |
92
|
|
|
$('#swTdDomain').click(function() { |
93
|
|
|
var domain = $('#swTdDomain').attr('url'); |
94
|
|
|
ipcRenderer.send('sw:openlink', domain); |
95
|
|
|
}); |
96
|
|
|
|
97
|
|
|
// Trigger Whois lookup |
98
|
|
|
$('#swSearchButtonSearch').click(function() { |
99
|
|
|
if ($(this).hasClass('is-loading')) { |
100
|
|
|
return true; |
101
|
|
|
} |
102
|
|
|
ipcRenderer.send('app:debug', "#swSearchButtonSearch was clicked"); |
103
|
|
|
|
104
|
|
|
singleWhois.input.domain = $('#swSearchInputDomain').val(); |
105
|
|
|
|
106
|
|
|
ipcRenderer.send('app:debug', "Looking up for {0}".format(singleWhois.input.domain)); |
107
|
|
|
|
108
|
|
|
$('#swSearchButtonSearch').addClass('is-loading'); |
109
|
|
|
$('#swSearchInputDomain').attr('readonly', ''); |
110
|
|
|
$('.notification:not(.is-hidden)').addClass('is-hidden'); |
111
|
|
|
$('#swTableWhoisinfo:not(.is-hidden)').addClass('is-hidden'); |
112
|
|
|
tableReset(); |
113
|
|
|
ipcRenderer.send("sw:lookup", singleWhois.input.domain); |
114
|
|
|
return undefined; |
115
|
|
|
}); |
116
|
|
|
|
117
|
|
|
// Open simple whois model |
118
|
|
|
$('.swMessageWhoisOpen').click(function() { |
119
|
|
|
ipcRenderer.send('app:debug', "Opening whois reply"); |
120
|
|
|
$('#swMessageWhois').addClass('is-active'); |
121
|
|
|
}); |
122
|
|
|
|
123
|
|
|
// Close simple whois modal |
124
|
|
|
$('#swMessageWhoisClose').click(function() { |
125
|
|
|
ipcRenderer.send('app:debug', "Closing whois reply"); |
126
|
|
|
$('#swMessageWhois').removeClass('is-active'); |
127
|
|
|
}); |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
|
131
|
|
|
// Reset registry table contents |
132
|
|
|
function tableReset() { |
133
|
|
|
ipcRenderer.send('app:debug', "Resetting whois result table"); |
134
|
|
|
$('#swTdDomain').attr('href', "#"); |
135
|
|
|
$('#swTdDomain').text('n/a'); |
136
|
|
|
|
137
|
|
|
$('#swTdUpdate').text('n/a'); |
138
|
|
|
$('#swTdRegistrar').text('n/a'); |
139
|
|
|
$('#swTdCreation').text('n/a'); |
140
|
|
|
$('#swTdCompany').text('n/a'); |
141
|
|
|
$('#swTdExpiry').text('n/a'); |
142
|
|
|
} |
143
|
|
|
|