[bknr-cvs] r1886 - branches/xml-class-rework/projects/mah-jongg/website

bknr at bknr.net bknr at bknr.net
Fri Mar 3 20:56:27 UTC 2006


Author: hhubner
Date: 2006-03-03 15:56:27 -0500 (Fri, 03 Mar 2006)
New Revision: 1886

Modified:
   branches/xml-class-rework/projects/mah-jongg/website/game.css
   branches/xml-class-rework/projects/mah-jongg/website/game.js
   branches/xml-class-rework/projects/mah-jongg/website/game.xsl
Log:
User interface now basically works.


Modified: branches/xml-class-rework/projects/mah-jongg/website/game.css
===================================================================
--- branches/xml-class-rework/projects/mah-jongg/website/game.css	2006-03-03 17:50:47 UTC (rev 1885)
+++ branches/xml-class-rework/projects/mah-jongg/website/game.css	2006-03-03 20:56:27 UTC (rev 1886)
@@ -56,7 +56,7 @@
 }
 
 .score-input {
-        width: 40px;
+        width: 70px;
         text-align: right;
 }
 

Modified: branches/xml-class-rework/projects/mah-jongg/website/game.js
===================================================================
--- branches/xml-class-rework/projects/mah-jongg/website/game.js	2006-03-03 17:50:47 UTC (rev 1885)
+++ branches/xml-class-rework/projects/mah-jongg/website/game.js	2006-03-03 20:56:27 UTC (rev 1886)
@@ -25,21 +25,39 @@
 }
 
 var check_new_game_inputs_interval;
+var winner_clicked = false;
 
+function set_winner_clicked()
+{
+    winner_clicked = true;
+    check_new_game_inputs();
+}
+
 function check_new_game_inputs()
 {
     if (!check_new_game_inputs_interval) {
         check_new_game_inputs_interval = setInterval("check_new_game_inputs()", 300);
     }
 
+    var is_valid = winner_clicked;
+
     for (i in winds) {
-        if ($(winds[i]).value.match(/^\s*$/)) {
-            $('make_game_button').disabled = 'disabled';
-            return false;
+        try {
+            var value = parseInt($(winds[i] + '-score').value) * (1 << parseInt($(winds[i] + '-doubles').value));
+            $(winds[i]).value = isNaN(value) ? '' : Math.min(value, 3000);
         }
+        catch (e) {
+            // Ignore errors
+        }
     }
 
-    $('make_game_button').disabled = undefined;
+    for (i in winds) {
+        if (!$(winds[i]).value.match(/^[1-9]/)) {
+            is_valid = false;
+        }
+    }
+
+    $('make_game_button').disabled = is_valid ? undefined : 'disabled';
     
     return true;
 }

Modified: branches/xml-class-rework/projects/mah-jongg/website/game.xsl
===================================================================
--- branches/xml-class-rework/projects/mah-jongg/website/game.xsl	2006-03-03 17:50:47 UTC (rev 1885)
+++ branches/xml-class-rework/projects/mah-jongg/website/game.xsl	2006-03-03 20:56:27 UTC (rev 1886)
@@ -125,19 +125,19 @@
     <img width="50" height="70" src="{@wind}.jpg"/>
    </td>
    <td>
-    <input type="radio" name="winner" value="{@wind}" onclick="check_new_game_inputs()"/>
+    <input type="radio" name="winner" value="{@wind}" onclick="return set_winner_clicked()"/>
    </td>
    <th>
     <xsl:value-of select="@name"/>
    </th>
    <td>
-    <input autocomplete="off" id="{@wind}-score" class="score-input" onchange="input_change('{@wind}');"/>
+    <input autocomplete="off" id="{@wind}-score" tabindex="1" class="score-input" onchange="return check_new_game_inputs();" value=""/>
    </td>
    <td>
-    <input autocomplete="off" id="{@wind}-doubles" class="score-input" onchange="input_change('{@wind}');" value="0"/>
+    <input autocomplete="off" id="{@wind}-doubles" tabindex="1" class="score-input" onchange="return check_new_game_inputs();" value="0"/>
    </td>
    <td>
-    <input autocomplete="off" id="{@wind}" name="{@wind}" class="score-input" readonly="readonly"/>
+    <input autocomplete="off" id="{@wind}" name="{@wind}" class="score-input" readonly="readonly" value=""/>
    </td>
   </tr>
  </xsl:template>




More information about the Bknr-cvs mailing list