Opened 10 years ago

Closed 10 years ago

#64 closed defect (fixed)

Patch: HtmlTidy bugfixes + charset

Reported by: Niko <ns@…> Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords: htmltidy
Cc:

Description

Changes:

  • plugin now makes use of HTMLArea._postback (instead of having its own iframe)
    (there was a bug for IE that poped up a window instead of opening it in the hidden iframe)
  • works with any encoding (always uses utf-8 as _postback sends utf-8-data)
Index: html-tidy.js
===================================================================
--- html-tidy.js        (Revision 38)
+++ html-tidy.js        (Arbeitskopie)
@@ -76,27 +76,6 @@
                    ["html-auto-tidy"]
 ];

-HtmlTidy.prototype.onGenerateOnce = function() {
-       var editor = this.editor;
-
-       var ifr = document.createElement("iframe");
-       ifr.name = "htiframe_name";
-       var s = ifr.style;
-       s.position = "absolute";
-       s.width = s.height = s.border = s.left = s.top = s.padding = s.margin = "0px";
-       document.body.appendChild(ifr);
-
-       var frm = '<form id="htiform_id" name="htiform_name" method="post" target="htiframe_name" action="';
-       frm += _editor_url + 'plugins/HtmlTidy/html-tidy-logic.php';
-       frm += '"><textarea name="htisource_name" id="htisource_id">';
-       frm += '</textarea></form>';
-
-       var newdiv = document.createElement('div');
-       newdiv.style.display = "none";
-       newdiv.innerHTML = frm;
-       document.body.appendChild(newdiv);
-};
-
 HtmlTidy.prototype.buttonPress = function(editor, id) {
        var i18n = HtmlTidy.I18N;

@@ -105,24 +84,13 @@

                var oldhtml = editor.getHTML();

-               // Ask the server for some nice new html, based on the old...
-               var myform = document.getElementById('htiform_id');
-               var txtarea = document.getElementById('htisource_id');
-               txtarea.value = editor.getHTML();
-
                // Apply the 'meanwhile' text, e.g. "Tidying HTML, please wait..."
                editor.setHTML(i18n['tidying']);

-               // The returning tidying processing script needs to find the editor
-               window._editorRef = editor;
-
-               // ...And send our old source off for processing!
-               myform.submit();
+        // Ask the server for some nice new html, based on the old...
+        HTMLArea._postback(_editor_url + 'plugins/HtmlTidy/html-tidy-logic.php', {'htisource_name' : oldhtml},
+                            function(javascriptResponse) { eval(javascriptResponse) });
+
                break;
        }
 };
-
-HtmlTidy.prototype.processTidied = function(newSrc) {
-       editor = this.editor;
-       editor.setHTML(newSrc);
-};
Index: html-tidy-logic.php
===================================================================
--- html-tidy-logic.php (Revision 38)
+++ html-tidy-logic.php (Arbeitskopie)
@@ -17,7 +17,7 @@

                0 => array("pipe", "r"),
                1 => array("pipe", "w")
        );
-       $process = proc_open("tidy -config html-tidy-config.cfg", $descriptorspec, $pipes);
+       $process = proc_open("tidy -utf8 -config html-tidy-config.cfg", $descriptorspec, $pipes);

        // Make sure the program started and we got the hooks...
        // Either way, get some source code into $source
@@ -57,26 +57,8 @@
        foreach ($srcLines as $line) {
                $jsMakeSrc .= "\tns += '" . str_replace("'","\'",$line) . "\\n';\n";
        }
-?>

-
-<html>
-  <head>
-    <script type="text/javascript">
-
-function setNewHtml() {
-       var htRef = window.parent._editorRef.plugins['HtmlTidy'];
-       htRef.instance.processTidied(tidyString());
-}
-function tidyString() {
-       var ns = '\n';
-       <?=$jsMakeSrc;?>
-       return ns;
-}
-
-    </script>
-  </head>
-
-  <body id="htiNewBody" onload="setNewHtml()">
-  </body>
-</html>
+?>
+var ns="";
+<?=$jsMakeSrc?>
+editor.setHTML(ns);

Change History (1)

comment:1 Changed 10 years ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

Applied in changeset:40

Note: See TracTickets for help on using tickets.