w2v-server: show merged vocabulary in with class "merged" (green)
diff --git a/templates/index.html.ep b/templates/index.html.ep
index 4745c90..32c8a07 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -123,7 +123,7 @@
            nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;}));
            nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;}));
          }
-         showMap({target: " "+urlParams.get('word')+" ", mergedEnd: 0, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
+         showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
          var t = $('#firsttable').DataTable({
            data: paraResults[0],
            "sScrollY": "780px",
@@ -139,7 +139,9 @@
            "columns": [
              { "data": "rank", type: "allnumeric" },
              { "data": "dist",  render: function ( data, type, row ) {return data.toFixed(3) }},
-             { "data": "word",  class: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return  '<a href="?' + urlprefix + '">' + data + '</a>' }}
+             { "data": "word",  class: "paradigmator", render: function ( data, type, row ) {
+               urlprefix.set("word", data); return  '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>' 
+             }}
            ],
            "columnDefs": [
              { className: "dt-right", "targets": [0,1] },
@@ -498,6 +500,26 @@
      var anchor_array = [];
      var text;
 
+     function getMergedClass(i) {
+       if(data.mergedEnd && i > data.mergedEnd) {
+         return " merged"
+       } else {
+         return "";
+       }
+     }
+
+     function getRankTooltip(i) {
+       if(data.mergedEnd) {
+         if(data.ranks[i] < data.mergedEnd) {
+           return "rank: "+i +"  "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+         } else {
+           return "rank: "+i +"  "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
+         }
+       } else {
+         return "rank: "+i +"  "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+       }
+     }
+
      function drawEmbedding() {
        var urlprefix =  new URLSearchParams(window.location.search);
        urlprefix.delete("word");
@@ -527,23 +549,16 @@
             res="marked ";
           }
           if(data.target.indexOf(" "+d+" ") >= 0) {
-            return res+"target";
-          } else if(data.ranks[i] < data.mergedEnd) {
-            return res+"merged";
+            res += "target";
+          } 
+          if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) {
+            return res+" merged";
           } else {
             return res;
           }
         })
         .attr("title", function(d, i) {
-          if(data.mergedEnd > 0) {
-            if(data.ranks[i] >= data.mergedEnd) {
-              return "rank: "+i +"  "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
-            } else {
-              return "rank: "+i +"  "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
-            }
-          } else {
-            return "rank: "+i +"  "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
-          }
+          return getRankTooltip(i);
         })
         .append("text")
         .attr("text-anchor", "top")
@@ -552,7 +567,7 @@
 
        g.append("svg:title")
         .text(function(d, i) {
-		      return "distance rank: "+ i +"  "+"\nfrequency rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+		      return getRankTooltip(i);
 	      });
 
        var zoomListener = d3.behavior.zoom()
@@ -674,7 +689,7 @@
          $.post('/derekovecs/getVecsByRanks',
                 JSON.stringify(nranks),
                 function(data, status){
-                  showMap({target: " "+urlParams.get('word')+" ", mergedEnd: 0, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
+                  showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
                 }, 'json');
        }
      }