Hello there, I wrote a program to visualise the log file. I used to
parse the data in a JSP page, and now I want to parse the data in
JavaScript. However, I looks like not working. It couldn't get the
data from the JSP. I tested many times, but don't know why!!! : (...
Can anyone help me to check it out see where is the problem please!!!
Thank you so much!!!!


<script><![CDATA[
                var svgDoc = document;          
                var ns = {
                        svg:"http://www.w3.org/2000/svg";,
                        xlink:"http://www.w3.org/1999/xlink"};  
                var wait = 1000;        //milisecond
                var nbLength = 50;
                var distance = 8;
                var vals={time:[],pp:[],unreg:[],reg:[],sea:[]};
                var shft={time:null,pp:null,unreg:null,reg:null,sea:null};
                var myLine={pp:null,unreg:null,reg:null,sea:null};
                var nbLine =4;
                var myPoly = [];
                var time = [];
                var nbTime =11;
                var record = {time:[], cID:[], sID:[], sIP:[], dIP:[], 
payload:[]};
                var preTime=0;
                var nPing=5, nReg=5, nUnreg=5, nSea=5;
                var curTime;
                var testTime=0;

                function init()
                {
                        var pingPong = svgDoc.getElementById('pingPong');
                        var unregister = svgDoc.getElementById('unregister');
                        var register = svgDoc.getElementById('register');
                        var search = svgDoc.getElementById('search');
                        var graphTime = svgDoc.getElementById('graphTime');
                        var theTime = svgDoc.getElementById('graphTime');
                        var pingPongStr;
                        var unregStr;
                        var regStr;
                        var searchStr;

                        //create line
                        pingPongStr = '<polyline xmlns="'+ns.svg+'" fill="none"
stroke="black" stroke-width="1.2"/>';
                        myLine['pp'] =
pingPong.appendChild(parseXML(pingPongStr,svgDoc).firstChild);

                        unregStr = '<polyline xmlns="'+ns.svg+'" fill="none" 
stroke="grey"
stroke-width="1.2"/>';
                        myLine['unreg'] =
unregister.appendChild(parseXML(unregStr,svgDoc).firstChild);

                        regStr = '<polyline xmlns="'+ns.svg+'" fill="none" 
stroke="green"
stroke-width="1.2"/>';
                        myLine['reg'] =
register.appendChild(parseXML(regStr,svgDoc).firstChild);

                        searchStr = '<polyline xmlns="'+ns.svg+'" fill="none" 
stroke="red"
stroke-width="1.2"/>';
                        myLine['sea'] =
search.appendChild(parseXML(searchStr,svgDoc).firstChild);
                                                
                        /*for(i=0; i<nbTime; i++)
                        {
                                var str = '<text xmlns="'+ns.svg+'" x="' + 
(i*40-10) + '" y="20"
font-size="10">00:00</text>';
                                time['t'+i] = 
theTime.appendChild(parseXML(str,svgDoc).firstChild);
                        }*/
                        setTimeout('getData()',wait);

                }

                //function to set the attributes
                function setAttr(elem,ns,attr,val)
                {
                        var target = (typeof elem == 'string') ?
svgDoc.getElementById(elem) : elem;
                        target.setAttributeNS(ns,attr,val);     
                }

                function getData()
                {
                        getURL('testingData.jsp',loadData);
                }

                function loadData(data)
                {
                        if(data.success)
                        {
                                eval("var content = new Array( " + data.content 
+ ")");
                                for(var i= 0; i<content.length; i++) //start 
with 1 is because the
first message is empty
                                {
                                        curTime = 
record['time'].push(content[i].time);
                                        if(curTime > testTime){
                                                
record['time'].push(content[i].time);
                                                
record['cID'].push(content[i].cID);
                                                
record['sID'].push(content[i].sID);
                                                
record['sIP'].push(content[i].sIP);
                                                
record['dIP'].push(content[i].dIP);
                                                
record['payload'].push(content[i].payload);
                                                testTime = curTime;
                                        }
                                }
        
                                
                                parseData();
                                
                                setTimeout('getData()',wait);
                        }               
                        else
                        {
                                alert('loading data failed');
                        }
                }

function parseData(){
        for(var i= 0; i<record['time'].length; i++)
        {
                /*if (record['cID'][i] == 1)
                ++nPing;
            else if (record['cID'][i]== 11)
                  ++nReg;
            else if (record['cID'][i] == 103)
                  ++nUnreg;
            else if (record['cID'][i]== 13)
                  ++nSea;*/
                //p<=7/content[i];
                //if(content[i]*i<=7)
                //vals['pp'].push(70-record['cID']); I tested this but nothing 
got
as well
                vals['pp'].push(70-nPing);
                vals['unreg'].push(70-nUnreg);
                vals['reg'].push(70-nReg);
                vals['sea'].push(70-nSea);
                vals['time'].push(record['time'][i]);
        }
        drawLine();
}

function drawLine(){

        while(vals['time'].length>=nbLength)
        {
                        shft['pp'] = (-1*distance+8)+ ',' + vals['pp'].shift() 
+ ' ';
                        shft['unreg'] = (-1*distance+8) + ',' + 
vals['unreg'].shift() + ' ';
                        shft['reg'] = (-1*distance+8) + ',' + 
vals['reg'].shift() + ' ';
                        shft['sea'] = (-1*distance+8) + ',' + 
vals['sea'].shift() + ' ';
                        //myT.shift();
        }
        //for(var i=1;i<=nbLine;i++) 
        myPoly[1] = (shft['pp'])?shft['pp']:'';
        myPoly[2] = (shft['unreg'])?shft['unreg']:'';
        myPoly[3] = (shft['reg'])?shft['reg']:'';
        myPoly[4] = (shft['sea'])?shft['sea']:'';
        
        for(j=0;j<vals['time'].length;j++){
                myPoly[1] += j*distance + "," + vals['pp'][j] + " ";
                myPoly[2] += j*distance+ "," + vals['unreg'][j]  + " ";
                myPoly[3] += j*distance + "," + vals['reg'][j] + " ";
                myPoly[4] += j*distance + "," + vals['sea'][j] + " ";
        }
                
        setAttr(myLine['pp'],null,'points',myPoly[1]);
        setAttr(myLine['unreg'],null,'points',myPoly[2]);
        setAttr(myLine['reg'],null,'points',myPoly[3]);
        setAttr(myLine['sea'],null,'points',myPoly[4]);
}

        ]]>
    </script>





-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to