2011-06-27 20:43:54 +00:00
|
|
|
var BeatHaven, _ajax, _beathaven, _pages, _player, _search, _session, _settings, _vkontakte;
|
|
|
|
_beathaven = null;
|
|
|
|
_session = 1;
|
|
|
|
_vkontakte = null;
|
|
|
|
_ajax = null;
|
|
|
|
_player = null;
|
|
|
|
_search = null;
|
|
|
|
_pages = null;
|
|
|
|
_settings = null;
|
|
|
|
$(function() {
|
|
|
|
var l, _ref;
|
|
|
|
l = document.location;
|
2011-06-29 04:11:54 +00:00
|
|
|
if ((_ref = l.host) !== 'beathaven.org' && _ref !== 'local.beathaven.org') {
|
2011-06-27 20:43:54 +00:00
|
|
|
l.href = 'http://beathaven.org/' + l.hash;
|
|
|
|
}
|
|
|
|
_beathaven = new BeatHaven();
|
|
|
|
_beathaven.init();
|
|
|
|
$(window).resize(function() {
|
|
|
|
return _beathaven.adjustSizes();
|
2011-06-27 18:41:36 +00:00
|
|
|
});
|
2011-06-27 20:43:54 +00:00
|
|
|
return window.setTimeout(function() {
|
|
|
|
return _beathaven.checkRedrawScrollbar();
|
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
BeatHaven = (function() {
|
|
|
|
function BeatHaven() {}
|
|
|
|
BeatHaven.prototype.last_height = false;
|
|
|
|
BeatHaven.prototype.init = function() {
|
|
|
|
this.adjustSizes();
|
|
|
|
this.checkRedrawScrollbar();
|
2011-06-29 04:11:54 +00:00
|
|
|
_vkontakte = new Vkontakte(2335068);
|
2011-06-27 20:43:54 +00:00
|
|
|
_vkontakte.init();
|
|
|
|
_ajax = new Ajax();
|
|
|
|
_player = new Player();
|
|
|
|
_player.initJplayer();
|
|
|
|
_search = new Search();
|
|
|
|
_pages = new Pages();
|
|
|
|
_settings = new Settings();
|
|
|
|
return _ajax.detectPage();
|
2011-06-27 18:41:36 +00:00
|
|
|
};
|
2011-06-27 20:43:54 +00:00
|
|
|
BeatHaven.prototype.adjustSizes = function() {
|
|
|
|
$('.data-container').height($(window).height() - $('.header-container').height());
|
|
|
|
$('.data-container').width($(window).width() - $('.player').width());
|
|
|
|
$('.player-container').height($(window).height());
|
|
|
|
$('.playlist').height($(window).height() - $('.player').height() - $('.player-container .additional-controls').height());
|
|
|
|
$('.data-container').scrollbar();
|
|
|
|
return $('.playlist').scrollbar();
|
|
|
|
};
|
|
|
|
BeatHaven.prototype.checkRedrawScrollbar = function() {
|
|
|
|
var focused_id, outer_height;
|
|
|
|
focused_id = false;
|
|
|
|
if (document.activeElement.id != null) {
|
|
|
|
focused_id = document.activeElement.id;
|
2011-06-27 18:41:36 +00:00
|
|
|
}
|
2011-06-27 20:43:54 +00:00
|
|
|
outer_height = $('.data-container > div').outerHeight();
|
|
|
|
if (outer_height > 300 && outer_height !== this.last_height) {
|
|
|
|
this.last_height = outer_height;
|
|
|
|
this.redrawScrollbar();
|
2011-06-27 18:41:36 +00:00
|
|
|
}
|
2011-06-27 20:43:54 +00:00
|
|
|
if (focused_id) {
|
|
|
|
document.getElementById(focused_id).focus();
|
|
|
|
focused_id = false;
|
2011-06-27 18:41:36 +00:00
|
|
|
}
|
2011-06-27 20:43:54 +00:00
|
|
|
return window.setTimeout(function() {
|
|
|
|
return _beathaven.checkRedrawScrollbar();
|
|
|
|
}, 500);
|
|
|
|
};
|
|
|
|
BeatHaven.prototype.redrawScrollbar = function() {
|
|
|
|
$('.data-container').html($('.data-container').find('.inner').first());
|
|
|
|
return $('.data-container').scrollbar();
|
2011-06-27 18:41:36 +00:00
|
|
|
};
|
2011-06-27 20:43:54 +00:00
|
|
|
return BeatHaven;
|
|
|
|
})();
|
|
|
|
String.prototype.htmlsafe = function() {
|
|
|
|
var item, replaces, str, _i, _len;
|
|
|
|
replaces = [["\\", "\\\\"], ["\"", """], ["<", "<"], [">", ">"]];
|
|
|
|
str = this;
|
|
|
|
for (_i = 0, _len = replaces.length; _i < _len; _i++) {
|
|
|
|
item = replaces[_i];
|
|
|
|
str = str.replace(item[0], item[1]);
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
};
|
|
|
|
String.prototype.trim = function() {
|
|
|
|
var str;
|
|
|
|
str = this;
|
|
|
|
while (str.indexOf(' ') !== -1) {
|
|
|
|
str = str.replace(' ', ' ');
|
|
|
|
}
|
|
|
|
if (str.charAt(0) === ' ') {
|
|
|
|
str = str.substring(1);
|
|
|
|
}
|
|
|
|
if (str.charAt(str.length - 1) === ' ') {
|
|
|
|
str = str.substring(0, str.length - 1);
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
};
|