133 lines
7.4 KiB
JavaScript
133 lines
7.4 KiB
JavaScript
let bar = new Nanobar();
|
|
|
|
function loadPlayer() {
|
|
$.ajax({
|
|
url: '/tools/csgo/data/' + $('#player-id').text(),
|
|
method: 'GET',
|
|
success: function (result) {
|
|
console.log(result);
|
|
var playerName = $('#player-name');
|
|
if (result.player_exists) {
|
|
$('#player-id').text(result.id);
|
|
$('.player-url').attr('href', "http://steamcommunity.com/id/" + result.id);
|
|
playerName.text(result.name);
|
|
$('#player-loc').append(" " + result.location);
|
|
$('#player-flag').addClass("flag-icon-" + result.country.toLowerCase());
|
|
$('#player-logo').html("<img src='" + result.avatar + "' alt='Avatar' class='img-fluid img-rounded'>");
|
|
$('#online-status').addClass(result.onStat).text(result.status);
|
|
$('#online-status-message').text(result.statusMes);
|
|
|
|
if (result.player_owns_game) {
|
|
$('.kills .value').text(result.total_kills);
|
|
$('.time_played .value').text(result.total_time_played);
|
|
$('.accuracy .value').text(result.total_accuracy);
|
|
$('.headshots .value').text(result.total_headshot_rate);
|
|
$('.mvps .value').text(result.total_mvps);
|
|
$('.wins .value').text(result.total_win_rate);
|
|
$('.bombs .value').text(result.total_planted_bombs);
|
|
$('.hostages .value').text(result.total_rescued_hostages);
|
|
$('.lastmatch #wins').text(result.last_match_wins);
|
|
$('.lastmatch #rounds').text(result.last_match_rounds);
|
|
$('.result').addClass(result.last_match_result);
|
|
$('.outcome').append(result.last_match_outcome);
|
|
if (result.last_match_result === 'win') {
|
|
$('.result .outcome').append('<svg><use xlink:href="#i-win-cup" ></use></svg>');
|
|
}
|
|
$('.lastmatch .weapon .fa').replaceWith('<svg class="icon"><use xlink:href="#i-' + result.weapon_list[result.last_match_favweapon_id][1] + '"></use></svg>');
|
|
$('.lastmatch .weapon .name').text(result.weapon_list[result.last_match_favweapon_id][0]);
|
|
$('.lastmatch .stats .stat.kills').html(result.last_match_favweapon_kills + ' <svg><use xlink:href="#i-kills"></use></svg>');
|
|
$('.lastmatch .stats .stat.accuracy').html(result.last_match_favweapon_accuracy + ' <svg><use xlink:href="#i-target-small"></use></svg>');
|
|
$('#kd').text(result.last_match_kd);
|
|
$('#kills').text(result.last_match_kills);
|
|
$('#deaths').text(result.last_match_deaths);
|
|
$('#mvps').text(result.last_match_mvps);
|
|
$('#damage').text(result.last_match_damage + " HP");
|
|
$('#money_spent').text(result.last_match_money_spent + " $");
|
|
$('#dominations').text(result.last_match_dominations);
|
|
$('#revenges').text(result.last_match_revenges);
|
|
$('#contribution_score').text(result.last_match_contribution_score);
|
|
$('.weapons .content').html(result.favweapons);
|
|
|
|
$('#total_kills').find('span').text(result.total_kills);
|
|
$('#total_deaths').find('span').text(result.total_deaths);
|
|
$('#total_kd').find('span').text(result.total_kd);
|
|
$('#total_score').find('span').text(result.total_contribution_score);
|
|
$('#total_damage').find('span').text(result.total_damage_done);
|
|
$('#total_shots').find('span').text(result.total_shots_fired);
|
|
$('#total_hits').find('span').text(result.total_shots_hit);
|
|
$('#total_accuracy').find('span').text(result.total_accuracy);
|
|
$('#total_headshots').find('span').text(result.total_kills_headshot);
|
|
$('#total_headshot_percent').find('span').text(result.total_headshot_rate);
|
|
$('#total_dominations').find('span').text(result.total_dominations);
|
|
$('#total_revenges').find('span').text(result.total_revenges);
|
|
$('#total_time_played').find('span').text(result.total_time_played);
|
|
$('#total_matches').find('span').text(result.total_matches_played);
|
|
$('#total_matches_won').find('span').text(result.total_matches_won);
|
|
$('#total_matches_won_percent').find('span').text(result.total_matches_won_percent);
|
|
$('#total_rounds').find('span').text(result.total_rounds_played);
|
|
$('#total_rounds_won').find('span').text(result.total_wins);
|
|
$('#total_rounds_won_percent').find('span').text(result.total_win_rate);
|
|
$('#total_mvp').find('span').text(result.total_mvps);
|
|
$('#total_pistol_rounds_won').find('span').text(result.total_wins_pistolround);
|
|
$('#total_bombs_planted').find('span').text(result.total_planted_bombs);
|
|
$('#total_bombs_defused').find('span').text(result.total_defused_bombs);
|
|
$('#total_enemies_blinded_killed').find('span').text(result.total_kills_enemy_blinded);
|
|
$('#total_knife_fights_won').find('span').text(result.total_kills_knife_fight);
|
|
$('#total_aiming_snipers_killed').find('span').text(result.total_kills_against_zoomed_sniper);
|
|
$('#total_taser_kills').find('span').text(result.total_kills_taser);
|
|
$('#total_kills_enemy_weapon').find('span').text(result.total_kills_enemy_weapon);
|
|
$('#total_money_earned').find('span').text(result.total_money_earned);
|
|
$('#total_weapon_spent').find('span').text(result.total_weapons_donated);
|
|
$('#total_windows_broken').find('span').text(result.total_broken_windows);
|
|
} else {
|
|
playerName.append('<small style="color:red">Dieser Spieler besitzt das Spiel Counter Strike: Global Offensive nicht!</small>')
|
|
}
|
|
} else {
|
|
playerName.html('<span style="color:red">Dieser Spieler existiert auf Steam nicht!</span>')
|
|
}
|
|
},
|
|
error: function () {
|
|
$('.fa-cog.fa-spin').removeClass("fa-cog").removeClass("fa-spin").addClass('fa-warning').css('color', 'red');
|
|
},
|
|
complete: function () {
|
|
bar.go(100);
|
|
},
|
|
timeout: 10000
|
|
});
|
|
}
|
|
|
|
$(window).ready(function () {
|
|
loadPlayer();
|
|
});
|
|
|
|
$(window).keydown(function (event) {
|
|
if (event.keyCode === 13) {
|
|
event.preventDefault();
|
|
bar = new Nanobar();
|
|
bar.go(20);
|
|
$('#player-id').text($('#search-input').val());
|
|
defaultPage();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
function defaultPage() {
|
|
$.ajax({
|
|
url: '/tools/csgo/getDefaultPage/' + $('#player-id').text(),
|
|
method: 'GET',
|
|
success: function (data) {
|
|
bar.go(40);
|
|
$('#csgo').replaceWith(data);
|
|
loadPlayer();
|
|
window.history.pushState("object or string", "CS:GO Tools | KingOfDog", "/tools/csgo/" + $('#player-id').text());
|
|
}
|
|
});
|
|
}
|
|
|
|
var delay = (function () {
|
|
var timer = 0;
|
|
return function (callback, ms) {
|
|
clearTimeout(timer);
|
|
timer = setTimeout(callback, ms);
|
|
};
|
|
})(); |