You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

414 lines
21 KiB

class CurrentUser {
constructor() {
document.getElementById("Header_CurrentUser").innerHTML = `Получение данных профиля с сервера... ПОДОЖДИ`;
this.fill_user();
}
fill_user() {
fetch("https://tf2.pblr-nyk.pro/api/profile/current", { credentials: "same-origin", headers: { 'Cache-Control': 'no-cache' } })
.then(response => response.json())
.catch(err => {
if (err.code == 429) {
$("#Header_CurrentUser").html("Слишком частые запросы с беку, обнови позднее позже!!");
$("#Header_Logout").html("");
return;
}
$("#Header_CurrentUser").html("Ошибка получения данных профиля! ");
$("#Header_Logout").html("(Обнови страницу для релога)");
return;
})
.then(response => {
if (response == null || "error" in response) {
//console.log(response.error);
$("#Header_CurrentUser").html("Ошибка получения данных профиля! ");
$("#Header_Logout").html("(Обнови страницу для релога)")
return;
}
document.getElementById("Header_CurrentUser").href = "#";
this.check_ban_in_header(response);
document.getElementById("Header_Logout").innerHTML = " (нажми чтоб выйти)";
//
document.getElementById("profile_list").remove();
document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response));
ReconstructVipSection(response);
});
}
check_ban_in_header(response) {
if (response.ban) {
document.getElementById("Header_CurrentUser").innerHTML = `Привет ${response.steam_data.nickname}! У меня хорошие новости!`;
document.getElementById("Header_CurrentBan").innerHTML = "У тебя БАН! (нажми чтоб посмотреть его)";
} else {
document.getElementById("Header_CurrentUser").innerHTML = `Привет ${response.steam_data.nickname}!`;
}
}
}
if (check_cookie_name("steam64")) {
var current_user = new CurrentUser();
}
function check_cookie_name(name) {
var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
if (match && match[2] != "None") { return true; }
else { return false; }
}
let captcha_error_div = `<div class="col" id="ModalCaptchaErrorText"><h6 style="color: red;" id="captcha_error">пук</h6></div>`;
let ProfileLinkError_div = `<div class="col" id="ProfileLinkIsNotFull"><h6 style="color: red;" id="profile_error">Долбаеб введи ссылку на профиль!</h6></div>`;
function CalculateVipEndDate(permition) {
return new Date((permition.u_timestamp + permition.amount) * 1000);
}
function FillPlayerInfo(data) {
let player_ban_div = "";
if (data.ban) {
let player_ban_length;
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 = `<p class="current-profile-text">Дата окончания: </p><p class="current-profile-text">${player_ban_end}</p>`
} else {
player_ban_length = '<p class="current-profile-text">Дата окончания: </p><p class="current-profile-text current-profile-text-color-alarm">Навсегда в бане</p>'
}
player_ban_div = `
<div id="ban_section">
<hr>
<p class="current-profile-text current-profile-bigtext">Статус бана: </p>
<p class="current-profile-text current-profile-bigtext current-profile-text-color-alarm">Забанен</p>
<br>
<p class="current-profile-text">ID бана: </p>
<p class="current-profile-text">${data.ban.id}</p>
<br>
<p class="current-profile-text">Причина бана: </p>
<p class="current-profile-text">${data.ban.ban_reason}</p>
<br>
<p class="current-profile-text">Кто выдал бан: </p>
<p class="current-profile-text">${data.ban.banned_by ? data.ban.banned_by : 'bot'}</p>
<!---->
<a href="${data.ban.admin_info.steam_url}" target="_blank" class="current-profile-text"><img style="height: 1.0rem;" class="rounded-1" src="site_content/images/logo/steam.png"></a>
<a href="https://vk.me/id${data.ban.admin_info.vk_id}" target="_blank" class="current-profile-text"><img style="height: 1.0rem;" class="rounded-1" src="site_content/images/logo/vk.png"></a>
<a href="#" class="current-profile-text" onclick="alert('Пиши в дискорд сюда: ${data.ban.admin_info.discord_name}');"><img style="height: 1.0rem;" class="rounded-1" src="site_content/images/logo/discord.png?version=2"></a>
<!---->
<br>
${player_ban_length}
</div>
`
}
let player_permition_div;
let player_permition_length = "";
let player_permition_continue = `(купить)`;
if (data.permition) {
let player_permition_status;
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) {
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();
$("#Modal_SelectPayMethod_CheckVIP_EndDate").html(`До: ${player_permition_end_date}`);
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) {
player_permition_end_date_color_status = `current-profile-text-color-maybe`;
} else {
player_permition_end_date_color_status = `current-profile-text-color-alarm`;
}
}
player_permition_length = `
<br>
<p class="current-profile-text">Дата окончания ${data.permition.status}: </p><p class="current-profile-text">${player_permition_end_date}</p>
`;
player_permition_status = `
<p class="current-profile-text current-profile-bigtext">Статус ${data.permition.status}: </p>
<p class="current-profile-text current-profile-bigtext">Имеется </p><a href="#" onclick="document.getElementById('Tab_VIP_Button').click();" class="current-profile-text current-profile-bigtext ${player_permition_end_date_color_status}">${player_permition_continue}</a>
`
} else {
player_permition_status = `
<p class="current-profile-text current-profile-bigtext">Статус ${data.permition.status}: </p>
<p class="current-profile-text current-profile-bigtext">Имеется</p>
`
}
$("#Modal_SelectPayMethod_CheckVIP_Status").html("(имеется)");
$("#Modal_SelectPayMethod_CheckVIP_Status").css("color", "green");
player_permition_div = `
<div id="vip_section">
<hr>
${player_permition_status}
${player_permition_length}
<br>
</div>
`
} else {
player_permition_div = `
<div id="vip_section">
<hr>
<p class="current-profile-text current-profile-bigtext">Статус VIP: </p>
<p class="current-profile-text current-profile-bigtext">Отсутствует </p><a href="#" onclick="document.getElementById('Tab_VIP_Button').click();" class="current-profile-text current-profile-bigtext current-profile-text-color-alarm">${player_permition_continue}</a>
<br>
<div>
`;
}
let player_statistic_div = "";
let total_gametime = 0;
/*
<div id="statistic_section">
<hr>
<p class="current-profile-text current-profile-bigtext">Статистика карт</p>
<br>
<p class="current-profile-text">zavod_3_jirikupdate - 1 день 2:19:13</p>
<br>
<p class="current-profile-text">zavod_3_jirik - 1 день 2:19:13</p>
<br>
<p class="current-profile-text">zavod_3 - 1 день 2:19:13</p>
</div>
*/
if (data.gametime) {
player_statistic_div = `<div id="statistic_section">
<hr>
<p class="current-profile-text current-profile-bigtext">Статистика карт</p>
`;
for (const srv in data.gametime) {
for (const map_name in data.gametime[srv]) {
//<a href="${data.ban.admin_info.steam_url}" target="_blank" class="current-profile-text"><img style="height: 1.0rem;" class="rounded-1" src="site_content/images/logo/steam.png"></a>
//<img style="height: 1.0rem;" class="rounded-1" src="${return_last_api_response().servers[srv].preview}">
let map = map_name.replace("workshop/", "").split(".ugc", 1)[0];
player_statistic_div += `<br><p class="current-profile-text">${map} - ${UNIX2FACTI_TIME(data.gametime[srv][map_name])}</p>`;
total_gametime += data.gametime[srv][map_name];
}
}
player_statistic_div += "</div>"
}
let player_data_div = `
<div class="col-md-8 col-sm-6 col-lg-6 col-xl-5 rounded border border-dark gy-3 p-4" style="background-color: #E2EFDE;" id="current_profile">
<div class="row">
<div class="col-6 offset-3">
<hr>
</div>
</div>
<div class="row" id="player_data">
<div class="col" id="player_data_window">
<div class="row">
<div class="col" style="text-align: left;">
<h2>${data.steam_data.nickname}</h2>
${player_ban_div}
${player_permition_div}
${player_statistic_div}
</div>
</div>
</div>
<div class="col-4">
<img class="img-fluid w-100 rounded-5" src="${data.steam_data.avatar}">
<p></p>
<!--<p>Убийств: 20</p>
<p>Смертей: 582</p>-->
<p>Наиграно: ${UNIX2FACTI_TIME(total_gametime)}</p>
<div class="row">
<div class="col justify-content-end">
<a href="${data.steamids.community_url}" target="_blank"><img class="img-fluid w-25" src="site_content/images/logo/steam.png" id="CurrentPlayerURL"></a>
</div>
</div>
</div>
</div>
</div>
`
return player_data_div;
}
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];
m = divmod(m, 60)[1];
let d = divmod(h, 24)[0];
h = divmod(h, 24)[1];
//бля простите я тупой
if (!s & !m & !h & !d) {
return "не играл";
}
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) {
return `${d} день ${time}`;
} else {
return `${d} дней ${time}`;
}
}
function human_name_impl_2(count, naming){
let number = Math.abs(count) % 100;
let number_post = number % 10;
if (number > 10 && number < 20) { return naming[2]; }
if (number_post > 1 && number_post < 5) { return naming[1]; }
if (number_post == 1) { return naming[0] }
return naming[2];
}
function ReconstructVipSection(data) {
$('#Modal_SelectPayMethod_Close').click(async function (ev) {
ev.preventDefault();
$('#Modal_SelectPayMethod').modal('hide');
});
$('#Modal_SelectPayMethod_CheckVIP').click(async function (ev) {
ev.preventDefault();
await fetch("https://tf2.pblr-nyk.pro/api/profile/current?requests=permition", { credentials: "same-origin", headers: { 'Cache-Control': 'no-cache' } })
.then(response => response.json())
.then(response => {
if (response.permition) {
$("#Modal_SelectPayMethod_CheckVIP_Status").html("(имеется)");
$("#Modal_SelectPayMethod_CheckVIP_Status").css("color", "green");
if (response.permition.amount) {
$("#Modal_SelectPayMethod_CheckVIP_EndDate").html(`До: ${CalculateVipEndDate(response.permition).toLocaleString()}`);
} else {
$("#Modal_SelectPayMethod_CheckVIP_EndDate").html(`бесконечность не предел`);
}
} else {
$("#Modal_SelectPayMethod_CheckVIP_Status").html("(отсутствует)");
$("#Modal_SelectPayMethod_CheckVIP_Status").css("color", "red");
$("#Modal_SelectPayMethod_CheckVIP_EndDate").html(`Время проверки: ${new Date().toLocaleString()}`);
}
});
});
$("#Section_VIP_buttons").empty();
const STEAM_TRADE = "https://steamcommunity.com/tradeoffer/new/?partner=47239992&token=8gNFVl7h";
const QIWI_TRADE = "https://qiwi.com/payment/form/99?currency=643&amount=(AMOUNT)&extra%5B%27comment%27%5D=(COMMENT)&extra%5B%27account%27%5D=79207516287&blocked%5B0%5D=sum&blocked%5B1%5D=account&blocked%5B2%5D=comment";
$("#Modal_SelectPayMethod_ProfileLink").attr("href", data.steamids.community_url);
$("#Modal_SelectPayMethod_ProfileName").html(`Вип будет выдан: ${data.steam_data.nickname}`);
/*let price_array = new Array(
["1 месяц", 150, "1 ключ", "site_content/images/vip/VIP_1_MOUNTH.jpg", "month"],
["1 неделя", 75, "20 рефов", "site_content/images/vip/VIP_7_DAYS.jpg", "week"],
["1 день", 20, "5 рефов", "site_content/images/vip/VIP_1_DAY.jpg", "day"],
["1 день", 0, "бесплатно", "site_content/images/vip/freevip.jpg", "free"]
);*/
let vip_select;
for (let price in api_prices) {
price = api_prices[price];
vip_select = `
<div class="col">
<div class="card">
<img class="card-img" src="${price.img_url}" alt="${price.human_duration}">
<div class="card-img-overlay d-flex flex-column" style="background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.7))">
<a href="#" class="stretched-link" id="Section_VIP_buttons_${price.period}"></a>
<div class="mt-auto">
<h5 class="vip-card-text">${price.human_duration}</h5>
<h6 class="vip-card-text">${price.money_price} Рублей</h6>
<h6 class="vip-card-text">${price.item_price}</h6>
</div>
</div>
</div>
</div>
`
$(vip_select).appendTo("#Section_VIP_buttons");
$(`#Section_VIP_buttons_${price.period}`).click(async function (ev) {
ev.preventDefault();
if(price.period != "free"){
$("#Modal_SelectPayMethod_PayButtons").show(0);
$("#Modal_SelectPayMethod_GetFreeButtons").hide(0);
$("#Modal_SelectPayMethod_QIWI_Button").attr("href", QIWI_TRADE.replace("(AMOUNT)", price.money_price).replace("(COMMENT)", data.steamids.steam2.replace(":", "%3A")));
$("#Modal_SelectPayMethod_QIWI_Value").html(`${price.money_price} Рублей`);
$("#Modal_SelectPayMethod_STEAM_Button").attr("href", STEAM_TRADE);
$("#Modal_SelectPayMethod_STEAM_Value").html(price.item_price);
try {
let value_qiwi = price.period in api_response.donate.month.statistic.qiwi? api_response.donate.month.statistic.qiwi[price.period] : 0;
let value_name_1 = human_name_impl_2(value_qiwi, ["раз", "раза", "раз"])
$("#Modal_SelectPayMethod_DonateStatsValue_qiwi").html(`${value_qiwi} ${value_name_1}`);
let value_steam = price.period in api_response.donate.month.statistic.steam? api_response.donate.month.statistic.steam[price.period] : 0;
let value_name_2 = human_name_impl_2(value_steam, ["раз", "раза", "раз"])
$("#Modal_SelectPayMethod_DonateStatsValue_steam").html(`${value_steam} ${value_name_2}`);
$("#Modal_SelectPayMethod_DonateStatsText_FREE").hide(0);
$("#Modal_SelectPayMethod_DonateStatsValue").show(0);
$("#Modal_SelectPayMethod_DonateStatsText").show(0);
} catch {
$("#Modal_SelectPayMethod_DonateStatsValue").hide(0);
$("#Modal_SelectPayMethod_DonateStatsText").hide(0);
}
} else {
$("#Modal_SelectPayMethod_DonateStatsValue").hide(0);
$("#Modal_SelectPayMethod_DonateStatsText").hide(0);
$("#Modal_SelectPayMethod_PayButtons").hide(0);
$("#Modal_SelectPayMethod_GetFreeButtons").show(0);
let value_free = "day" in api_response.donate.month.statistic.free? api_response.donate.month.statistic.free.day : 0;
let value_free_naming = human_name_impl_2(value_free, ["раз", "раза", "раз"])
$("#Modal_SelectPayMethod_DonateStatsValue_free").html(`${value_free} ${value_free_naming}`);
$("#Modal_SelectPayMethod_DonateStatsText_FREE").show(0);
}
$('#Modal_SelectPayMethod').modal('show');
return false;
});
}
}
$("#Modal_SelectPayMethod_GetFreeButton_Check").click(async function (ev) {
ev.preventDefault();
await fetch("https://tf2.pblr-nyk.pro/api/profile/current/freevip", { credentials: "same-origin", headers: { 'Cache-Control': 'no-cache' }, method:"POST"})
.then(response => response.json())
.then(response => {
if (response == 0) $("#Modal_SelectPayMethod_GetFreeButton_Text").html("У тебя уже есть права!");
else if (response == 1) $("#Modal_SelectPayMethod_GetFreeButton_Text").html("Права выданы! Балдей!");
else if (response > 1) $("#Modal_SelectPayMethod_GetFreeButton_Text").html(`Ты не можешь получить вип бесплатно, вернись через ${UNIX2FACTI_TIME(response)}`);
else if (response < 0) $("#Modal_SelectPayMethod_GetFreeButton_Text").html(`Наиграй на сервере еще ${UNIX2FACTI_TIME(response * -1)}`);
else $("#Modal_SelectPayMethod_GetFreeButton_Text").html("Сегодня не твой день");
})
.catch(err => {
if (err.code == 429) {
$("#Modal_SelectPayMethod_GetFreeButton_Text").html("Помедленее друг, не так сильно");
} else {
$("#Modal_SelectPayMethod_GetFreeButton_Text").html("Сегодня не твой день, друг...");
}
});
});
//secret egg
let konami_code = "";
let activated = false;
//$().keypress(function (event) {
document.addEventListener('keypress', (event) => {
//$(":root").keypress(function (event) {
if (activated) { return; }
konami_code += event.key;
if (konami_code.length == 6 || event.key == "-") {
if (konami_code == "nigger") {
activated = true;
$("#Tab_About").attr("href", "#SecretEgg");
$('.nav-pills a[href="#SecretEgg"]').tab('show');
(new Audio("site_content/sounds/sunboy-ledi-night-16.mp3")).play();
$("#Nav_MenuButtons").remove();
ChangeBackgoundImage("site_content/images/background/hasbik_dance.jpg");
//$('Tab_Secret_Egg').click();
}
konami_code = ""
}
});