Commit 8567dd74 authored by Leo Iannacone's avatar Leo Iannacone

we do not really need to wait window.on('load') event because scripts are...

we do not really need to wait window.on('load') event because scripts are located on the pottom of layout.ejs, so when they run html is already loaded - removed
parent 11b20007
...@@ -508,37 +508,35 @@ function Page_Distrubion(socket) ...@@ -508,37 +508,35 @@ function Page_Distrubion(socket)
debug(1, "changing view", "old:", old_view, "new:", new_view) debug(1, "changing view", "old:", old_view, "new:", new_view)
}); });
$(window).on('load', function () { if (! __check_hash_makes_sense())
if (! __check_hash_makes_sense()) return
return populate()
populate()
// Init sticky-package back_on_top on click
// Init sticky-package back_on_top on click $("#sticky-package").on("click", function(){
$("#sticky-package").on("click", function(){ $('html').animate({scrollTop: 0}, 100);
$('html').animate({scrollTop: 0}, 100); })
})
// WORKAROUND:
// WORKAROUND: // when page is loaded sidebar has offset().top
// when page is loaded sidebar has offset().top // equals 0. This is because html is loaded on socket
// equals 0. This is because html is loaded on socket // events. Sleep a while and call stiky.reset()
// events. Sleep a while and call stiky.reset() setTimeout(sticky.reset, 500);
this.setTimeout(sticky.reset, 500);
// WORKAROUND:
// WORKAROUND: // On incoming hundred of lines browser goes crazy.
// On incoming hundred of lines browser goes crazy. // Append lines every 200 mills.
// Append lines every 200 mills. function watch_for_new_lines() {
function watch_for_new_lines() { if (new_lines.length > 0) {
if (new_lines.length > 0) { file.append(new_lines.join(''))
file.append(new_lines.join('')) new_lines = []
new_lines = []
}
setTimeout(watch_for_new_lines, 200);
} }
watch_for_new_lines() setTimeout(watch_for_new_lines, 200);
}
watch_for_new_lines()
// Update html according with preferences // Update html according with preferences
preferences() preferences()
});
}
}
} }
...@@ -22,32 +22,28 @@ function Preferences() { ...@@ -22,32 +22,28 @@ function Preferences() {
// init prefence page // init prefence page
this.initPage = function() { this.initPage = function() {
$(window).on('load', function() { // set view according with config.preferences
for (key in config.preferences) {
// set view according with config.preferences var element = $("#preferences #" + key)
for (key in config.preferences) { if (element.attr('type') == "checkbox") {
var element = $("#preferences #" + key) element.prop('checked', config.preferences[key])
if (element.attr('type') == "checkbox") {
element.prop('checked', config.preferences[key])
}
else {
element.val(config.preferences[key])
}
} }
else {
element.val(config.preferences[key])
}
}
// on input change, set prefence // on input change, set prefence
$("#preferences input, #preferences select").change(function() { $("#preferences input, #preferences select").change(function() {
var key = $(this).attr('id') var key = $(this).attr('id')
var value = $(this).val() var value = $(this).val()
if ($(this).attr('type') == 'checkbox') if ($(this).attr('type') == 'checkbox')
value = $(this).is(':checked') value = $(this).is(':checked')
set(key,value) set(key,value)
// give to user an immediate feedback on show header // give to user an immediate feedback on show header
if (key == "header") { if (key == "header") {
page_generic.header() page_generic.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