From 62afe65ccf776ed00c84bcaccaeb098fbd328073 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sun, 9 Mar 2014 21:05:01 -0400 Subject: [PATCH] bugfix + deprecated templates.getTemplateNameFromUrl --- public/src/ajaxify.js | 10 +++++----- public/src/templates.js | 14 +------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 2b27c8e721..ef9fc7ce7d 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -48,7 +48,6 @@ var ajaxify = {}; if (url.indexOf(RELATIVE_PATH.slice(1)) !== -1) { url = url.slice(RELATIVE_PATH.length); } - var tpl_url = ajaxify.getTemplateMapping(url); var hash = ''; @@ -139,14 +138,15 @@ var ajaxify = {}; tpl_url = url.split('/'); while(tpl_url.length) { - if (templates.is_available(tpl_url)) { + if (templates.is_available(tpl_url.join('/'))) { + tpl_url = tpl_url.join('/'); break; } tpl_url.pop(); } - - if (!tpl_url) { - tpl_url = tpl_url[0].split('?')[0]; + + if (!tpl_url.length) { + tpl_url = url.split('/')[0].split('?')[0]; } } } else if (templates[url]) { diff --git a/public/src/templates.js b/public/src/templates.js index f416e74600..46a77e5052 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -66,18 +66,6 @@ } }; - templates.getTemplateNameFromUrl = function(url) { - var parts = url.split('?')[0].split('/'); - - for (var i = 0; i < parts.length; ++i) { - if (templates.is_available(parts[i])) { - return parts[i]; - } - } - - return ''; - }; - templates.preload_template = function(tpl_name, callback) { if(templates[tpl_name]) { return callback(); @@ -110,7 +98,7 @@ tpl_url = templates.get_custom_map(api_url.split('?')[0]); if (!tpl_url) { - tpl_url = templates.getTemplateNameFromUrl(api_url); + tpl_url = ajaxify.getTemplateMapping(api_url); } var template_data = null;