Skip to content

Commit 7863896

Browse files
committed
Source table before annotations
1 parent defc000 commit 7863896

1 file changed

Lines changed: 43 additions & 42 deletions

File tree

previewers/betatest/js/refiqdacore.js

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -316,88 +316,89 @@ if (xmlDoc.getElementsByTagName("Sources")[0]) {
316316
}
317317
}
318318

319-
// Create Annotations table if there are any annotations
320-
if (annotationRows.length > 0) {
321-
$('#filterby').append($('<option/>').prop('value', 'Annotations').text('Annotations'));
319+
// Create Sources table if there are any sources
320+
if (sourceRows.length > 0) {
321+
$('#filterby').append($('<option/>').prop('value', 'Sources').text('Sources'));
322322

323-
let annotationBlock = $('<div/>').width(tableWidth).appendTo($(".preview"));
324-
annotationBlock.append($("<h2/>").html("Annotations"));
325-
let annotationTable = createTable("Annotations", "Filename", "Type", "Selection", "Codes").appendTo(annotationBlock);
326-
annotationTable.addClass("annotationtable compact stripe");
323+
let sourceBlock = $('<div/>').width(tableWidth).appendTo($(".preview"));
324+
sourceBlock.append($("<h2/>").html("Sources"));
325+
let sourceTable = createTable("Sources", "Filename", "Type", "Selection", "Codes").appendTo(sourceBlock);
326+
sourceTable.addClass("sourcetable compact stripe");
327327

328-
annotationRows.forEach(function(rowData) {
329-
let tr = addRow(annotationTable, rowData.sourceRef, rowData.type, rowData.name, rowData.codes);
328+
sourceRows.forEach(function(rowData) {
329+
let tr = addRow(sourceTable, rowData.sourceRef, rowData.type, rowData.name, rowData.codes);
330330
tr.attr('data-guid', rowData.guid);
331331
tr.attr('data-matches', rowData.matches);
332332
});
333333

334-
var annotationDataTable = $(".annotationtable").DataTable({
335-
select: $('#filterby').val() == 'Annotations'
334+
sourceDataTable = $(".sourcetable").DataTable({
335+
select: $('#filterby').val() == 'Sources'
336336
});
337337

338338
if (typeof downloadFile === 'function') {
339339
$("a[data-entry-index]").click(downloadFile);
340-
$('.annotationtable').on('draw.dt', function() {
340+
$('.sourcetable').on('draw.dt', function() {
341341
$("a[data-entry-index]").off('click');
342342
$("a[data-entry-index]").click(downloadFile);
343343
});
344344
}
345345

346-
tables.push(annotationDataTable);
347-
annotationDataTable.on('select deselect', function(e, dt, type, indexes) {
346+
tables.push(sourceDataTable);
347+
sourceDataTable.on('select deselect', function(e, dt, type, indexes) {
348348
if (type === 'row') {
349-
var data = annotationDataTable.rows(indexes).data().pluck('id');
350-
annotationDataTable[type](indexes).nodes().to$().addClass('custom-selected');
351-
console.log('uG: ' + annotationDataTable[type](indexes).nodes().to$().attr('data-guid'));
352-
console.log(annotationDataTable.rows({ selected: true }).count());
353-
console.log("clearing sG in annotation");
349+
var data = sourceDataTable.rows(indexes).data().pluck('id');
350+
sourceDataTable[type](indexes).nodes().to$().addClass('custom-selected');
351+
console.log('uG: ' + sourceDataTable[type](indexes).nodes().to$().attr('data-guid'));
352+
console.log(sourceDataTable.rows({ selected: true }).count());
353+
console.log("clearing sG in source");
354354
selectedGUIDs = new Array();
355-
annotationDataTable.rows({ selected: true }).nodes().to$().each(function(index, element) { selectedGUIDs.push(element.dataset.guid) });
355+
sourceDataTable.rows({ selected: true }).nodes().to$().each(function(index, element) { selectedGUIDs.push(element.dataset.guid) });
356356
selectedGUIDs.forEach(guid => { console.log('Added ' + guid); });
357-
tables.filter(function(curTable) { return curTable !== annotationDataTable }).forEach(table => { table.draw() });
357+
tables.filter(function(curTable) { return curTable !== sourceDataTable }).forEach(table => { table.draw() });
358358
}
359359
});
360360
}
361361

362-
// Create Sources table if there are any sources
363-
if (sourceRows.length > 0) {
364-
$('#filterby').append($('<option/>').prop('value', 'Sources').text('Sources'));
362+
363+
// Create Annotations table if there are any annotations
364+
if (annotationRows.length > 0) {
365+
$('#filterby').append($('<option/>').prop('value', 'Annotations').text('Annotations'));
365366

366-
let sourceBlock = $('<div/>').width(tableWidth).appendTo($(".preview"));
367-
sourceBlock.append($("<h2/>").html("Sources"));
368-
let sourceTable = createTable("Sources", "Filename", "Type", "Selection", "Codes").appendTo(sourceBlock);
369-
sourceTable.addClass("sourcetable compact stripe");
367+
let annotationBlock = $('<div/>').width(tableWidth).appendTo($(".preview"));
368+
annotationBlock.append($("<h2/>").html("Annotations"));
369+
let annotationTable = createTable("Annotations", "Filename", "Type", "Selection", "Codes").appendTo(annotationBlock);
370+
annotationTable.addClass("annotationtable compact stripe");
370371

371-
sourceRows.forEach(function(rowData) {
372-
let tr = addRow(sourceTable, rowData.sourceRef, rowData.type, rowData.name, rowData.codes);
372+
annotationRows.forEach(function(rowData) {
373+
let tr = addRow(annotationTable, rowData.sourceRef, rowData.type, rowData.name, rowData.codes);
373374
tr.attr('data-guid', rowData.guid);
374375
tr.attr('data-matches', rowData.matches);
375376
});
376377

377-
sourceDataTable = $(".sourcetable").DataTable({
378-
select: $('#filterby').val() == 'Sources'
378+
var annotationDataTable = $(".annotationtable").DataTable({
379+
select: $('#filterby').val() == 'Annotations'
379380
});
380381

381382
if (typeof downloadFile === 'function') {
382383
$("a[data-entry-index]").click(downloadFile);
383-
$('.sourcetable').on('draw.dt', function() {
384+
$('.annotationtable').on('draw.dt', function() {
384385
$("a[data-entry-index]").off('click');
385386
$("a[data-entry-index]").click(downloadFile);
386387
});
387388
}
388389

389-
tables.push(sourceDataTable);
390-
sourceDataTable.on('select deselect', function(e, dt, type, indexes) {
390+
tables.push(annotationDataTable);
391+
annotationDataTable.on('select deselect', function(e, dt, type, indexes) {
391392
if (type === 'row') {
392-
var data = sourceDataTable.rows(indexes).data().pluck('id');
393-
sourceDataTable[type](indexes).nodes().to$().addClass('custom-selected');
394-
console.log('uG: ' + sourceDataTable[type](indexes).nodes().to$().attr('data-guid'));
395-
console.log(sourceDataTable.rows({ selected: true }).count());
396-
console.log("clearing sG in source");
393+
var data = annotationDataTable.rows(indexes).data().pluck('id');
394+
annotationDataTable[type](indexes).nodes().to$().addClass('custom-selected');
395+
console.log('uG: ' + annotationDataTable[type](indexes).nodes().to$().attr('data-guid'));
396+
console.log(annotationDataTable.rows({ selected: true }).count());
397+
console.log("clearing sG in annotation");
397398
selectedGUIDs = new Array();
398-
sourceDataTable.rows({ selected: true }).nodes().to$().each(function(index, element) { selectedGUIDs.push(element.dataset.guid) });
399+
annotationDataTable.rows({ selected: true }).nodes().to$().each(function(index, element) { selectedGUIDs.push(element.dataset.guid) });
399400
selectedGUIDs.forEach(guid => { console.log('Added ' + guid); });
400-
tables.filter(function(curTable) { return curTable !== sourceDataTable }).forEach(table => { table.draw() });
401+
tables.filter(function(curTable) { return curTable !== annotationDataTable }).forEach(table => { table.draw() });
401402
}
402403
});
403404
}

0 commit comments

Comments
 (0)