Skip to content

Node.js based forum software built for the modern web

optimizing ajaxify (still needs work though)

psychobunny712c382a281e
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index 8ca19edeae..2b27c8e721 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -127,10 +127,6 @@ var ajaxify = {};
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
};
- /*
- * this is complete hax and needs to be looked at. (fixing this is out of scope for what I'm currently refactoring)
- * -- psychobunny
- */
ajaxify.getTemplateMapping = function(url) {
var tpl_url = templates.get_custom_map(url.split('?')[0]);
@@ -142,13 +138,17 @@ var ajaxify = {};
} else {
tpl_url = url.split('/');
- if (tpl_url[0] === 'admin') {
- tpl_url = tpl_url[0] + '/' + tpl_url[1];
- } else {
+ while(tpl_url.length) {
+ if (templates.is_available(tpl_url)) {
+ break;
+ }
+ tpl_url.pop();
+ }
+
+ if (!tpl_url) {
tpl_url = tpl_url[0].split('?')[0];
}
}
-
} else if (templates[url]) {
tpl_url = url;
}
diff --git a/public/src/templates.js b/public/src/templates.js
index 7c013534af..f416e74600 100644
--- a/public/src/templates.js
+++ b/public/src/templates.js
@@ -69,16 +69,11 @@
templates.getTemplateNameFromUrl = function(url) {
var parts = url.split('?')[0].split('/');
- if (parts[0] === 'admin') {
- return parts = parts[0] + '/' + parts[1];
- } else {
- for (var i = 0; i < parts.length; ++i) {
- if (templates.is_available(parts[i])) {
- return parts[i];
- }
+ for (var i = 0; i < parts.length; ++i) {
+ if (templates.is_available(parts[i])) {
+ return parts[i];
}
}
-
return '';
};