Commits

Anonymous committed 0631f9a

paint center squares

  • Participants
  • Parent commits 89e0b57

Comments (0)

Files changed (1)

     document.forms[0].elements["pos_entry"].value = "" ;
     showpos() ;
 }
+function changecss(cls, atr, val) {
+    // thanks to Shawn Olson & http://www.shawnolson.net for the general mechanics behind this
+    var rules, tmp;
+    var r1, r2, s;
+
+    cls = cls.toLowerCase();
+    val = val.toLowerCase();
+
+    for (s = 0; s < document.styleSheets.length; s++) {
+	if (document.styleSheets[s]['rules']) {
+	    rules = 'rules';
+	} else if (document.styleSheets[s]['cssRules']) {
+	    rules = 'cssRules';
+	} else {
+	    // no rules found... browser unknown
+	}
+
+	for (r1 = 0; r1 < document.styleSheets[s][rules].length; r1++) {
+	    if (document.styleSheets[s][rules][r1].selectorText == val &&
+		document.styleSheets[s][rules][r1].style[atr]) {
+		break;
+	    }
+	}
+
+
+	for (r2 = 0; r2 < document.styleSheets[s][rules].length; r2++) {
+	    if (document.styleSheets[s][rules][r2].selectorText == cls &&
+		document.styleSheets[s][rules][r2].style[atr]) {
+		break;
+	    }
+	}
+	tmp = document.styleSheets[s][rules][r1].style[atr];
+	document.styleSheets[s][rules][r1].style[atr] = document.styleSheets[s][rules][r2].style[atr];
+	document.styleSheets[s][rules][r2].style[atr] = tmp;
+    }
+
+}
+
+
 // hook in
 window.onload = function() { init() ; showpos() ;}
 </script>
 		<font color="blue">Q</font><font color="red">B</font><font color="green">X</font>
 	</b></font><br>
 	Evan Gates<br>
-       	Tom Rokicki
+       	Tomas Rokicki
     </td>
 <td class="space"></td>
 <td id="C44" onclick="paint(this);"></td><td id="C6" onclick="paint(this);"></td><td id="C40" onclick="paint(this);"></td><td class="space"></td>
 </tr>
 <tr>
 <td class="space"></td>
-<td id="C9" onclick="paint(this);"></td><td id="CU">U</td><td id="C3" onclick="paint(this);"></td><td class="space"></td>
+<td id="C9" onclick="paint(this);"></td><td id="CU" onclick="changecss('td.' + this.className,'background-color','td.' + brush);">U</td><td id="C3" onclick="paint(this);"></td><td class="space"></td>
 </tr>
 <tr>
 <td class="space"></td>
 <td id="C42" onclick="paint(this);"></td><td id="C7" onclick="paint(this);"></td><td id="C45" onclick="paint(this);"></td>
 </tr>
 <tr>
-<td id="C34" onclick="paint(this);"></td><td id="CL">L</td><td id="C28" onclick="paint(this);"></td> <td class="space"></td>
-<td id="C27" onclick="paint(this);"></td><td id="CF">F</td><td id="C24" onclick="paint(this);"></td> <td class="space"></td>
-<td id="C25" onclick="paint(this);"></td><td id="CR">R</td><td id="C31" onclick="paint(this);"></td> <td class="space"></td>
-<td id="C30" onclick="paint(this);"></td><td id="CB">B</td><td id="C33" onclick="paint(this);"></td>
+<td id="C34" onclick="paint(this);"></td><td id="CL" onclick="changecss('td.' + this.className,'background-color','td.' + brush);">L</td><td id="C28" onclick="paint(this);"></td> <td class="space"></td>
+<td id="C27" onclick="paint(this);"></td><td id="CF" onclick="changecss('td.' + this.className,'background-color','td.' + brush);">F</td><td id="C24" onclick="paint(this);"></td> <td class="space"></td>
+<td id="C25" onclick="paint(this);"></td><td id="CR" onclick="changecss('td.' + this.className,'background-color','td.' + brush);">R</td><td id="C31" onclick="paint(this);"></td> <td class="space"></td>
+<td id="C30" onclick="paint(this);"></td><td id="CB" onclick="changecss('td.' + this.className,'background-color','td.' + brush);">B</td><td id="C33" onclick="paint(this);"></td>
 </tr>
 <tr>
 <td id="C61" onclick="paint(this);"></td><td id="C22" onclick="paint(this);"></td><td id="C58" onclick="paint(this);"></td> <td class="space"></td>
 <td id="C56" onclick="paint(this);"></td><td id="C12" onclick="paint(this);"></td><td id="C52" onclick="paint(this);"></td><td class="space"></td>
 <td class="big_r" colspan="7" rowspan="7" valign="top">
 	Click on a color in the palette then click on squares in the cube to paint them.
-	Center squares cannot be painted. Click step to step through a solution (does
-	not work with generate). You can manually edit or enter a cube in the text box
-	and click set when done. Benchmark reports initialization and solving times to
-	compare browsers.
+	Paint center squares first. Click step to step through a solution (does not work
+	with generate). You can manually edit or enter a cube in the text box and click
+	set when done. Benchmark reports initialization and solving times to compare
+	browsers.
 </td>
 </tr>
 <tr>
 <td class="space"></td>
-<td id="C21" onclick="paint(this);"></td><td id="CD">D</td><td id="C15" onclick="paint(this);"></td><td class="space"></td>
+<td id="C21" onclick="paint(this);"></td><td id="CD" onclick="changecss('td.' + this.className,'background-color','td.' + brush);">D</td><td id="C15" onclick="paint(this);"></td><td class="space"></td>
 <td class="void"></td><td class="void"></td><td class="void"></td><td class="space"></td>
 <td class="void"></td><td class="void"></td><td class="void"></td>
 </tr>
 <br>
 <div id="solution"></div>
 <div id="validation"></div>
-<p align="right">
-&copy; 2010 Evan Gates and Tom Rokicki<br>
+<br><br>
+&copy; 2010 Evan Gates and Tomas Rokicki<br>
 QBX is released under the <a href="http://www.gnu.org/licenses/gpl-2.0.html">GPLv2</a>
-</p>
 </form>
 </body></html>