Версия 18:24, 23 сентября 2015 | | Текущая версия на 19:18, 24 сентября 2015 |
Строка 1: | | Строка 1: |
| /* Функционал всплывающих подсказок с ТТХ модулей для World of Warships */ | | | /* Функционал всплывающих подсказок с ТТХ модулей для World of Warships */ |
? | var isDropDownBox = false; | | |
? | | | |
? | var moduleImages = { | | |
? | 'Орудия главного калибра': 'https://wiki.gcdn.co/images/2/24/Module_wows_artillery.png', | | |
? | 'Корпус': 'https://wiki.gcdn.co/images/1/17/Module_wows_hull.png', | | |
? | 'Полётный контроль': 'https://wiki.gcdn.co/images/8/8e/Module_wows_flightcontrol.png', | | |
? | 'Двигатель': 'https://wiki.gcdn.co/images/a/aa/Module_wows_engine.png', | | |
? | 'Система управления огнём': 'https://wiki.gcdn.co/images/f/f8/Module_wows_suo.png', | | |
? | 'Торпеды': 'https://wiki.gcdn.co/images/4/47/Module_wows_torpedoes.png', | | |
? | 'Истребители': 'https://wiki.gcdn.co/images/d/de/Module_wows_fighter.png', | | |
? | 'Торпедоносцы': 'https://wiki.gcdn.co/images/a/a1/Module_wows_torpedobomber.png', | | |
? | 'Бомбардировщики': 'https://wiki.gcdn.co/images/0/01/Module_wows_divebomber.png' | | |
? | }; | | |
? | | | |
? | $('.commentDrop').hover( | | |
? | function(){ | | |
? | if (!isDropDownBox) { | | |
? | $('#bodyContent').append('<div id="dropDownBox" style="position:absolute;"></div>'); | | |
? | isDropDownBox = true; | | |
? | } | | |
? | var offset = $(this).position(); | | |
? | | | |
? | var top = offset.top + $(this).height(); | | |
? | | | |
? | var obj = $.parseJSON($(this).find(".commentData").text()); | | |
? | | | |
? | var str = '<div class="d-comment"><div class="d-comment-head"><div class="d-comment-img">' + '<img width="60" height="60" src="' + moduleImages[obj.type] + '" alt="">' + '</div><div class="d-comment-name"><h3>' + obj.type + '</h3><span>' + obj.mark + '</span></div></div><div class="b-performance_text d-comment-body"><table class="t-performance">'; | | |
? | | | |
? | var items = []; | | |
? | | | |
? | $.each(obj.data, function(key, val){ | | |
? | items.push('<tr><td><span class="t-performance_right">' + val + '</span><span class="t-performance_left">' + key + '</span></td></tr>'); | | |
? | }); | | |
? | | | |
? | str += items.join('') + '</table></div></div>'; | | |
? | | | |
? | $("#dropDownBox").html(str); | | |
? | $("#dropDownBox").css({"top": top + "px", "left":offset.left + "px"}) | | |
? | $("#dropDownBox").show(); | | |
? | }, | | |
? | function(){ | | |
? | $("#dropDownBox").hide(); | | |
? | }); | | |
? | | | |
| /* Old */ | | | /* Old */ |
| function populatePlayerCount() { | | | function populatePlayerCount() { |
Текущая версия на 19:18, 24 сентября 2015
/* Функционал всплывающих подсказок с ТТХ модулей для World of Warships */
/* Old */
function populatePlayerCount() {
var games = {
"#Game_Population_WoT": "wot",
"#Game_Population_WoWP": "wowp",
"#Game_Population_WoTB": "wotb"
},
requests = {
"https://api.worldoftanks.com/wgn/servers/info/": "51b1718552c3bc828e3157bf34fdbdb9",
"https://api.worldoftanks.eu/wgn/servers/info/": "3502193af04bb0572b876d77bd34bfac",
"https://api.worldoftanks.asia/wgn/servers/info/": "be786d54f31e79c2b15038bef5a5730f",
"https://api.worldoftanks.ru/wgn/servers/info/": "0d0ee38f8837ae7ce3bd62bbdf1401b8"
},
requestParameters = {
language: "en"
};
$.each(games || {}, function (selector, gameId) {
if ($(selector).length) {
$.each(requests || [], function (url, appId) {
var data = $.extend({
application_id: appId,
game: gameId
},
requestParameters || {});
$.get(url, data, function (data, textStatus, jqXHR) {
if (data.status == "ok") {
var gameDataContainer = $(selector).parents("div.wot-frame-1");
$.each(data.data[gameId] || [], function (index, server) {
var serverName = server.server;
gameDataContainer.find('tr[data-server="' + serverName + '"] .population-count-container').html(server.players_online);
});
}
});
});
}
});
}
$(document).ready(populatePlayerCount);