diff --git a/assets/js/site.js b/assets/js/site.js index 74a78da..fbe9219 100644 --- a/assets/js/site.js +++ b/assets/js/site.js @@ -126,13 +126,6 @@ function sortServers() { } } -function renderPercentageBarText(server) { - var totalPlayers = getCurrentTotalPlayers(); - var playerCount = lastPlayerEntries[server]; - - showCaption('' + server + ': ' + formatNumber(playerCount) + ' online. ' + roundToPoint(playerCount / totalPlayers * 100, 10) + '% of ' + formatNumber(totalPlayers) + ' tracked players.'); -} - function updatePercentageBar() { var keys = Object.keys(lastPlayerEntries); @@ -164,12 +157,11 @@ function updatePercentageBar() { div = $('#perc_bar_part_' + safeNameCopy); div.mouseover(function(e) { - renderPercentageBarText(server); currentServerHover = server; }); div.mouseout(function(e) { - hideCaption(); + hideTooltip(); currentServerHover = undefined; }); } @@ -185,8 +177,6 @@ function updatePercentageBar() { leftPadding += width; })(i, keys[i], keys.length); } - - if (currentServerHover) renderPercentageBarText(currentServerHover); } function getCurrentTotalPlayers() { @@ -300,6 +290,9 @@ $(document).ready(function() { $('#big-graph-checkboxes').html(''); $('#big-graph-controls').css('display', 'none'); + $('#perc-bar').html(''); + $('.mojang-status').css('background', 'transparent'); + $("#stat_totalPlayers").text(0); $("#stat_networks").text(0); @@ -527,6 +520,15 @@ $(document).ready(function() { } }); + $(document).on('mousemove', function(e) { + if (currentServerHover) { + var totalPlayers = getCurrentTotalPlayers(); + var playerCount = lastPlayerEntries[currentServerHover]; + + renderTooltip(e.pageX + 10, e.pageY + 10, '' + currentServerHover + ': ' + roundToPoint(playerCount / totalPlayers * 100, 10) + '%
' + formatNumber(playerCount) + ' of ' + formatNumber(totalPlayers) + ' tracked players.'); + } + }); + $(window).on('resize', function() { updatePercentageBar();