Added legacy support for sigle call to api
diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index 8da1934..c03013f 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -23,7 +23,18 @@
url += '/' + match.docID;
url += '/' + match.textID;
*/
- url += '/' + match.textSigle;
+
+ var legacySigle = new RegExp('^([^_]+)_([^\.]+)\.(.+?)$');
+
+ // This is for legacy support
+ var legacy = legacySigle.exec(match.textSigle);
+ if (legacy[0]) {
+ url += '/' + legacy[1] + '/' + legacy[2] + '/' + legacy[3];
+ }
+ else {
+ url += '/' + match.textSigle;
+ }
+
url += '/' + match.matchID;
// { spans: true, layer:x, foundry : y}
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 90592ec..4adbfc0 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -27,16 +27,16 @@
'lib/highlight/highlight.pack',
'util'
], function (matchClass,
- hintClass,
- vcClass,
- tutClass,
- domReady,
- hintArray,
- vcArray,
- alertifyClass,
- sessionClass,
- tagger,
- selectMenuClass) {
+ hintClass,
+ vcClass,
+ tutClass,
+ domReady,
+ hintArray,
+ vcArray,
+ alertifyClass,
+ sessionClass,
+ tagger,
+ selectMenuClass) {
// Set hint array for hint helper
KorAP.hintArray = hintArray;
@@ -55,7 +55,7 @@
// Use alertify to log errors
alertifyClass.log(
(code === 0 ? '' : code + ': ') +
- msg,
+ msg,
'error',
10000
);
@@ -75,7 +75,7 @@
if (KorAP.Notifications !== undefined) {
var n = KorAP.Notifications;
for (var i = 0; i < n.length; i++) {
- alertifyClass.log(n[i][1], n[i][0], 10000);
+ alertifyClass.log(n[i][1], n[i][0], 10000);
};
};
@@ -92,13 +92,13 @@
var currentVC = loc.VC_allCorpora;
if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
- currentVC = loc.VC_oneCollection;
+ currentVC = loc.VC_oneCollection;
};
vcname.appendChild(
- document.createTextNode(
- document.getElementById('collection-name').value || currentVC
- )
+ document.createTextNode(
+ document.getElementById('collection-name').value || currentVC
+ )
);
input.parentNode.insertBefore(vcname, input);
@@ -114,28 +114,28 @@
for (i = 0; i < inactiveLi.length; i++) {
inactiveLi[i].addEventListener('click', function (e) {
- if (this._match !== undefined)
- this._match.open();
- else {
- // lazyLoad
- matchClass.create(this).open();
- };
- e.halt();
+ if (this._match !== undefined)
+ this._match.open();
+ else {
+ // lazyLoad
+ matchClass.create(this).open();
+ };
+ e.halt();
});
inactiveLi[i].addEventListener('keydown', function (e) {
- var code = _codeFromEvent(e);
-
- switch (code) {
- case 32:
- if (this._match !== undefined)
- this._match.toggle();
- else {
- // lazyLoad
- matchClass.create(this).open();
- };
- e.halt();
- break;
- };
+ var code = _codeFromEvent(e);
+
+ switch (code) {
+ case 32:
+ if (this._match !== undefined)
+ this._match.toggle();
+ else {
+ // lazyLoad
+ matchClass.create(this).open();
+ };
+ e.halt();
+ break;
+ };
});
};
@@ -158,66 +158,66 @@
if (KorAP.koralQuery !== undefined) {
if (resultButton !== null) {
- var kq;
- var toggle = document.createElement('a');
- toggle.setAttribute('title', loc.SHOW_KQ)
- toggle.classList.add('show-kq', 'button');
- toggle.appendChild(document.createElement('span'))
- .appendChild(document.createTextNode(loc.SHOW_KQ));
- resultButton.appendChild(toggle);
+ var kq;
+ var toggle = document.createElement('a');
+ toggle.setAttribute('title', loc.SHOW_KQ)
+ toggle.classList.add('show-kq', 'button');
+ toggle.appendChild(document.createElement('span'))
+ .appendChild(document.createTextNode(loc.SHOW_KQ));
+ resultButton.appendChild(toggle);
- var showKQ = function () {
- if (kq === undefined) {
- kq = document.createElement('div');
- kq.setAttribute('id', 'koralquery');
- kq.style.display = 'none';
- var kqInner = document.createElement('div');
- kq.appendChild(kqInner);
- kqInner.innerHTML = JSON.stringify(KorAP.koralQuery, null, ' ');
- hljs.highlightBlock(kqInner);
- var sb = document.getElementById('search');
- sb.insertBefore(kq, sb.firstChild);
- };
+ var showKQ = function () {
+ if (kq === undefined) {
+ kq = document.createElement('div');
+ kq.setAttribute('id', 'koralquery');
+ kq.style.display = 'none';
+ var kqInner = document.createElement('div');
+ kq.appendChild(kqInner);
+ kqInner.innerHTML = JSON.stringify(KorAP.koralQuery, null, ' ');
+ hljs.highlightBlock(kqInner);
+ var sb = document.getElementById('search');
+ sb.insertBefore(kq, sb.firstChild);
+ };
- if (kq.style.display === 'none') {
- kq.style.display = 'block';
- show['kq'] = true;
- }
- else {
- kq.style.display = 'none';
- delete show['kq'];
- };
- };
+ if (kq.style.display === 'none') {
+ kq.style.display = 'block';
+ show['kq'] = true;
+ }
+ else {
+ kq.style.display = 'none';
+ delete show['kq'];
+ };
+ };
- if (toggle !== undefined) {
-
- // Show koralquery
- toggle.addEventListener('click', showKQ);
- };
+ if (toggle !== undefined) {
+
+ // Show koralquery
+ toggle.addEventListener('click', showKQ);
+ };
};
if (KorAP.koralQuery["errors"]) {
- var errors = KorAP.koralQuery["errors"];
- for (var i in errors) {
+ var errors = KorAP.koralQuery["errors"];
+ for (var i in errors) {
- // Malformed query
- if (errors[i][0] === 302 && errors[i][2]) {
- obj.hint = hintClass.create();
- obj.hint.alert(errors[i][2], errors[i][1]);
- break;
- }
+ // Malformed query
+ if (errors[i][0] === 302 && errors[i][2]) {
+ obj.hint = hintClass.create();
+ obj.hint.alert(errors[i][2], errors[i][1]);
+ break;
+ }
- // no query
- else if (errors[i][0] === 301) {
- obj.hint = hintClass.create();
- obj.hint.alert(0, errors[i][1]);
- }
- }
+ // no query
+ else if (errors[i][0] === 301) {
+ obj.hint = hintClass.create();
+ obj.hint.alert(0, errors[i][1]);
+ }
+ }
};
// Session has KQ visibility stored
if (show["kq"])
- showKQ.apply();
+ showKQ.apply();
};
@@ -232,14 +232,14 @@
var cl = toggle.classList;
cl.add('align', 'right', 'button');
toggle.addEventListener(
- 'click',
- function (e) {
- var ol = document.querySelector('#search > ol');
- ol.toggleClass("align-left", "align-right");
- this.toggleClass("left", "right");
- });
+ 'click',
+ function (e) {
+ var ol = document.querySelector('#search > ol');
+ ol.toggleClass("align-left", "align-right");
+ this.toggleClass("left", "right");
+ });
toggle.appendChild(document.createElement('span'))
- .appendChild(document.createTextNode(loc.TOGGLE_ALIGN));
+ .appendChild(document.createTextNode(loc.TOGGLE_ALIGN));
resultButton.appendChild(toggle);
};
@@ -250,38 +250,38 @@
if (vcname) {
var vc;
var vcclick = function () {
- var view = document.getElementById('vc-view');
+ var view = document.getElementById('vc-view');
- // The vc is visible
- if (vcname.classList.contains('active')) {
- view.removeChild(vc.element());
- vcname.classList.remove('active');
- delete show['collection'];
- }
+ // The vc is visible
+ if (vcname.classList.contains('active')) {
+ view.removeChild(vc.element());
+ vcname.classList.remove('active');
+ delete show['collection'];
+ }
- // The vc is not visible
- else {
- if (vc === undefined)
- vc = _getCurrentVC(vcClass, vcArray);
- view.appendChild(vc.element());
- vcname.classList.add('active');
- show['collection'] = true;
- };
+ // The vc is not visible
+ else {
+ if (vc === undefined)
+ vc = _getCurrentVC(vcClass, vcArray);
+ view.appendChild(vc.element());
+ vcname.classList.add('active');
+ show['collection'] = true;
+ };
};
vcname.onclick = vcclick;
if (show['collection']) {
- vcclick.apply();
+ vcclick.apply();
};
};
-
+
/**
* Init Tutorial view
*/
if (document.getElementById('view-tutorial')) {
window.tutorial = tutClass.create(
- document.getElementById('view-tutorial'),
- session
+ document.getElementById('view-tutorial'),
+ session
);
obj.tutorial = window.tutorial;
}
@@ -306,30 +306,30 @@
var form = document.getElementById('searchform');
if (form !== null) {
form.addEventListener('submit', function (e) {
- var qf = document.getElementById('q-field');
+ var qf = document.getElementById('q-field');
- // No query was defined
- if (qf.value === undefined || qf.value === '') {
- qf.focus();
- e.halt();
- KorAP.log(700, "No query given");
- return;
- };
+ // No query was defined
+ if (qf.value === undefined || qf.value === '') {
+ qf.focus();
+ e.halt();
+ KorAP.log(700, "No query given");
+ return;
+ };
- // Store session information
- session.set("show", show);
+ // Store session information
+ session.set("show", show);
- // Set Virtual collection
- if (vc === undefined) {
- vc = _getCurrentVC(vcClass, vcArray);
- };
+ // Set Virtual collection
+ if (vc === undefined) {
+ vc = _getCurrentVC(vcClass, vcArray);
+ };
- if (vc !== undefined) {
- input.value = vc.toQuery();
- }
- else {
- delete input['value'];
- };
+ if (vc !== undefined) {
+ input.value = vc.toQuery();
+ }
+ else {
+ delete input['value'];
+ };
});
};
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;
},