Commit 59aabfde authored by Leo Iannacone's avatar Leo Iannacone

removed init function (useless) and added header() to show/hide header according with preferences

parent ee9f86a1
...@@ -2,7 +2,7 @@ var socket = io.connect('//' + config.hostname ); ...@@ -2,7 +2,7 @@ var socket = io.connect('//' + config.hostname );
var preferences = new Preferences() var preferences = new Preferences()
new Page_Generic().init(socket) var page_generic = new Page_Generic(socket)
if (window.location.pathname == config.paths.distribution) { if (window.location.pathname == config.paths.distribution) {
new Page_Distrubion(socket).start() new Page_Distrubion(socket).start()
......
function Page_Generic() function Page_Generic(socket)
{ {
var socket; var _e = config.events
function __get_status_html(status_package) { function __get_status_html(status_package) {
var s = status_package var s = status_package
...@@ -88,34 +88,42 @@ function Page_Generic() ...@@ -88,34 +88,42 @@ function Page_Generic()
}, },
} }
this.init = function(mysocket) { this.header = function() {
if (config.preferences.header) {
var _e = config.events $("#pageheader").show()
socket = mysocket $(".navbar .home-link").hide()
}
else {
$("#pageheader").hide()
$(".navbar .home-link").show()
}
}
// update distributions // update distributions
socket.on(_e.broadcast.distributions, function(socket_distributions) { socket.on(_e.broadcast.distributions, function(socket_distributions) {
debug_socket("received", _e.broadcast.distributions, socket_distributions) debug_socket("received", _e.broadcast.distributions, socket_distributions)
distributions.set(socket_distributions) distributions.set(socket_distributions)
}); });
socket.on(_e.client.status, function(packages_status) { socket.on(_e.client.status, function(packages_status) {
debug_socket("received", _e.client.status, packages_status) debug_socket("received", _e.client.status, packages_status)
status.set(packages_status) status.set(packages_status)
}) })
socket.on(_e.broadcast.status_update, function(package_status) { socket.on(_e.broadcast.status_update, function(package_status) {
debug_socket("received", _e.broadcast.status_update, packages_status) debug_socket("received", _e.broadcast.status_update, packages_status)
status.update(package_status) status.update(package_status)
}) })
socket.on(_e.error, function(error) { socket.on(_e.error, function(error) {
console.error("socket > " + error) console.error("socket > " + error)
}) })
// select current page in navbar // select current page in navbar
if (window.location.pathname != config.paths.distribution) { if (window.location.pathname != config.paths.distribution) {
$(".navbar li a[href='" + window.location.pathname + "']").parent().addClass("active") $(".navbar li a[href='" + window.location.pathname + "']").parent().addClass("active")
}
} }
this.header()
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment