[TIC-UI] fix the output image path
[archive/20170607/tools/tic.git] / public / src / js / page / image.js
index 45fa98a..9c82dca 100644 (file)
@@ -8,29 +8,29 @@ define([
     'use strict';
 
     // connected socket object
-    var client,
+    var client;
 
-        // the list of checked pakages
-        checkedPackagesList,
+    // the list of checked pakages
+    var checkedPackagesList;
 
-        // template for the URL
-        URL_EXPORTS = '<%= protocol %>//<%= hostname %>:<%= port %>/exports',
-
-        // the path for ks
-        PATH_TIC_KS = '/tmp/tic/ks/',
-
-        // the path for images
-        PATH_TIC_IMAGES = '/tmp/tic/images/';
+    // template for the URL
+    var URL_EXPORTS = '<%= protocol %>//<%= hostname %>:<%= port %>/exports';
 
+    // the path for ks
+    var PATH_TIC_KS = '/tmp/tic/ks/';
 
+    // the path for images
+    var PATH_TIC_IMAGES = '/tmp/tic/images/';
 
     function updateList(socket) {
+        if (!_.isEmpty(socket)) {
+            client = socket;
+        }
+
         var msgData = {
             path: PATH_TIC_IMAGES
         };
 
-        client = socket;
-
         client.emit('ws/fs/image/list/from', msgData);
 
         client.on('ws/fs/image/list/to', function (data) {
@@ -38,6 +38,7 @@ define([
 
             list = data.list;
             tableDomElem = $('#tic-image-list');
+            tableDomElem.empty();
 
             list.forEach(function (file) {
                 var liElem, aElem, spanElem, fileName, hrefPath;
@@ -156,7 +157,7 @@ define([
                 $('#tic-image-new-container').hide();
 
                 // upate the list of images
-                updateList();
+                updateList(null);
             });
         }