Commit 1c07000c authored by Leo Iannacone's avatar Leo Iannacone

try to call socket io.connect() at right moment - it takes a while, so do not...

try to call socket io.connect() at right moment - it takes a while, so do not wait for make other things
parent 972f4cfd
var socket = io.connect('/'); // main client javascript
var preferences = new Preferences() var preferences = new Preferences()
var page_generic = new Page_Generic(socket) var page_generic = new Page_Generic()
if (window.location.pathname == config.paths.distribution) {
new Page_Distrubion(socket).start()
}
else if (window.location.pathname == config.paths.preferences) { if (window.location.pathname == config.paths.preferences) {
preferences.initPage() preferences.initPage()
} }
else if (window.location.pathname == '/') { if (window.location.pathname == '/') {
// convert email addresses in the right format // convert email addresses in the right format
var emails = $(".email") var emails = $(".email")
$.each(emails, function (){ $.each(emails, function (){
...@@ -24,4 +20,12 @@ else if (window.location.pathname == '/') { ...@@ -24,4 +20,12 @@ else if (window.location.pathname == '/') {
real_email = '<a href="mailto:' + real_email + subject + '">' + real_email + '</a>' real_email = '<a href="mailto:' + real_email + subject + '">' + real_email + '</a>'
$(this).html(real_email) $(this).html(real_email)
}) })
}
var socket = io.connect('/');
page_generic.start(socket)
if (window.location.pathname == config.paths.distribution) {
new Page_Distrubion(socket).start()
} }
\ No newline at end of file
function Page_Generic(socket) function Page_Generic()
{ {
var _e = config.events var _e = config.events
...@@ -114,25 +114,27 @@ function Page_Generic(socket) ...@@ -114,25 +114,27 @@ function Page_Generic(socket)
window.document.title = config.title window.document.title = config.title
} }
// update distributions this.start = function (socket) {
socket.on(_e.broadcast.distributions, function(socket_distributions) { // update distributions
debug_socket("received", _e.broadcast.distributions, socket_distributions) socket.on(_e.broadcast.distributions, function(socket_distributions) {
distributions.set(socket_distributions) debug_socket("received", _e.broadcast.distributions, 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, package_status) debug_socket("received", _e.broadcast.status_update, package_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) {
......
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