1
0
Fork 0
oldhaven/app/assets/javascripts/ajax.coffee

52 lines
1.2 KiB
CoffeeScript
Raw Normal View History

2011-09-07 23:47:11 +00:00
class window.Ajax
2011-09-09 22:13:02 +00:00
referer: false
loadSettingsPage: ->
$.get '/templates/settings.html', (data) ->
_ajax.setArchor '/settings/'
_page.renderSettings _beathaven.localizeHTML $(data)
false
load404Page: ->
$.get '/404.html', (data) ->
$('.data-container .inner').html data
false
loadAboutPage: ->
$.get '/templates/about.html', (data) ->
_page.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
2011-06-27 18:41:36 +00:00
2011-09-09 22:13:02 +00:00
detectPage: () ->
if m = _ajax.getAnchor().match /\/artist\/(.+)\//
_search.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
2011-06-27 18:41:36 +00:00
2011-06-27 20:43:54 +00:00
$(window).bind 'hashchange', ->
2011-09-09 22:13:02 +00:00
#_ajax.detectPage()
false