diff --git a/ner-edith.js b/ner-edith.js
index 84070b5..6e60d87 100644
--- a/ner-edith.js
+++ b/ner-edith.js
@@ -52,6 +52,24 @@ function setupInterface(data, file, urls) {
var startIndex=0;
var endIndex=displayRows;
+ var has_changes = false;
+
+ function notifyChange() {
+ has_changes = true;
+
+ $("#save").attr('disabled', false);
+ }
+
+ function resetChanged() {
+ $("#save").attr('disabled', true);
+ has_changes = false;
+ }
+
+ var that =
+ {
+ hasChanges: function () { return has_changes; }
+ };
+
function updatePreview(nRow) {
if (urls == null) return;
@@ -132,6 +150,8 @@ function setupInterface(data, file, urls) {
let tableInfo = $(td).data('tableInfo');
data.data[tableInfo.nRow][tableInfo.column] = newValue;
+
+ notifyChange();
}
else {
$(td).html(editingTd.data);
@@ -205,6 +225,8 @@ function setupInterface(data, file, urls) {
data.data[tableInfo.nRow - 1]['TOKEN'] += data.data[tableInfo.nRow]['TOKEN'];
data.data.splice(tableInfo.nRow, 1);
+
+ notifyChange();
}
else if (editingTd.tokenizer_action.includes('split')) {
@@ -216,6 +238,8 @@ function setupInterface(data, file, urls) {
data.data[pos]['No.']++;
pos++;
}
+
+ notifyChange();
}
else if (editingTd.tokenizer_action.includes('start-sentence')) {
let pos = tableInfo.nRow;
@@ -225,6 +249,8 @@ function setupInterface(data, file, urls) {
pos++;
word_pos++;
}
+
+ notifyChange();
}
editingTd = null;
@@ -271,6 +297,8 @@ function setupInterface(data, file, urls) {
editingTd = null;
colorCode();
+
+ notifyChange();
}
};
@@ -423,7 +451,7 @@ function setupInterface(data, file, urls) {
`;
let save_html =
- ``
+ ``
$("#tableregion").html(table_html)
@@ -490,7 +518,6 @@ function setupInterface(data, file, urls) {
lnk.href = objectURL = url.createObjectURL(blob);
lnk.dispatchEvent(new MouseEvent('click'));
setTimeout(url.revokeObjectURL.bind(url, objectURL));
-
}
$('.saveButton').on('click', saveFile)
@@ -566,18 +593,31 @@ function setupInterface(data, file, urls) {
updateTable();
}
);
+
+ return that;
}
$(document).ready(
function() {
+
$('#tsv-file').change(
function(evt) {
loadFile ( evt,
function(results, file, urls) {
- setupInterface(results, file, urls);
+ var ner_edith = setupInterface(results, file, urls);
+
+ $(window).bind("beforeunload",
+ function() {
+
+ console.log(ner_edith.hasChanges());
+
+ if (ner_edith.hasChanges())
+ return confirm("You have unsaved changes. Do you want to save them before leaving?");
+ }
+ );
})
}
);
diff --git a/tools/README.md b/tools/README.md
index 494d653..52d3622 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -47,7 +47,7 @@ page2tsv PAGE5.xml PAGE.tsv --image-url=http://link-to-corresponding-image-5
For instance, for the file assets/example.xml:
```
-page2tsv example.xml example.tsv --image-url=http://content.staatsbibliothek-berlin.de/zefys/SNP27646518-18800101-0-3-0-0/left,top,width,height/full/0/default.jpg
+page2tsv example.xml example .tsv --image-url=http://content.staatsbibliothek-berlin.de/zefys/SNP27646518-18800101-0-3-0-0/left,top,width,height/full/0/default.jpg
```
---