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

48 lines
993 B
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
load404Page: ->
$.get '/404.html', (data) ->
$('.data-container .inner').html data
false
2011-09-17 10:20:07 +00:00
loadIndexPage: ->
$('#content').load '/greetings/'
2011-09-19 12:31:05 +00:00
_ajax.setTitle ''
2011-09-17 10:20:07 +00:00
false
2011-09-09 22:13:02 +00:00
loadAboutPage: ->
2011-09-19 12:31:05 +00:00
$('#content').load '/about/'
_ajax.setTitle 'About'
2011-09-09 22:13:02 +00:00
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().match /\/settings\//
2011-09-14 19:51:51 +00:00
_settings.loadSettingsPage()
2011-09-09 22:13:02 +00:00
else if _ajax.getAnchor().match /\/about\//
_ajax.loadAboutPage()
else
2011-09-19 12:31:05 +00:00
_ajax.loadIndexPage();
2011-09-09 22:13:02 +00:00
false
2011-06-27 18:41:36 +00:00
2011-06-27 20:43:54 +00:00
$(window).bind 'hashchange', ->
2011-09-14 19:51:51 +00:00
_ajax.detectPage()
2011-09-09 22:13:02 +00:00
false