/*
  LIGHTSTREAMER - www.lightstreamer.com
  JMS Stock-List Demo

  Copyright (c) Lightstreamer Srl

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/

import stocksGrid from './grid.js';

jms.TopicConnectionFactory.createTopicConnection("http://localhost:8080/", "ActiveMQ", null, null, {
    onConnectionCreated: function (conn) {
        // Connection succeeded, topic subscription
        var topicSession = conn.createSession(false, "PRE_ACK");
        var topic = topicSession.createTopic("stocksTopic");
        var consumer = topicSession.createConsumer(topic, null);

        // Add listener to message consumer
        consumer.setMessageListener({
            onMessage: function (message) {

                // Message received
                var feedMessage = message.getObject();
                if (!feedMessage.currentValues) {
                    return;
                }

                var key = feedMessage.itemName;
                var values = feedMessage.currentValues;

                // Update the view with the received data
                stocksGrid.updateRow(key, values);
            }
        });

        // Start the connection
        conn.start();
    },

    onConnectionFailed: function (errorCode, errorMessage) {

        // Connection failed, show the error
        alert("Error: " + errorCode + " " + errorMessage);

    },

    onLSClient: function (lsClient) {
        // Enable connection sharing and status widget (optional)
        lsClient.connectionSharing.enableSharing("JMSDemoCommonConnection", "ATTACH", "CREATE");
        lsClient.addListener(new StatusWidget("left", "0px", true));
    }
});
@@ -774,18 +774,16 @@
 null, %7B%0A
-  
   onConn
@@ -815,28 +815,24 @@
 conn) %7B%0A    
-   
- 
 // Connectio
@@ -859,28 +859,24 @@
 ubscription%0A
-    
     var topi
@@ -920,28 +920,24 @@
 %22PRE_ACK%22);%0A
-    
     var topi
@@ -981,28 +981,24 @@
 opic%22);%0A    
- 
-   
 var consumer
@@ -1047,20 +1047,16 @@
 );%0A%0A    
-  
-  
 // Add l
@@ -1083,20 +1083,16 @@
 onsumer%0A
-    
     cons
@@ -1123,22 +1123,16 @@
 %7B%0A      
-    
-  
 onMessag
@@ -1164,24 +1164,16 @@
         
-       
- 
 // Messa
@@ -1184,24 +1184,16 @@
 eceived%0A
-        
         
@@ -1239,24 +1239,16 @@
         
- 
-       
 if (!fee
@@ -1283,26 +1283,16 @@
         
-  
-        
 return;%0A
@@ -1303,30 +1303,19 @@
     
-  
-      %7D%0A%0A   
+%7D%0A%0A
         
     
@@ -1306,29 +1306,24 @@
  %7D%0A%0A        
-     
 var key = fe
@@ -1350,24 +1350,16 @@
         
-     
-   
 var valu
@@ -1399,24 +1399,16 @@
         
-       
- 
 // Updat
@@ -1441,24 +1441,16 @@
 ed data%0A
-        
         
@@ -1494,20 +1494,10 @@
     
- 
-     %7D%0A    
+%7D%0A
     
@@ -1501,20 +1501,16 @@
    %7D);%0A%0A
-    
     // S
@@ -1529,20 +1529,16 @@
 nection%0A
-    
     conn
@@ -1547,26 +1547,22 @@
 tart();%0A
-  
   %7D,%0A%0A
-  
   onConn
@@ -1609,28 +1609,24 @@
 Message) %7B%0A%0A
-    
     // Conne
@@ -1658,20 +1658,16 @@
 ror%0A    
-   
- 
 alert(%22E
@@ -1714,18 +1714,14 @@
 );%0A%0A
-  
   %7D,%0A%0A
-  
   on
@@ -1748,28 +1748,24 @@
 lsClient) %7B%0A
-    
     // Enabl
@@ -1814,28 +1814,24 @@
 tional)%0A    
- 
-   
 lsClient.con
@@ -1907,20 +1907,16 @@
 EATE%22);%0A
-    
     lsCl
@@ -1972,17 +1972,15 @@
 true));%0A
-  
   %7D%0A%7D);

Fix indentation