Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 10.02 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Shake The Shack Line!</title>
  4.  
  5.         <style>
  6.        
  7.             * {
  8.                 margin:0;
  9.             }
  10.        
  11.             html, body {
  12.                 margin:0;
  13.                 padding:0;
  14.                 font-size:1.5em;
  15.                 font-family:sans, "Arial", "Helvetica";
  16.                 background-color:#eee;
  17.                 color:#000;
  18.             }
  19.            
  20.             div {
  21.                 margin:0;
  22.                 padding:0;
  23.             }
  24.            
  25.             #idHeader {
  26.                 background-color:#00b7ee;
  27.                 font-weight:bold;
  28.                 text-align:center;
  29.             }
  30.  
  31.             #idBody {
  32.                 padding:1em 0em 0em 0em;
  33.                 color:#22376f;
  34.                 background-color:#ccf1fc;
  35.             }
  36.            
  37.             #idFooter {
  38.                 background-color:#00b7ee;
  39.                 font-weight:bold;
  40.                 text-align:right;
  41.             }
  42.            
  43.             /*--- */
  44.            
  45.             #mainMain {
  46.                 text-align:center;
  47.             }
  48.  
  49.             #infoWhichNote {
  50.                 margin-top:0.5em;
  51.                 text-align:center;
  52.             }
  53.            
  54.             #infoSoundLink {
  55.                 margin-top:0.5em;
  56.                 text-align:center;
  57.                 font-weight:bold;
  58.             }
  59.  
  60.             #timerSingPrompt {
  61.                 font-size:2.5em;
  62.                 font-weight:bold;
  63.                 text-align:center;
  64.                 margin-top:0.5em;
  65.             }
  66.            
  67.             #singProgWrapper {
  68.                 text-align:center;
  69.                 position:relative;
  70.             }
  71.                 #singProgBg {
  72.                     position:relative;
  73.                 }
  74.                 #singProgBar {
  75.                     position:relative;
  76.                     top:-50px;
  77.                 }
  78.                
  79.             #idListHolder {
  80.                 padding:0.5em 0em 0.5em 1.0em;
  81.                 background-color:#abe7f9;
  82.             }
  83.                 #idListHeader {
  84.                     font-weight:bold;
  85.                     font-style:italic;
  86.                     margin-bottom:0.33em;
  87.                 }
  88.                 #idList {
  89.                     color:#00b7ee;
  90.                     font-weight:normal;
  91.                 }
  92.                
  93.                 .nameOwn {
  94.                     padding-top:5px;
  95.                     padding-left:1.25em;
  96.                     color:#22376f;
  97.                     font-weight:bold;
  98.                 }
  99.                 .nameGhosted {
  100.                     padding-top:5px;
  101.                     padding-left:1.25em;
  102.                     color:#bdbdbd;
  103.                 }
  104.                 .nameRegular {
  105.                     padding-top:5px;
  106.                     padding-left:1.25em;
  107.                     color:#00b7ee
  108.                 }
  109.            
  110.         </style>
  111.        
  112.         <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
  113.        
  114.         <script type="text/javascript" src="shared.js"></script>
  115.  
  116.         <script type="text/javascript">
  117.  
  118.             var SING_DURATION = 5000;
  119.             var _id;
  120.             var _nextEventMs;
  121.             var _chordNum = 0;
  122.             var _noteIndex = -1;
  123.             var _doesAudio;
  124.  
  125.             var _intervalPost;
  126.             var _intervalDisplay;
  127.             var _timeDeltaMs;
  128.             var _roundTrip;
  129.             var _start;
  130.  
  131.             var _debug = (window.location.href).indexOf("debug") > -1;
  132.            
  133.             //
  134.            
  135.             function updateFromServer()
  136.             {
  137.                 doPrintNamesPost();
  138.                 doGetNextEvent();
  139.             }
  140.        
  141.             function doPrintNamesPost() // plus keepalive
  142.             {
  143.                 $.post("printHandler.php", { type:"names", keepalive:_id }, printNamesPostBack );
  144.             }
  145.             function printNamesPostBack($s)
  146.             {
  147.                 if ($s.indexOf("ERROR:") == 0)
  148.                 {
  149.                     alert($s);
  150.                     return;
  151.                 }
  152.                
  153.                 // parse incoming data, which is formatted like this:
  154.                 // id~name~position|id~name~position...
  155.                
  156.                 var sRecs = $s.split("|");
  157.                 var array = new Array();
  158.                 for (var i = 0; i < sRecs.length; i++)
  159.                 {
  160.                     var a = sRecs[i].split("~");
  161.                     array[i] = { id:a[0], name:a[1], position:a[2] };
  162.                 }
  163.                 array.sort(printNameSorter);
  164.                
  165.                 // print it nicely
  166.                
  167.                 var string = "";
  168.                
  169.                 for (var i = 0; i < array.length; i++)
  170.                 {
  171.                     var cls;
  172.                     var imgName;
  173.                    
  174.                     // node graphic
  175.                     if (array[i].id == _id) {
  176.                         imgName = "node_filled_50.png";
  177.                         cls = "nameOwn";
  178.                     }
  179.                     else if (array[i].position < -10) {
  180.                         imgName = "node_gray_50.png";
  181.                         cls = "nameGhosted";
  182.                     }
  183.                     else {
  184.                         imgName = "node_empty_50.png";
  185.                         cls = "nameRegular";
  186.                     }
  187.  
  188.                     string += "<div style='clear:left;float:left;'><img src='_img/" + imgName + "' /></div>";
  189.                     string += "<div class='" + cls + "'>" + array[i].name;
  190.                     if (_debug)
  191.                     {
  192.                         // position
  193.                         string += " (" + array[i].position + ")";
  194.                     }
  195.                     string += "</div>";
  196.                 }
  197.                 $("#idList").replaceWith("<div id='idList'>" + string + "</div>");
  198.             }
  199.            
  200.             function printNameSorter($o1,$o2)
  201.             {
  202.                 a = parseInt($o1.position);
  203.                 b = parseInt($o2.position);
  204.                 return a + b; // descending order
  205.             }
  206.            
  207.             $(document).ready(function()
  208.             {
  209.                 if (document.cookie && getCookie("id"))
  210.                 {
  211.                     _id = getCookie("id");
  212.                    
  213.                     if (! _id || _id.length == 0)
  214.                     {
  215.                         // DANGER
  216.                         window.location = "client_login.htm";
  217.                     }
  218.                 }
  219.                 else
  220.                 {
  221.                     // DANGER
  222.                     window.location = "client_login.htm";
  223.                 }
  224.                
  225.                 _doesAudio = browserAudioDetect();
  226.                 //_doesAudio = true;
  227.  
  228.                 doFirstTimePost();
  229.             });
  230.            
  231.             function doFirstTimePost()
  232.             {
  233.                 _start = new Date().getTime();
  234.                 $.post("timingInfoHandler.php", { id:_id }, firstTimePostBack);
  235.             }
  236.             function firstTimePostBack($s)
  237.             {
  238.                 var serverTimeMs = getPdlParam($s, 0);
  239.                
  240.                 var clientTimeMs = new Date().getTime();
  241.                 _timeDeltaMs = serverTimeMs - clientTimeMs;
  242.                 _roundTrip = clientTimeMs - _start;
  243.                
  244.                 /// alert('roundtrip=' + _roundTrip);
  245.                
  246.                 _nextEventMs = getPdlParam($s, 1);
  247.                 _chordNum = 0; //xxx
  248.                 _noteIndex = getPdlParam($s, 2);
  249.                 updateInfo();
  250.  
  251.                 // continue startup:
  252.                 updateFromServer();
  253.                 _intervalPost = setInterval(updateFromServer, 4000);
  254.                
  255.                 updateView();
  256.                 _intervalView = setInterval(updateView, 100);
  257.             }
  258.  
  259.             function doGetNextEvent()
  260.             {
  261.                 $.post("timingInfoHandler.php", {  id:_id }, getNextEventHandler);
  262.             }
  263.             function getNextEventHandler($s)
  264.             {
  265.                 _nextEventMs = getPdlParam($s, 1);
  266.                
  267.                 var wasNI = _noteIndex;
  268.                 _noteIndex = getPdlParam($s, 2);
  269.                
  270.                 var wasCN = _chordNum;
  271.                 _chordNum = 0; //xxx
  272.                
  273.                 if (_noteIndex != wasNI || _chordNum != wasCN) {
  274.                     updateInfo();
  275.                 }
  276.             }
  277.  
  278.             function secondsToString($sec)
  279.             {
  280.                 var min = (Math.floor($sec / 60)).toString();
  281.                 var sec = ($sec % 60).toString();
  282.                 if (sec.length == 1) sec = "0" + sec;
  283.                 return min + ":" + sec;
  284.             }
  285.            
  286.             function updateView()
  287.             {
  288.                 var nowAdjustedMs = new Date().getTime() + _timeDeltaMs + _roundTrip*0.33;
  289.                 var msLeft = _nextEventMs - nowAdjustedMs;
  290.                 var secLeft = Math.ceil(msLeft/1000); // NB "ceil"
  291.  
  292.                 if (nowAdjustedMs < _nextEventMs)
  293.                 {
  294.                     var strTime = secondsToString(secLeft);
  295.                     $("#timerSingPrompt").replaceWith("<div id='timerSingPrompt'>" + strTime + "</div>");
  296.                     //$("#infoSoundLink").show();
  297.                     $("#singProgWrapper").hide();
  298.                 }
  299.                 else // ... is in the past
  300.                 {
  301.                     if (nowAdjustedMs - _nextEventMs < SING_DURATION + 2000)
  302.                     {
  303.                         $("#timerSingPrompt").replaceWith("<div id='timerSingPrompt'>" + "SING NOW!" + "</div>");
  304.                         //$("#infoSoundLink").show();
  305.                         $("#singProgWrapper").show();
  306.                        
  307.                         // stretch progbar
  308.                         var w = ((nowAdjustedMs - _nextEventMs) / SING_DURATION) * 600;
  309.                         if (w > 600) w = 600;
  310.                         $("#progBarStretch").width(w);
  311.                         $("#progBarStretch").height(50);
  312.                     }
  313.                     else
  314.                     {
  315.                         $("#timerSingPrompt").replaceWith("<div id='timerSingPrompt' span style='font-size:2.5em;'>The next event will begin shortly<br/>&nbsp;</div>");
  316.                         //$("#infoSoundLink").hide();
  317.                         $("#singProgWrapper").hide();
  318.                     }
  319.                 }
  320.             }
  321.            
  322.             function playAudio($url)
  323.             {
  324.                 // change src property should have been changed by now
  325.                 document.getElementById("audioTag").play();
  326.             }
  327.  
  328.             function updateInfo()
  329.             {
  330.                 if (_noteIndex < 0) return;
  331.                
  332.                 var a = _chords[_chordNum]; // array of keys (eg, ["c1","e","g"])
  333.                 var key = a[_noteIndex]; // eg, "c1"
  334.                 var o = _allNotes[key];
  335.                 var sPhrase = o.phrase;
  336.                 var sPathMp3 = o.pathMp3;
  337.                 var sPathVideo = o.pathVideo;
  338.  
  339.                 //
  340.                
  341.                 /*
  342.                 var s = "When timer reaches zero,<br/>sing this note out loud:<br/>";
  343.                 s += '<img src="_img/note.png" border="0"/>';
  344.                 s += "<span style='font-size:1.5em'>" + sPhrase + "</span>";
  345.                 $("#infoWhichNote").replaceWith("<div id='infoWhichNote'>" + s + "</div>");
  346.                 */
  347.  
  348.                 //
  349.                
  350.                 if (_doesAudio) {
  351.                     // s = "<a href='#' onclick='playAudio(0); return false;' ><img src='_img/iconPlay2x.gif' border='0'/> HEAR THE NOTE</a>";
  352.                     s = "<a href='#' onclick='playAudio(0); return false;' ><img src='_img/iconPlay2x.gif' border='0'/> <b>Listen to the following note</b></a><br/>Then, sing it out loud<br/>when the timer reaches zero!";
  353.                 }
  354.                 else {
  355.                     // s = "<a href='" + sPathVideo + "'><img src='_img/iconPlay2x.gif' border='0'/> HEAR THE NOTE ON YOUTUBE</a>";
  356.                     s = "<a href='" + sPathVideo + "'><img src='_img/iconPlay2x.gif' border='0'/><b>Listen to the following note<br/>on YouTube</b></a><br/><br/>Then, sing it out loud<br/>when the timer reaches zero!";
  357.                 }
  358.                 $("#infoSoundLink").replaceWith("<div id='infoSoundLink'>" + s + "</div>");
  359.                
  360.                 //
  361.  
  362.                 // THIS DOESNT WORK
  363.                 // $("#audioTag source").attr("src", sPathMp3);
  364.                
  365.                 // THIS DOESNT WORK EITHER
  366.                 $("#audioTag source").replaceWith("<source src='" + sPathMp3 + "' />");
  367.  
  368.                 // THIS DOES, IT LOOKS LIKE
  369.                 $("#audioTag").replaceWith("<audio id='audioTag'><source src='" + sPathMp3 + "' /></audio>");
  370.             }
  371.            
  372.         </script>
  373.    
  374.     </head>
  375.     <body>
  376.    
  377.         <div id="idHeader"><img src="_img/header640.jpg" border="0" alt="Shake The Shack Line - Parsons MFADT Student Project" /></div>
  378.        
  379.         <div id="idBody">
  380.        
  381.             <div id="infoSoundLink"></div>
  382.                        
  383.             <div id="timerSingPrompt"></div>
  384.  
  385.             <div id="singProgWrapper">
  386.                 <div id="singProgBg"><img src="_img/progBarBg600.gif" border="0"/></div>
  387.                 <div id="singProgBar"><img id="progBarStretch" src="_img/progBarStretch.gif" width="600" height="50" border="0" /></div>
  388.             </div>
  389.            
  390.             <br/>
  391.            
  392.             <div id="idListHolder">
  393.                 <div id="idListHeader">Who's playing?</div>
  394.                 <img src="_img/node_begin_w32.png"/><br/><div id="idList">&nbsp;</div><div style="clear:left;"><img src="_img/node_end_w32.png"/></div>
  395.             </div>
  396.            
  397.             <audio id="audioTag">
  398.                 <!-- <source src="testtone.ogg" /> -->
  399.                 <!-- firefox!! -->
  400.                
  401.                 <source src="testtone.mp3" />
  402.             </audio>
  403.            
  404.         </div>
  405.  
  406.         <div id="idFooter"><a href="mailto:felaa538@newschool.edu?subject=Feedback - Shack Line Project" ><img src="_img/footer640.jpg" border="0" alt="Parsons MFA Design + Technology Student&nbsp;Project" /></a></div>
  407.  
  408.     </body>
  409. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement