Merge lp:~adamringhede/lenasys/branch into lp:~lenasysimpl1/lenasys/GammaBear
- branch
- Merge into GammaBear
Proposed by
Adam Ringhede
Status: | Merged | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 26 | ||||||||||||||||||||||||
Proposed branch: | lp:~adamringhede/lenasys/branch | ||||||||||||||||||||||||
Merge into: | lp:~lenasysimpl1/lenasys/GammaBear | ||||||||||||||||||||||||
Diff against target: |
709 lines (+285/-278) 5 files modified
DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js (+235/-0) DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php (+2/-243) Widget Library/sliderdemo.html (+2/-12) Widget Library/sliders.css (+2/-0) Widget Library/sliders.js (+44/-23) |
||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~adamringhede/lenasys/branch | ||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Victor Nagy | Approve | ||
Review via email:
|
Commit message
Description of the change
Fixes bugs
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Victor Nagy (galaxyabstractor) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js' |
2 | --- DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js 1970-01-01 00:00:00 +0000 |
3 | +++ DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js 2013-04-12 14:42:25 +0000 |
4 | @@ -0,0 +1,235 @@ |
5 | +var account="<?php echo $accountname ?>"; |
6 | +var duggaNr="<?php echo $duggaNr ?>"; |
7 | +var courseName="<?php echo $courseName ?>"; |
8 | +var courseOccasion="<?php echo $courseOccasion ?>"; |
9 | + |
10 | +$(document).ready(function() { |
11 | + fetchQuiz(); |
12 | + fetchQuizObject("ObjDesc"); |
13 | +}); |
14 | + |
15 | +/* login, courseName, courseOccasion, quizNr */ |
16 | +function fetchQuiz(){ |
17 | + console.log("post fetchQuiz "); |
18 | + $.post("../quizAjax/getQuiz.php", |
19 | + {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr }, |
20 | + fetchQuizCallBack, |
21 | + "json" |
22 | + ); |
23 | +} |
24 | + |
25 | +function fetchQuizCallBack(data){ |
26 | + console.log(data); |
27 | + if (typeof data.Error != 'undefined') { |
28 | + $("#result").append("<br/><h3>Error:"+data.Error+"</h3>"); |
29 | + } else { |
30 | + $("#result").append("<br/>Dugga nr:"+data.quizNr); |
31 | + $("#result").append("<br/>Kursnamn:"+data.quizCourseName); |
32 | + $("#result").append("<br/>Lista över dugga-objekt:"+data.quizObjectIDs); |
33 | + $("#result").append("<br/>Data:"+data.quizData); |
34 | + } |
35 | +} |
36 | + |
37 | +/* Evaluate the submited answer |
38 | + * (Alternativly, it just saves it if the dugga does not correct it self. ) |
39 | + */ |
40 | +function checkAnswer(submitstr){ |
41 | + $.post("../quizAjax/answerQuiz.php", |
42 | + {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, quizAnswer: submitstr}, |
43 | + checkAnswerCallBack, |
44 | + "json" |
45 | + ); |
46 | +} |
47 | + |
48 | +function checkAnswerCallBack(data){ |
49 | + console.log("checkAnswerCallBack:"); |
50 | + console.log(data); |
51 | + if (typeof data.Error != 'undefined') { |
52 | + $("#result").append("<br/><h3>Error:"+data.Error+"</h3>"); |
53 | + } else { |
54 | + for (var key in data) { |
55 | + $("#result").append("<br />"+data[key]); |
56 | + } |
57 | + } |
58 | +} |
59 | + |
60 | +/* Get a dugga object (object id's are fetched from the list with object ids which comes with the dugga) |
61 | + * Parameters: (POST) objectID, courseName, courseOccasion, quizNr, loginName |
62 | + */ |
63 | +function fetchQuizObject(objectName){ |
64 | + console.log("post fetchQuizObject"); |
65 | + $.post("../quizAjax/getQuizObject.php", |
66 | + {objectID: objectName, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, loginName: account}, |
67 | + fetchQuizObjectCallBack, |
68 | + "json" |
69 | + ); |
70 | +} |
71 | + |
72 | +function fetchQuizObjectCallBack(data){ |
73 | + if (typeof data.Error != 'undefined') { |
74 | + $("#result").append("<br/><h3>Error:"+data.Error+"</h3>"); |
75 | + } else { |
76 | + $("#result").append(data.objectData); |
77 | + } |
78 | +} |
79 | + |
80 | +function newbutton() { |
81 | + var funclist; |
82 | + var oplist; |
83 | + |
84 | + funclist = document.getElementById('function'); |
85 | + oplist = document.getElementById('operations'); |
86 | + |
87 | + oplist.innerHTML+="<option value='"+funclist.options[funclist.selectedIndex].value+"'>"+funclist.options[funclist.selectedIndex].text+"</option>"; |
88 | +} |
89 | + |
90 | +function deletebutton() { |
91 | + var elSel = document.getElementById('operations'); |
92 | + var i=0; |
93 | + for (i = elSel.length-1; i >= 0; i--) { |
94 | + if (elSel.options[i].selected) { |
95 | + elSel.remove(i); |
96 | + } |
97 | + } |
98 | +} |
99 | + |
100 | +function moveupbutton() { |
101 | + var elSel = document.getElementById('operations'); |
102 | + var ind=elSel.selectedIndex; |
103 | + var val; |
104 | + var tex; |
105 | + |
106 | + if( elSel.selectedIndex>0) { |
107 | + |
108 | + val=elSel.options[ind].value; |
109 | + tex=elSel.options[ind].text; |
110 | + |
111 | + elSel.options[ind].value=elSel.options[ind-1].value; |
112 | + elSel.options[ind].text=elSel.options[ind-1].text; |
113 | + |
114 | + elSel.options[ind-1].value=val; |
115 | + tex=elSel.options[ind-1].text=tex; |
116 | + |
117 | + elSel.selectedIndex--; |
118 | + } |
119 | +} |
120 | + |
121 | +function movedownbutton() { |
122 | + var elSel = document.getElementById('operations'); |
123 | + var ind=elSel.selectedIndex; |
124 | + var val; |
125 | + var tex; |
126 | + |
127 | + if(elSel.selectedIndex < elSel.length-1){ |
128 | + |
129 | + val=elSel.options[ind].value; |
130 | + tex=elSel.options[ind].text; |
131 | + |
132 | + elSel.options[ind].value=elSel.options[ind+1].value; |
133 | + elSel.options[ind].text=elSel.options[ind+1].text; |
134 | + |
135 | + elSel.options[ind+1].value=val; |
136 | + tex=elSel.options[ind+1].text=tex; |
137 | + |
138 | + elSel.selectedIndex++; |
139 | + } |
140 | +} |
141 | + |
142 | +function submbutton() { |
143 | + var submitstr=""; |
144 | + |
145 | + var elSel = document.getElementById('operations'); |
146 | + var i=0; |
147 | + |
148 | + for (i=elSel.length-1; i >= 0;i--) { |
149 | + submitstr+=elSel.options[i].value; |
150 | + } |
151 | + |
152 | + alert(submitstr); |
153 | + checkAnswer(submitstr); |
154 | +} |
155 | + |
156 | +function handler_mouseup() { |
157 | + clickstate=0; |
158 | +} |
159 | + |
160 | +function handler_mousedown() { |
161 | + clickstate=1; |
162 | +} |
163 | + |
164 | +function handler_mousemove (cx,cy) { |
165 | +// Make use of cx and cy... right now no use as this app does not use clicks |
166 | +} |
167 | + |
168 | +var v=0; |
169 | + |
170 | +function foo() { |
171 | + acanvas.width = acanvas.width; |
172 | + |
173 | + v+=0.1; |
174 | + |
175 | + context.translate(300,300); |
176 | + context.save(); |
177 | + |
178 | + var elSel = document.getElementById('operations'); |
179 | + var i=0; |
180 | + for (i=0;i<=elSel.length-1;i++) { |
181 | + if (elSel.options[i].value == "T1") { |
182 | + context.translate(100,0); |
183 | + } |
184 | + if (elSel.options[i].value == "T2") { |
185 | + context.translate(150,0); |
186 | + } |
187 | + if (elSel.options[i].value == "T3") { |
188 | + context.translate(200,0); |
189 | + } |
190 | + if (elSel.options[i].value == "RP") { |
191 | + context.rotate(v); |
192 | + } |
193 | + if (elSel.options[i].value == "RN") { |
194 | + context.rotate(-v); |
195 | + } |
196 | + if (elSel.options[i].value == "S1") { |
197 | + context.scale(0.25,0.25); |
198 | + } |
199 | + if (elSel.options[i].value == "S2") { |
200 | + context.scale(0.5,0.5); |
201 | + } |
202 | + if (elSel.options[i].value == "S3") { |
203 | + context.scale(0.75,0.75); |
204 | + } |
205 | + if (elSel.options[i].value == "S4") { |
206 | + context.scale(1.5,1.5); |
207 | + } |
208 | + if (elSel.options[i].value == "D1") { |
209 | + drawball(0,0,40,30,10,"#f84",45.0,22.5); |
210 | + } |
211 | + if (elSel.options[i].value == "D2") { |
212 | + drawball(0,0,40,30,10,"#4f8",45.0,22.5); |
213 | + } |
214 | + if (elSel.options[i].value == "D3") { |
215 | + drawball(0,0,40,30,10,"#84f",45.0,22.5); |
216 | + } |
217 | + } |
218 | + |
219 | + // Must count saves |
220 | + // Restore equal amount of times |
221 | + |
222 | + /* |
223 | + context.beginPath(); |
224 | + drawcircle(40,'#f0f'); |
225 | + |
226 | + context.lineWidth = 0.5; |
227 | + |
228 | + context.moveTo(0,0); |
229 | + context.rect(0,0,30,30); |
230 | + |
231 | + context.stroke(); |
232 | + */ |
233 | + context.restore(); |
234 | + context.globalAlpha = 0.5 |
235 | + context.rotate(-v*0.6); |
236 | + drawsun(); |
237 | + |
238 | + setTimeout("foo();",100); |
239 | +} |
240 | \ No newline at end of file |
241 | |
242 | === modified file 'DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php' |
243 | --- DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php 2013-04-04 11:30:02 +0000 |
244 | +++ DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php 2013-04-12 14:42:25 +0000 |
245 | @@ -9,250 +9,9 @@ |
246 | <html> |
247 | <head> |
248 | <meta charset="UTF-8"/> |
249 | - <script type="text/javascript" src="../../../../js/jquery.js"></script> |
250 | - <script lang='Javascript'> |
251 | - var account="<?php echo $accountname ?>"; |
252 | - var duggaNr="<?php echo $duggaNr ?>"; |
253 | - var courseName="<?php echo $courseName ?>"; |
254 | - var courseOccasion="<?php echo $courseOccasion ?>"; |
255 | - |
256 | - $(document).ready(function() { |
257 | - fetchQuiz(); |
258 | - fetchQuizObject("ObjDesc"); |
259 | - }); |
260 | - |
261 | - //login, courseName, courseOccasion, quizNr |
262 | - function fetchQuiz(){ |
263 | - console.log("post fetchQuiz "); |
264 | - $.post("../quizAjax/getQuiz.php", |
265 | - {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr }, |
266 | - fetchQuizCallBack, |
267 | - "json" |
268 | - ); |
269 | - } |
270 | - |
271 | - function fetchQuizCallBack(data){ |
272 | - console.log(data); |
273 | - if (typeof data.Error != 'undefined') { |
274 | - $("#result").append("<br/><h3>Error:"+data.Error+"</h3>"); |
275 | - } else { |
276 | - $("#result").append("<br/>Dugga nr:"+data.quizNr); |
277 | - $("#result").append("<br/>Kursnamn:"+data.quizCourseName); |
278 | - $("#result").append("<br/>Lista över dugga-objekt:"+data.quizObjectIDs); |
279 | - $("#result").append("<br/>Data:"+data.quizData); |
280 | - } |
281 | - } |
282 | - |
283 | - //Kontrollera om inskickat svar är rätt (alternativt bara spara det om duggan inte rättas automatiskt) |
284 | - function checkAnswer(submitstr){ |
285 | - $.post("../quizAjax/answerQuiz.php", |
286 | - {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, quizAnswer: submitstr}, |
287 | - checkAnswerCallBack, |
288 | - "json" |
289 | - ); |
290 | - } |
291 | - |
292 | - function checkAnswerCallBack(data){ |
293 | - console.log("checkAnswerCallBack:"); |
294 | - console.log(data); |
295 | - if (typeof data.Error != 'undefined') { |
296 | - $("#result").append("<br/><h3>Error:"+data.Error+"</h3>"); |
297 | - } else { |
298 | - for (var key in data) { |
299 | - $("#result").append("<br />"+data[key]); |
300 | - } |
301 | - } |
302 | - } |
303 | - |
304 | - //Hämta ett dugga objekt (objekt id:n hämtas från listan med objekt id:n som kommer med duggan) |
305 | - //////Parameters: (POST) objectID, courseName, courseOccasion, quizNr, loginName |
306 | - function fetchQuizObject(objectName){ |
307 | - console.log("post fetchQuizObject"); |
308 | - $.post("../quizAjax/getQuizObject.php", |
309 | - {objectID: objectName, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, loginName: account}, |
310 | - fetchQuizObjectCallBack, |
311 | - "json" |
312 | - ); |
313 | - } |
314 | - |
315 | - function fetchQuizObjectCallBack(data){ |
316 | - if (typeof data.Error != 'undefined') { |
317 | - $("#result").append("<br/><h3>Error:"+data.Error+"</h3>"); |
318 | - } else { |
319 | - $("#result").append(data.objectData); |
320 | - } |
321 | - } |
322 | - </script> |
323 | - |
324 | + <script type="text/javascript" src="../../../../js/jquery.js"></script> |
325 | <script type="text/javascript" src="../../../../js/dugga.js"></script> |
326 | - |
327 | - <script lang='Javascript'> |
328 | - |
329 | - function newbutton() |
330 | - { |
331 | - var funclist; |
332 | - var oplist; |
333 | - |
334 | - funclist=document.getElementById('function'); |
335 | - oplist=document.getElementById('operations'); |
336 | - |
337 | - oplist.innerHTML+="<option value='"+funclist.options[funclist.selectedIndex].value+"'>"+funclist.options[funclist.selectedIndex].text+"</option>"; |
338 | - |
339 | - } |
340 | - |
341 | - function deletebutton() |
342 | - { |
343 | - var elSel = document.getElementById('operations'); |
344 | - var i=0; |
345 | - for (i=elSel.length-1;i>=0;i--) { |
346 | - if (elSel.options[i].selected) { |
347 | - elSel.remove(i); |
348 | - } |
349 | - } |
350 | - } |
351 | - |
352 | - function moveupbutton() |
353 | - { |
354 | - var elSel = document.getElementById('operations'); |
355 | - var ind=elSel.selectedIndex; |
356 | - var val; |
357 | - var tex; |
358 | - |
359 | - if(elSel.selectedIndex>0){ |
360 | - |
361 | - val=elSel.options[ind].value; |
362 | - tex=elSel.options[ind].text; |
363 | - |
364 | - elSel.options[ind].value=elSel.options[ind-1].value; |
365 | - elSel.options[ind].text=elSel.options[ind-1].text; |
366 | - |
367 | - elSel.options[ind-1].value=val; |
368 | - tex=elSel.options[ind-1].text=tex; |
369 | - |
370 | - elSel.selectedIndex--; |
371 | - } |
372 | - } |
373 | - |
374 | - function movedownbutton() |
375 | - { |
376 | - var elSel = document.getElementById('operations'); |
377 | - var ind=elSel.selectedIndex; |
378 | - var val; |
379 | - var tex; |
380 | - |
381 | - if(elSel.selectedIndex<elSel.length-1){ |
382 | - |
383 | - val=elSel.options[ind].value; |
384 | - tex=elSel.options[ind].text; |
385 | - |
386 | - elSel.options[ind].value=elSel.options[ind+1].value; |
387 | - elSel.options[ind].text=elSel.options[ind+1].text; |
388 | - |
389 | - elSel.options[ind+1].value=val; |
390 | - tex=elSel.options[ind+1].text=tex; |
391 | - |
392 | - elSel.selectedIndex++; |
393 | - } |
394 | - |
395 | - } |
396 | - |
397 | - function submbutton() |
398 | - { |
399 | - var submitstr=""; |
400 | - |
401 | - var elSel = document.getElementById('operations'); |
402 | - var i=0; |
403 | - |
404 | - for (i=elSel.length-1;i>=0;i--) { |
405 | - submitstr+=elSel.options[i].value; |
406 | - } |
407 | - |
408 | - alert(submitstr); |
409 | - checkAnswer(submitstr); |
410 | - } |
411 | - |
412 | - function handler_mouseup() |
413 | - { |
414 | - clickstate=0; |
415 | - } |
416 | - |
417 | - function handler_mousedown() |
418 | - { |
419 | - clickstate=1; |
420 | - } |
421 | - |
422 | - function handler_mousemove (cx,cy) |
423 | - { |
424 | - // Make use of cx and cy... right now no use as this app does not use clicks |
425 | - } |
426 | - |
427 | - var v=0; |
428 | - |
429 | - function foo() |
430 | - { |
431 | - acanvas.width = acanvas.width; |
432 | - |
433 | - v+=0.1; |
434 | - |
435 | - context.translate(300,300); |
436 | - context.save(); |
437 | - |
438 | - var elSel = document.getElementById('operations'); |
439 | - var i=0; |
440 | - for (i=0;i<=elSel.length-1;i++) { |
441 | - if(elSel.options[i].value=="T1"){ |
442 | - context.translate(100,0); |
443 | - }if(elSel.options[i].value=="T2"){ |
444 | - context.translate(150,0); |
445 | - }if(elSel.options[i].value=="T3"){ |
446 | - context.translate(200,0); |
447 | - }if(elSel.options[i].value=="RP"){ |
448 | - context.rotate(v); |
449 | - }if(elSel.options[i].value=="RN"){ |
450 | - context.rotate(-v); |
451 | - }if(elSel.options[i].value=="S1"){ |
452 | - context.scale(0.25,0.25); |
453 | - }if(elSel.options[i].value=="S2"){ |
454 | - context.scale(0.5,0.5); |
455 | - }if(elSel.options[i].value=="S3"){ |
456 | - context.scale(0.75,0.75); |
457 | - }if(elSel.options[i].value=="S4"){ |
458 | - context.scale(1.5,1.5); |
459 | - }if(elSel.options[i].value=="D1"){ |
460 | - drawball(0,0,40,30,10,"#f84",45.0,22.5); |
461 | - }if(elSel.options[i].value=="D2"){ |
462 | - drawball(0,0,40,30,10,"#4f8",45.0,22.5); |
463 | - }if(elSel.options[i].value=="D3"){ |
464 | - drawball(0,0,40,30,10,"#84f",45.0,22.5); |
465 | - } |
466 | - } |
467 | - |
468 | - |
469 | - |
470 | - // Must count saves |
471 | - // Restore equal amount of times |
472 | - |
473 | -/* |
474 | - context.beginPath(); |
475 | - drawcircle(40,'#f0f'); |
476 | - |
477 | - context.lineWidth = 0.5; |
478 | - |
479 | - context.moveTo(0,0); |
480 | - context.rect(0,0,30,30); |
481 | - |
482 | - context.stroke(); |
483 | -*/ |
484 | - context.restore(); |
485 | - context.globalAlpha = 0.5 |
486 | - context.rotate(-v*0.6); |
487 | - drawsun(); |
488 | - |
489 | - setTimeout("foo();",100); |
490 | - |
491 | - } |
492 | - |
493 | - </script> |
494 | + <script type="text/javascript" src="johan_dugga_datorgrafik_1_transforms.js"></script> |
495 | |
496 | </head> |
497 | <body onload="setupcanvas();"> |
498 | |
499 | === modified file 'Widget Library/sliderdemo.html' |
500 | --- Widget Library/sliderdemo.html 2013-04-03 14:29:36 +0000 |
501 | +++ Widget Library/sliderdemo.html 2013-04-12 14:42:25 +0000 |
502 | @@ -3,19 +3,9 @@ |
503 | <head> |
504 | <title>Slider Demo</title> |
505 | <link rel="stylesheet" type="text/css" media="screen" href="sliders.css"> |
506 | + <script type="text/javascript" src="../etc/PIE/PIE.js"></script> |
507 | + <script type="text/javascript" src="../js/jquery.js"></script> |
508 | <script type="text/javascript" src="sliders.js"></script> |
509 | - <script> |
510 | - function createDemoSliders() { |
511 | - str = ""; |
512 | - str += makePanel(250, 200); |
513 | - str += makeLabel("Slider"); |
514 | - str += makeSlider("slider", 1, 2, 7, 4.5, 160, 5); |
515 | - str += makeLabel("Binary"); |
516 | - str += makeBinary("binary", 0); |
517 | - str += makePanelEnd(); |
518 | - document.getElementById("container").innerHTML = str; |
519 | - } |
520 | - </script> |
521 | </head> |
522 | <body onload="createDemoSliders();" onmousedown="mbPress(event);" onmouseup="mbRelease(event);"> |
523 | <div id="container"> |
524 | |
525 | === modified file 'Widget Library/sliders.css' |
526 | --- Widget Library/sliders.css 2013-04-03 14:29:36 +0000 |
527 | +++ Widget Library/sliders.css 2013-04-12 14:42:25 +0000 |
528 | @@ -9,6 +9,7 @@ |
529 | font-family: Arial; |
530 | background-color: #d0d0d4; |
531 | background: linear-gradient(to bottom, #f0f0e8 0%, #e8e8e8 1%, #b8b8b0 17%); |
532 | + -pie-background: linear-gradient(top, #f0f0e8 0%, #e8e8e8 1%, #b8b8b0 17%); |
533 | border-radius: 10px; |
534 | padding:6px; |
535 | } |
536 | @@ -79,4 +80,5 @@ |
537 | border-width: 1px; |
538 | box-shadow: 2px 2px 2px #444; |
539 | background: linear-gradient(to bottom, #fff 0%,#e0e0d8 60%); |
540 | + -pie-background: linear-gradient(top, #fff 0%,#e0e0d8 60%); |
541 | } |
542 | \ No newline at end of file |
543 | |
544 | === modified file 'Widget Library/sliders.js' |
545 | --- Widget Library/sliders.js 2013-04-03 14:29:36 +0000 |
546 | +++ Widget Library/sliders.js 2013-04-12 14:42:25 +0000 |
547 | @@ -4,13 +4,34 @@ |
548 | |
549 | */ |
550 | |
551 | +// Fixes css3 for IE |
552 | +function attachPIE() { |
553 | + $('*').each(function() { |
554 | + PIE.attach(this); |
555 | + }); |
556 | +} |
557 | + |
558 | +// Creates a demo |
559 | +function createDemoSliders() { |
560 | + str = ""; |
561 | + str += makePanel(250, 200); |
562 | + str += makeLabel("Slider"); |
563 | + str += makeSlider("slider", 1, 2, 7, 4.5, 160, 5); |
564 | + str += makeLabel("Binary"); |
565 | + str += makeBinary("binary", 0); |
566 | + str += makePanelEnd(); |
567 | + document.getElementById("container").innerHTML = str; |
568 | + attachPIE(); |
569 | + |
570 | +} |
571 | + |
572 | // Recursive Pos of div in document - should work in most browsers |
573 | function findPos(obj) { |
574 | var curLeft = curTop = 0; |
575 | - if(obj.offsetParent) { |
576 | + if (obj.offsetParent) { |
577 | curLeft = obj.offsetLeft |
578 | curTop = obj.offsetTop |
579 | - while(obj = obj.offsetParent) { |
580 | + while (obj = obj.offsetParent) { |
581 | curLeft += obj.offsetLeft |
582 | curTop += obj.offsetTop |
583 | } |
584 | @@ -29,7 +50,7 @@ |
585 | |
586 | function readSlider(sliderId) { |
587 | var value = parseFloat(document.getElementById(sliderId + "box").value); |
588 | - if(isNaN(value)) { |
589 | + if (isNaN(value)) { |
590 | value = 0.0; |
591 | } |
592 | return value; |
593 | @@ -37,7 +58,7 @@ |
594 | |
595 | function readBinary(binaryId) { |
596 | lf = document.getElementById(binaryId + "marker").style.left; |
597 | - if(lf == "2px") { |
598 | + if (lf == "2px") { |
599 | return 0; |
600 | } else { |
601 | return 1; |
602 | @@ -52,7 +73,7 @@ |
603 | |
604 | // The idea is to have a few functions like this one and minimum javascript intervention |
605 | function updateBinary(event, binaryId) { |
606 | - if(mb) { |
607 | + if (mb) { |
608 | coords = findPos(event.currentTarget); |
609 | coords.x = event.clientX - coords.x; |
610 | coords.y = event.clientY - coords.y; |
611 | @@ -68,24 +89,24 @@ |
612 | |
613 | // The idea is to have a few functions like this one and minimum javascript intervention |
614 | function updateSlider(event, kind, min, max, length, sliderId, boxId) { |
615 | - if(mb) { |
616 | + if (mb) { |
617 | coords = findPos(event.currentTarget); |
618 | coords.x = event.clientX - coords.x; |
619 | coords.y = event.clientY - coords.y; |
620 | cx = coords.x / length; |
621 | sd = max - min; |
622 | value = min + (sd * cx); |
623 | - if(value > max) value = max; |
624 | - if(kind == 0) { |
625 | + if (value > max) value = max; |
626 | + if (kind == 0) { |
627 | value = Math.round(value); |
628 | } |
629 | - if(kind == 1) { |
630 | + if (kind == 1) { |
631 | value = Math.round(value * 10.0) / 10.0; |
632 | } |
633 | - if(kind == 2) { |
634 | + if (kind == 2) { |
635 | value = Math.round(value * 100.0) / 100.0; |
636 | } |
637 | - if(kind == 3) { |
638 | + if (kind == 3) { |
639 | value = Math.round(value * 1000.0) / 1000.0; |
640 | } |
641 | document.getElementById(boxId).value = value; |
642 | @@ -94,10 +115,10 @@ |
643 | } |
644 | |
645 | function sliderPosition(value, min, max, length) { |
646 | - if(value < min) { |
647 | + if (value < min) { |
648 | value = min; |
649 | } |
650 | - if(value > max) { |
651 | + if (value > max) { |
652 | value = max; |
653 | } |
654 | pos = Math.round(((value - min) / (max - min)) * length); |
655 | @@ -106,25 +127,25 @@ |
656 | |
657 | function changeSlider(value, sliderId, kind, min, max, length) { |
658 | value = parseFloat(value); |
659 | - if(isNaN(value)) { |
660 | + if (isNaN(value)) { |
661 | value = 0.0; |
662 | } |
663 | - if(value < min) { |
664 | + if (value < min) { |
665 | value = min; |
666 | } |
667 | - if(value > max) { |
668 | + if (value > max) { |
669 | value = max; |
670 | } |
671 | - if(kind == 0) { |
672 | + if (kind == 0) { |
673 | value = Math.round(value); |
674 | } |
675 | - if(kind == 1) { |
676 | + if (kind == 1) { |
677 | value = Math.round(value * 10.0) / 10.0; |
678 | } |
679 | - if(kind == 2) { |
680 | + if (kind == 2) { |
681 | value = Math.round(value * 100.0) / 100.0; |
682 | } |
683 | - if(kind == 3) { |
684 | + if (kind == 3) { |
685 | value = Math.round(value * 1000.0) / 1000.0; |
686 | } |
687 | pos = sliderPosition(value, min, max, length); |
688 | @@ -158,10 +179,10 @@ |
689 | function makeSlider(sliderId, kind, minValue, maxValue, midValue, sliderWidth, defaultValue) { |
690 | s = ""; |
691 | defaultPosition = sliderPosition(defaultValue, minValue, maxValue, sliderWidth); |
692 | - if(defaultValue < minValue) { |
693 | + if (defaultValue < minValue) { |
694 | defaultValue = minValue; |
695 | } |
696 | - if(defaultValue > maxValue) { |
697 | + if (defaultValue > maxValue) { |
698 | defaultValue = maxValue; |
699 | } |
700 | s += "<input id='" + sliderId + "box' value='" + defaultValue + "' type='text' class='sliderBox' onBlur='changeSlider(this.value,\"" + sliderId + "\"," + kind + "," + minValue + "," + maxValue + "," + sliderWidth + ");'>"; |
701 | @@ -178,7 +199,7 @@ |
702 | |
703 | function makeBinary(binaryId, defaultValue) { |
704 | s = ""; |
705 | - if(defaultValue == 1) { |
706 | + if (defaultValue == 1) { |
707 | defaultPosition = 20; |
708 | defaultColor = "#ddd"; |
709 | } else { |