class window.Ajax referer: false loadArtistData: (name) -> _search.showSpinner() name = name.split(' ').join('+') $.get '/artist/' +name+ '/', (data) -> if data.status? if data.status is 'loading' _search.showArtistPics data.pics setTimeout () -> _ajax.loadArtistData name , 3000 else if data.status is 'corrected' _ajax.loadArtistData data.page else if data.status is 'suggestions' _search.hideSpinner() _search.showSuggestions data.values else if data.status == 'loading_failed' _search.hideSpinner() _search.showError() else _ajax.setArchor '/artist/' +name+ '/' _pages.renderArtist data #_search.hideSpinner() false loadSearchPage: -> false loadSettingsPage: -> $.get '/templates/settings.html', (data) -> _ajax.setArchor '/settings/' _pages.renderSettings _beathaven.localizeHTML $(data) false load404Page: -> $.get '/404.html', (data) -> $('.data-container .inner').html data _beathaven.redrawScrollbar() false loadAboutPage: -> $.get '/templates/about.html', (data) -> _pages.renderTextpage data _ajax.setTitle 'About' false setArchor: (anchor) -> @referer = this.getAnchor() window.location.hash = '#' +anchor getAnchor: () -> window.location.hash.substring 1; setTitle: (title) -> document.title = title+ ' @ BeatHaven' go: (url) -> this.setArchor url false detectPage: () -> if m = _ajax.getAnchor().match /\/artist\/(.+)\// _ajax.loadArtistData m[1] else if _ajax.getAnchor() == '' or _ajax.getAnchor().match /\/search\// _ajax.loadSearchPage(); else if _ajax.getAnchor().match /\/settings\// _ajax.loadSettingsPage() else if _ajax.getAnchor().match /\/about\// _ajax.loadAboutPage() else _ajax.loadSearchPage() false $('a.data.artist').live 'click', -> _ajax.loadArtistData $(this).html() false $(window).bind 'hashchange', -> _ajax.detectPage() false