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

defined page_generic object

parent 934d765f
// update distributions var socket = io.connect('//' + config.hostname );
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>');
});
});
socket.on('error', function(data) { console.error(data) }); new Page_Generic().init(socket)
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)
})
if (window.location.pathname == config.paths.distribution) { if (window.location.pathname == config.paths.distribution) {
new Page_Distrubion().init(socket) new Page_Distrubion().init(socket)
......
...@@ -293,7 +293,7 @@ function Page_Distrubion() ...@@ -293,7 +293,7 @@ function Page_Distrubion()
update.page(old_data) update.page(old_data)
}); });
$(window).on('load', function (){ $(window).on('load', function () {
__check_hash_makes_sense() __check_hash_makes_sense()
populate() 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 @@ ...@@ -45,10 +45,10 @@
<script> <script>
var config = <%- JSON.stringify(web) %> var config = <%- JSON.stringify(web) %>
var socket = io.connect('//' + config.hostname );
</script> </script>
<script src='/javascripts/utils.js'></script> <script src='/javascripts/utils.js'></script>
<script src='/javascripts/page_generic.js'></script>
<script src='/javascripts/page_distribution.js'></script> <script src='/javascripts/page_distribution.js'></script>
<script src='/javascripts/main.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