aikinetix

ryan dotrace

Nov 18th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 4.06 KB | None | 0 0
  1. <html><object type="{0C55C096-0F1D-4F28-AAA2-85EF591126E7}" cotype="cs" id="cosymantecbfw" style="width: 0px; height: 0px; display: block;"></object><head>
  2.     <title>Dot Race</title>
  3.     <style>
  4.         body
  5.         {
  6.             background-image:url('felixwall.jpg');
  7.             background-size:100% 100%;
  8.             background-repeat:no-repeat;
  9.             font-family:arial;
  10.             font-size:14px;
  11.             color:#333333;
  12.         }
  13.         #gamebox
  14.         {
  15.             width:320px;
  16.             background:#cccccc;
  17.             border:2px solid #333333;
  18.             border-radius:4px;
  19.             margin-left:auto;
  20.             margin-right:auto;
  21.             box-shadow:5px 5px 15px #000000;
  22.         }
  23.     </style>
  24.     <script type="text/javascript" src="http://balance3e.com/random.js"></script><style type="text/css"></style>
  25.     <script>
  26.         function DotRace()
  27.         {
  28.             //Assumes: User enters a goal distance in box.
  29.             //Results: Gives an alert with winning dot color
  30.             if(!document.getElementById('distanceBox').value){
  31.                 alert('Please enter the goal distance.');
  32.                 return;
  33.             }
  34.             var goal, dot1, dot1step, dot2, dot2step;
  35.            
  36.             goal = document.getElementById('distanceBox').value;
  37.             document.getElementById('maxSpan').innerHTML = goal;
  38.             document.getElementById('maxSpan2').innerHTML = goal;
  39.             document.getElementById('dot1Prog').max = goal;
  40.             document.getElementById('dot2Prog').max = goal;
  41.             dot1step = RandomInt(1, document.getElementById('stepBox').value);
  42.             dot2step = RandomInt(1, document.getElementById('stepBox').value);
  43.            
  44.             dot1 = document.getElementById('dot1Prog').value + dot1step;
  45.             document.getElementById('dot1Prog').value = dot1;
  46.             document.getElementById('dot1Span').innerHTML = dot1;
  47.            
  48.             dot2 = document.getElementById('dot2Prog').value + dot2step;
  49.             document.getElementById('dot2Prog').value = dot2;
  50.             document.getElementById('dot2Span').innerHTML = dot2;
  51.            
  52.             if(dot1 >= goal && dot2 >= goal) {
  53.                 document.getElementById('dot1Span').value = goal;
  54.                 document.getElementById('dot2Span').value = goal;
  55.                 alert('Both Dots tied! Game is resetting!');
  56.                 resetGame();
  57.             }
  58.             else if(dot1 >= goal) {
  59.                 document.getElementById('dot1Span').value = goal;
  60.                 alert('Red Dot wins! Game is resetting!');
  61.                 resetGame();
  62.             }
  63.             else if(dot2 >= goal) {
  64.                 document.getElementById('dot2Span').value = goal;
  65.                 alert('Blue Dot wins! Game is resetting!');
  66.                 resetGame();
  67.             }
  68.             return;
  69.         }
  70.         function updateMax()
  71.         {
  72.             goal = document.getElementById('distanceBox').value;
  73.             document.getElementById('maxSpan').innerHTML = goal;
  74.             document.getElementById('maxSpan2').innerHTML = goal;
  75.             document.getElementById('dot1Prog').max = goal;
  76.             document.getElementById('dot2Prog').max = goal;
  77.             return;
  78.         }
  79.         function resetGame()
  80.         {
  81.             dot1 = 0;
  82.             dot2 = 0;
  83.             document.getElementById('dot1Span').innerHTML = dot1;
  84.             document.getElementById('dot1Prog').value = dot1;
  85.             document.getElementById('dot2Span').innerHTML = dot2;
  86.             document.getElementById('dot2Prog').value = dot2;
  87.         }
  88.     </script>
  89. <script type="text/javascript" id="waxCS">var WAX = function () { var _arrInputs; return { getElement: function (i) { return _arrInputs[i]; }, setElement: function(i){ _arrInputs=i; } } }(); function waxGetElement(i) { return WAX.getElement(i); } function coSetPageData(t, d){ if('wax'==t) { WAX.setElement(d);} }</script></head>
  90. <body cz-shortcut-listen="true">
  91. <br><br>
  92. <div id="gamebox">
  93.     <h1 style="text-align:center">Online Dot Race</h1>
  94.     <p style="text-align:center">
  95.         Race Length: <input type="text" size="4" id="distanceBox" value="20" style="margin-left:10px" oninput="updateMax();"><br>
  96.         Step Distance: <input type="text" size="4" id="stepBox" value="3">
  97.     </p>
  98.     <p style="margin-left:36px;">
  99.         Red Dot: <progress id="dot1Prog" value="0" max="20" style="margin-left:2px"></progress>
  100.         <span id="dot1Span">0</span>/<span id="maxSpan">20</span>
  101.         <br>
  102.         Blue Dot: <progress id="dot2Prog" value="0" max="20"></progress>
  103.         <span id="dot2Span">0</span>/<span id="maxSpan2">20</span>
  104.         <br>
  105.     </p>
  106.     <p style="text-align:center">
  107.         <input type="button" style="width:250px; height:30px;" value="Take a Step" onclick="DotRace();">
  108.     </p>
  109. </div>
  110.  
  111. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment