Welcome, Guest
  • Author Topic: Help understanding this iframe script  (Read 2416 times)

    david007

    • Seasoned Programmer
    • ***
    • Posts: 127
      • View Profile
    Help understanding this iframe script
    « on: 04/06/07, 17:55 »
    Hi all . could any one explain this ifrome script to me. I perticulerly intrestend in know this part:


        //push url
        var pushURL = win.pushURL;
        win.pushURL = "";
        if (pushURL != "") {
            lpOnURLPush(pushURL);
        }

       //handle control command
       var controlCommand = win.controlCommand;
       win.controlCommand = "";
       if ((typeof(controlCommand) != "undefined") && (controlCommand != null) && (controlCommand != "")) {
          handleControlCommand(controlCommand);
       }

    }

    I want to know what does the above part is doing and also want to know how we can write server response to iframe so we can use it inside javascript.looking forward for some explaination here.Thanks

    Code: [Select]
    document.writeln('<div id="hiddentext" style="z-index:0;position:absolute;visibility:hidden;left:0;top:13px">'+
        '<iframe name="lpCommFrame" id="lpCommFrame" src="https://localhost/22121212/?cmd=file&file=chatTemplate&template=SYSTEM!lpCommFrame&amp;site=22121212&amp;sessionkey=H6766563567357947376K479024" frameborder="0" border="0" width="350" height="220" title="Background">'+
        'This functionality requires frames. </iframe>'+
    '</div>');

    document.writeln('<form id="lpSendText" action="https://localhost/hc/22121212/chatSend" method="post" target="lpCommFrame" >');
    document.writeln('<input name="text" id="chatline" type="hidden" value="" />');
    document.writeln('<input name="cmd"     type="hidden" value="file" />');
    document.writeln('<input name="file"    type="hidden" value="chatText" />');
    document.writeln('<input name="site"    type="hidden" value="5296924" />');
    document.writeln('<input name="sessionkey" type="hidden" value="H6766563567357947376K479024" />');
    document.writeln('</form>');

    function jsHandleWidth(w)
    {
    if (w == 60) {
    var u = "https://localhost/22121212/?cmd=file&file=chatText&site=22121212&sessionkey=H6766563567357947376K479024&d=" + jsGetDate();
    document["lpCommFrame"].location = u;
    } else
    if (w == 70) {
    loadAddins();
    } else
    if (w == 90) {
    loop = false;
    lpOnSendTextFail( lastText, 2);
    }
    }


    function jsCheckCommFrame() {

    var win = window.frames['lpCommFrame'];
    try{
            if ((typeof(win) == "undefined") || (win.document.body == null) || (typeof(win.document.body) == "undefined"))
                return;
    }catch(e){
        reportError(e,'jsCheckCommFrame_win');
        return;
        }

        //test for server error
    var newtext = win.document.body.innerHTML;
    if ( newtext!=null && typeof(newtext)!="undefined" && (newtext!="")) {
    var controlmsg = newtext.substring(0,10);
    if (controlmsg == "<br>Server") {
        lpOnSendTextFail( lastText, 1);
        return;
    }
        }

        var textArray = win.chatLines;
        if(textArray==null) return;
        var lineCount = textArray.length;
        if (lineCount != prevLineCount) {
            prevLineCount = lineCount;

            //convert chat array
            var chatLines = new Array();
            for(iline=0;  iline<lineCount;  iline++){
                var jLine = textArray[iline];
                if(jLine.length!=4) continue;
                chatLines[iline] = new LPChatLine( jLine[0], jLine[1], jLine[2], jLine[3] );
            }
            if( lpLastLineIndex != chatLines.length ) {
                lpOnAddLines( chatLines, lpLastLineIndex );
                lpLastLineIndex = chatLines.length;
            }

            unsentLine = "";
            // If we have unsent lines because we switched from Java to Javascript - send the next line.
            if (sendingUnsentLines){
                sendUnsentLines();
            }
        }

        //push url
        var pushURL = win.pushURL;
        win.pushURL = "";
        if (pushURL != "") {
            lpOnURLPush(pushURL);
        }

    //handle control command
    var controlCommand = win.controlCommand;
    win.controlCommand = "";
    if ((typeof(controlCommand) != "undefined") && (controlCommand != null) && (controlCommand != "")) {
    handleControlCommand(controlCommand);
    }

    }

    function lpOnURLPush ( url ){
        var attr = "screenX=0,screenY=0,left=0,top=0,scrollbars=1,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=1,menubar=1,toolbar=1,status=1,titlebar=1,z-lock=0,resizable=1";
        attr = attr + ",height=" + screen.height + ",width=" + screen.width;
        window.open(url,"HCPushWindow",attr);
    }

    function handleControlCommand(controlCommand)
    {
    if (controlCommand == "loadAddins") {
    loadAddins();
    } else
    if (controlCommand.indexOf("repTyping") == 0) {
    var repTyping = controlCommand.indexOf("1") > -1;
    lpOnRepTyping(repTyping);
    } else
    if (! handlePluginCommand(controlCommand)) ; // keep handling command
    }