Changeset 13687 for trunk/FACT++/www/shift
- Timestamp:
- 05/13/12 11:30:56 (13 years ago)
- Location:
- trunk/FACT++/www/shift
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/shift/calendar.js
r13685 r13687 359 359 }; 360 360 361 var sp = document.createElement("span"); 362 sp.appendChild(document.createTextNode("*")); 363 sp.style.color="darkred"; 364 sp.style.display="none"; 365 td.appendChild(sp); 366 361 367 tr.appendChild( td ); 362 368 } … … 380 386 381 387 requestAll(this.yy, this.mm); 388 requestAllComments(this.yy, this.mm); 382 389 if (this.year==this.yy && this.month==this.mm) 383 390 requestComment(this.year, this.month, this.date); … … 432 439 return; 433 440 434 while (td.childNodes.length> 1)441 while (td.childNodes.length>2) 435 442 td.removeChild(td.lastChild); 436 443 … … 454 461 } 455 462 456 if (td.childNodes.length> 1)463 if (td.childNodes.length>2) 457 464 td.className += " enabled"; 458 465 else … … 486 493 var m = c.getAttribute("data-m"); 487 494 var d = c.getAttribute("data-d"); 488 489 var uri = "calendar.php?y="+y+"&m="+m+"&d="+d+"&c="+encodeURIComponent(c.value); 495 var v = c.value; 496 497 var uri = "calendar.php?y="+y+"&m="+m+"&d="+d+"&c="+encodeURIComponent(v); 490 498 491 499 var xmlHttp = new XMLHttpRequest(); 492 500 xmlHttp.open('POST', uri, true); 493 xmlHttp.onload = function 501 xmlHttp.onload = function() 494 502 { 495 503 if (xmlHttp.status!=200) … … 499 507 } 500 508 501 alert("Comment inserted successfully.") 509 alert("Comment inserted successfully."); 510 511 var td = document.getElementById(m+"-"+d); 512 alert(td.childNodes[1]+"/"+v); 513 if (v=="") 514 { 515 td.childNodes[1].style.display="none"; 516 td.title="Click to select this date."; 517 } 518 else 519 { 520 td.childNodes[1].style.display=""; 521 td.title=v; 522 } 523 502 524 }; 503 525 … … 527 549 } 528 550 551 var td = document.getElementById(mm+"-"+dd); 552 529 553 c.color="#888"; 530 554 if (xmlHttp.responseText=="") 555 { 531 556 c.value="enter comment here"; 557 td.childNodes[1].style.display="none"; 558 td.title=""; 559 } 532 560 else 561 { 533 562 c.value = xmlHttp.responseText; 563 td.childNodes[1].style.display=""; 564 td.title=xmlHttp.responseText; 565 } 534 566 535 567 c.setAttribute("data-y", yy); … … 585 617 } 586 618 619 function requestAllComments(yy, mm) 620 { 621 var uri = "calendar.php?comment&y="+yy+"&m="+mm; 622 var xmlHttp = new XMLHttpRequest(); 623 xmlHttp.open('POST', uri, true); 624 xmlHttp.onload = function () 625 { 626 if (xmlHttp.status!=200) 627 { 628 alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); 629 return; 630 } 631 632 if (xmlHttp.responseText<4) 633 return; 634 635 var pos = 6; 636 637 while (pos<xmlHttp.responseText.length) 638 { 639 var len = parseInt(xmlHttp.responseText.substr(pos-6, 4), 10); 640 var dd = parseInt(xmlHttp.responseText.substr(pos-2, 2), 10); 641 var com = xmlHttp.responseText.substr(pos, len); 642 pos += len+6; 643 644 if (com!="") 645 { 646 var td = document.getElementById(mm+"-"+dd); 647 td.childNodes[1].style.display=""; 648 td.title=com; 649 } 650 } 651 }; 652 653 xmlHttp.send(); 654 } 655 587 656 this.setDate = function() 588 657 { -
trunk/FACT++/www/shift/calendar.php
r13685 r13687 81 81 if (isset($_GET['comment'])) 82 82 { 83 if (!isset($_GET['d'])) 84 return; 85 86 $d = $_GET['d']; 87 88 $query = "SELECT c FROM Comments WHERE y=".$y." AND m=".$m." AND d=".$d; 83 $query = "SELECT d, c FROM Comments WHERE y=".$y." AND m=".$m; 84 if (isset($_GET['d'])) 85 $query .= " AND d=".$_GET['d']; 89 86 90 87 $result = mysql_query($query); … … 92 89 return header('HTTP/1.0 500 '.mysql_error()); 93 90 94 $row = mysql_fetch_array($result, MYSQL_NUM); 91 if (isset($_GET['d'])) 92 { 93 $row = mysql_fetch_array($result, MYSQL_NUM); 94 print($row[1]); 95 return; 96 } 95 97 96 print($row[0]); 98 while ($row = mysql_fetch_array($result, MYSQL_NUM)) 99 { 100 printf("%04d%02d%s", strlen($row[1]), $row[0], $row[1]); 101 } 97 102 98 103 return;
Note:
See TracChangeset
for help on using the changeset viewer.