diff --git a/index.html b/index.html index 36fa556..47ac65c 100644 --- a/index.html +++ b/index.html @@ -208,8 +208,8 @@ transition: background-image 1s;" id="main_container">
- -

Чтоб увидить цены, сначала введи профиль (>ТЫК<)

+
+

Чтоб увидить цены, сначала авторизируйся через стим

@@ -251,8 +251,9 @@ transition: background-image 1s;" id="main_container">
-

Проверь свой профиль на фактах!

-
На этой странице после ввода твоего профиля, появится вся твоя статистика на фактах, наличие банов и их история, а так-же возможность купить випку!
+

Проверь профиль на фактах!

+
На этой странице после ввода профиля, появится вся статистика на фактах, наличие банов и их история.
+
Если авторизоваться, то сразу будет твой профиль
@@ -501,8 +502,8 @@ transition: background-image 1s;" id="main_container"> - - + + diff --git a/site_content/js/API.js b/site_content/js/API.js index 058067b..38f44ee 100644 --- a/site_content/js/API.js +++ b/site_content/js/API.js @@ -19,11 +19,12 @@
*/ +const Keys = { Enter: 13 }; $(async function() { $(document).on("keypress", "input", function (e) { var code = e.keyCode || e.which; - if (code == 13) { + if (code === Keys.Enter) { e.preventDefault(); return false; } @@ -35,6 +36,7 @@ $(async function() { await RequestAPI(); if(window.location.href.endsWith("#RulesSection")){ + // trigger event click document.getElementById('Rules_Button').click(); } @@ -76,7 +78,7 @@ let invalid_captcha = `

ДЯДЯ ТЫ ДУРАЧЕК, КАПЧА НЕПРАВИЛЬНАЯ, ЖМИ СНОВА НА КНОПКУ

` - +// use templates function generate_server_card_div(data){ return `
@@ -116,6 +118,7 @@ async function RequestAPI() { .then(res => res.json()) .then(res => { FillServices(res); + // $('#current_players').text(res.servers.statistic.player_now) document.getElementById("current_players").innerHTML = res.servers.statistic.player_now; document.getElementById("max_per_day").innerHTML = res.servers.statistic.player_max; document.getElementById("servers_works").innerHTML = res.servers.statistic.working_servers + '/' + res.servers.statistic.total_servers; diff --git a/site_content/js/Player_API.js b/site_content/js/Player_API.js index 287f2b1..d8f8ab5 100644 --- a/site_content/js/Player_API.js +++ b/site_content/js/Player_API.js @@ -1,34 +1,36 @@ -$(async function() { +$(async function () { await CheckCurrentUser(); }) -async function CheckCurrentUser(){ - if(!check_cookie_name("steam64")){return;} - await fetch("https://tf2.pblr-nyk.pro/player_api/v1/current_user", {credentials:"same-origin", headers: {'Cache-Control':'no-cache'}}) - .then(response => response.json()) - .then(response => { - if("error" in response) { - console.log(response.error); - } else { - var current_user = document.getElementById("Header_CurrentUser"); - var current_ban = document.getElementById("Header_CurrentBan"); - var logout = document.getElementById("Header_Logout"); - current_user.href = "#"; - if (response.ban) { - current_user.innerHTML = `Привет ${response.steam_data.nickname}! У меня хорошие новости!` - current_ban.innerHTML = "У тебя БАН! (нажми чтоб посмотреть его)"; +async function CheckCurrentUser() { + if (!check_cookie_name("steam64")) { return; } + await fetch("https://tf2.pblr-nyk.pro/player_api/v1/current_user", { credentials: "same-origin", headers: { 'Cache-Control': 'no-cache' } }) + .then(response => response.json()) + .then(response => { + if ("error" in response) { + console.log(response.error); } else { - current_user.innerHTML = `Привет ${response.steam_data.nickname}!` + var current_user = document.getElementById("Header_CurrentUser"); + var current_ban = document.getElementById("Header_CurrentBan"); + var logout = document.getElementById("Header_Logout"); + current_user.href = "#"; + if (response.ban) { + current_user.innerHTML = `Привет ${response.steam_data.nickname}! У меня хорошие новости!`; + current_ban.innerHTML = "У тебя БАН! (нажми чтоб посмотреть его)"; + } else { + current_user.innerHTML = `Привет ${response.steam_data.nickname}!`; + } + logout.innerHTML = ` (нажми чтоб выйти)`; + document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response)); + ReconstructVipSection(response); } - logout.innerHTML = ` (нажми чтоб выйти)` - } - }) + }) } function check_cookie_name(name) { var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); - if (match && match[2] != "None") {return true;} - else {return false;} + if (match && match[2] != "None") { return true; } + else { return false; } } let captcha_error_div = `
пук
` @@ -36,18 +38,18 @@ let ProfileLinkError_div = `
response.json()) + .then(response => { + console.log("captcha id: " + response.id); + // captcha_id = response.id; + // form_captcha.captcha_img.src = "https://tf2.pblr-nyk.pro/player_api/v1/captcha?id=" + response.id; + return response.id; + }); +} + $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () { console.log("setup captcha modal"); let form_url = document.forms["formProfileSectionInput"]; let form_captcha = document.forms["formCaptchaHandler"]; let captcha_id; - await RefreshCaptcha(); - async function RefreshCaptcha() { - await fetch("https://tf2.pblr-nyk.pro/player_api/v1/captcha", {method:'POST'}) - .then(response => response.json()) - .then(response => { - console.log("captcha id: " + response.id); - captcha_id = response.id; - form_captcha.captcha_img.src = "https://tf2.pblr-nyk.pro/player_api/v1/captcha?id=" + response.id; - }); - } + const captchaId = await RefreshCaptcha(); + captcha_id = captchaId; + form_captcha.captcha_img.src = "https://tf2.pblr-nyk.pro/player_api/v1/captcha?id=" + captchaId; $('#check_captcha_submit_button').click(async function (ev) { //ev.preventDefault(); - if ($('#ModalCaptchaErrorText')) { $('#ModalCaptchaErrorText').remove();} + if ($('#ModalCaptchaErrorText')) { $('#ModalCaptchaErrorText').remove(); } await CheckAndFill(ev); return false; }); async function CheckAndFill(event) { - if(form_captcha.captcha.value.length == 0){ - if(!document.getElementById("captcha_error")){ - document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend",captcha_error_div); + if (form_captcha.captcha.value.length == 0) { + if (!document.getElementById("captcha_error")) { + document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend", captcha_error_div); } document.getElementById("captcha_error").innerHTML = "Капчу введи!"; return; @@ -98,7 +104,7 @@ $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () { $("#check_captcha_close_button").prop("disabled", true); $("#check_captcha_submit_button").prop("disabled", true); - if(document.getElementById("current_profile")){ + if (document.getElementById("current_profile")) { document.getElementById("current_profile").remove(); } console.log(new Date()); @@ -110,8 +116,8 @@ $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () { ///////////////////////////////////////////////////////// if ("error" in response) { console.log(`id: ${captcha_id} error: ${response}`); - if(!document.getElementById("captcha_error")){ - document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend",captcha_error_div); + if (!document.getElementById("captcha_error")) { + document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend", captcha_error_div); } if (response.error == "incorrect captcha") { document.getElementById("captcha_error").innerHTML = "Капча невалидна, попробуй снова!"; @@ -120,32 +126,33 @@ $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () { } RefreshCaptcha(); } else if ("detail" in response) { - if(!document.getElementById("captcha_error")){ - document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend",captcha_error_div); + if (!document.getElementById("captcha_error")) { + document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend", captcha_error_div); } document.getElementById("captcha_error").innerHTML = "Ошибка: " + response.detail[0].msg; RefreshCaptcha(); } else { console.log(response); - document.getElementById("profile_stats").insertAdjacentHTML("beforeend",FillPlayerInfo(response)); - ReconstructVipSection(response); + document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response)); + //ReconstructVipSection(response); $('#check_captcha_close_button').click(); } form_captcha.captcha.value = ''; - }); -}}); + }); + } +}); function CalculateVipEndDate(permition) { - return new Date((permition["UNIX_TIMESTAMP(`reg_date`)"] + permition.amount) * 1000); + return new Date((permition["UNIX_TIMESTAMP(`reg_date`)"] + permition.amount) * 1000); } function FillPlayerInfo(data) { let player_ban_div = ""; - if(data.ban) { + if (data.ban) { let player_ban_length; - if (data.ban.ban_length > 0){ + if (data.ban.ban_length > 0) { let player_ban_end = new Date((new Date(data.ban.timestamp)).getTime() + (data.ban.ban_length * 60 * 1000)).toLocaleString(); player_ban_length = `

Дата окончания:

${player_ban_end}

` } else { @@ -179,23 +186,23 @@ function FillPlayerInfo(data) { let player_permition_div; let player_permition_length = ""; - + let player_permition_continue = `(купить)`; - if(data.permition) { + if (data.permition) { let player_permition_status; - if (data.permition.status == "VIP"){ + if (data.permition.status == "VIP") { let player_permition_end_date = `бесконечны`; let player_permition_end_date_color_status = `current-profile-text-color-normal`; - if(data.permition.amount){ + if (data.permition.amount) { player_permition_continue = `(продлить)`; let date = CalculateVipEndDate(data.permition);// new Date((data.permition["UNIX_TIMESTAMP(`reg_date`)"] + data.permition.amount) * 1000); player_permition_end_date = date.toLocaleString(); document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `До: ${player_permition_end_date}`; - if(date.getTime() - new Date().getTime() > 604800000){ + if (date.getTime() - new Date().getTime() > 604800000) { player_permition_end_date_color_status = `current-profile-text-color-normal`; - } else if (date.getTime() - new Date().getTime() > 259200000){ + } else if (date.getTime() - new Date().getTime() > 259200000) { player_permition_end_date_color_status = `current-profile-text-color-maybe`; } else { player_permition_end_date_color_status = `current-profile-text-color-alarm`; @@ -212,7 +219,7 @@ function FillPlayerInfo(data) {

Имеется

${player_permition_continue} ` - + } else { player_permition_status = `

Статус ${data.permition.status}:

@@ -256,14 +263,14 @@ function FillPlayerInfo(data) {

zavod_3 - 1 день 2:19:13

*/ - if(data.gametime){ + if (data.gametime) { player_statistic_div = `

Статистика карт

`; - for(const srv in data.gametime) { - for(const map_name in data.gametime[srv]){ + for (const srv in data.gametime) { + for (const map_name in data.gametime[srv]) { // // let map = map_name.replace("workshop/", "").split(".ugc", 1)[0]; @@ -310,9 +317,9 @@ function FillPlayerInfo(data) { return player_data_div; } -function UNIX2FACTI_TIME(u_time){ +function UNIX2FACTI_TIME(u_time) { const divmod = (x, y) => [Math.floor(x / y), x % y]; - + let s = divmod(u_time, 60)[1]; let m = divmod(u_time, 60)[0]; let h = divmod(m, 60)[0]; @@ -321,50 +328,50 @@ function UNIX2FACTI_TIME(u_time){ h = divmod(h, 24)[1]; //бля простите я тупой - if(!s&!m&!h&!d){ + if (!s & !m & !h & !d) { return "не играл"; } - let time = `${h>9?h:'0'+h}:${m>9?m:'0'+m}:${s>9?s:'0'+s}`; + let time = `${h > 9 ? h : '0' + h}:${m > 9 ? m : '0' + m}:${s > 9 ? s : '0' + s}`; if (!d) { return time; - } else if (d<2){ + } else if (d < 2) { return `${d} день ${time}`; } else { return `${d} дней ${time}`; } } -function ReconstructVipSection(data){ - $('#Modal_SelectPayMethod_Close').click(async function(ev) { +function ReconstructVipSection(data) { + $('#Modal_SelectPayMethod_Close').click(async function (ev) { ev.preventDefault(); $('#Modal_SelectPayMethod').modal('hide'); }); - $('#Modal_SelectPayMethod_CheckVIP').click(async function(ev) { + $('#Modal_SelectPayMethod_CheckVIP').click(async function (ev) { ev.preventDefault(); - await fetch("https://tf2.pblr-nyk.pro/player_api/v1/player/permitions?steam_url=" + document.forms["formProfileSectionInput"].steamurl.value) - .then(response => response.json()) - .then(response => { - if(response.permition){ - document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(имеется)"; - document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: green;"; - if(response.permition.amount){ - document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `До: ${CalculateVipEndDate(response.permition).toLocaleString()}`; + await fetch("https://tf2.pblr-nyk.pro/player_api/v1/player/permitions?steam_url=" + document.forms["formProfileSectionInput"].steamurl.value, { credentials: "same-origin", headers: { 'Cache-Control': 'no-cache' } }) + .then(response => response.json()) + .then(response => { + if (response.permition) { + document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(имеется)"; + document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: green;"; + if (response.permition.amount) { + document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `До: ${CalculateVipEndDate(response.permition).toLocaleString()}`; + } else { + document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `бесконечность не предел`; + } } else { - document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `бесконечность не предел`; + document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(отсутствует)"; + document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: red;"; + document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `Время проверки: ${new Date().toLocaleString()}`; } - } else { - document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(отсутствует)"; - document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: red;"; - document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `Время проверки: ${new Date().toLocaleString()}`; - } - }); + }); }); //document.getElementById("Section_VIP_check_profile")?document.getElementById("Section_VIP_check_profile").remove():null; - while(document.getElementById("Section_VIP_buttons").firstChild) { + while (document.getElementById("Section_VIP_buttons").firstChild) { document.getElementById("Section_VIP_buttons").lastChild.remove(); } @@ -380,10 +387,10 @@ function ReconstructVipSection(data){ ["VIP (1 месяц)", 150, "1 ключ", "site_content/images/vip/VIP_1_MOUNTH.jpg", "month"], ["VIP (1 неделя)", 75, "20 рефов", "site_content/images/vip/VIP_7_DAYS.jpg", "seven_day"], ["VIP (1 день)", 20, "5 рефов", "site_content/images/vip/VIP_1_DAY.jpg", "day"] - ); + ); let vip_select; - for(const select in price_array) { + for (const select in price_array) { vip_select = `
@@ -401,9 +408,9 @@ function ReconstructVipSection(data){
` document.getElementById("Section_VIP_buttons").insertAdjacentHTML("beforeend", vip_select); - $(`#Section_VIP_buttons_${price_array[select][4]}`).click(async function(ev) { + $(`#Section_VIP_buttons_${price_array[select][4]}`).click(async function (ev) { ev.preventDefault(); - document.getElementById('Modal_SelectPayMethod_QIWI_Button').href = QIWI_TRADE.replace("(AMOUNT)", price_array[select][1]).replace("(COMMENT)",data.steamids.steam2.replace(":","%3A")); + document.getElementById('Modal_SelectPayMethod_QIWI_Button').href = QIWI_TRADE.replace("(AMOUNT)", price_array[select][1]).replace("(COMMENT)", data.steamids.steam2.replace(":", "%3A")); document.getElementById('Modal_SelectPayMethod_QIWI_Value').innerHTML = `${price_array[select][1]} Рублей`; document.getElementById('Modal_SelectPayMethod_STEAM_Button').href = STEAM_TRADE; document.getElementById('Modal_SelectPayMethod_STEAM_Value').innerHTML = price_array[select][2]; @@ -449,13 +456,13 @@ $('#Section_VIP_buttons_month').click(async function(ev) { let konami_code = ""; let activated = false; document.addEventListener('keypress', (event) => { - if(activated){return;} + if (activated) { return; } konami_code += event.key; - if(konami_code.length == 6 || event.key == "-"){ - if(konami_code == "nigger"){ + if (konami_code.length == 6 || event.key == "-") { + if (konami_code == "nigger") { activated = true; - document.getElementById("Tab_About").href="#SecretEgg"; + document.getElementById("Tab_About").href = "#SecretEgg"; $('.nav-pills a[href="#SecretEgg"]').tab('show'); (new Audio("site_content/sounds/sunboy-ledi-night-16.mp3")).play(); document.getElementById("Nav_MenuButtons").remove()