function getPage() { var hash = window.location.hash; hash = hash.split('#/')[1]; if (hash) { var Title = formatTitle(hash); load_page('#/' + hash, Title); } else { load_page('#/home', 'Simple yet intricate, small yet strong, security through insecurity. We are Cyber-Sec.Org'); } } function formatTitle(string) { var String1 = string.charAt(0).toUpperCase() + string.slice(1); return String1.replace("_", " "); } function new_xhr(){ var xhr_object = null; if(window.XMLHttpRequest) // FF & others xhr_object = new XMLHttpRequest(); else if(window.ActiveXObject){ // IE try { xhr_object = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); } } else { alert("Your browser doesn't support XMLHTTPRequest objects..."); xhr_object = false; } return xhr_object; } function load_page(select, title) { var xhr2 = new_xhr(); anchor = select.split('#/')[1]; xhr2.onreadystatechange = function(){ if ( xhr2.readyState == 4 ){ if(xhr2.status != 200){ // document.getElementById("Content").innerHTML ="Error code " + xhr2.status; load_page('./#/404', '404'); return false; } else { document.getElementById("Content").innerHTML = xhr2.responseText; if (window.location.href.match(new RegExp('#/.*$'))){window.location = window.location.href.replace(new RegExp('#/.*$'),'#/' + anchor);} else window.location = window.location.href + "#/" + anchor; } } else { document.getElementById("Content").innerHTML = "





\"\"






"; } } location.hash = "#/" + anchor; if (title) { document.title = ('Cyber-Sec.Org - ' + title); } else { PageTitle = formatTitle(anchor); document.title = ('Cyber-Sec.Org - ' + PageTitle); } xhr2.open("GET", select.split('#/')[1]+".php5", true); xhr2.send(null); } function pageload(hash) { if(hash) { if($.browser.msie) { hash = encodeURIComponent(hash); } $("#Content").load(hash + ".php5"); } else { $("#Content").empty(); } } $(document).ready(function(){ $.historyInit(pageload, "jquery_history.html"); $("a[rel='history']").click(function(){ var hash = this.href; hash = hash.replace(/^.*#/, ''); $.historyLoad(hash); return false; }); }); function PlainAjax() { this.timeout = 300000; this.requests = new Array(); this.reqnextid = 0; this.request = function(paramstring, resultfunc) { this.cleanUpRequests(); if (this.conftext == null || confirm(this.conftext)) { var request = new this.PlainAjaxRequest(this.reqnextid, paramstring, resultfunc); this.requests.push(request); if (request.autoresend != undefined && request.autoresend != null) { request.prepareAutoRequest(); request.doRequest(); setInterval(request.autoRequest, request.autoresend); } else { request.doRequest(); } ++this.reqnextid; } } this.cleanUpRequests = function() { for ( var i = 0; i < this.requests.length; ++i) { current = new Date().getTime(); if (current - this.requests[i].timestamp > this.timeout) this.requests.splice(i, 1); } } this.getRequest = function(id) { return this.requests[this.getPos(id)]; } this.delRequest = function(id) { this.requests.splice(this.getPos(id), 1); } this.getPos = function(id) { for ( var i = 0; i < this.requests.length; ++i) if (this.requests[i].id == id) return i; throw "Request not found"; } this.PlainAjaxRequest = function(id, paramString, resultfunc) { this.id = id; this.resultfunc = resultfunc; this.timestamp = new Date().getTime(); this.xmlhttp; this.respurl; this.resultloc; this.paramloc; this.autoresend; this.conftext; this.loadmsg; this.loadmsgloc; this.trimText = function(text) { while (text.substring(0, 1) == ' ') text = text.substring(1, text.length); while (text.substring(text.length - 1, text.length) == ' ') text = text.substring(0, text.length - 1); return text; } this.processParamString = function(paramString) { var pars = paramString.split(';'); for ( var pari = 0; pari < pars.length; ++pari) { var parStr = pars[pari]; var par = parStr.split(':'); if (par.length == 2) { var name = this.trimText(par[0]); var value = this.trimText(par[1]); switch (name) { case "respurl": this.respurl = value; break; case "resultloc": this.resultloc = value; break; case "paramloc": this.paramloc = value; break; case "autoresend": this.autoresend = value; break; case "conftext": this.conftext = value; break; case "loadmsg": this.loadmsg = value; break; } } } } this.processParamString(paramString); this.performAction; this.prepareAction = function() { var reqId = this.id; this.performAction = function() { var request = window.plainajax.getRequest(reqId); if (request.xmlhttp.readyState == 4 && request.xmlhttp.status == 200) { var resp = request.xmlhttp.responseText; if (request.resultloc) { var htmlElement = document .getElementById(request.resultloc); if (htmlElement.tagName == 'TEXTAREA') { htmlElement.value = resp; } else { htmlElement.innerHTML = resp; } } if (request.resultfunc != undefined && request.resultfunc != null) { request.resultfunc(resp); } if (request.autoresend == undefined && request.autoresend != null) { window.plainajax.delRequest(reqId); } } } } this.autoRequest; this.prepareAutoRequest = function() { var reqId = this.id; this.autoRequest = function() { var request = window.plainajax.getRequest(reqId); request.doRequest(); } } this.doRequest = function() { this.prepareAction(); this.initXmlHttp(); if (this.loadmsg != null) { var target = this.loadmsgloc == null ? this.resultloc : this.loadmsgloc; var targetElement = document.getElementById(target); if (targetElement == null) alert('Warning: target HTML element not found: ' + target); if (targetElement.tagName == 'TEXTAREA') targetElement.value = this.loadmsg; else targetElement.innerHTML = this.loadmsg; } this.timestamp = new Date().getTime(); this.xmlhttp.send(querystring); } this.createUrl = function() { var connectchar = this.respurl.indexOf('?') != -1 ? '&' : '?'; var url = this.respurl + connectchar + "timeStamp=" + this.timestamp; return url; } this.getFields = function() { var pdiv = document.getElementById(this.paramloc); var fieldtypes = new Array("input", "textarea", "select"); fields = new Array(); for (typei = 0; typei < fieldtypes.length; ++typei) { var fieldtype = fieldtypes[typei]; var nodes = pdiv.getElementsByTagName(fieldtype); for (nodeid = 0; nodeid < nodes.length; ++nodeid) { var node = nodes[nodeid]; if ((fieldtype != "input" || (fieldtype == "input" && node.type != "button" && node.type != "file") && ((node.type != "checkbox" && node.type != "radio") || (node.checked))) && ((fieldtype == "input" || fieldtype == "textarea" || fieldtype == "select") && !node.disabled)) fields.push(node); } } return fields; } this.createQueryString = function() { querystring = ''; if (this.paramloc != null) { var fields = this.getFields(); for (i = 0; i < fields.length; ++i) { var node = fields[i]; if (node.name != "" && node.type != "file") querystring += '&' + node.name + '=' + escape(node.value); } } return querystring; } this.initXmlHttp = function() { var querystring = this.createQueryString(); this.xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0"); var method = (this.paramloc == null) ? "GET" : "POST"; this.xmlhttp.open(method, this.createUrl(), true); this.xmlhttp.onreadystatechange = this.performAction; this.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); this.xmlhttp.setRequestHeader("Connection", "close"); this.xmlhttp.setRequestHeader("Content-length", querystring.length); } } } var plainajax = new PlainAjax(); window.plainajax = plainajax;