summaryrefslogtreecommitdiff
path: root/engines/kokompe/temp/KoControlRule.js
blob: 9c698c880b576e67267e6f0a26393e016230c8c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

function KoControlRule() {
	this.Element = $(document.createElement("INPUT"));
	this.Element.addClass("KoRule");
	this.Element.attr("type", "text");
	var rules = $("#rules");
	rules.append(this.Element);
	
	var t = this;
	this.Element.change(function(event) {
		t.SetRule(t.Element.val());
	});
}

KoControlRule.prototype = {
	SetRule: function(rule) {
		this.Rule = rule;
		// TODO: Perhaps we should check, here, if the rules make sense?
		KoDraw.EvaluateRules();
	},
	
	GetRule: function() {
		return this.Rule;
	},
	
	Evaluate: function() {
		// This will evaluate the rule given and make necessary adjustments for the rules to be fulfilled.
		var terms = this.Rule.split(/[<=>]/); // At the moment we only handle "=".
		if (terms.length < 2) {
			return false;
		}
		terms[0] = trim(terms[0])
		terms[1] = trim(terms[1])
		
	}
}