7
// Recursive Pos of div in document - should work in most browsers
8
function findPos(obj) {
9
var curLeft = curTop = 0;
10
if(obj.offsetParent) {
11
curLeft = obj.offsetLeft
12
curTop = obj.offsetTop
13
while(obj = obj.offsetParent) {
14
curLeft += obj.offsetLeft
15
curTop += obj.offsetTop
26
ui read widget functions
30
function readSlider(sliderId) {
31
var value = parseFloat(document.getElementById(sliderId + "box").value);
38
function readBinary(binaryId) {
39
lf = document.getElementById(binaryId + "marker").style.left;
49
ui change widget functions
53
// The idea is to have a few functions like this one and minimum javascript intervention
54
function updateBinary(event, binaryId) {
56
coords = findPos(event.currentTarget);
57
coords.x = event.clientX - coords.x;
58
coords.y = event.clientY - coords.y;
60
document.getElementById(binaryId + "marker").style.left = 20 + "px";
61
document.getElementById(binaryId).style.backgroundColor = "#ddd";
62
}else if(coords.x < 16) {
63
document.getElementById(binaryId + "marker").style.left = 2 + "px";
64
document.getElementById(binaryId).style.backgroundColor = "#777";
69
// The idea is to have a few functions like this one and minimum javascript intervention
70
function updateSlider(event, kind, min, max, length, sliderId, boxId) {
72
coords = findPos(event.currentTarget);
73
coords.x = event.clientX - coords.x;
74
coords.y = event.clientY - coords.y;
75
cx = coords.x / length;
77
value = min + (sd * cx);
78
if(value > max) value = max;
80
value = Math.round(value);
83
value = Math.round(value * 10.0) / 10.0;
86
value = Math.round(value * 100.0) / 100.0;
89
value = Math.round(value * 1000.0) / 1000.0;
91
document.getElementById(boxId).value = value;
92
document.getElementById(sliderId).style.left = Math.ceil((length) * ((value - min) / sd)) + "px";
96
function sliderPosition(value, min, max, length) {
103
pos = Math.round(((value - min) / (max - min)) * length);
107
function changeSlider(value, sliderId, kind, min, max, length) {
108
value = parseFloat(value);
119
value = Math.round(value);
122
value = Math.round(value * 10.0) / 10.0;
125
value = Math.round(value * 100.0) / 100.0;
128
value = Math.round(value * 1000.0) / 1000.0;
130
pos = sliderPosition(value, min, max, length);
131
document.getElementById(sliderId + "box").value = value;
132
document.getElementById(sliderId + "marker").style.left = pos + "px";
137
ui make widget functions
141
function makeLabel(name) {
143
s += "<div class='label'>" + name + "</div>";
147
function makePanel(width, height) {
149
s += "<div class='panel' style='height: " + height + "px; width: " + width + "px;'>";
153
function makePanelEnd() {
158
function makeSlider(sliderId, kind, minValue, maxValue, midValue, sliderWidth, defaultValue) {
160
defaultPosition = sliderPosition(defaultValue, minValue, maxValue, sliderWidth);
161
if(defaultValue < minValue) {
162
defaultValue = minValue;
164
if(defaultValue > maxValue) {
165
defaultValue = maxValue;
167
s += "<input id='" + sliderId + "box' value='" + defaultValue + "' type='text' class='sliderBox' onBlur='changeSlider(this.value,\"" + sliderId + "\"," + kind + "," + minValue + "," + maxValue + "," + sliderWidth + ");'>";
168
s += "<div id='" + sliderId + "' class='sliderLine' style='width:" + sliderWidth + "px;'";
169
s += " onmousemove='updateSlider(event," + kind + "," + minValue + "," + maxValue + "," + sliderWidth + ",\"" + sliderId + "marker\",\"" + sliderId + "box\");'";
170
s += " onmouseup='updateSlider(event," + kind + "," + minValue + "," + maxValue + "," + sliderWidth + ",\"" + sliderId + "marker\",\"" + sliderId + "box\");'>";
171
s += " <div id='" + sliderId + "marker' class='sliderMarker' style='left:" + defaultPosition + "px;'></div>";
173
s += "<div class='slidermidValue' style='width:" + sliderWidth + "px;'>" + midValue;
174
s += "<div class='sliderminValue'>" + minValue + "</div>";
175
s += "<div class='slidermaxValue'>" + maxValue + "</div></div>";
179
function makeBinary(binaryId, defaultValue) {
181
if(defaultValue == 1) {
182
defaultPosition = 20;
183
defaultColor = "#ddd";
186
defaultColor = "#777";
188
s += "<div id='" + binaryId + "' class='binaryLine' style='background-color:" + defaultColor + ";' onmousemove='updateBinary(event,\"" + binaryId + "\");' onmouseup='updateBinary(event,\"" + binaryId + "\");'>";
189
s += "<div id='" + binaryId + "marker' class='binaryMarker' style='left:" + defaultPosition + "px;'></div>";
196
function mbPress(event) {
200
function mbRelease(event) {
b'\\ No newline at end of file'