w2v-js: ajax call for classic collocators from inside datatable
diff --git a/templates/index.html.ep b/templates/index.html.ep
index 38a41a0..32be0a8 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -168,56 +168,60 @@
$('#display_error')
.html('Error: ' + xhr.status + ' ' + xhr.statusText);
}
- })
+ });
- $.post('/derekovecs/getClassicCollocators',
- JSON.stringify(paraResults[0][0].rank),
- function(collocators, status) {
- collocatorTable = $('#classicoloctable').DataTable({
- data: collocators,
- "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 data.toFixed(3) }},
- { "data": "lfmd", render: function ( data, type, row ) {return data.toFixed(3) }},
- { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
- { "data": "npmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
- { "data": "word", sClass: "collocator" }
- ],
- "columnDefs": [
- { className: "dt-right", "targets": [0,1,2,3] },
- { "searchable": false,
- "orderable": false,
- "targets": []
- },
- { "type": "scientific", targets: [2,3] },
- { "orderSequence": [ "desc" ], "targets": [ 0, 1, 2, 3 ] },
- { "orderSequence": [ "asc", "desc" ], "targets": [ 4 ] },
- ],
- "oLanguage": {
- "sSearch": "Filter: "
- },
- "order": [[ 1, 'desc' ]],
- } );
- }, 'json');
+ classicCollocatorTable = $('#classicoloctable').DataTable({
+ ajax: {
+ method: "POST",
+ url: '/derekovecs/getClassicCollocators',
+ dataType: 'json',
+ dataSrc: "",
+ timeout: 30000,
+ data: function ( d ) {
+ return JSON.stringify(paraResults[0][0].rank);
+ }
+ },
+ "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 data.toFixed(3) }},
+ { "data": "lfmd", render: function ( data, type, row ) {return data.toFixed(3) }},
+ { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
+ { "data": "npmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
+ { "data": "word", sClass: "collocator" }
+ ],
+ "columnDefs": [
+ { className: "dt-right", "targets": [0,1,2,3] },
+ { "searchable": false,
+ "orderable": false,
+ "targets": []
+ },
+ { "type": "scientific", targets: [2,3] },
+ { "orderSequence": [ "desc" ], "targets": [ 0, 1, 2, 3 ] },
+ { "orderSequence": [ "asc", "desc" ], "targets": [ 4 ] },
+ ],
+ "oLanguage": {
+ "sSearch": "Filter: "
+ },
+ "order": [[ 1, 'desc' ]],
+ });
collocatorTable.on( 'order.dt search.dt', function () {
collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
} );
- } ).draw();
+ }).draw();
+ }
- if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
- var index = parseInt(localStorage['tab']||'0');
- $("#tabs").tabs({ active: index });
- }
+ if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
+ var index = parseInt(localStorage['tab']||'0');
+ $("#tabs").tabs({ active: index });
}
$("#tabs").css("visibility", "visible"); // now we can show the tabs
-
});
$(function(){
@@ -931,7 +935,7 @@
<th>llr</th>
<th title="log-frequency biased mutual dependency">lfmd</th>
<th title="frequency biased pointwise mutual information">fpmi</th>
- <th title="normalized mutual information">npmi</th>
+ <th title="normalized pointwise mutual information">npmi</th>
<th>collocator</th>
</tr>
</thead>