48 lines
993 B
CoffeeScript
Raw Normal View History

2011-09-08 03:47:11 +04:00
class window.Ajax
2011-09-10 02:13:02 +04:00
referer: false
load404Page: ->
$.get '/404.html', (data) ->
$('.data-container .inner').html data
false
2011-09-17 14:20:07 +04:00
loadIndexPage: ->
$('#content').load '/greetings/'
2011-09-19 16:31:05 +04:00
_ajax.setTitle ''
2011-09-17 14:20:07 +04:00
false
2011-09-10 02:13:02 +04:00
loadAboutPage: ->
2011-09-19 16:31:05 +04:00
$('#content').load '/about/'
_ajax.setTitle 'About'
2011-09-10 02:13:02 +04: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 22:41:36 +04:00
2011-09-10 02:13:02 +04:00
detectPage: () ->
if m = _ajax.getAnchor().match /\/artist\/(.+)\//
_search.loadArtistData m[1]
else if _ajax.getAnchor().match /\/settings\//
2011-09-14 23:51:51 +04:00
_settings.loadSettingsPage()
2011-09-10 02:13:02 +04:00
else if _ajax.getAnchor().match /\/about\//
_ajax.loadAboutPage()
else
2011-09-19 16:31:05 +04:00
_ajax.loadIndexPage();
2011-09-10 02:13:02 +04:00
false
2011-06-27 22:41:36 +04:00
2011-06-28 00:43:54 +04:00
$(window).bind 'hashchange', ->
2011-09-14 23:51:51 +04:00
_ajax.detectPage()
2011-09-10 02:13:02 +04:00
false