Added VC.checkRewrite() class method
Change-Id: If8a557a37a59eb850f936bcfd1a591b789f3a933
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 3e9f16e..5ba68d1 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -176,13 +176,39 @@
},
+ // Check if the virtual corpus contains a rewrite
+ // This is a class method
+ checkRewrite : function (json) {
+
+ // There is a rewrite attribute
+ if (json['rewrites'] !== undefined) {
+ return true;
+ }
+
+ // There is a group to check for rewrites
+ else if (json['@type'] === 'koral:docGroup') {
+ var ops = json['operands'];
+ if (ops === undefined)
+ return false;
+
+ for (var i in ops) {
+
+ // "this" is the class
+ if (this.checkRewrite(ops[i])) {
+ return true;
+ };
+ };
+ };
+ return false;
+ },
+
/**
* Clean the virtual document to uspecified doc.
*/
clean : function () {
if (this._root.ldType() !== "non") {
- this._root.destroy();
- this.root(unspecDocClass.create(this));
+ this._root.destroy();
+ this.root(unspecDocClass.create(this));
};
return this;
},