Allow the server to control category visibility

This commit is contained in:
Cryptkeeper 2016-02-23 19:19:15 -06:00
parent 28160054c0
commit 9ac6502394
4 changed files with 21 additions and 19 deletions

@ -10,8 +10,6 @@ var isConnected = false;
var mojangServicesUpdater;
var sortServersTask;
var categoriesVisible = true;
function updateServerStatus(lastEntry) {
var info = lastEntry.info;
var div = $('#status_' + safeName(info.name));
@ -108,19 +106,6 @@ function sortServers() {
}
}
function setCategoriesVisible(newCategoriesVisible) {
categoriesVisible = newCategoriesVisible;
$('.category-header').css('display', (categoriesVisible ? 'block' : 'none'));
$('.server-container').css('margin', (categoriesVisible ? '10px auto' : '0 auto'));
sortServers();
if (typeof(localStorage)) {
localStorage.setItem('categoriesVisible', categoriesVisible);
}
}
function setAllGraphVisibility(visible) {
if (visible) {
var keys = Object.keys(hiddenGraphData);
@ -305,8 +290,6 @@ $(document).ready(function() {
});
socket.on('add', function(servers) {
createCategories();
if (Object.keys(publicConfig.categories).length > 0) {
$('#category-controller').css('display', 'block');
}

@ -6,9 +6,26 @@ var lastMojangServiceUpdate;
var publicConfig;
var createdCategories = false;
var categoriesVisible;
function setPublicConfig(json) {
publicConfig = json;
$('#server-container-list').html('');
createdCategories = false;
createCategories();
setCategoriesVisible(publicConfig.categoriesVisible);
}
function setCategoriesVisible(newCategoriesVisible) {
categoriesVisible = newCategoriesVisible;
$('.category-header').css('display', (categoriesVisible ? 'block' : 'none'));
$('.server-container').css('margin', (categoriesVisible ? '10px auto' : '0 auto'));
sortServers();
}
function createCategories() {

@ -31,5 +31,6 @@
"major": "Major Networks",
"midsized": "Midsized Networks",
"small": "Small Networks"
}
},
"categoriesVisible": true
}

@ -67,7 +67,8 @@ function handleRequest(req, res) {
categories: categories,
graphDuration: config.graphDuration,
servers: servers,
bootTime: util.getBootTime()
bootTime: util.getBootTime(),
categoriesVisible: config.categoriesVisible || false
};
res.write('setPublicConfig(' + JSON.stringify(publicConfig) + ');');