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 page_generic = new Page_Generic(socket)
if (window.location.pathname == config.paths.distribution) {
new Page_Distrubion(socket).start()
}
var page_generic = new Page_Generic()
else if (window.location.pathname == config.paths.preferences) {
if (window.location.pathname == config.paths.preferences) {
preferences.initPage()
}
else if (window.location.pathname == '/') {
if (window.location.pathname == '/') {
// convert email addresses in the right format
var emails = $(".email")
$.each(emails, function (){
......@@ -25,3 +21,11 @@ else if (window.location.pathname == '/') {
$(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
......@@ -114,6 +114,7 @@ function Page_Generic(socket)
window.document.title = config.title
}
this.start = function (socket) {
// update distributions
socket.on(_e.broadcast.distributions, function(socket_distributions) {
debug_socket("received", _e.broadcast.distributions, socket_distributions)
......@@ -133,6 +134,7 @@ function Page_Generic(socket)
socket.on(_e.error, function(error) {
console.error("socket > " + error)
})
}
// select current page in navbar
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