Added legacy support for sigle call to api
diff --git a/dev/js/src/match.js b/dev/js/src/match.js
index 28d2154..6299220 100644
--- a/dev/js/src/match.js
+++ b/dev/js/src/match.js
@@ -47,68 +47,68 @@
// No match defined
if (arguments.length < 1 ||
- match === null ||
- match === undefined) {
- throw new Error('Missing parameters');
+ match === null ||
+ match === undefined) {
+ throw new Error('Missing parameters');
}
// Match defined as a node
else if (match instanceof Node) {
- this._element = match;
+ this._element = match;
- // Circular reference !!
- match["_match"] = this;
+ // Circular reference !!
+ match["_match"] = this;
-/*
- this.corpusID = match.getAttribute('data-corpus-id'),
- this.docID = match.getAttribute('data-doc-id'),
- this.textID = match.getAttribute('data-text-id'),
-*/
- if (match.hasAttribute('data-text-sigle')) {
- this.textSigle = match.getAttribute('data-text-sigle')
- }
- else {
- this.textSigle = match.getAttribute('data-corpus-id') +
- '/' +
- match.getAttribute('data-doc-id') +
- '/' +
- match.getAttribute('data-text-id');
- };
+ /*
+ this.corpusID = match.getAttribute('data-corpus-id'),
+ this.docID = match.getAttribute('data-doc-id'),
+ this.textID = match.getAttribute('data-text-id'),
+ */
+ if (match.hasAttribute('data-text-sigle')) {
+ this.textSigle = match.getAttribute('data-text-sigle')
+ }
+ else {
+ this.textSigle = match.getAttribute('data-corpus-id') +
+ '/' +
+ match.getAttribute('data-doc-id') +
+ '/' +
+ match.getAttribute('data-text-id');
+ };
- this.matchID = match.getAttribute('data-match-id');
+ this.matchID = match.getAttribute('data-match-id');
- // List of available annotations
- this.available = match.getAttribute('data-available-info').split(' ');
+ // List of available annotations
+ this.available = match.getAttribute('data-available-info').split(' ');
}
// Match as an object
else {
- // Iterate over allowed match terms
- for (var i in _matchTerms) {
- var term = _matchTerms[i];
- this[term] = match[term] !== undefined ? match[term] : undefined;
- };
+ // Iterate over allowed match terms
+ for (var i in _matchTerms) {
+ var term = _matchTerms[i];
+ this[term] = match[term] !== undefined ? match[term] : undefined;
+ };
};
this._avail = {
- tokens : [],
- spans : [],
- rels : []
+ tokens : [],
+ spans : [],
+ rels : []
};
// Iterate over info layers
for (var i = 0; i < this.available.length; i++) {
- var term = this.available[i];
+ var term = this.available[i];
- // Create info layer objects
- try {
- var layer = require('match/infolayer').create(term);
- this._avail[layer.type].push(layer);
- }
- catch (e) {
- continue;
- };
+ // Create info layer objects
+ try {
+ var layer = require('match/infolayer').create(term);
+ this._avail[layer.type].push(layer);
+ }
+ catch (e) {
+ continue;
+ };
};
return this;
@@ -149,18 +149,18 @@
// There is an element to open
if (this._element === undefined || this._element === null)
- return false;
+ return false;
// The element is already opened
if (element.classList.contains('active'))
- return false;
+ return false;
// Add active class to element
element.classList.add('active');
// Already there
if (element.classList.contains('action'))
- return true;
+ return true;
// Create action buttons
var ul = document.createElement('ul');
@@ -174,14 +174,14 @@
// Add close button
var close = document.createElement('li');
close.appendChild(document.createElement('span'))
- .appendChild(document.createTextNode(loc.CLOSE));
+ .appendChild(document.createTextNode(loc.CLOSE));
close.classList.add('close');
close.setAttribute('title', loc.CLOSE);
// Add info button
var info = document.createElement('li');
info.appendChild(document.createElement('span'))
- .appendChild(document.createTextNode(loc.SHOWINFO));
+ .appendChild(document.createTextNode(loc.SHOWINFO));
info.classList.add('info');
info.setAttribute('title', loc.SHOWINFO);
@@ -189,14 +189,14 @@
// Close match
close.addEventListener('click', function (e) {
- e.halt();
- that.close()
+ e.halt();
+ that.close()
});
// Add information, unless it already exists
info.addEventListener('click', function (e) {
- e.halt();
- that.info().toggle();
+ e.halt();
+ that.info().toggle();
});
ul.appendChild(close);
@@ -208,9 +208,9 @@
// Todo: Test toggle
toggle : function () {
if (this._element.classList.contains('active'))
- this.close();
+ this.close();
else
- this.open();
+ this.open();
},
@@ -233,16 +233,16 @@
// Create match info
if (this._info === undefined)
- this._info = infoClass.create(this);
+ this._info = infoClass.create(this);
// There is an element to append
if (this._element === undefined ||
- this._element === null)
- return this._info;
+ this._element === null)
+ return this._info;
// Info is already activated
if (this._info._element !== undefined)
- return this._info;
+ return this._info;
return this._info;
},