Commit 1753f983 by Valera Rozuvan Committed by Alexander Kryklia

Added ability to insert automatic "return" for dynamic element functions, and…

Added ability to insert automatic "return" for dynamic element functions, and graph label dynamic element functions.
parent 72d500c1
......@@ -25,7 +25,7 @@ define('ElOutput', ['logme'], function (logme) {
return;
function processFuncObj(obj) {
var paramNames, funcString, func, special, el;
var paramNames, funcString, func, special, el, disableAutoReturn;
// We are only interested in functions that are meant for output to an
// element.
......@@ -48,8 +48,30 @@ define('ElOutput', ['logme'], function (logme) {
return;
}
disableAutoReturn = obj['@disable_auto_return'];
funcString = obj['#text'];
if (
(disableAutoReturn === undefined) ||
(
(typeof disableAutoReturn === 'string') &&
(disableAutoReturn.toLowerCase() !== 'true')
)
) {
if (funcString.search(/return/i) === -1) {
funcString = 'return ' + funcString;
}
} else {
if (funcString.search(/return/i) === -1) {
logme(
'ERROR: You have specified a JavaScript ' +
'function without a "return" statemnt. Your ' +
'function will return "undefined" by default.'
);
}
}
// Make sure that all HTML entities are converted to their proper
// ASCII text equivalents.
funcString = $('<div>').html(funcString).text();
......
......@@ -23,7 +23,7 @@ define('GLabelElOutput', ['logme'], function (logme) {
return;
function processFuncObj(obj) {
var paramNames, funcString, func;
var paramNames, funcString, func, disableAutoReturn;
// We are only interested in functions that are meant for output to an
// element.
......@@ -46,8 +46,30 @@ define('GLabelElOutput', ['logme'], function (logme) {
return;
}
disableAutoReturn = obj['@disable_auto_return'];
funcString = obj['#text'];
if (
(disableAutoReturn === undefined) ||
(
(typeof disableAutoReturn === 'string') &&
(disableAutoReturn.toLowerCase() !== 'true')
)
) {
if (funcString.search(/return/i) === -1) {
funcString = 'return ' + funcString;
}
} else {
if (funcString.search(/return/i) === -1) {
logme(
'ERROR: You have specified a JavaScript ' +
'function without a "return" statemnt. Your ' +
'function will return "undefined" by default.'
);
}
}
// Make sure that all HTML entities are converted to their proper
// ASCII text equivalents.
funcString = $('<div>').html(funcString).text();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment