Minor changes for code publication and persistant method to VC
diff --git a/dev/js/src/datepicker.js b/dev/js/src/datepicker.js
index 59a3ec2..8608efe 100644
--- a/dev/js/src/datepicker.js
+++ b/dev/js/src/datepicker.js
@@ -118,6 +118,18 @@
return this._element;
},
+ /**
+ * Get the current date in string format.
+ */
+ today : function () {
+ var today = new Date();
+ var str = today.getYear() + 1900;
+ var m = today.getMonth() + 1;
+ var d = today.getDate();
+ str += '-' + (m < 10 ? '0' + m : m);
+ str += '-' + (d < 10 ? '0' + d : d);
+ return str;
+ },
/**
* Increment the year.
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 7938a9e..da94a73 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -8,6 +8,7 @@
'lib/alertify',
'api',
'mailToChiffre',
+ 'lib/highlight/highlight.pack',
'util'
], function (matchClass,
hintClass,
@@ -155,6 +156,15 @@
// Initialize documentation links
obj.tutorial.initDocLinks(document);
+ if (KorAP.currentQuery !== undefined) {
+ var sb = document.getElementById('searchbar');
+ var kq = document.createElement('div');
+ kq.setAttribute('id', 'koralquery');
+ sb.parentNode.insertBefore(kq, sb.nextSibling);
+ kq.innerHTML = JSON.stringify(KorAP.currentQuery, null, ' ');
+ hljs.highlightBlock(kq);
+ };
+
/**
* Init hint helper
* has to be final because of
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 1aed3cf..5cf2284 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -192,6 +192,7 @@
root : function (obj) {
if (arguments.length === 1) {
var e = this.element();
+
if (e.firstChild !== null) {
if (e.firstChild !== obj.element()) {
e.replaceChild(obj.element(), e.firstChild);
@@ -225,7 +226,7 @@
// Initialize root
this._element.appendChild(this._root.element());
-
+
return this._element;
},
@@ -239,6 +240,42 @@
return this;
},
+ /**
+ * Make the vc persistant by injecting the current timestamp
+ * as a creation date limit criterion.
+ */
+ makePersistant : function () {
+// this.root().wrapOnRoot('and');
+ var todayStr = KorAP._vcDatePicker.today();
+ var doc = docClass.create();
+ var root = this.root();
+
+ if (root.ldType() === 'docGroup' &&
+ root.operation === 'and') {
+ root.append(cond);
+ }
+ else {
+ root.wrapOnRoot('and');
+ root.append(doc);
+ };
+
+ doc.key("creationDate");
+ doc.type("date");
+ doc.matchop("leq");
+ doc.value(todayStr);
+
+/*
+ {
+ "@type" : "koral:doc",
+ "key" : "creationDate",
+ "type" : "type:date",
+ "match" : "match:leq",
+ "value" : todayStr
+ }
+ this.root().append(cond);
+*/
+ this.update();
+ },
/**
* Get the generated json string