mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 23:15:48 +01:00
fixes to get nodebb to at least load on IE
This commit is contained in:
@@ -158,7 +158,7 @@ var ajaxify = {};
|
|||||||
|
|
||||||
var scripts = [],
|
var scripts = [],
|
||||||
script,
|
script,
|
||||||
children_nodes = body_el.childNodes,
|
children_nodes = $(body_el).children(),
|
||||||
child,
|
child,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
(function(module) {
|
(function (module) {
|
||||||
|
|
||||||
var config = {},
|
var config = {},
|
||||||
templates,
|
templates,
|
||||||
@@ -12,11 +12,11 @@
|
|||||||
fs = require('fs');
|
fs = require('fs');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
templates.force_refresh = function(tpl) {
|
templates.force_refresh = function (tpl) {
|
||||||
return !!config.force_refresh[tpl];
|
return !!config.force_refresh[tpl];
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.get_custom_map = function(tpl) {
|
templates.get_custom_map = function (tpl) {
|
||||||
if (config['custom_mapping'] && tpl) {
|
if (config['custom_mapping'] && tpl) {
|
||||||
for (var pattern in config['custom_mapping']) {
|
for (var pattern in config['custom_mapping']) {
|
||||||
if (tpl.match(pattern)) {
|
if (tpl.match(pattern)) {
|
||||||
@@ -28,11 +28,11 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.is_available = function(tpl) {
|
templates.is_available = function (tpl) {
|
||||||
return jQuery.inArray(tpl, available_templates) !== -1;
|
return jQuery.inArray(tpl, available_templates) !== -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
templates.ready = function(callback) {
|
templates.ready = function (callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (this.ready_callback) {
|
if (this.ready_callback) {
|
||||||
this.ready_callback();
|
this.ready_callback();
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
templates.prepare = function(raw_tpl, data) {
|
templates.prepare = function (raw_tpl, data) {
|
||||||
var template = {};
|
var template = {};
|
||||||
template.html = raw_tpl;
|
template.html = raw_tpl;
|
||||||
template.parse = parse;
|
template.parse = parse;
|
||||||
@@ -62,10 +62,10 @@
|
|||||||
var loaded = templatesToLoad.length;
|
var loaded = templatesToLoad.length;
|
||||||
|
|
||||||
for (var t in templatesToLoad) {
|
for (var t in templatesToLoad) {
|
||||||
(function(file) {
|
(function (file) {
|
||||||
fs.readFile(__dirname + '/../templates/' + file + '.tpl', function(err, html) {
|
fs.readFile(__dirname + '/../templates/' + file + '.tpl', function (err, html) {
|
||||||
var template = function() {
|
var template = function () {
|
||||||
this.toString = function() {
|
this.toString = function () {
|
||||||
return this.html;
|
return this.html;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadClient() {
|
function loadClient() {
|
||||||
jQuery.when(jQuery.getJSON(RELATIVE_PATH + '/templates/config.json'), jQuery.getJSON(RELATIVE_PATH + '/api/get_templates_listing')).done(function(config_data, templates_data) {
|
jQuery.when(jQuery.getJSON(RELATIVE_PATH + '/templates/config.json'), jQuery.getJSON(RELATIVE_PATH + '/api/get_templates_listing')).done(function (config_data, templates_data) {
|
||||||
config = config_data[0];
|
config = config_data[0];
|
||||||
available_templates = templates_data[0];
|
available_templates = templates_data[0];
|
||||||
templates.ready();
|
templates.ready();
|
||||||
@@ -96,11 +96,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
templates.init = function(templates_to_load) {
|
templates.init = function (templates_to_load) {
|
||||||
loadTemplates(templates_to_load || []);
|
loadTemplates(templates_to_load || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.getTemplateNameFromUrl = function(url) {
|
templates.getTemplateNameFromUrl = function (url) {
|
||||||
var parts = url.split('?')[0].split('/');
|
var parts = url.split('?')[0].split('/');
|
||||||
|
|
||||||
for (var i = 0; i < parts.length; ++i) {
|
for (var i = 0; i < parts.length; ++i) {
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
templates.load_template = function(callback, url, template) {
|
templates.load_template = function (callback, url, template) {
|
||||||
var location = document.location || window.location,
|
var location = document.location || window.location,
|
||||||
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||||
|
|
||||||
@@ -129,13 +129,13 @@
|
|||||||
var template_data = null;
|
var template_data = null;
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
var timestamp = new Date().getTime(); //debug
|
var timestamp = new Date().getTime(); //debug
|
||||||
|
|
||||||
if (!templates[tpl_url]) {
|
if (!templates[tpl_url]) {
|
||||||
jQuery.get(RELATIVE_PATH + '/templates/' + tpl_url + '.tpl?v=' + timestamp, function(html) {
|
jQuery.get(RELATIVE_PATH + '/templates/' + tpl_url + '.tpl?v=' + timestamp, function (html) {
|
||||||
var template = function() {
|
var template = function () {
|
||||||
this.toString = function() {
|
this.toString = function () {
|
||||||
return this.html;
|
return this.html;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -154,9 +154,9 @@
|
|||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
|
|
||||||
jQuery.get(API_URL + api_url, function(data) {
|
jQuery.get(API_URL + api_url, function (data) {
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
ajaxify.go('404');
|
ajaxify.go('404');
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
|
|
||||||
template_data = data;
|
template_data = data;
|
||||||
parse_template();
|
parse_template();
|
||||||
}).fail(function(data) {
|
}).fail(function (data) {
|
||||||
template_data = {};
|
template_data = {};
|
||||||
parse_template();
|
parse_template();
|
||||||
});
|
});
|
||||||
@@ -182,20 +182,20 @@
|
|||||||
|
|
||||||
document.getElementById('content').innerHTML = templates[tpl_url].parse(template_data);
|
document.getElementById('content').innerHTML = templates[tpl_url].parse(template_data);
|
||||||
|
|
||||||
jQuery('#content [template-variable]').each(function(index, element) {
|
jQuery('#content [template-variable]').each(function (index, element) {
|
||||||
var value = null;
|
var value = null;
|
||||||
|
|
||||||
switch (element.getAttribute('template-type')) {
|
switch (element.getAttribute('template-type')) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
value = (element.value === 'true' || element.value === '1') ? true : false;
|
value = (element.value === 'true' || element.value === '1') ? true : false;
|
||||||
break;
|
break;
|
||||||
case 'int': // Intentional fall-through
|
case 'int': // Intentional fall-through
|
||||||
case 'integer':
|
case 'integer':
|
||||||
value = parseInt(element.value);
|
value = parseInt(element.value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
value = element.value;
|
value = element.value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.set(element.getAttribute('template-variable'), value);
|
templates.set(element.getAttribute('template-variable'), value);
|
||||||
@@ -208,20 +208,20 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.flush = function() {
|
templates.flush = function () {
|
||||||
parsed_variables = {};
|
parsed_variables = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.get = function(key) {
|
templates.get = function (key) {
|
||||||
return parsed_variables[key];
|
return parsed_variables[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.set = function(key, value) {
|
templates.set = function (key, value) {
|
||||||
parsed_variables[key] = value;
|
parsed_variables[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//modified from https://github.com/psychobunny/dcp.templates
|
//modified from https://github.com/psychobunny/dcp.templates
|
||||||
var parse = function(data) {
|
var parse = function (data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
function replace(key, value, template) {
|
function replace(key, value, template) {
|
||||||
@@ -230,7 +230,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeRegex(block) {
|
function makeRegex(block) {
|
||||||
return new RegExp("<!-- BEGIN " + block + " -->[^]*<!-- END " + block + " -->", 'g');
|
return new RegExp("<!-- BEGIN " + block + " -->[\\s\\S]*<!-- END " + block + " -->", 'g');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBlock(regex, block, template) {
|
function getBlock(regex, block, template) {
|
||||||
@@ -299,7 +299,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (namespace) {
|
if (namespace) {
|
||||||
var regex = new RegExp("{" + namespace + "[^]*?}", 'g');
|
var regex = new RegExp("{" + namespace + "[\\s\\S]*?}", 'g');
|
||||||
template = template.replace(regex, '');
|
template = template.replace(regex, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
{
|
{
|
||||||
"custom_mapping": {
|
"custom_mapping": {
|
||||||
"admin/testing/categories[^]*": "admin/testing/categories",
|
"admin/testing/categories.*": "admin/testing/categories",
|
||||||
"admin/topics[^]*": "admin/topics",
|
"admin/topics.*": "admin/topics",
|
||||||
"admin/categories[^]*": "admin/categories",
|
"admin/categories.*": "admin/categories",
|
||||||
"admin/users[^]*": "admin/users",
|
"admin/users.*": "admin/users",
|
||||||
"admin/redis[^]*": "admin/redis",
|
"admin/redis.*": "admin/redis",
|
||||||
"admin/index[^]*": "admin/index",
|
"admin/index.*": "admin/index",
|
||||||
"admin/themes[^]*": "admin/themes",
|
"admin/themes.*": "admin/themes",
|
||||||
"admin/plugins[^]*": "admin/plugins",
|
"admin/plugins.*": "admin/plugins",
|
||||||
"^admin/settings[^]*": "admin/settings",
|
"^admin/settings.*": "admin/settings",
|
||||||
"admin/twitter[^]*": "admin/twitter",
|
"admin/twitter.*": "admin/twitter",
|
||||||
"admin/facebook[^]*": "admin/facebook",
|
"admin/facebook.*": "admin/facebook",
|
||||||
"admin/gplus[^]*": "admin/gplus",
|
"admin/gplus.*": "admin/gplus",
|
||||||
"admin/motd/?$": "admin/motd",
|
"admin/motd/?$": "admin/motd",
|
||||||
"admin/groups/?$": "admin/groups",
|
"admin/groups/?$": "admin/groups",
|
||||||
"install/?$": "install/mail",
|
"install/?$": "install/mail",
|
||||||
"install/mail/?": "install/mail",
|
"install/mail/?": "install/mail",
|
||||||
"install/social/?": "install/social",
|
"install/social/?": "install/social",
|
||||||
"install/privileges/?": "install/privileges",
|
"install/privileges/?": "install/privileges",
|
||||||
"users/sort-posts": "users",
|
"users/sort-posts": "users",
|
||||||
"users/latest": "users",
|
"users/latest": "users",
|
||||||
"users/sort-reputation": "users",
|
"users/sort-reputation": "users",
|
||||||
"users/search": "users",
|
"users/search": "users",
|
||||||
"user[^]*edit": "accountedit",
|
"user.*edit": "accountedit",
|
||||||
"user[^]*following": "following",
|
"user.*following": "following",
|
||||||
"user[^]*followers": "followers",
|
"user.*followers": "followers",
|
||||||
"user[^]*settings": "accountsettings",
|
"user.*settings": "accountsettings",
|
||||||
"user[^]*favourites": "favourites",
|
"user.*favourites": "favourites",
|
||||||
"user/[^]*": "account",
|
"user/.*": "account",
|
||||||
|
|
||||||
"recent": "recent",
|
"recent": "recent",
|
||||||
"unread": "unread",
|
"unread": "unread",
|
||||||
"popular": "category",
|
"popular": "category",
|
||||||
"active": "category",
|
"active": "category",
|
||||||
"search": "search",
|
"search": "search",
|
||||||
"reset/[^]*": "reset_code",
|
"reset/.*": "reset_code",
|
||||||
"reset": "reset"
|
"reset": "reset"
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user