/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1
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
37
38
39
40
41
42
43
// Recursive Pos of div in document - should work in most browsers
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return {
		x:curleft,
		y:curtop
	}
}

// The idea is to have a few functions like this one and minimum javascript intervention		
function updateslider(e, kind, smin, smax, slen, sliderid, boxid) {
	if(mb) {
		coords = findPos(e.currentTarget);
		coords.x = e.clientX - coords.x;
		coords.y = e.clientY - coords.y;
		cx = coords.x / slen;
		sd = smax - smin;
		val = smin + (sd * cx);
		if(kind == 1) {
			val = Math.round(val);
		}
		document.getElementById(boxid).value = val;				
		document.getElementById(sliderid).style.left = Math.ceil((slen) * ((val - smin) / sd))+"px";
	}
}

var mb = 0;

function mbpress(e) {
	mb = 1;
}

function mbrelease(e) {
	mb = 0;
}