Skip to content

Commit

Permalink
'corrections' global variable is obsolete (#41), adapt viewer.js and …
Browse files Browse the repository at this point in the history
…editor.js later + removed old loadannotations()
  • Loading branch information
proycon committed Nov 23, 2016
1 parent 9a76311 commit 4197651
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions flat/style/flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var selector = ""; //structural element to select when clicking/hovering: empty
var struction = {}; //structural items
var annotations = {}; //annotations per structure item
var declarations = {};
var corrections = {};
var docid = null;
var initialannotationlist = [];
var initialdeclarationlist = [];
Expand Down Expand Up @@ -144,57 +143,6 @@ function loadannotations(annotationresponse) {
}


function loadannotations(annotationlist) {
//load annotations from the annotation data response in memory, called by update()

annotationlist.forEach(function(annotation){
annotation.scope.forEach(function(target){ //using scope (deep/recursive) instead of targets (shallow/explicit) as we want to process nested span annotations as well
if (!(annotations[target])) annotations[target] = {};
if (!(latestannotations[target])) latestannotations[target] = {};
var annotationid = getannotationid(annotation);
annotations[target][annotationid] = annotation; //TODO: creates too many copies in case of span annotation (issue #41)
annotations[target][annotationid].annotationid = annotationid;
latestannotations[target][annotationid] = true;
});
if ((annotation.type == "correction") && (annotation.id)) {
corrections[annotation.id] = annotation;
if ((annotation.suggestions.length > 0) && (annotation.new.length === 0)) {
//find the annotation the suggestions apply to and act as if
//that is part of the correction
target = annotation.targets[0];
Object.keys(annotations[target]).forEach(function(annotationid){
if (annotationid != "self") {
if ((annotations[target][annotationid].type == annotation.suggestions[0].type) && (annotations[target][annotationid].set == annotation.suggestions[0].set)) {
if (!annotations[target][annotationid].incorrection) {
annotations[target][annotationid].incorrection = [annotation.id];
} else {
annotations[target][annotationid].incorrection.push(annotation.id);
}
}
}
});
}
}
});

//find old annotations that are no longer in the response, delete them
Object.keys(latestannotations).forEach(function(target){
if (annotations[target]) {
Object.keys(annotations[target]).forEach(function(annotationid){
if (!latestannotations[target][annotationid]) delete annotations[target][annotationid];
});
}
});

/*
if (function_exists(mode + '_onloadannotations')) {
f = eval(mode + '_onloadannotations');
f(annotationlist);
}
*/
}


function loaddeclarations(declarationlist) {
//parse the metadata response and populate the declarations structure in memory, declarationlist is supplied through the server-side template on page load
declarationlist.forEach(function(declaration){
Expand Down

0 comments on commit 4197651

Please sign in to comment.