About page, lots of fixin
This commit is contained in:
@@ -9,22 +9,22 @@ Ajax = (function() {
|
||||
if (data.status != null) {
|
||||
if (data.status === 'loading') {
|
||||
_search.showArtistPics(data.pics);
|
||||
return setTimeout(function() {
|
||||
setTimeout(function() {
|
||||
return _ajax.loadArtistData(name);
|
||||
}, 3000);
|
||||
} else if (data.status === 'corrected') {
|
||||
return _ajax.loadArtistData(data.page);
|
||||
_ajax.loadArtistData(data.page);
|
||||
} else if (data.status === 'suggestions') {
|
||||
_search.hideSpinner();
|
||||
return _search.showSuggestions(data.values);
|
||||
_search.showSuggestions(data.values);
|
||||
} else if (data.status === 'loading_failed') {
|
||||
_search.hideSpinner();
|
||||
return _search.showError();
|
||||
_search.showError();
|
||||
}
|
||||
return _beathaven.redrawScrollbar();
|
||||
} else {
|
||||
_ajax.setArchor('/artist/' + name + '/');
|
||||
_pages.renderArtist(data);
|
||||
return _beathaven.redrawScrollbar();
|
||||
return _pages.renderArtist(data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
@@ -50,6 +50,13 @@ Ajax = (function() {
|
||||
});
|
||||
return false;
|
||||
};
|
||||
Ajax.prototype.loadAboutPage = function() {
|
||||
$.get('/templates/about.html', function(data) {
|
||||
_pages.renderTextpage(data);
|
||||
return _ajax.setTitle('About');
|
||||
});
|
||||
return false;
|
||||
};
|
||||
Ajax.prototype.setArchor = function(anchor) {
|
||||
this.referer = this.getAnchor();
|
||||
return window.location.hash = '#' + anchor;
|
||||
@@ -72,6 +79,8 @@ Ajax = (function() {
|
||||
_ajax.loadSearchPage();
|
||||
} else if (_ajax.getAnchor().match(/\/settings\//)) {
|
||||
_ajax.loadSettingsPage();
|
||||
} else if (_ajax.getAnchor().match(/\/about\//)) {
|
||||
_ajax.loadAboutPage();
|
||||
} else {
|
||||
_ajax.loadSearchPage();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ _settings = null;
|
||||
$(function() {
|
||||
var l, _ref;
|
||||
l = document.location;
|
||||
if ((_ref = l.host) !== 'beathaven.org' && _ref !== 'localhost') {
|
||||
if ((_ref = l.host) !== 'beathaven.org' && _ref !== 'local.beathaven.org') {
|
||||
l.href = 'http://beathaven.org/' + l.hash;
|
||||
}
|
||||
_beathaven = new BeatHaven();
|
||||
@@ -28,7 +28,7 @@ BeatHaven = (function() {
|
||||
BeatHaven.prototype.init = function() {
|
||||
this.adjustSizes();
|
||||
this.checkRedrawScrollbar();
|
||||
_vkontakte = new Vkontakte(document.location.host === 'beathaven.org' ? 2335068 : 2383163);
|
||||
_vkontakte = new Vkontakte(2335068);
|
||||
_vkontakte.init();
|
||||
_ajax = new Ajax();
|
||||
_player = new Player();
|
||||
|
||||
@@ -52,6 +52,7 @@ Pages = (function() {
|
||||
$('.data-container .inner').html('').append(artist_info).append(albums_info);
|
||||
yaCounter7596904.hit(_ajax.getAnchor(), data.artist.name, _ajax.referer);
|
||||
_ajax.setTitle(data.artist.name);
|
||||
_beathaven.redrawScrollbar();
|
||||
return false;
|
||||
};
|
||||
Pages.prototype.renderSearch = function(data) {
|
||||
@@ -80,6 +81,10 @@ Pages = (function() {
|
||||
return false;
|
||||
};
|
||||
Pages.prototype.renderSettings = function(data) {
|
||||
if (_session.getUser().name == null) {
|
||||
_ajax.go('/search/');
|
||||
return false;
|
||||
}
|
||||
$('.data-container').css({
|
||||
background: 'none'
|
||||
});
|
||||
@@ -89,5 +94,17 @@ Pages = (function() {
|
||||
$('.settings-container .tabs .tab').first().trigger('click');
|
||||
return false;
|
||||
};
|
||||
Pages.prototype.renderTextpage = function(data) {
|
||||
$('.data-container').css({
|
||||
background: 'url(/images/concrete_wall_2.png) 0 -30px repeat'
|
||||
});
|
||||
$('.data-container .inner').html(data);
|
||||
_beathaven.redrawScrollbar();
|
||||
return false;
|
||||
};
|
||||
return Pages;
|
||||
})();
|
||||
})();
|
||||
$('.about').live('click', function() {
|
||||
_ajax.go('/about/');
|
||||
return false;
|
||||
});
|
||||
@@ -30,5 +30,10 @@ Session = (function() {
|
||||
$.post(url, q_params, callback);
|
||||
return false;
|
||||
};
|
||||
Session.prototype.reloadSession = function() {
|
||||
return _session.query('/user/auth', {}, function(ar) {
|
||||
return _session.setUser(ar.user);
|
||||
});
|
||||
};
|
||||
return Session;
|
||||
})();
|
||||
@@ -2,36 +2,54 @@ var Settings;
|
||||
Settings = (function() {
|
||||
function Settings() {}
|
||||
Settings.prototype.getAccountInfo = function(callback) {
|
||||
return _session.query('/user/update/', {}, callback);
|
||||
_session.query('/user/update/', {}, callback);
|
||||
return false;
|
||||
};
|
||||
Settings.prototype.saveAccountInfo = function(params, callback) {
|
||||
return _session.query('/user/update', params, callback);
|
||||
_session.query('/user/update', params, callback);
|
||||
return false;
|
||||
};
|
||||
Settings.prototype.loadFormData = function(form) {
|
||||
if (form === 'account') {
|
||||
$('.settings-container .form input[name$="username"]').val(_session.getUser().name);
|
||||
return $('.settings-container .form input[name$="email"]').val(_session.getUser().email);
|
||||
$('.settings-container .form input[name$="email"]').val(_session.getUser().email);
|
||||
} else if (form === 'lastfm') {
|
||||
if (_session.getUser().lastfm_username) {
|
||||
return $('.form-container input[name$="username"]').first().val(_session.getUser().lastfm_username);
|
||||
$('.form-container input[name$="username"]').first().val(_session.getUser().lastfm_username);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Settings.prototype.updateLastfmLogin = function() {
|
||||
if (window.lastfm_popup.closed) {
|
||||
_session.query('/user/auth', {}, function(ar) {
|
||||
_session.setUser(ar.user);
|
||||
return _settings.loadFormData('lastfm');
|
||||
});
|
||||
} else {
|
||||
setTimeout(_settings.updateLastfmLogin, 100);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
return Settings;
|
||||
})();
|
||||
$('.settings').live('click', function() {
|
||||
return _ajax.go('/settings/');
|
||||
_ajax.go('/settings/');
|
||||
return false;
|
||||
});
|
||||
$('.settings-container .tabs .tab').live('click', function() {
|
||||
if (!$(this).hasClass('active')) {
|
||||
$('.settings-container .tabs .tab').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
$('.form-container').html($('.forms .' + $(this).attr('data-fieldset')).html());
|
||||
return _settings.loadFormData($(this).attr('data-fieldset'));
|
||||
_settings.loadFormData($(this).attr('data-fieldset'));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$('.lastfm-connect').live('click', function() {
|
||||
return window.open(_session.getUser().lastfm_login_url);
|
||||
window.lastfm_popup = window.open(_session.getUser().lastfm_login_url);
|
||||
setTimeout(_settings.updateLastfmLogin, 100);
|
||||
return false;
|
||||
});
|
||||
$('.settings-container .form input').live('blur', function() {
|
||||
var active_tab, params;
|
||||
@@ -41,8 +59,10 @@ $('.settings-container .form input').live('blur', function() {
|
||||
username: $('.settings-container .form input[name$="username"]').first().val(),
|
||||
email: $('.settings-container .form input[name$="email"]').first().val()
|
||||
};
|
||||
return _settings.saveAccountInfo(params, function() {
|
||||
return $('#header-container .hello .greating').text('Hi there, ' + (params.username.length > 0 ? params.username : '%username%') + '!');
|
||||
_settings.saveAccountInfo(params, function() {
|
||||
$('.header-container .hello .greating span').text((params.username.length > 0 ? params.username : '%username%'));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
@@ -1,15 +1,24 @@
|
||||
var Vkontakte;
|
||||
Vkontakte = (function() {
|
||||
Vkontakte.prototype.qr = null;
|
||||
Vkontakte.prototype.api_id = null;
|
||||
function Vkontakte(api_id) {
|
||||
this.api_id = api_id;
|
||||
}
|
||||
Vkontakte.prototype.getApiId = function() {
|
||||
return this.api_id;
|
||||
};
|
||||
Vkontakte.prototype.init = function() {
|
||||
this.qr = [];
|
||||
VK.init({
|
||||
apiId: this.api_id
|
||||
});
|
||||
return VK.Auth.getLoginStatus(this.authInfo);
|
||||
window.vkAsyncInit = function() {
|
||||
VK.init({
|
||||
apiId: _vkontakte.getApiId()
|
||||
});
|
||||
return VK.Auth.getLoginStatus(_vkontakte.authInfo);
|
||||
};
|
||||
return setTimeout(function() {
|
||||
return $('#vk_api_transport').append('<script async="async" src="http://vkontakte.ru/js/api/openapi.js"></script>');
|
||||
}, 0);
|
||||
};
|
||||
Vkontakte.prototype.authInfo = function(response) {
|
||||
var _session;
|
||||
@@ -31,20 +40,22 @@ Vkontakte = (function() {
|
||||
name: r.response
|
||||
}, function(ar2) {
|
||||
_session.setUser(ar2.user);
|
||||
return $('.header-container .hello .greating').text('Hi there, ' + (_session.getUser().name ? _session.getUser().name : '%username%') + '!');
|
||||
return $('.header-container .hello .greating').html('Tēnā koe, <span class="settings">' + (_session.getUser().name ? _session.getUser().name : '%username%') + '</span>!');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
_session.setUser(ar.user);
|
||||
}
|
||||
return $('.header-container .hello .greating').text('Hi there, ' + (_session.getUser().name ? _session.getUser().name : '%username%') + '!');
|
||||
$('.header-container .hello').show();
|
||||
return $('.header-container .hello .greating').html('Tēnā koe, <span class="settings">' + (_session.getUser().name ? _session.getUser().name : '%username%') + '</span>!');
|
||||
});
|
||||
} else {
|
||||
_session = new Session({});
|
||||
_session.setUser({});
|
||||
$('#vk_login, .auth_notice').css({
|
||||
display: 'block'
|
||||
});
|
||||
$('#vk_logout').hide();
|
||||
$('.header-container .hello').hide();
|
||||
}
|
||||
return window._session = _session;
|
||||
};
|
||||
@@ -117,11 +128,15 @@ Vkontakte = (function() {
|
||||
};
|
||||
return Vkontakte;
|
||||
})();
|
||||
$(function() {
|
||||
$('#vk_login').click(function() {
|
||||
return VK.Auth.login(_vkontakte.authInfo(), 8);
|
||||
});
|
||||
return $('#vk_logout').click(function() {
|
||||
return VK.Auth.logout(_vkontakte.authInfo());
|
||||
});
|
||||
$('#vk_login').live('click', function() {
|
||||
VK.Auth.login(function(response) {
|
||||
_vkontakte.authInfo(response);
|
||||
return false;
|
||||
}, 8);
|
||||
return false;
|
||||
});
|
||||
$('#vk_logout').live('click', function() {
|
||||
_ajax.go('/search/');
|
||||
VK.Auth.logout(_vkontakte.authInfo);
|
||||
return false;
|
||||
});
|
||||
Reference in New Issue
Block a user