You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/public/src/variables.js

42 lines
881 B
JavaScript

"use strict";
/*global ajaxify*/
(function(ajaxify) {
var parsedVariables = {};
ajaxify.variables = {};
ajaxify.variables.set = function(key, value) {
parsedVariables[key] = value;
};
ajaxify.variables.get = function(key) {
return parsedVariables[key];
};
ajaxify.variables.flush = function() {
parsedVariables = {};
};
ajaxify.variables.parse = function() {
$('#content [template-variable]').each(function(index, element) {
var value = null;
switch ($(element).attr('template-type')) {
case 'boolean':
value = ($(element).val() === 'true' || $(element).val() === '1') ? true : false;
break;
case 'int':
case 'integer':
value = parseInt($(element).val(), 10);
break;
default:
value = $(element).val();
break;
}
ajaxify.variables.set($(element).attr('template-variable'), value);
});
};
}(ajaxify || {}));