IW4M-Admin/Admin/webfront/players.html

118 lines
3.4 KiB
HTML
Raw Normal View History

<script>
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
var curFrom = 0;
function getNextPage() {
curFrom += 15;
return curFrom;
}
function getPrevPage() {
if ((curFrom - 15) >= 0) {
curFrom -= 15;
return (curFrom);
}
else {
curFrom = 0;
return 0;
}
}
function printPlayer(player, i) {
var p = "";
p +=
"<div class=\"playerInfo table alternate_" + i % 2 + "\"> \
<div class=\"tableCell\"><a href=\"/profile?id=" + player['playerID'] + "\">" + escapeHtml(player['playerName']) + "</a></div> \
<div class=\"tableCell\">" + getColorForLevel(player['playerLevel'], player['playerLevel']) + "</div>";
p +=
"<div class=\"tableCell alignRight\">" + checkJustNow(player['LastSeen']) + " ago</div> \
</div>";
$("#playersTable").append(p);
}
function getPlayer(ident, identValue) {
$("#playersTable").html("");
$(".loader").fadeIn();
$.getJSON("/getplayer?" + ident + "=" + identValue, function (result) {
$.each(result, function (i, player) {
printPlayer(player, i);
});
}).done(function (data) {
$(".loader").fadeOut();
}).fail(function () {
$(".loader").fadeOut();
});
}
function getRecentPlayers(offset) {
$("#playersTable").html("");
$(".loader").fadeIn();
$.getJSON("/getplayer?recent=1&offset=" + offset, function (result) {
$.each(result, function (i, player) {
printPlayer(player, i);
});
}).done(function (data) { $(".loader").fadeOut(); })
.error(function (data) { $(".loader").fadeOut(); })
}
$(document).ready(function () {
if (parseGet('id') != "undefined")
getPlayer('id', parseGet('id'));
else if (parseGet('name') != "undefined")
getPlayer('name', parseGet('name'));
else {
getRecentPlayers(0);
}
});
$('#content').on('click', 'div.hiddenWrapper span', function () {
$(this).parent().find('.hiddenElements').toggle()
});
</script>
<div class="playerSearchWrap">
<input type="button" class="searchButton" name="Search" value="Search" />
<input type="text" class="search" placeholder="Player Name..." />
</div>
<div class="contentHeader table">
<div class="contentColumn tableCell">Name</div>
<div class="contentColumn tableCell">Level</div>
<div class="contentColumn tableCell alignRight">Last Seen</div>
</div>
<div id="playersTable">
</div>
<hr />
<div id="paginationButtons" class="table">
<div id="previousPage" class="tableCell"><a href=# onclick="getRecentPlayers(getPrevPage())"><<</a></div>
<div id="nextPage" class="tableCell"><a href=# onclick="getRecentPlayers(getNextPage())">>></a></div>
</div>
<script>
$('.searchButton').click(function () {
if ($('.search').val().length > 0)
getPlayer('name', $('.search').val());
});
$(document).keypress(function (e) {
if (e.which == 13) {
$('.searchButton').click();
}
});
</script>