Node.js based forum software built for the modern web
added popstate functionality
Julian Lamc351d8341821
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex e83d16fbf4..2b5698fef6 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -21,11 +21,13 @@ var ajaxify = {};window.onpopstate = function(event) {- // this breaks reloading and results in ajaxify.go calling twice, believe it messes around with sockets. ill come back for you later bitchez- // ajaxify.go(document.location.href.replace(rootUrl +'/', ''));+ console.log('popstate called:', event);+ if (event !== null && event.state && event.state.url) ajaxify.go(event.state.url, null, null, true);};- ajaxify.go = function(url, callback, custom_tpl) {+ ajaxify.go = function(url, callback, template, quiet) {+ console.log('go', url, quiet);+ // "quiet": If set to true, will not call pushState// leave room and join globalapp.enter_room('global');@@ -41,7 +43,12 @@ var ajaxify = {};}if (templates[tpl_url]) {- window.history.pushState({}, url, "/" + url);+ if (quiet !== true) {+ console.log('pushing state');+ window.history.pushState({+ "url": url+ }, url, "/" + url);+ }jQuery('#footer').fadeOut(100);jQuery('#content').fadeOut(100);@@ -55,7 +62,7 @@ var ajaxify = {};}jQuery('#content, #footer').fadeIn(200);- }, custom_tpl);+ }, url, template);return true;diff --git a/public/src/templates.js b/public/src/templates.jsindex 95c7f76566..de538645e8 100644--- a/public/src/templates.js+++ b/public/src/templates.js@@ -160,14 +160,12 @@ var templates = {};}());-function load_template(callback, custom_tpl) {+function load_template(callback, url, template) {var location = document.location || window.location,rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');- var url = location.href.replace(rootUrl +'/', '');url = (url === '' || url === '/') ? 'home' : url;-jQuery.get(API_URL + url, function(data) {var tpl = templates.get_custom_map(url);