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
|
// Copyright (C) 2015 Remy van Elst
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
var request = createRequestObject();
var dataReturn='';
var ajaxTimeout='';
var enterChecker=false;
function createRequestObject()
{
var ro;
var browser = navigator.appName;
if(browser == 'Microsoft Internet Explorer')
{
ro = new ActiveXObject('Microsoft.XMLHTTP');
}
else{
ro = new XMLHttpRequest();
ro.setRequestHeader('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest');
}
return ro;
}
function makeRequest (url, fun)
{
enterChecker=false;
request.open('get', url);
request.onreadystatechange = function() { handleResponse(fun); }
try{
request.send(null);
window.history.pushState('wut', 'SSL Decoder for ' + document.getElementById('host').value, '/ssl/?port=' + document.getElementById('port').value + '&csr=' + document.getElementById('csr').value + '&s=&host=' + document.getElementById('host').value);
}
catch(err){
alert('Error occured: '+err);
showElementbyID(false, 'preloader');
showElementbyID(false, 'resultDiv');
showElementbyID(true, 'sslform');
}
}
function handleResponse(fun) {
if(request.readyState < 4)
{
ajaxTimeout=setTimeout('handleResponse(\''+fun+'\')',10);
}
else if(request.readyState == 4 && !enterChecker)
{
enterChecker=true;
var response = request.responseText;
dataReturn=response;
if(fun!='')
ajaxTimeout=setTimeout(fun+'()', 200);
}
}
function stopAjax()
{
clearTimeout('ajaxTimeout');
ajaxTimeout='';
}
function showContent(){
showElementbyID(false, 'preloader');
document.getElementById('resultDiv').innerHTML=dataReturn;
}
function showElementbyID(show, element){
if(show)
document.getElementById(element).style.display='block';
else
document.getElementById(element).style.display='none';
}
function strStartsWith(str, prefix) {
return str.indexOf(prefix) === 0;
}
|