Commit 45373a00 authored by Leo Iannacone's avatar Leo Iannacone

defined page_generic object

parent 934d765f
// update distributions
socket.on(config.events.broadcast.distributions, function(distributions) {
$('#distributions ul').html('');
distributions.forEach(function (name){
$('#distributions ul').append('<li id="distribution-' + name +'"><a href="'+ config.paths.distribution + '#'+ name + '">' + name + '</li>');
});
});
var socket = io.connect('//' + config.hostname );
socket.on('error', function(data) { console.error(data) });
socket.on('status', function(data) {
console.log('status')
console.log(data)
})
socket.on(config.events.broadcast.status_update, function(data) {
console.log('status_update')
console.log(data)
})
new Page_Generic().init(socket)
if (window.location.pathname == config.paths.distribution) {
new Page_Distrubion().init(socket)
......
......@@ -293,7 +293,7 @@ function Page_Distrubion()
update.page(old_data)
});
$(window).on('load', function (){
$(window).on('load', function () {
__check_hash_makes_sense()
populate()
});
......
function Page_Generic()
{
var socket;
var update = {
distributions: function(distributions) {
$('#distributions ul').html('');
distributions.forEach(function (name){
$('#distributions ul').append('<li id="distribution-' + name +'"><a href="'+ config.paths.distribution + '#'+ name + '">' + name + '</li>');
});
if (window.location.pathname == config.paths.distribution) {
data = Utils.from_hash_to_data()
if (Utils.check_data_distribution(data)) {
$("#distributions li[id='distribution-" + data.distribution.name + "']").addClass('active')
}
}
}
}
this.init = function(mysocket) {
socket = mysocket
// update distributions
socket.on(config.events.broadcast.distributions, function(distributions) {
update.distributions(distributions)
});
socket.on('error', function(data) { console.error(data) });
socket.on('status', function(data) {
console.log('status')
console.log(data)
})
socket.on(config.events.broadcast.status_update, function(data) {
console.log('status_update')
console.log(data)
})
}
}
......@@ -45,10 +45,10 @@
<script>
var config = <%- JSON.stringify(web) %>
var socket = io.connect('//' + config.hostname );
</script>
<script src='/javascripts/utils.js'></script>
<script src='/javascripts/page_generic.js'></script>
<script src='/javascripts/page_distribution.js'></script>
<script src='/javascripts/main.js'></script>
......
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