1
0
Fork 0

Fixed album url. Closes #44

This commit is contained in:
magnolia-fan 2011-06-17 19:13:47 +04:00
parent 48ab2826aa
commit 7e0db9074e
2 changed files with 11 additions and 14 deletions

View File

@ -2,7 +2,7 @@ var Ajax = {
loadArtistData: function(name) { loadArtistData: function(name) {
$('#search-container input').attr('disabled', 'disabled').blur(); $('#search-container input').attr('disabled', 'disabled').blur();
$('#search-container img').show(); $('#search-container img').show();
name = name.replace(' ', '+'); name = name.split(' ').join('+');
Ajax.setArchor('/artist/'+ name +'/'); Ajax.setArchor('/artist/'+ name +'/');
$.get('/artist/'+ name +'/', function(data){ $.get('/artist/'+ name +'/', function(data){
if (typeof data.error != 'undefined') { if (typeof data.error != 'undefined') {
@ -51,24 +51,20 @@ var Ajax = {
}, },
setArchor: function(anchor) { setArchor: function(anchor) {
window.location = '#'+ anchor; window.location.hash = '#'+ anchor;
}, },
getAnchor: function() { getAnchor: function() {
var tmp = window.location.href.split('#'); return window.location.hash.substring(1);
if (typeof tmp[1] !== 'undefined') {
return tmp[1];
}
return '';
}, },
detectStartPage: function() { detectPage: function() {
if (m = this.getAnchor().match(/\/artist\/(.+)\//)) { if (m = Ajax.getAnchor().match(/\/artist\/(.+)\//)) {
this.loadArtistData(m[1]); Ajax.loadArtistData(m[1]);
} else if (this.getAnchor() === '' || this.getAnchor().match(/\/search\//)) { } else if (Ajax.getAnchor() === '' || Ajax.getAnchor().match(/\/search\//)) {
this.loadSearchPage(); Ajax.loadSearchPage();
} else { } else {
this.load404Page(); Ajax.load404Page();
} }
} }
} }
@ -88,4 +84,5 @@ $(function(){
Ajax.loadArtistData($('#search_field').val()); Ajax.loadArtistData($('#search_field').val());
return false; return false;
}); });
$(window).bind('hashchange', Ajax.detectPage);
}) })

View File

@ -10,7 +10,7 @@ var beathaven = {
init: function () { init: function () {
this.drawInterface(); this.drawInterface();
this.adjustSizes(); this.adjustSizes();
Ajax.detectStartPage(); Ajax.detectPage();
}, },
drawInterface: function() { drawInterface: function() {