66 lines
1.8 KiB
JavaScript
66 lines
1.8 KiB
JavaScript
$(function(){
|
|
if (document.location.host != 'beathaven.org' && document.location.host != 'localhost') {
|
|
document.location.href = 'http://beathaven.org/'+ document.location.hash;
|
|
}
|
|
beathaven.init();
|
|
$(window).resize(beathaven.adjustSizes)
|
|
window.setTimeout(beathaven.checkRedrawScrollbar, 500);
|
|
})
|
|
var beathaven = {
|
|
|
|
last_height: false,
|
|
|
|
init: function () {
|
|
this.drawInterface();
|
|
this.adjustSizes();
|
|
Ajax.detectPage();
|
|
},
|
|
|
|
drawInterface: function() {
|
|
},
|
|
|
|
adjustSizes: function() {
|
|
$('#data-container').height($(window).height() - $('#header-container').height());
|
|
$('#data-container').width($(window).width() - $('#player').width()).scrollbar();
|
|
$('#player-container').height($(window).height());
|
|
$('#playlist').height($(window).height() - $('#player').height() - $('#player-container .additional-controls').height());
|
|
|
|
$('#playlist').scrollbar();
|
|
},
|
|
|
|
checkRedrawScrollbar: function() {
|
|
var focused_id = false;
|
|
if (typeof document.activeElement.id !== 'undefined') {
|
|
focused_id = document.activeElement.id;
|
|
}
|
|
var outer_height = $('#data-container > div').outerHeight();
|
|
if (outer_height > 300 && outer_height != beathaven.last_height) {
|
|
beathaven.last_height = outer_height;
|
|
beathaven.redrawScrollbar();
|
|
}
|
|
if (focused_id) {
|
|
document.getElementById(focused_id).focus();
|
|
focused_id = false;
|
|
}
|
|
window.setTimeout(beathaven.checkRedrawScrollbar, 500);
|
|
},
|
|
|
|
redrawScrollbar: function() {
|
|
$('#data-container').html($('#data-container').find('.inner').first());
|
|
$('#data-container').scrollbar();
|
|
}
|
|
}
|
|
|
|
String.prototype.htmlsafe = function() {
|
|
var replaces = [
|
|
["\\", "\\\\"],
|
|
["\"", """],
|
|
["<", "<"],
|
|
[">", ">"]
|
|
];
|
|
var str = this;
|
|
for (var i = 0; i < replaces.length; i++) {
|
|
str = str.replace(replaces[i][0], replaces[i][1]);
|
|
}
|
|
return str;
|
|
} |