Last active
December 24, 2018 08:00
-
-
Save ecwu/e451017418f249760114ea1556f48cad to your computer and use it in GitHub Desktop.
[Server status checker] #JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tableMaker(num,name,status,detail,domain,style){ | |
var table = "<td>" + num + "</td>" + "<td>" + name + "</td>" + "<td class='" + style + "'>" + status + "</td>" + "<td>" + detail + "</td>" + "<td>" + domain + "</td>"; | |
return table; | |
} | |
function inlineContentsGenerator(order,requestUrl,siteName,id){ | |
respondCode = get_status_code(requestUrl); | |
if (respondCode === "200"){ | |
var contents = tableMaker(order,siteName,"Service Online",parseInt(respondCode),requestUrl,"btn-success"); | |
}else{ | |
var contents = tableMaker(order,siteName,"Service Unavailable",parseInt(respondCode),requestUrl,"btn-danger"); | |
} | |
document.getElementById(id).innerHTML = contents; | |
} | |
/* | |
Respond Code Service Design by DRJ | |
*/ | |
function get_status_code(checkURL){ | |
var value = $.ajax( | |
{ | |
type: 'get', | |
async: false, | |
url: 'https://demonist.top/status.php', | |
data: { | |
url: checkURL | |
}, | |
dataType: 'jsonp', | |
jsonp: 'jsoncallback', | |
jsonpCallback:"success_jsonpCallback", | |
success: function (data) { | |
console.log(checkURL + ": " + data.status_code); | |
return data.status_code; | |
}, | |
error: function () { | |
} | |
}); | |
return parseInt(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment