2014-03-18 23:54:18 -07:00
|
|
|
$(function(){
|
|
|
|
|
|
|
|
var hotSwap = function(page, pushSate){
|
|
|
|
if (pushSate) history.pushState(null, null, '/' + page);
|
2014-04-10 18:33:41 -07:00
|
|
|
$('.pure-menu-selected').removeClass('pure-menu-selected');
|
|
|
|
$('a[href="/' + page + '"]').parent().addClass('pure-menu-selected');
|
2014-03-25 15:21:17 -07:00
|
|
|
$.get("/get_page", {id: page}, function(data){
|
2014-04-10 18:33:41 -07:00
|
|
|
$('main').html(data);
|
2014-03-18 23:54:18 -07:00
|
|
|
}, 'html')
|
|
|
|
};
|
|
|
|
|
|
|
|
$('.hot-swapper').click(function(event){
|
2014-03-19 13:24:29 -07:00
|
|
|
if (event.which !== 1) return;
|
2014-03-18 23:54:18 -07:00
|
|
|
var pageId = $(this).attr('href').slice(1);
|
|
|
|
hotSwap(pageId, true);
|
|
|
|
event.preventDefault();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
window.addEventListener('load', function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
window.addEventListener("popstate", function(e) {
|
2014-03-19 13:36:44 -07:00
|
|
|
hotSwap(location.pathname.slice(1));
|
2014-03-18 23:54:18 -07:00
|
|
|
});
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
|
2014-04-10 18:33:41 -07:00
|
|
|
window.statsSource = new EventSource("/api/live_stats");
|
2014-03-19 13:24:29 -07:00
|
|
|
|
2014-04-03 19:56:53 -07:00
|
|
|
});
|