Advertisement
Guest User

audio alerts on input trigger

a guest
Jan 9th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.18 KB | None | 0 0
  1. ~inc:header.inc~
  2. <table style="padding-left: 10px;">
  3. <tr><td><b>Application:</b></td><td>&nbsp;</td><td>Genset 1</td></tr>
  4. <tr><td><b>Company Name:</b></td><td>&nbsp;</td><td>Power Contintuity</td></tr>
  5. <tr><td><b>MAC Address:</b></td><td>&nbsp;</td><td>~Config(M)~</td></tr>
  6. </table>
  7.  
  8. <div id="content">
  9.  
  10. <h1>Graphical Status <a id="error">- ERROR!</a></h1>
  11. <p>~Inputs(S)~</p>
  12. <audio preload="auto">
  13.         <source src="success.wav"></source>
  14.         Your browser isn't invited for super fun audio time.
  15. </audio>
  16. <div id="status">
  17.     <div id="loading" style="display:none">Error:<br />Connection to EMACSYS board was lost.</div>
  18.     <div id="display">
  19.         <p></span></p>
  20.         <p>Inputs:<br /><span style="font-size:20pt"></p>
  21.         <a id="btn0">&bull; Input 1</a><br>
  22.         <a id="btn1">&bull; Input 2</a><br>
  23.         <a id="btn2">&bull; Input 3</a><br>
  24.         <a id="btn3">&bull; Input 4</a><br>
  25.         <a id="btn4">&bull; Input 5</a><br>
  26.         <a id="btn5">&bull; Input 6</a><br>
  27.         <a id="btn6">&bull; Input 7</a><br>
  28.         <a id="btn7">&bull; Input 8</a><br>
  29.         <a id="btn8">&bull; Input 9</a><br>
  30.         <a id="btn9">&bull; Input 10</a><br>
  31.         <a id="btn10">&bull; Input 11</a><br>
  32.         <a id="btn11">&bull; Input 12</a><br>
  33.         <a id="btn12">&bull; Input 13</a><br>
  34.         <a id="btn13">&bull; Input 14</a><br>
  35.         <a id="btn14">&bull; Input 15</a><br>
  36.         <a id="btn15">&bull; Input 16</a><br>
  37.         </span> </p>
  38.         <p>Canopy Temperature: <a id="analogue0">?</a>
  39.         <br /><span style="font-size:20pt">
  40.         <a id="pot0">&rsaquo;</a>
  41.         <a id="pot1">&rsaquo;</a>
  42.         <a id="pot2">&rsaquo;</a>
  43.         <a id="pot3">&rsaquo;</a>
  44.         <a id="pot4">&rsaquo;</a>
  45.         <a id="pot5">&rsaquo;</a>
  46.         <a id="pot6">&rsaquo;</a>
  47.         <a id="pot7">&rsaquo;</a>
  48.         <a id="pot8">&rsaquo;</a>
  49.         <a id="pot9">&rsaquo;</a>
  50.         </span></p>
  51.         <p>Engine Heater Temperature: <a id="analogue1">?</a> (30-90 normal)
  52.         <br /><span style="font-size:20pt">
  53.         <a id="1pot0">&rsaquo;</a>
  54.         <a id="1pot1">&rsaquo;</a>
  55.         <a id="1pot2">&rsaquo;</a>
  56.         <a id="1pot3">&rsaquo;</a>
  57.         <a id="1pot4">&rsaquo;</a>
  58.         <a id="1pot5">&rsaquo;</a>
  59.         <a id="1pot6">&rsaquo;</a>
  60.         <a id="1pot7">&rsaquo;</a>
  61.         <a id="1pot8">&rsaquo;</a>
  62.         <a id="1pot9">&rsaquo;</a>
  63.         </span></p>
  64.     </div>
  65. </div>
  66.  
  67. <script type="text/javascript">
  68. // Parses the xmlResponse from status.xml and updates the status box
  69. function updateStatus(xmlData) {
  70.     // Check if a timeout occurred
  71.     if(!xmlData)
  72.     {
  73.         document.getElementById('display').style.display = 'none';
  74.         document.getElementById('loading').style.display = 'inline';
  75.         return;
  76.     }
  77.  
  78.     // Make sure we're displaying the status display
  79.     document.getElementById('loading').style.display = 'none';
  80.     document.getElementById('display').style.display = 'inline';
  81.  
  82.     // Play audio on state change loader
  83.  
  84.     // Loop over all the LEDs
  85.     for(i = 0; i < 16; i++) {
  86.         if(getXMLValue(xmlData, 'input'+i) == '1') {
  87.             document.getElementById('btn' + i).style.color = '#d00';
  88.             document.getElementById('btn' + i).innerHTML = ('&bull; ALERT ' + i);
  89.             document.getElementById('error').style.color = '#d00';
  90.             document.getElementByTag("audio");
  91.             audio.play();
  92.             }
  93.         else {
  94.             document.getElementById('btn' + i).style.color = '#090';
  95.             document.getElementById('btn' + i).innerHTML = '&bull;' + getXMLValue(xmlData, 'inputname'+i);
  96.             document.getElementById('error').style.color = '#fff';
  97.             document.getElementByTag("audio");
  98.             audio.stop();
  99.         }
  100.     }
  101.     // Sounds
  102.  
  103.     // Loop over all the buttons
  104.  
  105.     // Update the POT value
  106.     document.getElementById('analogue0').innerHTML =getXMLValue(xmlData,'analogue0');
  107.     val=0;
  108.     for(i = 0; i < 10; i++) {
  109.     val=val+10;
  110.     if(getXMLValue(xmlData, 'analogue0') >val)
  111.         document.getElementById('pot' + i).style.color = '#090';
  112.     else
  113.         document.getElementById('pot' + i).style.color = '#fff';
  114.     }
  115.  
  116.     // Update the POT value 2
  117.     document.getElementById('analogue1').innerHTML =getXMLValue(xmlData,'analogue1');
  118.     val=0;
  119.     for(i = 0; i < 10; i++) {
  120.     val=val+10;
  121.     if(getXMLValue(xmlData, 'analogue1') >val)
  122.         document.getElementById('1pot' + i).style.color = '#090';
  123.     else
  124.         document.getElementById('1pot' + i).style.color = '#fff';
  125.     }
  126.  
  127.  
  128. }
  129. setTimeout("newAJAXCommand('status.xml', updateStatus, true)",500);
  130. </script>
  131.  
  132. </div>
  133.  
  134.  
  135. ~inc:footer.inc~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement