   jobInfo = 
     workers: {}
 
-  flushWorkers =  ->
-    for from,w of jobInfo.workers
-      if $(".workers-list li##{from} .twinkle").length > 0
-        if w.active
-          $(".workers-list li##{from} .twinkle").addClass('twinkle-on')
-        else
-          $(".workers-list li##{from} .twinkle").removeClass('twinkle-on')
-        $(".workers-list li##{from} input.worker-visible").prop "checked", w.visible 
+  flushWorkers =  (from,w) ->
+    if $(".workers-list li##{from} .twinkle").length > 0
+      if w.active
+        $(".workers-list li##{from} .twinkle").addClass('twinkle-on')
       else
-        style = if w.active then 'twinkle-on' else ''
-        workerVisible = if w.visible then 'checked' else ''
-        $(".workers-list").append "<li id='#{from}'>
-        <div class='twinkle #{style}'></div>
-        <input type='checkbox' name='#{from}' class='worker-visible' #{workerVisible}>
-        <a href='#' class='worker-detail'>#{from}</a>
-        </li>"
-      if $(".terminals .term-#{from}").length == 0 and w.visible
-        htmlStr = "<div class='row term-#{from}'>
-          <div class='col-lg-12'>
-            <div class='shell-wrap'>
-              <div class='titlebar'>
-                <div class='buttons'>
-                  <div class='close'>
-                    <a class='closebutton' href='#' id='#{from}'><span><strong>x</strong></span></a>
-                  </div>
+        $(".workers-list li##{from} .twinkle").removeClass('twinkle-on')
+      $(".workers-list li##{from} input.worker-visible").prop "checked", w.visible 
+    else
+      style = if w.active then 'twinkle-on' else ''
+      workerVisible = if w.visible then 'checked' else ''
+      $(".workers-list").append "<li id='#{from}'>
+      <div class='twinkle #{style}'></div>
+      <input type='checkbox' name='#{from}' class='worker-visible' #{workerVisible}>
+      <a href='#' class='worker-detail'>#{from}</a>
+      </li>"
+    if $(".terminals .term-#{from}").length == 0 and w.visible
+      htmlStr = "<div class='row term-#{from}'>
+        <div class='col-lg-12'>
+          <div class='shell-wrap'>
+            <div class='titlebar'>
+              <div class='buttons'>
+                <div class='close'>
+                  <a class='closebutton' href='#' id='#{from}'><span><strong>x</strong></span></a>
                 </div>
-                node: #{from}
               </div>
-              <ul class='shell-body'>
-                <li class='cursor'>loading output......</li>
-              </ul>
+              node: #{from}
             </div>
+            <ul class='shell-body'>
+              <li class='cursor'>loading output......</li>
+            </ul>
           </div>
-        </div><br/>"
-        $('.terminals').append htmlStr
-      act = if w.visible then 'show' else 'hide'
-      $(".terminals .term-#{from}")[act]('fast')
+        </div>
+      </div><br/>"
+      $('.terminals').append htmlStr
+    act = if w.visible then 'show' else 'hide'
+    $(".terminals .term-#{from}")[act]('fast')
 
     $('a.worker-detail').off('click').on 'click', ->
       workerId = $(this).text()

    onlyOne = (w for w,x of jobInfo.workers).length == 1
    jobInfo.workers[data.from].active = true
    jobInfo.workers[data.from].visible = true if onlyOne
    flushWorkers()
    $('td.tsourceNum').text (w for w,x of jobInfo.workers when x.active).length
    if (w for w,x of jobInfo.workers when x.active).length > 0
      $('td.tstate').text 'running...'

      id = $(this).attr('id')
      if id and jobInfo.workers[id]
        jobInfo.workers[id].visible = false
        flushWorkers(id,jobInfo.workers[id])
    $('input.worker-visible').off('change').on 'change', ->
      id = $(this).attr('name')
      if id and jobInfo.workers[id]
        jobInfo.workers[id].visible = $(this).is(':checked')
        flushWorkers(id,jobInfo.workers[id])

    if jobInfo.socket
      attachList = (w for w,x of jobInfo.workers when x.visible)
