CLEANUP: moved javascript to separate file
authorArun Persaud <arun@nubati.net>
Sat, 1 Nov 2008 22:52:14 +0000 (15:52 -0700)
committerArun Persaud <arun@nubati.net>
Sat, 1 Nov 2008 22:56:07 +0000 (15:56 -0700)
doesn't need to be in every html page. better to have it in its own file, so that it can be cached by the server.

Signed-off-by: Arun Persaud <arun@nubati.net>
include/game.js [new file with mode: 0644]
include/output.php

diff --git a/include/game.js b/include/game.js
new file mode 100644 (file)
index 0000000..862d8b6
--- /dev/null
@@ -0,0 +1,45 @@
+/* some code to highlight the current trick and to switch between different tricks */
+/* which trick is currently highlighted*/
+var current=0;
+
+/* do the higlighting */
+function hl(num) {
+    if(document.getElementById){
+       var i;
+       for(i=0;i<14;i++){
+           if(document.getElementById("trick"+i))
+               document.getElementById("trick"+i).style.display = 'none';
+       }
+       document.getElementById("trick"+num).style.display = 'block';
+       current=num;
+    }
+}
+
+/* highlight the last trick, useful when a page is called the first time*/
+function high_last(){
+    if(document.getElementById){
+       var i;
+       for(i=13;i>=0;i--) {
+           if(document.getElementById("trick"+i))
+               {
+                   hl(i);
+                   current=i;
+                   break;
+               }
+       }
+    }
+}
+
+/* highlight the next trick */
+function hl_next()
+{
+    if(document.getElementById("trick"+(current+1)))
+       hl(current+1);
+}
+
+/* highlight the previous trick */
+function hl_prev()
+{
+    if(document.getElementById("trick"+(current-1)))
+       hl(current-1);
+}
index 47fddfea50ae2aeab4261edf75cd4c1f9fbb1af8..17bd9e26fdb8c5502649ac0cce5d527edc83bd2d 100644 (file)
@@ -271,43 +271,7 @@ function output_header()
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
      <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
      <link rel="stylesheet" type="text/css" href="css/standard014.css" />
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
      <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
      <link rel="stylesheet" type="text/css" href="css/standard014.css" />
-     <script type="text/javascript">
-       var current=0;
-       function hl(num) {
-         if(document.getElementById){
-          var i;
-          for(i=0;i<14;i++){
-            if(document.getElementById("trick"+i))
-              document.getElementById("trick"+i).style.display = 'none';
-          }
-          document.getElementById("trick"+num).style.display = 'block';
-          current=num;
-        }
-       }
-       function high_last(){
-        if(document.getElementById){
-          var i;
-          for(i=13;i>=0;i--) {
-            if(document.getElementById("trick"+i))
-              {
-                hl(i);
-                current=i;
-                break;
-              }
-          }
-        }
-       }
-       function hl_next()
-        {
-          if(document.getElementById("trick"+(current+1)))
-            hl(current+1);
-        }
-       function hl_prev()
-        {
-          if(document.getElementById("trick"+(current-1)))
-            hl(current-1);
-        }
-     </script>
+     <script type="text/javascript" src="include/game.js"> </script>
   </head>
 <body onload="high_last();">
 <div class="header">
   </head>
 <body onload="high_last();">
 <div class="header">