Changeset 13526 for trunk/FACT++/www/index.js
- Timestamp:
- 05/02/12 22:01:52 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/index.js
r13523 r13526 19 19 function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); } 20 20 function valid(str) { if (str==undefined) return false; if (str.length==0) return false; return true;} 21 function isSliding(){ return $("table0").offsetLeft!=0 && $("table1").offsetLeft!=0; } 22 function cycleCol(el) 23 { 24 var col = el.getAttribute("data-col"); 25 col++; 26 col %= 31; 27 el.setAttribute("data-col", col); 28 if (col>16) 29 col = 31-col; 30 var hex = col.toString(16); 31 el.style.color = "#"+hex+"0"+hex+"0"+hex+"f"; 32 } 21 33 22 34 function onload() 23 35 { 36 /* 37 alert("0 -- "+navigator.appCodeName+"\n"+ 38 "1 -- "+navigator.appName+"\n"+ 39 "2 -- "+navigator.appVersion+"\n"+ 40 "3 -- "+navigator.platform+"\n"+ 41 "4 -- "+navigator.userAgent); 42 */ 24 43 loadPage("fact", 0); 44 } 45 46 function onresize() 47 { 48 var z = $("body").getAttribute("data-visible"); 49 doresize(z); 25 50 } 26 51 … … 68 93 { 69 94 var table = $("table"+z); 70 table.setAttribute("data-file", "");71 72 95 var p = table.tBodies.length==3 ? 1 : 0; 73 96 … … 122 145 td.setAttribute("class", "container"); 123 146 td.setAttribute("id", "container"); 124 td.setAttribute("onclick", "save();");147 //td.setAttribute("onclick", "save();"); 125 148 td.setAttribute("colspan", "3"); 126 149 tr.appendChild(td); … … 195 218 } 196 219 197 198 220 // --------------------------------------- 199 200 if ($("canvas") == null)201 {202 /*203 tr = document.createElement("tr");204 tr.setAttribute("class", "row");205 206 td = document.createElement("td");207 td.setAttribute("id", "debug");208 td.setAttribute("colspan", "3");209 td.setAttribute("height", "100%");210 tr.appendChild(td);211 212 table.appendChild(tr);*/213 }214 221 215 222 tr = document.createElement("tr"); … … 217 224 218 225 td = document.createElement("td"); 219 td.setAttribute("id", 226 td.setAttribute("id", "debug"); 220 227 td.setAttribute("colspan", "3"); 221 228 tr.appendChild(td); … … 223 230 tbody.appendChild(tr); 224 231 232 // --------------------------------------- 233 225 234 table.setAttribute("data-file", name); 226 } 227 228 function onresize() 229 { 230 var z = $("body").getAttribute("data-visible"); 231 235 doresize(z); 236 } 237 238 function doresize(z) 239 { 232 240 var img = $("image"+z); 233 241 var canv = $("canvas"+z); … … 238 246 var H = window.innerHeight; 239 247 240 img.width = 1; 241 img.height = 1; 242 248 //img.width = 1; 249 //img.height = 1; 250 251 var h = $("table"+z).offsetHeight; 252 253 //alert(img.height+"/"+img.offsetHeight+"/"+img.parentNode.offsetHeight); 254 255 // Be aware that this is recursive! 243 256 img.width = W; 244 img.height += H - $("table"+z).offsetHeight;257 img.height += H - h; 245 258 246 259 canv.width = img.width; … … 250 263 $('debug').innerHTML = ""; 251 264 $('debug').innerHTML += "|W="+W +"/"+H; 265 $('debug').innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight; 252 266 } 253 267 … … 259 273 if ($("table0").style.display=="none" && $("table1").style.display=="none") 260 274 { 275 $("table0").style.display=""; 261 276 $("table1").style.display=""; 277 278 $("table0").style.left=window.innerWidth+"px"; 279 $("table1").style.left="0px"; 280 262 281 $("body").setAttribute("data-visible", "1"); 263 282 264 onresize();283 doresize(1); 265 284 266 285 refresh_text(); … … 269 288 } 270 289 271 intervalSlide = setInterval("doSlideOut("+z+")", 25); 272 } 290 //intervalSlide = setInterval("doSlideOut("+z+")", 25); 291 292 //var k = (z+1)%2; 293 //$("table"+k).style.display=""; 294 //$("table"+z).style.display=""; 295 //$("table"+k).style.zIndex="0"; 296 //$("table"+z).style.zIndex="1"; 297 //$("table"+k).style.left=0; 298 //$("table"+z).style.left=0; 299 //$("table"+k).style.backgroundColor = "#ffffff"; 300 //$("table"+z).style.backgroundColor = "#ffffff"; 301 //doresize(k); 302 //intervalSlide = setInterval("doSlide("+z+",1)", 50); 303 304 $("body").setAttribute("data-visible", (z+1)%2); 305 intervalSlide = setInterval("doShift("+z+")", 75); 306 } 307 308 function doShift(z) 309 { 310 var W = window.innerWidth; 311 312 var t0 = $("table0"); 313 var t1 = $("table1"); 314 315 var x0 = t0.offsetLeft; 316 var x1 = t1.offsetLeft; 317 318 if (/*x1<0 && x0>=0 &&*/ z==0) 319 { 320 x0 += W/5; 321 x1 += W/5; 322 323 if (x1>=0) 324 { 325 x0 = W; 326 x1 = 0; 327 328 clearInterval(intervalSlide); 329 } 330 } 331 332 if (/*x0>0 && x1<=0 &&*/ z==1) 333 { 334 x0 -= W/5; 335 x1 -= W/5; 336 337 if (x0<=0) 338 { 339 x0 = 0; 340 x1 = -W-1; 341 342 clearInterval(intervalSlide); 343 } 344 } 345 346 t0.style.left = parseInt(x0, 10)+"px"; 347 t1.style.left = parseInt(x1, 10)+"px"; 348 } 349 350 /* 351 function doSlide(z, dir) 352 { 353 var k = (z+1)%2; 354 355 var W = window.innerWidth; 356 357 var tz = $("table"+z); 358 var tk = $("table"+k); 359 360 var xz = tz.offsetLeft; 361 var xk = tk.offsetLeft; 362 363 var ixz = parseInt(xz, 10); 364 var ikz = parseInt(xk, 10); 365 366 ixz += dir*W/10; 367 ikz -= dir*W/10; 368 369 tz.style.left = parseInt(ixz, 10)+"px"; 370 tk.style.left = parseInt(ikz, 10)+"px"; 371 372 if (ixz>W/2) 373 { 374 clearInterval(intervalSlide); 375 376 $("table"+k).style.zIndex="1"; 377 $("table"+z).style.zIndex="0"; 378 379 $("body").setAttribute("data-visible", k); 380 doresize(k); 381 382 intervalSlide = setInterval("doSlide("+z+",-1)", 50); 383 } 384 if (ikz>0) 385 { 386 clearInterval(intervalSlide); 387 388 tz.style.left = 0; 389 tk.style.left = 0; 390 391 tz.style.display="none"; 392 } 393 } 394 273 395 274 396 function doSlideOut(z) … … 293 415 294 416 $("body").setAttribute("data-visible", z); 295 onresize();417 doresize(z); 296 418 297 419 intervalSlide = setInterval("doSlideIn("+z+")", 25); … … 311 433 312 434 var ix = parseInt(x, 10); 313 if (ix==0)314 {315 clearInterval(intervalSlide);316 return;317 }318 435 319 436 ix -= W/10; … … 322 439 323 440 table.style.left=ix+"px"; 324 } 441 442 if (ix<=0) 443 { 444 clearInterval(intervalSlide); 445 return; 446 } 447 } 448 */ 325 449 326 450 function refresh_text() … … 331 455 // Is sliding or no file defined? 332 456 var fname = table.getAttribute("data-file"); 333 if ( table.offsetLeft>0|| !valid(fname))457 if (isSliding() || !valid(fname)) 334 458 { 335 459 setTimeout("refresh_text()", 1000); … … 360 484 } 361 485 362 update_text(fname, xmlHttp.responseText); 486 if (!isSliding()) 487 { 488 cycleCol($("ldot"+z)); 489 update_text(fname, xmlHttp.responseText); 490 } 363 491 setTimeout("refresh_text()", 3000); 364 492 } … … 373 501 return; 374 502 375 if ( status == false)503 if (!status) 376 504 e.style.textDecoration="line-through"; 377 505 else … … 385 513 return; 386 514 387 if (valid(str) == true)515 if (valid(str)) 388 516 { 389 517 e.style.color="#000"; … … 433 561 434 562 time.innerHTML = 435 "& middot; "+date0.toUTCString()+" ·";//getUTCFullYear()+"/"+date0.getUTCMonth()+"/"+date0.getUTCDate()+" "+date0.getUTCHours()+":"+date0.getUTCMinutes()+":"+date0.getUTCSeconds()+"."+date0.getUTCMilliseconds();563 "• "+date0.toUTCString()+" •";//getUTCFullYear()+"/"+date0.getUTCMonth()+"/"+date0.getUTCDate()+" "+date0.getUTCHours()+":"+date0.getUTCMinutes()+":"+date0.getUTCSeconds()+"."+date0.getUTCMilliseconds(); 436 564 ltime.innerHTML = 437 "& middot; "+date1.toLocaleString()+" ·";//ISOlocalDateStr();//ltoString();565 "• "+date1.toLocaleString()+" •";//ISOlocalDateStr();//ltoString(); 438 566 439 567 // ---------------------------------------------------- … … 460 588 form = form.replace("\$"+(col-1), cols[col].length==0 ? "--" : cols[col]); 461 589 590 if (cols.length<=1) 591 form = "---"; 592 462 593 var newe = document.createElement("div"); 463 594 newe.innerHTML = form; … … 480 611 // Is sliding or no data file defined? 481 612 var fname = canvas==null ? "" : canvas.getAttribute("data-file"); 482 if ( $("table"+z).offsetLeft>0|| !valid(fname))613 if (isSliding() || !valid(fname)) 483 614 { 484 615 setTimeout("refresh_graphics()", 1000); … … 509 640 } 510 641 511 process_eventdata(xmlHttp.responseText); 642 if (!isSliding()) 643 { 644 cycleCol($("rdot"+z)); 645 process_eventdata(xmlHttp.responseText); 646 } 512 647 setTimeout("refresh_graphics()", 5000) 513 648 } … … 752 887 $("image"+z).src = canv.toDataURL("image/png"); 753 888 } 889 754 890 /* 755 891 function save() 756 892 { 757 var canvas = $("canvas"); 893 var z = $("body").getAttribute("data-visible"); 894 895 var canvas = $("canvas"+z); 758 896 var img = canvas.toDataURL("image/png"); 759 897 … … 763 901 } 764 902 */ 765 766 903 window['onload'] = onload;
Note:
See TracChangeset
for help on using the changeset viewer.