w2v-server: add KorAP-links for each collocator window position
diff --git a/templates/index.html.ep b/templates/index.html.ep
index 9851b45..5ede4fe 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -10,11 +10,12 @@
     <script src = "https://cdn.datatables.net/plug-ins/1.10.16/sorting/scientific.js"></script>
     <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
     <script
-      src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
-           integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
-           crossorigin="anonymous"></script>
+        src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
+        integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
+        crossorigin="anonymous"></script>
     <script>
      var urlParams = new URLSearchParams(window.location.search);
+     var currentWord = urlParams.get("word");
 
      $('#firstable').hide();
      $(document).ready(function() {
@@ -40,10 +41,14 @@
              });
          });
 
-         function changeCharColor(txt, heat) {
+         function changeCharColor(txt, heat, word) {
              var newText = "";
              for (var i=0, l=txt.length; i<l; i++) {
-                 newText += (i == 5 ? txt.charAt(i) : '<span style="background-color:'+getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span>');
+                 newText += (i == 5 ? txt.charAt(i) : '<a href="http://korap.ids-mannheim.de/kalamar/?ql=cosmas2&q=' +
+                                                      currentWord + ' /' +  (i > 5? '%2B' : '-') + 'w' +
+                                                      Math.abs(i-5) + ':' +  Math.abs(i-5) + ' ' + word +
+                                                      '" target="korap"><span style="background-color:' +
+                                                      getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>');
              }
              return newText;
          }
@@ -53,12 +58,12 @@
              return ["hsl(",hue,",90%,70%)"].join("");
          }
 
-         function bitvec2window(n, heat) {
+         function bitvec2window(n, heat, word) {
              var str = n.toString(2).padStart(10, "0")
                         .replace(/^([0-9]{5})/, '$1x')
                         .replace(/0/g, '·')
                         .replace(/1/g, '+');
-             return changeCharColor(str, heat);
+             return changeCharColor(str, heat, word);
          }
 
          % use Mojo::ByteStream 'b';
@@ -127,7 +132,7 @@
                  "dom": '<"top">rt<"bottom"flp><"clear">',
                  "columns": [
                      { "data": "rank", type: "allnumeric" },
-                     { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat) }},
+                     { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
                      { "data": "max",  render: function ( data, type, row ) {return data.toFixed(3) }},
                      { "data": "conorm", render: function ( data, type, row ) {return data.toFixed(3) }},
                      { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) }  },
@@ -503,8 +508,8 @@
                 T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
                 T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
                 return "translate(" +
-                                (d.x) + "," +
-                                (d.y) + ")";
+                                 (d.x) + "," +
+                                 (d.y) + ")";
             });
      }
 
@@ -514,8 +519,8 @@
             .data(data.words)
             .attr("transform", function(d, i) {
                 return "translate(" +
-                                 ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
-                                 ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
+                                  ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
+                                  ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
      }
 
      var svg;
@@ -840,7 +845,7 @@
                   <td align="right">
                   </td>
                   <script
-                    src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
+                      src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
                       </td>
                 </tr>
               </tbody>