diff --git a/js/derekovecs.js b/js/derekovecs.js
new file mode 100644
index 0000000..4e114bc
--- /dev/null
+++ b/js/derekovecs.js
@@ -0,0 +1,173 @@
+function queryKorAPpoliqarp(query) {
+    window.open('http://korap.ids-mannheim.de/kalamar/?ql=poliqarp&q='+encodeURIComponent(query), 'KorAP');
+}
+
+
+function queryKorAPalternatives(alt1, alt2) {
+    queryKorAPpoliqarp("{1:[orth="+ alt1 +"]} | {2:[orth=" + alt2 +"]}");
+}
+
+function paradigmatorClick(e, target, paradigmator) {
+    if (e.which === 2) {
+        e.preventDefault();
+        queryKorAPalternatives(target, paradigmator);
+        return false;
+    }
+}
+
+
+function makeVocabDistanceTable(id, baseURL) {
+  var urlprefix =  new URLSearchParams(window.location.search);
+  return $(id).DataTable({
+    ajax: {
+      method: "GET",
+      url: baseURL + '/getBiggestVocabDistances',
+      dataType: 'json',
+      dataSrc: function (result) {
+        return result;
+      },
+      timeout: 30000,
+    },
+    "initComplete":function(settings, json){
+      vocabDistanceTable.columns.adjust().draw();
+    },
+    "createdRow": function (row, data, rowIndex) {
+      $.each($('td.collocator', row), function (colIndex) {
+        $(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB") + " f1: "+ccResult.f1+ " total: "+ccResult.N);
+      });
+    },
+    "sScrollY": "780px",
+    "bScrollCollapse": true,
+    "bPaginate": false,
+    "bJQueryUI": true,
+    "dom": '<"top">rt<"bottom"flp><"clear">',
+    "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 class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>' 
+      }}
+    ],
+    "columnDefs": [
+      { className: "dt-right", "targets": [0,1] },
+      { "searchable": false,
+        "orderable": false,
+        "targets": 0
+      },
+      { "orderSequence": [ "desc" ], "targets": [ 1 ] },
+      { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] },
+    ],
+    "oLanguage": {
+      "sSearch": "Filter: "
+    },
+    "order": [[ 1, 'desc' ]]
+  });
+}
+
+function toFixed(n, d) {
+  if(typeof n != "number") {
+    return n;
+  } else {
+    return n.toFixed(d);
+  }
+}
+
+function toExponential(n, d) {
+  if(typeof n != "number") {
+    return n;
+  } else {
+    return n.toExponential(d);
+  }
+}
+
+function bitmask2window(autofocus, win) {
+  var af_str = autofocus.toString(2).padStart(10, "0")
+    .replace(/^([0-9]{5})/, '$1 ')
+    .replace(/0/g, '·')
+    .replace(/1/g, '◼');
+  var w_str = win.toString(2).padStart(10, "0")
+    .replace(/^([0-9]{5})/, '$1 ')
+    .replace(/0/g, '·')
+    .replace(/1/g, 'o');
+  for (var i=0, l=af_str.length; i<l; i++) {
+    if(af_str.charAt(i) == '·' && w_str.charAt(i) == 'o' ) {
+      af_str = af_str.substring(0, i) + "◽" + af_str.substring(i+1);
+    }
+  }
+  return af_str;
+}
+
+function makeClassicCollocatorTable(id, baseURL, wordIndex) {
+  $.fn.dataTable.ext.errMode = 'throw';
+  var classicCollocatorTable = $('#classicoloctable').DataTable({
+    ajax: {
+      method: "GET",
+      url: baseURL + '/getClassicCollocators',
+      dataType: 'json',
+      dataSrc: function (result) {
+        ccResult = result;
+        $("#rawfreq_tt").attr("title", "Raw frequencies of the co-occurence.\n"
+                              + "f(" + ccResult.w1+")=" + ccResult.f1.toLocaleString("en-GB") + ";\n"
+                              + "N=" + ccResult.N.toLocaleString("en-GB"));
+        return result.collocates;
+      },
+      warning: function (request, error) {
+      },
+      timeout: 30000,
+      data: { w: wordIndex }
+    },
+    "initComplete":function(settings, json){
+      $("td.collocator").click(function(){
+        queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
+      });
+      classicCollocatorTable.columns(".detail").visible(false);
+      $("#ccd").css('width', '680px');
+      classicCollocatorTable.columns.adjust().draw();
+    },
+    "createdRow": function (row, data, rowIndex) {
+      $.each($('td.collocator', row), function (colIndex) {
+        $(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB") + " f1: "+ccResult.f1+ " total: "+ccResult.N);
+      });
+    },
+    "sScrollY": "780px",
+    "bScrollCollapse": true,
+    "bPaginate": false,
+    "bJQueryUI": true,
+    "dom": '<"top">rt<"bottom"flp><"clear">',
+    "columns": [
+      //                      { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
+      { "data": "llr",  render: function ( data, type, row ) {return toFixed(data, 0) }},
+      { "data": "pmi", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      { "data": "md", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      { "data": "lfmd", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      //             { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(2) }  },
+      { "data": "npmi", render: function ( data, type, row ) {return toFixed(data, 3) }},
+      { "data": "dice", render: function ( data, type, row ) {return toExponential(data, 2) }},
+      { "data": "ld", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      { "data": "af", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      { "data": "delta", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      { "data": "afwin", width: "auto", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitmask2window(data, row.win) }},
+      { "data": "lncount", render: function ( data, type, row ) {return toFixed(data, 1) }},
+      { "data": "rncount", render: function ( data, type, row ) {return toFixed(data, 1) }},
+      { "data": "lnpmi", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      { "data": "rnpmi", render: function ( data, type, row ) {return toFixed(data, 2) }},
+      { "data": "f" },
+      { "data": "word",  sClass: "collocator" }
+    ],
+    "columnDefs": [
+      { className: "dt-right", "targets": [0,1,2,3,4,5,6,7,8,10,11,12,13,14] },
+      { className: "dt-right detail", "targets": [5,10,11,12,13] },
+      { "searchable": false,
+        "orderable": false,
+        "targets": []
+      },
+      { "orderSequence": [ "desc" ], "targets": [0,1,2,3,4,5,6,7,10,11,12,13,14] },
+      { "orderSequence": [ "asc", "desc" ], "targets": [8,9,15] },
+    ],
+    "oLanguage": {
+      "sSearch": "Filter: "
+    },
+    "order": [[ 7, 'desc' ]],
+  });
+  return classicCollocatorTable;
+}
