Allow hiding non-alert rows
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Fri, 13 May 2011 12:06:02 -0600
changeset 111 b6104db990af
parent 110 46289ac20636
child 112 b82d94bbf47a
Allow hiding non-alert rows
autoimplementation.html
--- a/autoimplementation.html	Thu May 12 13:38:40 2011 -0600
+++ b/autoimplementation.html	Fri May 13 12:06:02 2011 -0600
@@ -14,7 +14,7 @@
 	font-family: sans-serif;
 	border-color: black;
 }
-.alert {
+div.alert {
 	color: red;
 	font-weight: bold;
 }
@@ -74,6 +74,25 @@
 styleWithCSS false and the second is with it true.  (The second table is left
 blank in IE and Opera, which don't support styleWithCSS.)
 
+<p>
+<!-- Note: this is completely not a hack at all. -->
+<style id=alerts>/* tr:not(.alert):not(:first-child) { display: none } */</style>
+
+<label><input id=alert-checkbox type=checkbox checked onclick='updateAlertRowStyle()'> Display non-alert rows</label>
+
+<script>
+function updateAlertRowStyle() {
+	var checked = document.querySelector("#alert-checkbox").checked;
+	var style = document.querySelector("#alerts");
+	if (checked && !/^\/\*/.test(style.textContent)) {
+		style.textContent = "/* " + style.textContent + " */";
+	} else if (!checked) {
+		style.textContent = style.textContent.replace(/(\/\* | \*\/)/g, "");
+	}
+}
+updateAlertRowStyle();
+</script>
+
 <h1>Table of Contents</h1>
 <ul>
 </ul>
@@ -1473,6 +1492,7 @@
 	} catch (e) {
 		specCell.firstChild.contentEditable = "inherit";
 		specCell.firstChild.removeAttribute("spellcheck");
+		specCell.parentNode.className = "alert";
 		specCell.lastChild.className = "alert";
 		specCell.lastChild.textContent = "Exception: " + e;
 		if (typeof e == "object" && "stack" in e) {
@@ -1494,6 +1514,7 @@
 	var newValue = specCell.lastChild.textContent;
 
 	if (oldValue === null || oldValue !== newValue) {
+		specCell.parentNode.className = "alert";
 		var alertDiv = document.createElement("div");
 		specCell.lastChild.appendChild(alertDiv);
 		alertDiv.className = "alert";
@@ -1578,6 +1599,7 @@
 			testDiv.contenteditable = "inherit";
 			testDiv.removeAttribute("spellcheck");
 		}
+		browserCell.parentNode.className = "alert";
 		browserCell.lastChild.className = "alert";
 		browserCell.lastChild.textContent = "Exception: " + e;
 		if (typeof e == "object" && "stack" in e) {