Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var iarray = new Object();
- iarray.register_process = 0;
- iarray.login_process = 0;
- iarray.url_hash_loaded = 0;
- iarray.url_hash_last = false;
- iarray.order_node = false;
- iarray.order_game = false;
- iarray.services_avail = false;
- iarray.service_active = false;
- iarray.services = false;
- iarray.support_messages_t = false;
- iarray.current_page = 'main';
- iarray.support_active = false;
- iarray.support_reply = false;
- $(document).ready(function() {
- render_news();
- account();
- });
- function dateformat(date) {
- var d = new Date(date);
- return ('0' + d.getDate()).slice(-2) + "." + ('0' + (d.getMonth() + 1)).slice(-2) + "." + d.getFullYear();
- }
- function post_auth_events() {}
- function post_account_events() {
- if (iarray.games && iarray.nodes) {
- render_services();
- } else {
- render_tech();
- }
- render_support();
- setInterval('render_support_q()', 5000);
- }
- function post_tech_events() {
- render_services();
- }
- function post_services_events() {
- render_preorders();
- setInterval('render_service()', 5000);
- if (iarray.user.ulevel == 2) {
- $('.free').hide();
- $('.services .title').html('Список серверов: <label class="link_s" onclick="$(\'.free\').show()">показать все</label>');
- }
- }
- $(window).on('hashchange', function() {
- if (window.location.hash) {
- var page = window.location.hash.replace('#', '');
- if (page != '') {
- switch (page) {
- case 'logout':
- logout();
- break;
- default:
- switch_panel(page);
- }
- }
- }
- });
- function switch_panel(page) {
- if (page != '') {
- iarray.current_page = page;
- $("#pages").children().hide();
- if ($("." + page).length) {
- document.title = $("." + page).find(".title").text() + " - SAMP-Host.Ru";
- $("." + page).stop(true, true).fadeIn(300);
- } else {
- document.title = "Страница не найдена - SAMP-Host.Ru";
- $(".404").stop(true, true).fadeIn(300);
- }
- $("#main_page").hide();
- $(".advants").hide();
- $("#about").hide();
- $("#dynamic").show();
- switch (page) {
- case 'main':
- $("#main_page").fadeIn(300);
- $(".advants").fadeIn(300);
- $("#about").fadeIn(300);
- $("#dynamic").hide();
- document.title = "Главная страница - SAMP-Host.Ru";
- break;
- case 'order':
- if (iarray.user.auth) {
- iarray.service_active = false;
- } else {
- switch_panel('login');
- iarray.url_hash_last = page;
- }
- break;
- case 'services':
- if (iarray.user.auth) {
- iarray.service_active = false;
- } else {
- switch_panel('login');
- iarray.url_hash_last = page;
- }
- break;
- case 'support':
- if (iarray.user.auth) {
- iarray.service_active = false;
- } else {
- switch_panel('login');
- iarray.url_hash_last = page;
- }
- break;
- case 'login':
- if (iarray.user.auth) {
- switch_panel('main');
- iarray.service_active = false;
- } else {
- }
- break;
- case 'register':
- if (iarray.user.auth) {
- iarray.service_active = false;
- switch_panel('main');
- } else {
- }
- break;
- case 'recovery':
- if (iarray.user.auth) {
- iarray.service_active = false;
- switch_panel('main');
- } else {
- }
- break;
- }
- }
- }
- function render_balance(balance) {
- if (iarray.user) {
- if (balance) {
- iarray.user.balance = parseInt(iarray.user.balance) + parseInt(balance);
- }
- $("#profile_balance").text(iarray.user.balance + " руб.");
- $(".timer").html(iarray.user.balance + " руб. - <a href='#pay'>Пополнить</a>");
- }
- }
- function pay() {
- $.post(
- "/includes/back.php?func=pay", {
- sum: $("#pay_sum").val()
- },
- function(info) {
- if (info.success == 1) {
- var payment = new UnitPay();
- payment.createWidget({
- publicKey: "101721-b881b",
- sum: info.payment.sum,
- account: info.payment.id,
- desc: "Оплата платежа #" + info.payment.id,
- locale: "ru",
- });
- payment.success(function(params) {
- render_balance(info.payment.sum);
- });
- } else {
- if (info.auth == false) {
- account('login');
- } else {
- alert(info.error);
- }
- }
- $("#dialog").dialog('close');
- });
- }
- function render_services() {
- if (iarray.games && iarray.nodes) {
- $.getJSON("/includes/back.php?func=services", function(services) {
- $("#preorders_list").html('');
- $("#services_list").html('');
- iarray.services = {};
- if (services) {
- $.each(services, function(key, value) {
- if ($(".service-" + value['id']).length) {
- $(".service-" + value['id']).remove();
- }
- iarray.services[value['id']] = {};
- iarray.services[value['id']]['id'] = value['id'];
- iarray.services[value['id']]['node_id'] = value['node_id'];
- iarray.services[value['id']]['user_id'] = value['user_id'];
- iarray.services[value['id']]['ip'] = value['ip'];
- iarray.services[value['id']]['port'] = value['port'];
- iarray.services[value['id']]['user'] = value['user'];
- iarray.services[value['id']]['password'] = value['password'];
- iarray.services[value['id']]['game_id'] = value['game_id'];
- iarray.services[value['id']]['hostname'] = value['hostname'];
- iarray.services[value['id']]['slots'] = value['slots'];
- iarray.services[value['id']]['slots_cur'] = value['slots_cur'];
- iarray.services[value['id']]['online'] = value['online'];
- iarray.services[value['id']]['order_date'] = value['order_date'];
- iarray.services[value['id']]['expires_date'] = value['expires_date'];
- iarray.services[value['id']]['load'] = value['load'];
- iarray.services[value['id']]['free'] = value['free'];
- iarray.services[value['id']]['status'] = value['status'];
- iarray.services[value['id']]['mysql_name'] = value['mysql_name'];
- iarray.services[value['id']]['mysql_user'] = value['mysql_user'];
- iarray.services[value['id']]['mysql_password'] = value['mysql_password'];
- iarray.services[value['id']]['mysql_host'] = value['mysql_host'];
- if (value['hostname'].length > 33) {
- hostname = value['hostname'].substr(0, 30) + "...";
- } else {
- hostname = value['hostname'];
- }
- if (value['free'] == 1) {
- var free = ' free';
- } else {
- var free = '';
- }
- if (value['status'] == 1) {
- $("#pages").append("<div class='service-" + value['id'] + "' id='service-page'><p class='title'>Управление сервером</p><div><table class='service_table'><tr><td><img src='" + iarray.games[value['game_id']].icon + "' class='icon-24-s'> <b class='service_hostname' id='service_hostname-" + value['id'] + "'>" + hostname + "</b> <b id='service_status-" + value['id'] + "'>" + status + "</b><br><b class='service_ip'>IP: " + value['ip'] + ":" + value['port'] + "</b><img src='" + iarray.nodes[value['node_id']].icon + "' class='icon-16-f'> " + iarray.nodes[value['node_id']].location + "</td><td class='service_controlls'><img src='/imgs/icons/start.png' onclick='service_action(" + value['id'] + ", \"cmd_start\")' title='Запуск/Перезагрузка сервера'> <img src='/imgs/icons/stop.png' onclick='service_action(" + value['id'] + ", \"cmd_stop\")' title='Отключение сервера'> <img src='/imgs/icons/reinstall.png' onclick='service_action(" + value['id'] + ", \"cmd_install\", 1)' title='Переустановка сервера'></td></tr><tr><td colspan='2'><hr class='service_hr'></td></tr><tr><td><div class='service_console' id='console-" + value['id'] + "'>Загрузка...</div></td><td class='service_info_d'><div class='expires_info'>Сервер активен до:<br><label id='service_expires_d-" + value['id'] + "'>" + dateformat(value['expires_date']) + "</label><br><br><label class='service_menu_label' onclick='show_extend(" + value['id'] + ")'>Продлить</label><br><hr class='service_hr'><label id='service_slots_d-" + value['id'] + "'>" + value['slots'] + "</label> слотов<br><br><label class='service_menu_label' onclick='show_edit(" + value['id'] + ")'>Изменить</label><hr class='service_hr'>FTP информация<br><br><label class='service_menu_label' onclick='show_ftp(" + value['id'] + ")'>Показать</label><hr class='service_hr'>MySQL база данных<br><br><label class='service_menu_label' onclick='show_mysql(" + value['id'] + ")'>Показать</label></div></td></tr></table></div></div>");
- $("#services_list").append("<table class='service_item" + free + "'><tr><td class='l_service_ip'><img src='" + iarray.games[value['game_id']].icon + "' class='icon-16-g'> " + value['ip'] + ":" + value['port'] + "</td><td class='l_preorder_slots'>" + value['slots'] + " слотов</td><td class='l_preorder_node'><img src='" + iarray.nodes[value['node_id']].icon + "' class='icon-16-f'> " + iarray.nodes[value['node_id']].name + "</td><td class='l_service_period'>До: " + dateformat(value['expires_date']) + "</td><td class='l_pay'><a class='l_edit_label' title='Панель управления' href='#service-" + value['id'] + "' onclick='iarray.service_active = " + value['id'] + "'>Управление</a></td><td></td></tr></table>");
- if (value['online'] == 1) {
- $("#service_status-" + value['id']).text('online');
- $("#service_status-" + value['id']).css('color', '#4ead6d');
- } else {
- $("#service_status-" + value['id']).text('offline');
- $("#service_status-" + value['id']).css('color', '#c93434');
- }
- } else {
- $("#services_list").append("<table class='service_item'><tr><td class='l_service_ip'><img src='" + iarray.games[value['game_id']].icon + "' class='icon-16-g'> " + value['ip'] + ":" + value['port'] + "</td><td class='l_preorder_slots'>" + value['slots'] + " слотов</td><td class='l_preorder_node'><img src='" + iarray.nodes[value['node_id']].icon + "' class='icon-16-f'> " + iarray.nodes[value['node_id']].name + "</td><td class='l_service_period'>До: " + dateformat(value['expires_date']) + "</td><td class='l_pay'><label class='l_edit_label' title='Продлить' onclick='show_extend(" + value['id'] + ")'>Продлить</label></td><td></td></tr></table>");
- }
- $("#services_list").fadeIn(300);
- });
- iarray.services_avail = 1;
- }
- post_services_events();
- });
- }
- }
- function show_ftp(gid) {
- $("#dialog").html("<form action='http://files.samp-host.ru/index.php' method='post' id='filemanager' target='_blank'><table><tr><td>Хост:</td><td><input type='text' value='" + iarray.nodes[iarray.services[gid].node_id].ip + "' class='ftp_input' name='ftpserver' readonly></td></tr><tr><td>Логин:</td><td><input type='text' value='" + iarray.services[gid].user + "' class='ftp_input' name='username' readonly></td></tr><tr><td>Пароль:</td><td><input type='text' value='" + iarray.services[gid].password + "' class='ftp_input' name='password' readonly><input type='hidden' name='ftpserverport' value='21'></td></tr><tr><td colspan='2' style='text-align:center'><label onclick='$(\"#filemanager\").submit()' class='l_edit_label'>Войти в менеджер файлов</label></td><tr></table><input type='hidden' name='protocol' value='FTP'><input type='hidden' name='language' value='ru'><input type='hidden' name='skin' value='shinra'><input type='hidden' name='ftpmode' value='binary'><input type='hidden' name='state' value='browse'><input type='hidden' name='state2' value='main'><input type='hidden' name='Login' value='Вход'></form>");
- $("#dialog").dialog({
- title: 'FTP информация',
- autoOpen: true,
- width: 'auto',
- height: 'auto',
- resizable: false,
- modal: true,
- draggable: false
- });
- }
- function show_mysql(gid) {
- $("#dialog").html("<form action='http://" + iarray.services[gid].mysql_host + "/phpmyadmin' id='phpmyadmin' target='_blank'><table><tr><td>Хост:</td><td><input type='text' value='" + iarray.services[gid].mysql_host + "' class='ftp_input' readonly></td></tr><tr><td>Имя базы данных:</td><td><input type='text' value='" + iarray.services[gid].mysql_name + "' class='ftp_input' readonly></td></tr><tr><td>Пользователь:</td><td><input type='text' value='" + iarray.services[gid].mysql_user + "' name='pma_username' class='ftp_input' readonly></td></tr><tr><td>Пароль:</td><td><input type='text' value='" + iarray.services[gid].mysql_password + "' name='pma_password' class='ftp_input' readonly></td></tr><tr><td colspan='2' style='text-align:center'><label onclick='$(\"#phpmyadmin\").submit()' class='l_edit_label'>Войти в phpMyAdmin</label></td><tr></table></form>");
- $("#dialog").dialog({
- title: 'MySQL база данных',
- autoOpen: true,
- width: 'auto',
- height: 'auto',
- resizable: false,
- modal: true,
- draggable: false
- });
- }
- function show_extend(gid) {
- $("#dialog").html("<div><table class='order_confirm_t'><tr><td>" + iarray.services[gid].slots + " слотов</td><td align='right' width='300px'>Период продления: <select class='extend_period_select'><option value='1'>1 месяц</option><option value='3'>3 месяца (5% скидка)</option><option value='6'>6 месяцев (15% скидка)</option></select></td></tr><tr><td colspan='2' with='100%'>Итоговая сумма: <b id='extend_total_sum'></b> руб.</td></tr></table><span class='l_edit_label' onclick='service_extend(" + gid + ")'>Продлить</span></div>");
- extend_calculate(gid);
- $(".extend_period_select").change(function() {
- extend_calculate(gid);
- });
- $("#dialog").dialog({
- title: 'Продление сервера',
- autoOpen: true,
- width: 'auto',
- height: 'auto',
- resizable: false,
- modal: true,
- draggable: false
- });
- }
- function extend_calculate(gid) {
- var total = 0;
- var slots = iarray.services[gid].slots;
- var cost = iarray.games[iarray.services[gid].game_id].cost;
- var period = parseInt($(".extend_period_select").val());
- switch (period) {
- case 1:
- total = parseInt(slots * cost);
- break;
- case 3:
- total = (slots * cost) * period;
- total = parseInt(total - ((total / 100) * 5));
- break;
- case 6:
- total = (slots * cost) * period;
- total = parseInt(total - ((total / 100) * 15));
- break;
- }
- $("#extend_total_sum").text(total);
- }
- function service_extend(gid) {
- $.post(
- "/includes/back.php?func=service_extend", {
- id: gid,
- period: $(".extend_period_select").val()
- },
- function(info) {
- if (info.success == 1) {
- switch (info.type) {
- case 1:
- render_service();
- if (iarray.current_page == 'services') {
- render_services();
- }
- break;
- case 2:
- var payment = new UnitPay();
- payment.createWidget({
- publicKey: "101721-b881b",
- sum: info.payment.sum,
- account: info.payment.id,
- desc: "Оплата платежа #" + info.payment.id,
- locale: "ru",
- });
- payment.success(function(params) {
- render_service();
- if (iarray.current_page == 'services') {
- render_services();
- }
- });
- payment.error(function(message, params) {
- });
- break;
- }
- } else {
- if (info.auth == false) {
- account('login');
- } else {
- alert(info.error);
- }
- }
- $("#dialog").dialog('close');
- });
- }
- function show_edit(gid) {
- $("#dialog").html("<table class='order_confirm_t'><tr><td colspan='2'><div id='edit_slots_slider'></div></td></tr><tr><td><input type='number' id='edit_slots_input' value='" + iarray.services[gid].slots + "'> шт.</td><td align='right'>Итоговая сумма: <b id='edit_total_sum'>0</b> руб.</td></tr></table><span class='l_edit_label' onclick='service_edit(" + gid + ")'>Изменить</span>");
- $("#edit_slots_slider").slider({
- range: "min",
- value: iarray.services[gid].slots,
- min: parseInt(iarray.games[iarray.services[gid].game_id].minslots),
- max: parseInt(iarray.games[iarray.services[gid].game_id].maxslots),
- slide: function(event, ui) {
- $("#edit_slots_input").val(ui.value);
- edit_calculate(gid);
- }
- });
- $("#edit_slots_input").change(function() {
- $("#edit_slots_slider").slider('value', $("#edit_slots_input").val());
- edit_calculate(gid);
- });
- $("#dialog").dialog({
- title: 'Изменение слотов',
- autoOpen: true,
- width: 'auto',
- height: 'auto',
- resizable: false,
- modal: true,
- draggable: false
- });
- }
- function edit_calculate(gid) {
- var slots = parseInt(iarray.services[gid].slots);
- var new_slots = parseInt($("#edit_slots_input").val());
- var cost = iarray.games[iarray.services[gid].game_id].cost / 30;
- var days_left = parseInt(((new Date(iarray.services[gid].expires_date) / 1000) - (Date.now() / 1000)) / 86400);
- var total = 0;
- if (new_slots >= slots) {
- total = parseInt((days_left * cost) * (new_slots - slots));
- } else {
- total = 0;
- }
- $("#edit_total_sum").text(total);
- }
- function service_edit(gid) {
- if (confirm('Вы уверены что хотите изменить количество слотов?')) {
- $.post(
- "/includes/back.php?func=service_edit", {
- id: gid,
- new_slots: $("#edit_slots_input").val()
- },
- function(info) {
- if (info.success == 1) {
- switch (info.type) {
- case 1:
- render_service();
- service_action(gid, "cmd_start");
- break;
- case 2:
- var payment = new UnitPay();
- payment.createWidget({
- publicKey: "101721-b881b",
- sum: info.payment.sum,
- account: info.payment.id,
- desc: "Оплата платежа #" + info.payment.id,
- locale: "ru",
- });
- payment.success(function(params) {
- render_service();
- service_action(gid, "cmd_start");
- });
- payment.error(function(message, params) {});
- break;
- }
- } else {
- if (info.auth == false) {
- account('login');
- } else {
- alert(info.error);
- }
- }
- $("#dialog").dialog('close');
- });
- }
- }
- function render_service() {
- if (iarray.service_active) {
- $.getJSON("/includes/back.php?func=service&id=" + iarray.service_active, function(service) {
- if (service.id == iarray.service_active) {
- $("#console-" + iarray.service_active).html(service.console);
- if (service.hostname.length > 33) {
- hostname = service.hostname.substr(0, 30) + "...";
- } else {
- hostname = service.hostname;
- }
- $("#service_hostname-" + iarray.service_active).text(hostname);
- var d = $("#console-" + iarray.service_active);
- d.scrollTop(d.prop('scrollHeight'));
- if (service.game_status == 1) {
- $("#service_status-" + iarray.service_active).text('online');
- $("#service_status-" + iarray.service_active).css('color', '#4ead6d');
- } else {
- $("#service_status-" + iarray.service_active).text('offline');
- $("#service_status-" + iarray.service_active).css('color', '#c93434');
- }
- $("#service_expires_d-" + iarray.service_active).text(dateformat(service.expires_date));
- $("#service_slots_d-" + iarray.service_active).text(service.slots_max);
- }
- iarray.services[service.id]['slots'] = service.slots_max;
- iarray.services[service.id]['expires_date'] = service.expires_date;
- });
- }
- }
- function service_action(gid, action, reinstall = 0) {
- if ((reinstall == 1 && confirm('Вы уверены что хотите переустановить сервер?')) || reinstall == 0) {
- $(".service_controlls img").fadeOut(200);
- $.post(
- "/includes/back.php?func=service_action", {
- id: gid,
- action: action
- },
- function(info) {
- if (info.success == 1) {
- $(".service_controlls img").fadeIn(200);
- } else {
- $(".service_controlls img").fadeIn(200);
- alert(info.error);
- }
- });
- }
- }
- function render_news() {
- $.getJSON("/includes/back.php?func=news", function(data) {
- if (data) {
- $.each(data, function(key, value) {
- $(".news_box").append("<table class='news_item'><tr><td class='news_time'>" + value['date'] + "</td></tr><tr><td>" + value['text'] + "</td></tr></table>");
- });
- }
- });
- }
- function order(p_iteam, game, node, slots, period) {
- $("#" + p_iteam + " .l_pay_label").hide();
- $("#" + p_iteam + " .icon-24-d").hide();
- $("#" + p_iteam + " .l_load").show();
- $.post(
- "/includes/back.php?func=order", {
- game: game,
- node: node,
- slots: slots,
- period: period
- },
- function(info) {
- if (info.success == 1) {
- switch (info.type) {
- case 1:
- remove_preorder(p_iteam);
- account();
- break;
- case 2:
- var payment = new UnitPay();
- payment.createWidget({
- publicKey: "101721-b881b",
- sum: info.payment.sum,
- account: info.payment.id,
- desc: "Оплата платежа #" + info.payment.id,
- locale: "ru",
- });
- payment.success(function(params) {
- remove_preorder(p_iteam);
- render_services();
- });
- payment.error(function(message, params) {
- $("#" + p_iteam + " .l_pay_label").show();
- $("#" + p_iteam + " .icon-24-d").show();
- $("#" + p_iteam + " .l_load").hide();
- });
- setTimeout("$('#" + p_iteam + " .l_pay_label').show();$('#" + p_iteam + " .icon-24-d').show();$('#" + p_iteam + " .l_load').hide();", 15000)
- break;
- }
- } else {
- if (info.auth == false) {
- account('login');
- } else {
- alert(info.error);
- }
- }
- }
- );
- }
- function account(next_page = false, force = false) {
- $.getJSON("/includes/back.php?func=account", function(account) {
- iarray.user = account;
- if (account.auth == true) {
- $(".header_py_list").html("<li class='py_link'><a href='#services'>Список серверов</a></li><li class='reg_link'><a href='#profile'>Профиль</a></li><li class='lk_link'><a href='#logout'>Выход</a></li>");
- $(".timer_title").text("Баланс:");
- $(".timer").html(account.balance + " руб. - <a href='#pay'>Пополнить</a>");
- $(".profile .title").text("Профиль: " + account.login);
- $(".reg_link a").text(account.login);
- $("#profile_email").text(account.email);
- $("#profile_balance").text(account.balance + " руб.");
- post_account_events();
- } else {
- $(".timer_title").text("Нам уже:");
- $(".header_py_list").html("<li class='py_link'><a href='#services'>Панель управления</a></li><li class='lk_link'><a href='#' onclick='login_open_box()'>Личный кабинет</a></li><li class='reg_link'><a href='#register'>Регистрация</a></li>");
- $(".timer").text(account.times);
- }
- }).complete(function() {
- if (next_page) {
- if (force) {
- window.location = "#" + next_page;
- switch_panel(next_page, true);
- } else {
- window.location = "#" + next_page;
- }
- }
- if (iarray.url_hash_loaded == 0) {
- if (window.location.hash) {
- var page = window.location.hash.replace('#', '');
- switch (page) {
- case 'logout':
- window.location = "#main";
- break;
- default:
- switch_panel(page);
- }
- }
- iarray.url_hash_loaded = 1;
- }
- });
- }
- function render_tech() {
- $.getJSON("/includes/back.php?func=games", function(games) {
- iarray.games = games;
- $(".order_games").html('');
- $.each(games, function(key, value) {
- if (value['status'] == 1) {
- $(".order_games").append("<div id='game-" + value['id'] + "' class='order_game_item' style='background-image: url(" + value['image'] + ")' onclick='select_game(" + value['id'] + ")'><label class='order_label'>" + value['name'] + "</label></div>");
- }
- });
- }).complete(function() {
- $.getJSON("/includes/back.php?func=nodes", function(nodes) {
- iarray.nodes = nodes;
- $(".order_nodes").html('');
- $.each(nodes, function(key, value) {
- if (value['discount'] != "0") {
- $(".order_nodes").append("<div id='node-" + value['id'] + "' class='order_node_item' style='background-image: url(" + value['image'] + ")' onclick='select_node(" + value['id'] + ")' title='Скидка " + value['discount'] + "%!'><label class='order_label'>" + value['name'] + "</label><img src='/imgs/icons/sale.png' class='sale_i'><img src='" + value['icon'] + "' class='image_i'></div>");
- } else {
- $(".order_nodes").append("<div id='node-" + value['id'] + "' class='order_node_item' style='background-image: url(" + value['image'] + ")' onclick='select_node(" + value['id'] + ")'><label class='order_label'>" + value['name'] + "</label><img src='" + value['icon'] + "' class='image_i'></div>");
- }
- });
- }).complete(function() {
- post_tech_events();
- });
- });
- }
- function select_game(id) {
- $(".order_games").find(".order_game_item").css('border', '3px solid rgb(231, 179, 0)');
- $(".order_games #game-" + id).css('border', '3px solid rgb(36, 153, 0)');
- iarray.order_game = id;
- render_order_info();
- }
- function select_node(id) {
- $(".order_nodes").find(".order_node_item").css('border', '3px solid rgb(231, 179, 0)');
- $(".order_nodes #node-" + id).css('border', '3px solid rgb(36, 153, 0)')
- iarray.order_node = id;
- render_order_info();
- }
- function render_order_info() {
- if (iarray.order_node && iarray.order_game) {
- var node = iarray.nodes[iarray.order_node];
- var game = iarray.games[iarray.order_game];
- var current_slots = parseInt((game.maxslots / 100) * 25);
- eval('var location = ' + node.google_location + ';');
- var map = new google.maps.Map(document.getElementById('google_map'), {
- zoom: 6,
- center: location
- });
- var marker = new google.maps.Marker({
- position: location,
- map: map
- });
- $("#order_details").html("<table><tr><td>" + game.name + "</td></tr><tr><td>" + node.location + "</td></tr><tr><td>" + node.protection + "</td></tr><tr><td><a href='" + game.protocol + "://" + node.testip + ":" + game.testport + "'>" + node.testip + ":" + game.testport + "</a></td></tr><tr><td>" + game.cost + " руб./слот</td></tr></table>");
- $(".order_info").fadeIn(300);
- $("#order_slots_input").val(current_slots);
- $("#order_slots_slider").slider({
- range: "min",
- value: current_slots,
- min: parseInt(game.minslots),
- max: parseInt(game.maxslots),
- slide: function(event, ui) {
- $("#order_slots_input").val(ui.value);
- order_calculate();
- }
- });
- $("#order_slots_input").change(function() {
- $("#order_slots_slider").slider('value', $("#order_slots_input").val());
- order_calculate();
- });
- $("#order_slots_input").attr('min', game.minslots);
- $("#order_slots_input").attr('max', game.maxslots);
- $(".order_confirm").fadeIn(300);
- $(".order_period_select").change(function() {
- order_calculate();
- });
- order_calculate();
- } else {
- $(".order_info").fadeOut(300);
- }
- }
- function order_calculate() {
- if (iarray.order_node && iarray.order_game) {
- var game = iarray.games[iarray.order_game];
- var node = iarray.nodes[iarray.order_node];
- var period = parseInt($(".order_period_select").val());
- var slots = $("#order_slots_input").val();
- var total = 0;
- var discount_p = 0;
- var discount = parseInt(node.discount);
- switch (period) {
- case 1:
- total = parseInt(slots * game.cost);
- break;
- case 3:
- total = (slots * game.cost) * period;
- total = parseInt(total - ((total / 100) * 5));
- discount_p = 5;
- break;
- case 6:
- total = (slots * game.cost) * period;
- total = parseInt(total - ((total / 100) * 15));
- discount_p = 15;
- break;
- }
- if (discount != 0) {
- total = parseInt(total - ((total / 100) * discount));
- if (discount_p != 0) {
- $("#discount_label").text("Экономия " + (discount + discount_p) + "%!");
- } else {
- $("#discount_label").text("Экономия " + discount + "%!");
- }
- } else {
- if (discount_p != 0) {
- $("#discount_label").text("Экономия " + discount_p + "%!");
- } else {
- $("#discount_label").text("");
- }
- }
- $("#total_sum").text(total);
- }
- }
- function preorder() {
- if (iarray.order_node && iarray.order_game) {
- var user = iarray.user;
- var game = iarray.games[iarray.order_game];
- var node = iarray.nodes[iarray.order_node];
- var period = parseInt($(".order_period_select").val());
- var slots = parseInt($("#order_slots_input").val());
- if (slots >= parseInt(game['minslots']) && slots <= parseInt(game['maxslots'])) {
- var preorders = {};
- if (Cookies.get('preorders-' + user.id)) {
- preorders = JSON.parse(Cookies.get('preorders-' + user.id));
- var k = Object.keys(preorders).length + 1;
- preorders[k] = {};
- preorders[k]['i'] = k;
- preorders[k]['g'] = iarray.order_game;
- preorders[k]['s'] = slots;
- preorders[k]['n'] = iarray.order_node;
- preorders[k]['p'] = period;
- Cookies.set('preorders-' + user.id, JSON.stringify(preorders), {
- expires: 365
- });
- } else {
- preorders[1] = {};
- preorders[1]['i'] = 1;
- preorders[1]['g'] = iarray.order_game;
- preorders[1]['s'] = slots;
- preorders[1]['n'] = iarray.order_node;
- preorders[1]['p'] = period;
- Cookies.set('preorders-' + user.id, JSON.stringify(preorders), {
- expires: 365
- });
- }
- render_preorders();
- window.location = "#services";
- order_reset_form();
- } else {
- $("#order_slots_input").val(game['minslots']);
- $("#order_slots_slider").slider('value', $("#order_slots_input").val());
- order_calculate();
- }
- }
- }
- function order_reset_form() {
- $(".order_nodes").find(".order_node_item").css('border', '3px solid rgb(231, 179, 0)');
- $(".order_games").find(".order_game_item").css('border', '3px solid rgb(231, 179, 0)');
- $(".order_info").hide();
- $(".order_confirm").hide();
- iarray.order_node = false;
- iarray.order_game = false;
- }
- function render_preorders() {
- var user = iarray.user;
- if (Cookies.get('preorders-' + user.id)) {
- var preorders = JSON.parse(Cookies.get('preorders-' + user.id));
- preorders = Object.keys(preorders).map(function(key) {
- return preorders[key];
- });
- preorders = preorders.reverse();
- if (preorders != '') {
- $("#preorders_list").html('');
- $.each(preorders, function(key, value) {
- var period = value['p'];
- var slots = value['s'];
- var game = iarray.games[value['g']];
- var node = iarray.nodes[value['n']];
- var total = 0;
- switch (period) {
- case 1:
- total = parseInt(slots * game.cost);
- var month = 'месяц';
- break;
- case 3:
- total = (slots * game.cost) * period;
- total = parseInt(total - ((total / 100) * 5));
- var month = 'месяца';
- break;
- case 6:
- total = (slots * game.cost) * period;
- total = parseInt(total - ((total / 100) * 15));
- var month = 'месяцев';
- break;
- }
- if (node.discount != "0") {
- total = parseInt(total - ((total / 100) * node.discount));
- }
- $("#preorders_list").append("<table class='preorder_item' id='" + value['i'] + "'><tr><td class='l_preorder_name'><img src='" + iarray.games[value['g']].icon + "' class='icon-16-g'> " + iarray.games[value['g']].name + " сервер</td><td class='l_preorder_slots'>" + slots + " слотов</td><td class='l_preorder_node'><img src='" + iarray.nodes[value['n']].icon + "' class='icon-16-f'> " + iarray.nodes[value['n']].name + "</td><td class='l_preorder_period'>" + period + " " + month + " - " + total + " руб.</td><td class='l_pay'><label class='l_pay_label' title='Оплатить заказ' onclick='order(" + value['i'] + ", " + value['g'] + ", " + value['n'] + ", " + value['s'] + ", " + period + ")'>Оплатить</label></td><td class='l_load'><img src='/imgs/icons/load.gif'></td><td><img src='/imgs/icons/del.png' onclick='remove_preorder(" + value['i'] + ")' class='icon-24-d' title='Удалить'></td></tr></table>");
- });
- } else {
- if (iarray.services_avail == false) {
- $("#preorders_list").html('<div>У вас пока нет серверов, <a href="#order">закажите</a> прямо сейчас!</div>');
- }
- }
- } else {
- if (iarray.services_avail == false) {
- $("#preorders_list").html('<div>У вас пока нет серверов, <a href="#order">закажите</a> прямо сейчас!</div>');
- }
- }
- $('#preorders_list').fadeIn(300);
- }
- function remove_preorder(id) {
- var user = iarray.user;
- if (Cookies.get('preorders-' + user.id)) {
- var preorders = JSON.parse(Cookies.get('preorders-' + user.id));
- delete preorders[id];
- var i = 1;
- preorders_n = {};
- $.each(preorders, function(key, value) {
- preorders_n[i] = {};
- preorders_n[i]['i'] = i;
- preorders_n[i]['g'] = value['g'];
- preorders_n[i]['s'] = value['s'];
- preorders_n[i]['n'] = value['n'];
- preorders_n[i]['p'] = value['p'];
- i++;
- });
- Cookies.set('preorders-' + user.id, JSON.stringify(preorders_n), {
- expires: 365
- });
- $("#preorders_list #" + id).fadeOut(300, function() {
- $("#preorders_list #" + id).remove();
- render_preorders();
- });
- }
- }
- function register() {
- if (iarray.register_process == 0) {
- iarray.register_process = 1;
- if ($("#register_login").val() && $("#register_password").val() && $("#register_password_1").val() && $("#register_email").val()) {
- if ($("#register_password").val() == $("#register_password_1").val()) {
- $.post(
- "/includes/back.php?func=register", {
- login: $("#register_login").val(),
- password: $("#register_password").val(),
- email: $("#register_email").val()
- },
- function(info) {
- if (info.success == 1) {
- if (iarray.url_hash_last) {
- account(iarray.url_hash_last, true);
- } else {
- account('services');
- }
- } else {
- if (info.error) {
- d_error(info.error, 'register');
- iarray.register_process = 0;
- }
- }
- $(document).find('input:password').val('');
- }
- );
- } else {
- d_error('Пароли не совпадают!', 'register');
- iarray.register_process = 0;
- }
- } else {
- d_error('Заполните все поля!', 'register');
- iarray.register_process = 0;
- }
- }
- }
- function login(ext = false) {
- if (iarray.user.auth == false) {
- if (iarray.login_process == 0) {
- if (ext) {
- var login = $("." + ext).find("#login").val();
- var password = $("." + ext).find("#password").val();
- } else {
- var login = $("#login").val();
- var password = $("#password").val();
- }
- if (login != '' && password != '') {
- iarray.login_process = 1;
- $.post(
- "/includes/back.php?func=login", {
- login: login,
- password: password
- },
- function(info) {
- if (info.success == 1) {
- iarray.login_process = 0;
- if (iarray.url_hash_last) {
- account(iarray.url_hash_last, true);
- } else {
- account('services');
- }
- $("#ajax").fadeOut(500);
- post_auth_events();
- } else {
- if (info.error) {
- d_error(info.error, 'login');
- iarray.login_process = 0;
- }
- }
- $(document).find('input:password').val('');
- }
- );
- } else {
- d_error('Заполните все поля!', 'login');
- }
- }
- }
- }
- function logout() {
- if (iarray.user.auth == true) {
- $.getJSON("/includes/back.php?func=logout", function(data) {
- if (data.success == 1) {
- iarray.services_avail = false;
- iarray.url_hash_last = false;
- iarray.service_active = false;
- window.location = "#main";
- account();
- } else {
- alert(data.error);
- }
- });
- }
- }
- function d_error(text, page = false) {
- if (page) {
- if ($("." + page).find("#error").length) {
- $("." + page).find("#error").text(text);
- $("." + page).find("#error").finish().stop(true, true).show('pulsate', 500).delay(5000).fadeOut(500);
- } else {
- alert(text);
- }
- } else {
- if ($("#error").length) {
- $("#error").text(text);
- $("#error").finish().stop(true, true).show('pulsate', 500).delay(5000).fadeOut(500);
- } else {
- alert(text);
- }
- }
- }
- function render_support_q() {
- if (iarray.current_page == 'support') {
- render_support();
- }
- }
- function render_support() {
- if (iarray.user.auth == true) {
- var user = iarray.user;
- $.getJSON("/includes/back.php?func=support&list", function(data) {
- if (data) {
- $("#support_messages").text("");
- iarray.support_messages_t = true;
- iarray.support_reply = false;
- $("#support_close_button").show();
- if (user.ulevel == 1) {
- $.each(data, function(key, value) {
- $("#support_messages").append("<table class='support_item'><tr><td class='support_avatar_item'><img src='/imgs/support-lvl-" + value['ulevel'] + ".png'></td><td class='support_message_item'>" + value['message'] + "</td></tr><tr><td colspan='2' class='support_date_item'>" + dateformat(value['date']) + "</td></tr></table>");
- });
- show_support_area();
- }
- if (user.ulevel == 2) {
- $.each(data, function(key, value) {
- $(".support-" + value['user_id']).remove();
- $("#support_messages").append("<a href='/#support-" + value['user_id'] + "' onclick='iarray.support_active = " + value['user_id'] + ";show_support_area(" + value['user_id'] + ")' id='support_link-" + value['user_id'] + "'><table class='support_item'><tr><td class='support_avatar_item'><img src='/imgs/support-lvl-" + value['ulevel'] + ".png'></td><td class='support_message_item'>" + value['title'] + "</td></tr><tr><td colspan='2' class='support_date_item'>" + dateformat(value['date']) + "</td></tr></table></a>");
- $("#pages").append("<div class='support-" + value['user_id'] + "' id='support-page'><p class='title'>Просмотр запроса: <label onclick='render_user_services(" + value['user_id'] + ")' class='link_s'>Сервера</label></p><div id='support_messages'></div></div>");
- $(".support-" + value['user_id'] + " .support_item").remove();
- if (value['messages'][Object.keys(value['messages']).length]['ulevel'] == 2) {
- $("#support_link-" + value['user_id']).css('opacity', 0.5);
- }
- $.each(value['messages'], function(k, v) {
- $(".support-" + value['user_id'] + " #support_messages").append("<table class='support_item'><tr><td class='support_avatar_item'><img src='/imgs/support-lvl-" + v['ulevel'] + ".png'></td><td class='support_message_item'>" + v['message'] + "</td></tr><tr><td colspan='2' class='support_date_item'>" + dateformat(v['date']) + "</td></tr></table>");
- });
- $(".support-" + value['user_id']).append("<div id='support_area'><textarea id='support_message-" + value['user_id'] + "' class='support_message' placeholder='Сообщение до 2048 символов'></textarea><br><label id='support_reply_b' class='l_support_label' onclick='support_reply(" + value['user_id'] + ")'>Отправить</label> <img src='/imgs/icons/del.png' onclick='support_close(" + value['user_id'] + ")' class='icon-24-d-s' title='Закрыть' id='support_close_button'> <label id='error'></label></div>");
- });
- $("#support_controlls").hide();
- }
- } else {
- iarray.support_messages_t = false;
- if (iarray.support_reply == false) {
- $("#support_area").hide();
- $("#support_close_button").hide();
- $("#support_messages").text("У вас нет активных запросов в техническую поддержку.");
- $("#support_controlls").html("<label class='l_support_label' onclick='show_support_area();iarray.support_reply = true;'>Задать вопрос</label>");
- $("#support_controlls").fadeIn(300);
- }
- if (user.ulevel == 2) {
- $("#support_controlls").hide();
- }
- }
- });
- }
- }
- function render_user_services(user_id) {
- $(".user_services").remove();
- $("#pages").append("<div class='user_services'><p class='title'>Сервера клиента #" + user_id + "</p><div id='services_list'></div></div>");
- $.each(iarray.services, function(key, value) {
- if (value['user_id'] == user_id) {
- $(".user_services #services_list").append("<table class='service_item'><tr><td class='l_service_ip'><img src='" + iarray.games[value['game_id']].icon + "' class='icon-16-g'> " + value['ip'] + ":" + value['port'] + "</td><td class='l_preorder_slots'>" + value['slots'] + " слотов</td><td class='l_preorder_node'><img src='" + iarray.nodes[value['node_id']].icon + "' class='icon-16-f'> " + iarray.nodes[value['node_id']].name + "</td><td class='l_service_period'>До: " + dateformat(value['expires_date']) + "</td><td class='l_pay'><a class='l_edit_label' title='Панель управления' href='#service-" + value['id'] + "' onclick='iarray.service_active = " + value['id'] + "'>Управление</a></td><td></td></tr></table>");
- }
- window.location = '#user_services';
- $(".user_services #services_list").fadeIn(200);
- });
- }
- function show_support_area(page = false) {
- if (page) {
- $(".support-" + page + " #support_area").fadeIn(300);
- } else {
- $("#support_controlls").hide();
- $("#support_area").fadeIn(300);
- if (iarray.support_messages_t) {
- } else {
- $("#support_messages").text("");
- $("#support_close_button").hide();
- }
- }
- }
- function support_reply(page = false) {
- if (page) {
- if ($("#support_message-" + page).val().length >= 6 && $("#support_message-" + page).val().length <= 2048) {
- $.post(
- "/includes/back.php?func=support&reply", {
- message: $("#support_message-" + page).val(),
- user_id: page
- },
- function(info) {
- if (info.success == 1) {
- $(".support-" + page + " #support_messages").append("<table class='support_item'><tr><td class='support_avatar_item'><img src='/imgs/support-lvl-" + iarray.user.ulevel + ".png'></td><td class='support_message_item'>" + $("#support_message-" + page).val() + "</td></tr><tr><td colspan='2' class='support_date_item'>" + dateformat(new Date()) + "</td></tr></table>");
- $("#support_message-" + page).val('');
- $(".support-" + page + " #support_close_button").fadeIn(300);
- $("#support_link-" + page).css('opacity', 0.5);
- window.location = '#support';
- } else {
- d_error(info.error, 'support-' + page);
- }
- }
- );
- } else {
- d_error('Сообщение должно содержать от 6 до 2048 символов!', 'support-' + page);
- }
- } else {
- if ($("#support_message").val().length >= 6 && $("#support_message").val().length <= 2048) {
- $.post(
- "/includes/back.php?func=support&reply", {
- message: $("#support_message").val()
- },
- function(info) {
- if (info.success == 1) {
- $("#support_messages").append("<table class='support_item'><tr><td class='support_avatar_item'><img src='/imgs/support-lvl-" + iarray.user.ulevel + ".png'></td><td class='support_message_item'>" + $("#support_message").val() + "</td></tr><tr><td colspan='2' class='support_date_item'>" + dateformat(new Date()) + "</td></tr></table>");
- $("#support_message").val('');
- $("#support_close_button").fadeIn(300);
- iarray.support_messages_t = true;
- iarray.support_reply = false;
- } else {
- d_error(info.error, 'support');
- }
- }
- );
- } else {
- d_error('Сообщение должно содержать от 6 до 2048 символов!', 'support');
- }
- }
- }
- function support_close(page = false) {
- if (iarray.user.auth == true) {
- if (page) {
- if (confirm('Вы уверены что хотите закрыть запрос?')) {
- $.getJSON("/includes/back.php?func=support&close&user_id=" + page, function(data) {
- if (data.success == 1) {
- $(".support-" + page).remove();
- window.location = '#support';
- $("#support_link-" + page).fadeOut();
- } else {
- alert(data.error);
- }
- });
- }
- } else {
- if (confirm('Вы уверены что хотите закрыть запрос?')) {
- $("#support_messages").html("");
- $.getJSON("/includes/back.php?func=support&close", function(data) {
- if (data.success == 1) {
- iarray.support_messages_t = false;
- iarray.support_reply = false;
- $("#support_area").hide();
- $("#support_close_button").hide();
- $("#support_messages").text("У вас нет активных запросов в техническую поддержку.");
- $("#support_controlls").html("<label class='l_support_label' onclick='show_support_area()'>Задать вопрос</label>");
- $("#support_controlls").fadeIn(300);
- } else {
- alert(data.error);
- }
- });
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement