]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 320275 - !Node "compat" hack is very broken
authortimeless%mozdev.org <>
Wed, 28 Dec 2005 04:51:58 +0000 (04:51 +0000)
committertimeless%mozdev.org <>
Wed, 28 Dec 2005 04:51:58 +0000 (04:51 +0000)
r=wicked a=justdave

template/en/default/bug/edit.html.tmpl

index 7975f7177cb78c6fb901c836a22252721a34e208..b4b57d41e4028933b58e0324c3978acc23862638 100644 (file)
 
   /* Outputs a link to call replyToComment(); used to reduce HTML output */
   function addReplyLink(id) {
-    /* XXX this should really be updated to use the DOM Core's
-     * createElement, but finding a container isn't trivial */
-    document.write('[<a href="#add_comment" onclick="replyToComment(' + 
-        id + ');">reply<' + '/a>]');
+      /* XXX this should really be updated to use the DOM Core's
+       * createElement, but finding a container isn't trivial.
+       */
+      document.write('[<a href="#add_comment" onclick="replyToComment(' + 
+                     id + ');">reply<' + '/a>]');
   }
 
   /* Adds the reply text to the `comment' textarea */
   function replyToComment(id) {
-    /* pre id="comment_name_N" */
-    var text_elem = document.getElementById('comment_text_'+id);
-    var text = getText(text_elem);
-
-    /* make sure we split on all newlines -- IE or Moz use \r and \n
-     * respectively */
-    text = text.split(/\r|\n/);
-
-    var replytext = "";
-    for (var i=0; i < text.length; i++) {
-        replytext += "> " + text[i] + "\n"; 
-    }
+      /* pre id="comment_name_N" */
+      var text_elem = document.getElementById('comment_text_'+id);
+      var text = getText(text_elem);
+
+      /* make sure we split on all newlines -- IE or Moz use \r and \n
+       * respectively.
+       */
+      text = text.split(/\r|\n/);
+
+      var replytext = "";
+      for (var i=0; i < text.length; i++) {
+          replytext += "> " + text[i] + "\n"; 
+      }
 
-    replytext = "(In reply to comment #" + id + ")\n" + replytext + "\n";
+      replytext = "(In reply to comment #" + id + ")\n" + replytext + "\n";
 
     [% IF Param("insidergroup") && UserInGroup(Param("insidergroup")) %]
       if (document.getElementById('isprivate-'+id).checked) {
       }
     [% END %]
 
-    /* <textarea id="comment"> */
-    var textarea = document.getElementById('comment');
-    textarea.value += replytext;
+      /* <textarea id="comment"> */
+      var textarea = document.getElementById('comment');
+      textarea.value += replytext;
 
-    textarea.focus();
+      textarea.focus();
   }
 
-  if (!Node) {
-    /* MSIE doesn't define Node, so provide a compatibility array */
-    var Node = {
-        TEXT_NODE: 3,
-        ENTITY_REFERENCE_NODE: 5
-    };
+  if (typeof Node == 'undefined') {
+      /* MSIE doesn't define Node, so provide a compatibility object */
+      window.Node = {
+          TEXT_NODE: 3,
+          ENTITY_REFERENCE_NODE: 5
+      };
   }
 
   /* Concatenates all text from element's childNodes. This is used
    * instead of innerHTML because we want the actual text (and
-   * innerText is non-standard) */
+   * innerText is non-standard).
+   */
   function getText(element) {
-    var child, text = "";
-    for (var i=0; i < element.childNodes.length; i++) {
-        child = element.childNodes[i];
-        var type = child.nodeType;
-        if (type == Node.TEXT_NODE || type == Node.ENTITY_REFERENCE_NODE) {
-            text += child.nodeValue;
-        } else {
-            /* recurse into nodes of other types */
-            text += getText(child);
-        }
-    }
-    return text;
+      var child, text = "";
+      for (var i=0; i < element.childNodes.length; i++) {
+          child = element.childNodes[i];
+          var type = child.nodeType;
+          if (type == Node.TEXT_NODE || type == Node.ENTITY_REFERENCE_NODE) {
+              text += child.nodeValue;
+          } else {
+              /* recurse into nodes of other types */
+              text += getText(child);
+          }
+      }
+      return text;
   }
 
 [% IF UserInGroup(Param('timetrackinggroup')) %]
   var fRemainingTime = [% bug.remaining_time %]; // holds the original value
   function adjustRemainingTime() {
-     // subtracts time spent from remaining time
-     var new_time;
-
-     // prevent negative values if work_time > fRemainingTime
-     new_time =
-        Math.max(fRemainingTime - document.changeform.work_time.value, 0.0);
-     // get upto 2 decimal places
-     document.changeform.remaining_time.value =
+      // subtracts time spent from remaining time
+      var new_time;
+
+      // prevent negative values if work_time > fRemainingTime
+      new_time =
+          Math.max(fRemainingTime - document.changeform.work_time.value, 0.0);
+      // get upto 2 decimal places
+      document.changeform.remaining_time.value =
           Math.round(new_time * 100)/100;
   }
 
   function updateRemainingTime() {
-     // if the remaining time is changed manually, update fRemainingTime
-     fRemainingTime = document.changeform.remaining_time.value;
+      // if the remaining time is changed manually, update fRemainingTime
+      fRemainingTime = document.changeform.remaining_time.value;
   }
 
 [% END %]