mirror of
https://github.com/qurator-spk/neat.git
synced 2025-06-13 21:59:54 +02:00
notify user on page reload
This commit is contained in:
parent
b82b8175a9
commit
bcfb8220d3
2 changed files with 44 additions and 4 deletions
46
ner-edith.js
46
ner-edith.js
|
@ -52,6 +52,24 @@ function setupInterface(data, file, urls) {
|
||||||
var startIndex=0;
|
var startIndex=0;
|
||||||
var endIndex=displayRows;
|
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) {
|
function updatePreview(nRow) {
|
||||||
|
|
||||||
if (urls == null) return;
|
if (urls == null) return;
|
||||||
|
@ -132,6 +150,8 @@ function setupInterface(data, file, urls) {
|
||||||
let tableInfo = $(td).data('tableInfo');
|
let tableInfo = $(td).data('tableInfo');
|
||||||
|
|
||||||
data.data[tableInfo.nRow][tableInfo.column] = newValue;
|
data.data[tableInfo.nRow][tableInfo.column] = newValue;
|
||||||
|
|
||||||
|
notifyChange();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(td).html(editingTd.data);
|
$(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[tableInfo.nRow - 1]['TOKEN'] += data.data[tableInfo.nRow]['TOKEN'];
|
||||||
|
|
||||||
data.data.splice(tableInfo.nRow, 1);
|
data.data.splice(tableInfo.nRow, 1);
|
||||||
|
|
||||||
|
notifyChange();
|
||||||
}
|
}
|
||||||
else if (editingTd.tokenizer_action.includes('split')) {
|
else if (editingTd.tokenizer_action.includes('split')) {
|
||||||
|
|
||||||
|
@ -216,6 +238,8 @@ function setupInterface(data, file, urls) {
|
||||||
data.data[pos]['No.']++;
|
data.data[pos]['No.']++;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notifyChange();
|
||||||
}
|
}
|
||||||
else if (editingTd.tokenizer_action.includes('start-sentence')) {
|
else if (editingTd.tokenizer_action.includes('start-sentence')) {
|
||||||
let pos = tableInfo.nRow;
|
let pos = tableInfo.nRow;
|
||||||
|
@ -225,6 +249,8 @@ function setupInterface(data, file, urls) {
|
||||||
pos++;
|
pos++;
|
||||||
word_pos++;
|
word_pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notifyChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
editingTd = null;
|
editingTd = null;
|
||||||
|
@ -271,6 +297,8 @@ function setupInterface(data, file, urls) {
|
||||||
editingTd = null;
|
editingTd = null;
|
||||||
|
|
||||||
colorCode();
|
colorCode();
|
||||||
|
|
||||||
|
notifyChange();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -423,7 +451,7 @@ function setupInterface(data, file, urls) {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let save_html =
|
let save_html =
|
||||||
`<button class="btn btn-primary saveButton">Save Changes</button>`
|
`<button class="btn btn-primary saveButton" id="save" disabled>Save Changes</button>`
|
||||||
|
|
||||||
$("#tableregion").html(table_html)
|
$("#tableregion").html(table_html)
|
||||||
|
|
||||||
|
@ -490,7 +518,6 @@ function setupInterface(data, file, urls) {
|
||||||
lnk.href = objectURL = url.createObjectURL(blob);
|
lnk.href = objectURL = url.createObjectURL(blob);
|
||||||
lnk.dispatchEvent(new MouseEvent('click'));
|
lnk.dispatchEvent(new MouseEvent('click'));
|
||||||
setTimeout(url.revokeObjectURL.bind(url, objectURL));
|
setTimeout(url.revokeObjectURL.bind(url, objectURL));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.saveButton').on('click', saveFile)
|
$('.saveButton').on('click', saveFile)
|
||||||
|
@ -566,18 +593,31 @@ function setupInterface(data, file, urls) {
|
||||||
updateTable();
|
updateTable();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(
|
$(document).ready(
|
||||||
function() {
|
function() {
|
||||||
|
|
||||||
$('#tsv-file').change(
|
$('#tsv-file').change(
|
||||||
function(evt) {
|
function(evt) {
|
||||||
|
|
||||||
loadFile ( evt,
|
loadFile ( evt,
|
||||||
function(results, file, urls) {
|
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?");
|
||||||
|
}
|
||||||
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -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:
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue