Undefined JS variables when loading dialogs

Last post 04-06-2011, 11:32 PM by Kenneth. 10 replies.
Sort Posts: Previous Next
  •  03-24-2011, 11:51 AM 66836

    Undefined JS variables when loading dialogs

    I am testing CuteEditor 6.6 for deployment, and for some reason when I click to insert hyperlink, firefox says:
     
    Error: arg is undefined
    Source File: /CuteEditor/Scripts/Dialog/Dialog_TagHead.js
    Line: 1
    Error: editor is undefined
    Source File: /CuteEditor/Scripts/Dialog/Dialog_Tag_A.js
    Line: 102
     
    Subsequently the "Browse" button is unclickable.
     
    Also, likely related, when I click to view the image gallery I get:
     
    Error: Oxba is null
    Source File: /CuteEditor/Dialogs/phpuploader/ajaxuploaderresource.php?type=script
    Line: 16
    And the Image button:
     
    Error: arg is undefined
    Source File: /CuteEditor/Scripts/Dialog/Dialog_TagHead.js
    Line: 1
    Error: element is undefined
    Source File: /CuteEditor/Scripts/Dialog/Dialog_Tag_Input.js
    Line: 1
     
    Then clicking browse:
     
    Error: editor is undefined
    Source File: /CuteEditor/Scripts/Dialog/Dialog_Tag_Input.js
    Line: 1
     
  •  03-24-2011, 3:46 PM 66839 in reply to 66836

    Re: Undefined JS variables when loading dialogs

    Dear
     
    http://phphtmledit.com/EnableAll.php , I tested this online demo, it works fine on my end. Can you reproduce it  on this online demo?
     
    Please save the following snippet to test.php and then run test.php:
     
    <?php include_once("cuteeditor_files/include_CuteEditor.php") ; ?>
    <html> 
        <head>
     </head>
        <body>  
      <form name="theForm" action="Get_HtmlContent.php" method="post" ID="Form1">
            <?php
                $editor=new CuteEditor();
                $editor->ID="Editor1";
                $editor->Text="Type here";
                $editor->EditorBodyStyle="font:normal 12px arial;";
                $editor->Draw();
                $editor=null;           
                //use $_POST["Editor1"]to retrieve the data
            ?>      
      </form>
     </body>
    </html>
     
    Please tell us the test result.
     
    Thank you for asking
  •  03-24-2011, 5:50 PM 66844 in reply to 66839

    Re: Undefined JS variables when loading dialogs

    The simple test works. I did figure out part of the cause. I can't get it to work inside a popup.
     
    Linking to the editor like this works:
    <a href='/CuteEditor/test.php'>Edit</a>
     
    But this breaks it:
    <a href='BLOCKED SCRIPTwindow.open("CuteEditor/test.php", "", "screenX=45,screenY=20,left=45,top=20,width=800,height=600,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=o,scrollbars=yes");'>Edit</a>

    Any ideas on that? Is it reproducible for you that way? Maybe I'm mis-using window.open somehow?
     
    Thanks for the help.
  •  03-25-2011, 11:14 AM 66851 in reply to 66844

    Re: Undefined JS variables when loading dialogs

    Dear zBrain,
     
    Please follow steps:
     
    1. Save the following code to dad.html
    <HTML>
    <HEAD>
    <SCRIPT>
        function popupCuteEditor(v_form, v_field) {
            var newWin, v_pagestring;
            w = 770;
            h = 500;
            LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
            TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
            settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=';
            v_pagestring = "kid.php?form=" + v_form + "&field=" + v_field;
            newWin = window.open(v_pagestring, "HTMLEdit", settings + LeftPosition + 'resizable=yes')
        }
    </SCRIPT>
    <TITLE>Parent Page</TITLE>
    </HEAD>
    <body>
     <FORM name="f1" id="f1" method=POST target='kid'>
      <textarea name="t1" cols="100" rows="15">Text Area 1 Text</textarea><br/>
      <input type="button" value="Edit In CuteEditor" name="B1"  onclick="popupCuteEditor('f1','t1')">
     </FORM>
    </BODY>
    </HTML>
    2. Save the following code to kid.php
    <?php include_once("cuteeditor_files/include_CuteEditor.php") ; ?>
    <html>
    <head>
    <TITLE>Kid Child Window</TITLE>
    </head>
    <body bottomMargin="0" topMargin="0" marginwidth="0" marginheight="0"
     onload="setTimeout(getparentdata,1000);" bgcolor="#efefef">

    <FORM name="fkid" method=POST>
     <h1>Enable All Toolbars</h1>
     <p>This example shows you all the predefined buttons.</p>
     <br />
     <?php
     $editor=new CuteEditor();
     $editor->ID="Editor1";
     $editor->Text="Type here";
     $editor->EditorBodyStyle="font:normal 12px arial;";
     $editor->EditorWysiwygModeCss="php.css";
     $editor->Draw();
     $editor=null;
     
     //use $_POST["Editor1"]to retrieve the data
     ?> <br />
     <INPUT type="button" value='Get Parent data' onClick="getparentdata();">
     <INPUT type="button" value='Set Parent value'
      onClick="tellDad(); window.close();"> <br />
     </form>
    <script type="text/javascript">
      // querystring
      // Call function by x = querystring("variable") returns variable=x
            function querystring(key)
      {   
       var value = null;
       for (var i=0;i<querystring.keys.length;i++)
       {
       if (querystring.keys[i]==key)
       {
       value = querystring.values[i];
       break;
       }
       }
       return value;
      }
      querystring.keys = new Array();
      querystring.values = new Array();
      function querystring_parse()
      {
       var query = window.location.search.substring(1);
       var pairs = query.split("&");  
       for (var i=0;i<pairs.length;i++)
       {
        var pos = pairs[i].indexOf('=');
        if (pos >= 0)
        {
        var argname = pairs[i].substring(0,pos);
        var value = pairs[i].substring(pos+1);
        querystring.keys[querystring.keys.length] = argname;
        querystring.values[querystring.values.length] = value;
        }
       }
      }  
      querystring_parse();
      // Set the parent windows form and field to a variable
      var v_parentform, v_field, v_form;
      v_field = querystring("field");
      v_form = querystring("form");
      var v_parent = "window.opener.";
      v_parentform = eval(v_parent + v_form);   
      function tellDad()
      {
       var editor1=document.getElementById('CE_Editor1_ID');
       var editdoc = editor1.GetDocument(); 
       v_parentform.elements[v_field].value=editdoc.body.innerHTML;
      }
      function Onload()
      {
       getparentdata();
       resizeWindow();
      }

      function getparentdata()
      { 
       var editor1=document.getElementById('CE_Editor1_ID');
       var editdoc = editor1.GetDocument(); 
       editdoc.body.innerHTML = v_parentform.elements[v_field].value;
      }

      function resizeWindow() {
       var iWidth = 720 + 18;
       var iHeight = 380 + 44;
       window.resizeTo(iWidth,iHeight)
      }
     </SCRIPT>
    </body>
    </html>

    3. Open dad.html, and have some test.
     
    Thank you for asking
  •  03-25-2011, 11:59 AM 66853 in reply to 66851

    Re: Undefined JS variables when loading dialogs

    I get v_parentform not defined on this line :

       editdoc.body.innerHTML = v_parentform.elements[v_field].value;

    in:

    function getparentdata()
    {
    var editor1=document.getElementById('CE_Editor1_ID');
    var editdoc = editor1.GetDocument();
    editdoc.body.innerHTML = v_parentform.elements[v_field].value;
    }
  •  03-26-2011, 9:49 PM 66867 in reply to 66853

    Re: Undefined JS variables when loading dialogs

    Hi zBrain,
     
    Find the line below
     
     v_parentform = eval(v_parent + v_form);   
     Change to
     
     v_parentform = window.opener.document.getElementById(v_form);
     
     
    Regards,
     
    Ken
  •  03-31-2011, 2:16 PM 66946 in reply to 66867

    Re: Undefined JS variables when loading dialogs

    ok, now we're back to the original error, this is what I get when I click the button to open kid.php:
     
    Error: arg is undefined
    Source File: http://127.0.0.1/test/cuteeditor_files/Scripts/Dialog/Dialog_TagHead.js
    Line: 1
     
    Error: editor is undefined
    Source File: http://127.0.0.1/test/cuteeditor_files/Scripts/Dialog/Dialog_Tag_A.js
    Line: 102
  •  04-01-2011, 10:46 PM 66961 in reply to 66946

    Re: Undefined JS variables when loading dialogs

    Hi zBrain,
     
    Please send a mail to [email protected]. I will send you two files, it should fix this issue.
     
    Regards,
     
    Ken
  •  04-04-2011, 2:58 PM 66982 in reply to 66961

    Re: Undefined JS variables when loading dialogs

    Thanks Kenneth, that seems to have fixed it.
  •  04-06-2011, 9:06 AM 67048 in reply to 66982

    Re: Undefined JS variables when loading dialogs

    I've now noticed a new, similar error that is likely related.
     
    When I click the"image button" button, then browse I get:
     
    Error: arg is undefined
    Source File: http://eve-crtm.org/ccms/lib/CuteEditor/Scripts/Dialog/Dialog_SelectImage.js
    Line: 1
     
    I'm also getting:
     
    Error: CuteWebUI_AjaxUploader_Initialize is not defined
    Source File: BLOCKED SCRIPTalert('TODO: FIXME')
    Line: 0
     
    In a few spots.
  •  04-06-2011, 11:32 PM 67060 in reply to 67048

    Re: Undefined JS variables when loading dialogs

    Hi zBrain,
     
    Is your site online? If so, please send me the test page url and set up ftp access for me. I will check it and get back to you as soon as possible.
     
     
    Regards,
     
    Ken
View as RSS news feed in XML