Fix errors when profilesUrl is not defined in config (text undefined)

This commit is contained in:
Norbert Renner 2020-01-02 13:36:33 +01:00
parent 568cd887d8
commit 83ffa4091d

View file

@ -134,6 +134,8 @@ BR.Profile = L.Evented.extend({
},
_setValue: function(profileText, profileEditorActivated) {
profileText = profileText || '';
if (L.DomUtil.get('profile_editor').classList.contains('active')) {
// Set value of the full editor and exit
this.editor.setValue(profileText);
@ -141,17 +143,19 @@ BR.Profile = L.Evented.extend({
return;
}
if (!profileText) return;
// Otherwise, create user friendly form
var params = {};
var global = profileText.split('---context:').filter(function(e) {
return e.startsWith('global');
});
if (global) {
if (global && global.length > 0) {
// Remove ---context:global line
global = global[0].split('\n').slice(1);
// Comment is mandatory
var assignRegex = /assign\s*(\w*)\s*=?\s*([\w\.]*)\s*#\s*%(.*)%\s*(\|\s*(.*)\s*\|\s*(.*)\s*)?$/;
var params = {};
global.forEach(function(item) {
var match = item.match(assignRegex);
var value;