Ignore:
Timestamp:
05/13/12 11:30:56 (12 years ago)
Author:
tbretz
Message:
Implemented a mark for an attached comment, display comment in tooltip.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/www/shift/calendar.js

    r13685 r13687  
    359359            };
    360360
     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
    361367            tr.appendChild( td );
    362368        }
     
    380386
    381387        requestAll(this.yy, this.mm);
     388        requestAllComments(this.yy, this.mm);
    382389        if (this.year==this.yy && this.month==this.mm)
    383390            requestComment(this.year, this.month, this.date);
     
    432439                return;
    433440
    434             while (td.childNodes.length>1)
     441            while (td.childNodes.length>2)
    435442                td.removeChild(td.lastChild);
    436443
     
    454461            }
    455462
    456             if (td.childNodes.length>1)
     463            if (td.childNodes.length>2)
    457464                td.className += " enabled";
    458465            else
     
    486493        var m = c.getAttribute("data-m");
    487494        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);
    490498
    491499        var xmlHttp = new XMLHttpRequest();
    492500        xmlHttp.open('POST', uri, true);
    493         xmlHttp.onload = function ()
     501        xmlHttp.onload = function()
    494502        {
    495503            if (xmlHttp.status!=200)
     
    499507            }
    500508
    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
    502524        };
    503525
     
    527549            }
    528550
     551            var td = document.getElementById(mm+"-"+dd);
     552
    529553            c.color="#888";
    530554            if (xmlHttp.responseText=="")
     555            {
    531556                c.value="enter comment here";
     557                td.childNodes[1].style.display="none";
     558                td.title="";
     559            }
    532560            else
     561            {
    533562                c.value = xmlHttp.responseText;
     563                td.childNodes[1].style.display="";
     564                td.title=xmlHttp.responseText;
     565            }
    534566
    535567            c.setAttribute("data-y", yy);
     
    585617    }
    586618
     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
    587656    this.setDate = function()
    588657    {
Note: See TracChangeset for help on using the changeset viewer.