Merge "[incident #1828157] WebGUI regression test fix"
diff --git a/htdocs/WebApplicationFramework/FrameworkMain.js b/htdocs/WebApplicationFramework/FrameworkMain.js
index e8a6fce..f5534b6 100644
--- a/htdocs/WebApplicationFramework/FrameworkMain.js
+++ b/htdocs/WebApplicationFramework/FrameworkMain.js
@@ -200,9 +200,11 @@
     }
 
     var browser = browserCheck();
-    if ((browser[0].toLowerCase() == "firefox" && parseInt(browser[1].split(".")[0]) >= 38) || browser[0].toLowerCase() == "chrome") {
+    var not_first_run = localStorage.getItem('_not_first_run_');
+    if ((not_first_run == 'true') || ((browser[0].toLowerCase() == "firefox" && parseInt(browser[1].split(".")[0]) >= 38) || browser[0].toLowerCase() == "chrome")) {
         start();
     } else {
+        localStorage.setItem('_not_first_run_', 'true');
         var html = '' +
         '<div id="UnsupportedBrowser">' +
             '<p>This browser is not supported: ' + browser[0] + ' ' + browser[1] + '</p>' +
@@ -249,4 +251,4 @@
         });
         taskList.taskOperation();
     };
-}
\ No newline at end of file
+}
diff --git a/htdocs/WebApplicationFramework/Views/View_MultipliedViewAligner.js b/htdocs/WebApplicationFramework/Views/View_MultipliedViewAligner.js
index e05c64b..7cdad4a 100644
--- a/htdocs/WebApplicationFramework/Views/View_MultipliedViewAligner.js
+++ b/htdocs/WebApplicationFramework/Views/View_MultipliedViewAligner.js
@@ -19,23 +19,39 @@
     
     var v_multipliedSubviews = [];
     var v_alignerSize = 0;
-    
+
+    var v_last_viewmodelBundle;
+
     var v_this = this;
-    
+
     /** public functions */
 
     this.applicationCreated = function() {
         preprocessSubviewDescriptors(v_customData, 0);
     };
 
+    this.setSelection = function(selection) {
+        $("#" + v_mainId + " .Aligner").removeClass("Selected");
+        if (selection != undefined)
+            for (var i = 0; i < selection.length; ++i)
+                $("#" + v_mainId + "_" + selection[i] + " .Aligner").addClass("Selected");
+    };
+
     this.refresh = function(p_fullRefresh) {
         if (p_fullRefresh) {
-            $("#" + v_parentId).empty();
-            v_multipliedSubviews = [];
-            fullRefresh();
+            var viewmodelBundle = v_dataViewmodel.getViewmodelBundle();
+            if (v_last_viewmodelBundle != viewmodelBundle)
+            {
+                v_last_viewmodelBundle = viewmodelBundle;
+                $("#" + v_parentId).empty();
+                v_multipliedSubviews = [];
+                fullRefresh();
+                v_this.setSelection(v_dataViewmodel.getSelectionIndx());
+            }
         } else if (ViewUtils.checkVisibility(v_conditionViewmodel, v_mainId)) {
             for (var i = 0; i < v_multipliedSubviews.length; ++i) {
                 v_multipliedSubviews[i].refresh();
+                v_this.setSelection(v_dataViewmodel.getSelectionIndx());
             }
         }
     };
@@ -55,15 +71,14 @@
     }
     
     function fullRefresh() {
-        var viewmodelBundle = v_dataViewmodel.getViewmodelBundle();
-        v_alignerSize = viewmodelBundle.length;
+        v_alignerSize = v_last_viewmodelBundle.length;
         v_customData.idsCreating = [];
-        for (var i = 0; i < viewmodelBundle.length; ++i) {
+        for (var i = 0; i < v_last_viewmodelBundle.length; ++i) {
             v_customData.idsCreating.push(v_mainId + "_" + i);
         }
         createAligner();
-        for (var i = 0; i < viewmodelBundle.length; ++i) {
-            createSubviews(viewmodelBundle[i], v_customData.multipliedSubviews, [v_customData.idsCreating[i]], v_mainId + "_" + i + "_");
+        for (var i = 0; i < v_last_viewmodelBundle.length; ++i) {
+            createSubviews(v_last_viewmodelBundle[i], v_customData.multipliedSubviews, [v_customData.idsCreating[i]], v_mainId + "_" + i + "_");
         }
     }
     
diff --git a/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_FSM_SVG.js b/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_FSM_SVG.js
index 38e4af7..38b88bf 100644
--- a/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_FSM_SVG.js
+++ b/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_FSM_SVG.js
@@ -54,9 +54,18 @@
                 if (state != undefined)
                 {
                     state = state.node.val;
-                    var activeIndx = lsvgdec.indexOf(state);
-                    var colorindx = lsvgdec.lastIndexOf("<rect fill=\"#FEFECE\"", activeIndx);
-                    lsvgdec = replaceAt(lsvgdec, colorindx, "<rect fill=\"#ffafaf\"");
+                    if (state.indexOf(',') != -1)
+                        state = state.split(',');
+                    else
+                        state = [state];
+
+                    for (var i = 0; i < state.length; ++i) 
+                        if (!i || (state[i] != state[i - 1]))
+                        {
+                            var activeIndx = lsvgdec.indexOf(state[i]);
+                            var colorindx = lsvgdec.lastIndexOf("<rect fill=\"#FEFECE\"", activeIndx);
+                            lsvgdec = replaceAt(lsvgdec, colorindx, "<rect fill=\"#ffafaf\"");
+                        }
                 }
                 lValues[0] = {val: lsvgdec};
             }
diff --git a/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_Multiplier.js b/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_Multiplier.js
index 1ca73d4..4a8b21b 100644
--- a/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_Multiplier.js
+++ b/htdocs/WebApplications/CustomizableApp/ViewModels/ViewModel_Multiplier.js
@@ -16,9 +16,10 @@
     var v_selections = [];
 
     var v_currentBundle = [];
-    
+    var v_last_response;
+
     var v_this = this;
-    
+
     /** public functions - interface for parent */ 
 
     this.setSelectionToControl = function(p_selection) {
@@ -45,12 +46,20 @@
     };
 
     this.getViewmodelBundle = function() {
+        
         var response = v_viewmodel.getResponseElement(v_dataPaths[0]);
         var numberOfBundles = 0;
         if (response != undefined && response.list != undefined) {
             numberOfBundles = response.list.length;
         }
         
+        var vmbjson = JSON.stringify(response);
+        if (v_last_response != vmbjson && numberOfBundles != v_currentBundle.length)
+        {
+            v_last_response = vmbjson;
+            v_currentBundle = [];
+        }
+        
         var currentBundles = v_currentBundle.length;
         if (numberOfBundles < currentBundles) {
             while (v_currentBundle.length > numberOfBundles) {
@@ -61,9 +70,16 @@
                 v_currentBundle.push(createBundle(i));
             }
         }
-        
+
         return v_currentBundle;
     };
+    
+    this.getSelectionIndx = function() {
+        if (v_selections[0])
+            return v_selections[0].selection;
+        else
+            return 0;
+    };
 
     /** private functions */
     
@@ -158,7 +174,7 @@
 };
 
 CViewModel_Multiplier.providesInterface = function() {
-    return ["getViewmodelBundle"];
+    return ["getViewmodelBundle", "getSelectionIndx"];
 };
 
 CViewModel_Multiplier.getCustomDataSchema = function() {