| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- var bodyContentElementID = document.getElementById("body_cont");
- var loadingBarElementID = document.getElementById("loadingbar");
- function changeCurrentPage(fileName, extraid, a = -1)
- {
- event.preventDefault();
- window.stop();
-
- bodyContentElementID.innerHTML = "";
- const tempBodyElementID = $("#body_cont");
- tempBodyElementID.stop();
- console.log(a);
-
- if(a != -1)
- {
- const url = `/panel/${fileName}/${extraid}`;
-
- window.history.pushState(null, null, url);
-
- switch(a)
- {
- case 1:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/profile.php?test=" + extraid,
- callback: function()
- {
- console.log("newXHR readyState:"+newXHR.readyState)
- console.log("newXHR status"+newXHR.status)
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- bodyContentElementID.innerHTML = newXHR.response;
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 2:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/change_skin.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- tempBodyElementID.html(newXHR.response);
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 3:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/inbox.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- bodyContentElementID.innerHTML = newXHR.response;
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 4:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/applications.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- bodyContentElementID.innerHTML = newXHR.response;
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 5:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/application.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- bodyContentElementID.innerHTML = newXHR.response;
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 6:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/vehicle.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- bodyContentElementID.innerHTML = newXHR.response;
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 7:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/faction.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- bodyContentElementID.innerHTML = newXHR.response;
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 8:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/friends.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- tempBodyElementID.html(newXHR.response);
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 9:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/gov.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- tempBodyElementID.html(newXHR.response);
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 10:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/property.php?test=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- bodyContentElementID.innerHTML = newXHR.response;
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- }
- }
- else
- {
- const oldMenu = document.getElementsByClassName("selected");
-
- if(oldMenu.length > 0)
- {
- oldMenu[0].classList.remove("selected");
- }
-
- const newMenu = document.getElementById(fileName);
-
- if(newMenu)
- {
- newMenu.classList.add("selected");
- }
- window.history.pushState(null, null, extraid);
-
- loadingBarElementID.classList.add("active");
-
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/player/" + fileName + ".php",
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- tempBodyElementID.html(newXHR.response);
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- }
- }
- function sendXHR(options)
- {
- // (Modern browsers) OR (Internet Explorer 5 or 6).
- newXHR = new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP");
-
- if(options.sendJSON === true)
- {
- options.contentType = "application/json; charset=utf-8";
- options.data = JSON.stringify(options.data);
- }
- else
- {
- options.contentType = "application/x-www-form-urlencoded";
- }
-
- newXHR.open(options.type, options.url, options.async || true);
- newXHR.setRequestHeader("Content-Type", options.contentType);
- newXHR.send((options.type == "POST") ? options.data : null);
- newXHR.onreadystatechange = options.callback; // Will execute a function when the HTTP request state changes.
- return newXHR;
- }
- function changeCurrentPage_A(fileName, extraid, a = -1)
- {
- event.preventDefault();
- window.stop();
-
- bodyContentElementID.innerHTML = "";
- const tempBodyElementID = $("#body_cont");
- tempBodyElementID.stop();
-
- if(a != -1)
- {
- const url = `/admin/${fileName}/${extraid}`;
-
- window.history.pushState(null, null, url);
-
- switch(a)
- {
- case 1:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/admin/application.php?app_id=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- tempBodyElementID.html(newXHR.response);
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- case 2:
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/admin/players.php?app_id=" + extraid,
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- tempBodyElementID.html(newXHR.response);
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- break;
- }
- }
- else
- {
- const oldMenu = document.getElementsByClassName("selected");
-
- if(oldMenu.length > 0)
- {
- oldMenu[0].classList.remove("selected");
- }
-
- const newMenu = document.getElementById(fileName);
-
- if(newMenu)
- {
- newMenu.classList.add("selected");
- }
- window.history.pushState(null, null, extraid);
-
- loadingBarElementID.classList.add("active");
-
- sendXHR
- ({
- type: "GET",
- url: "./modules/template/admin/" + fileName + ".php",
- callback: function()
- {
- if(newXHR.readyState == 4 && newXHR.status == 200)
- {
- tempBodyElementID.html(newXHR.response);
- loadingBarElementID.classList.remove("active");
- }
- }
- });
- }
- }
- $(window).bind("popstate", function(e)
- {
- e = e.originalEvent.state;
- e ? alert(e.lasturl) : alert("Use the menu to navigate.")
- });
|