Commit dbab0d33 authored by timeless%mozdev.org's avatar timeless%mozdev.org

Bug 320275 !Node "compat" hack is very broken

r=myk a=justdave
parent db151383
...@@ -109,9 +109,11 @@ ...@@ -109,9 +109,11 @@
[% END %] [% END %]
<script type="text/javascript"> <script type="text/javascript">
if (!Node) { if (typeof Node == 'undefined') {
/* MSIE doesn't define Node, so provide a compatibility array */ /* MSIE doesn't define Node, so provide a compatibility object */
var Node = { TEXT_NODE: 3 }; window.Node = {
TEXT_NODE: 3
};
} }
function toggleDisplay(node) function toggleDisplay(node)
...@@ -119,7 +121,7 @@ function toggleDisplay(node) ...@@ -119,7 +121,7 @@ function toggleDisplay(node)
var display = node.style.display; var display = node.style.display;
if (display == "none") { if (display == "none") {
node.style.display = node.style.display =
("oldDisplay" in node) ? node.oldDisplay : "block"; ("oldDisplay" in node) ? node.oldDisplay : "block";
return true; return true;
} }
...@@ -132,18 +134,18 @@ function listToggle(event) ...@@ -132,18 +134,18 @@ function listToggle(event)
{ {
var node = event.target; var node = event.target;
if (!node) if (!node)
node = event.srcElement; node = event.srcElement;
if (node.nodeType == Node.TEXT_NODE) if (node.nodeType == Node.TEXT_NODE)
node = node.parentNode; node = node.parentNode;
var toggle = node.nextSibling; var toggle = node.nextSibling;
while (toggle && toggle.tagName != "UL") while (toggle && toggle.tagName != "UL")
toggle = toggle.nextSibling; toggle = toggle.nextSibling;
if (toggle) { if (toggle) {
node.firstChild.data = toggleDisplay(toggle) ? "[-]" : "[+]"; node.firstChild.data = toggleDisplay(toggle) ? "[-]" : "[+]";
} }
} }
</script> </script>
[% PROCESS global/footer.html.tmpl %] [% PROCESS global/footer.html.tmpl %]
......
...@@ -31,28 +31,30 @@ ...@@ -31,28 +31,30 @@
/* Outputs a link to call replyToComment(); used to reduce HTML output */ /* Outputs a link to call replyToComment(); used to reduce HTML output */
function addReplyLink(id) { function addReplyLink(id) {
/* XXX this should really be updated to use the DOM Core's /* XXX this should really be updated to use the DOM Core's
* createElement, but finding a container isn't trivial */ * createElement, but finding a container isn't trivial.
document.write('[<a href="#add_comment" onclick="replyToComment(' + */
id + ');">reply<' + '/a>]'); document.write('[<a href="#add_comment" onclick="replyToComment(' +
id + ');">reply<' + '/a>]');
} }
/* Adds the reply text to the `comment' textarea */ /* Adds the reply text to the `comment' textarea */
function replyToComment(id) { function replyToComment(id) {
/* pre id="comment_name_N" */ /* pre id="comment_name_N" */
var text_elem = document.getElementById('comment_text_'+id); var text_elem = document.getElementById('comment_text_'+id);
var text = getText(text_elem); var text = getText(text_elem);
/* make sure we split on all newlines -- IE or Moz use \r and \n /* make sure we split on all newlines -- IE or Moz use \r and \n
* respectively */ * respectively.
text = text.split(/\r|\n/); */
text = text.split(/\r|\n/);
var replytext = "";
for (var i=0; i < text.length; i++) { var replytext = "";
replytext += "> " + text[i] + "\n"; 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 Param("insidergroup") && UserInGroup(Param("insidergroup")) %]
if (document.getElementById('isprivate-'+id).checked) { if (document.getElementById('isprivate-'+id).checked) {
...@@ -60,66 +62,67 @@ ...@@ -60,66 +62,67 @@
} }
[% END %] [% END %]
/* <textarea id="comment"> */ /* <textarea id="comment"> */
var textarea = document.getElementById('comment'); var textarea = document.getElementById('comment');
textarea.value += replytext; textarea.value += replytext;
textarea.focus(); textarea.focus();
} }
if (!Node) { if (typeof Node == 'undefined') {
/* MSIE doesn't define Node, so provide a compatibility array */ /* MSIE doesn't define Node, so provide a compatibility object */
var Node = { window.Node = {
TEXT_NODE: 3, TEXT_NODE: 3,
ENTITY_REFERENCE_NODE: 5 ENTITY_REFERENCE_NODE: 5
}; };
} }
/* Concatenates all text from element's childNodes. This is used /* Concatenates all text from element's childNodes. This is used
* instead of innerHTML because we want the actual text (and * instead of innerHTML because we want the actual text (and
* innerText is non-standard) */ * innerText is non-standard).
*/
function getText(element) { function getText(element) {
var child, text = ""; var child, text = "";
for (var i=0; i < element.childNodes.length; i++) { for (var i=0; i < element.childNodes.length; i++) {
child = element.childNodes[i]; child = element.childNodes[i];
var type = child.nodeType; var type = child.nodeType;
if (type == Node.TEXT_NODE || type == Node.ENTITY_REFERENCE_NODE) { if (type == Node.TEXT_NODE || type == Node.ENTITY_REFERENCE_NODE) {
text += child.nodeValue; text += child.nodeValue;
} else { } else {
/* recurse into nodes of other types */ /* recurse into nodes of other types */
text += getText(child); text += getText(child);
} }
} }
return text; return text;
} }
[% IF UserInGroup(Param('timetrackinggroup')) %] [% IF UserInGroup(Param('timetrackinggroup')) %]
var fRemainingTime = [% bug.remaining_time %]; // holds the original value var fRemainingTime = [% bug.remaining_time %]; // holds the original value
function adjustRemainingTime() { function adjustRemainingTime() {
// subtracts time spent from remaining time // subtracts time spent from remaining time
var new_time; var new_time;
// prevent negative values if work_time > fRemainingTime // prevent negative values if work_time > fRemainingTime
new_time = new_time =
Math.max(fRemainingTime - document.changeform.work_time.value, 0.0); Math.max(fRemainingTime - document.changeform.work_time.value, 0.0);
// get upto 2 decimal places // get upto 2 decimal places
document.changeform.remaining_time.value = document.changeform.remaining_time.value =
Math.round(new_time * 100)/100; Math.round(new_time * 100)/100;
} }
function updateRemainingTime() { function updateRemainingTime() {
// if the remaining time is changed manually, update fRemainingTime // if the remaining time is changed manually, update fRemainingTime
fRemainingTime = document.changeform.remaining_time.value; fRemainingTime = document.changeform.remaining_time.value;
} }
[% END %] [% END %]
function updateCommentTagControl(checkbox, form) { function updateCommentTagControl(checkbox, form) {
if (checkbox.checked) { if (checkbox.checked) {
form.comment.className='bz_private'; form.comment.className='bz_private';
} else { } else {
form.comment.className=''; form.comment.className='';
} }
} }
//--> //-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment