Guest User

Untitled

a guest
Jul 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 12.94 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Testing Application.</title>
  5.     <meta content="UTF-8" />
  6.     <meta name="apple-mobile-web-app-capable" content="yes" />
  7.     <script type="text/javascript" src="jquery.js"></script>
  8. </head>
  9. <body>
  10.     <form action="" method="post" >
  11.     <audio controls="controls">
  12.         <source src="02_mick drove a truck.mp3" >
  13.     </audio>
  14.     <input type="submit" value="Submit" id="submit" name="submit" />
  15.     <input type="button" value="slideShowBtn" id="slideShowBtn" name="slideShowBtn" />
  16.     <div style="width:377px;">
  17.     <div id="divPart4" class="divPart">
  18.     <ul>
  19.         <li><span class="02_mick drove a truck.txt">Mick drove a truck!</span><br /></li>
  20.         <li><span class="03_a truck full of ducks.txt">a truck full of ducks,</span><br /></li>
  21.         <li><span class="04_a truck full of ducks.txt">a truck full of ducks</span><br /></li>
  22.         <li><span class="05_up the tricky truck track.txt">up the Tricky Truck Track.</span></li>
  23.     </ul>
  24.     </div>
  25.     </div>
  26.     <div style="width:377px;">
  27.     <div id="divPart5" class="divPart">
  28.     </div>
  29.     </div>
  30.     <div style="width:377px;">
  31.     <div id="divPart6" class="divPart">
  32.     <ul>
  33.         <li><span class="06_what good luck.txt">What good luck!</span><br/></li>
  34.         <li><span class="07_the king needs ducks.txt">The king needs ducks.</span><br/></li>
  35.         <li><span class="08_the king needs ducks.txt">The king needs ducks,</span><br/></li>
  36.         <li><span class="09_will pay big bucks.txt">will pay big bucks.</span></li>
  37.     </ul>
  38.     </div>
  39.     </div>
  40.     </form>
  41.     <?php
  42.         if (isset($_POST['submit']))
  43.         {
  44.             f();
  45.         }
  46.        
  47.         function f() {
  48.            
  49.             $urlList = array();
  50.            
  51.             $urlList[0] = "02_mick drove a truck";
  52.             $urlList[1] = "03_a truck full of ducks";
  53.             $urlList[2] = "04_a truck full of ducks";
  54.             $urlList[3] = "05_up the tricky truck track";
  55.             $urlList[4] = "06_what good luck";
  56.             $urlList[5] = "07_the king needs ducks";
  57.             $urlList[6] = "08_the king needs ducks";
  58.             $urlList[7] = "09_will pay big bucks";
  59.            
  60.             foreach ($urlList as $value)
  61.             {
  62.                 $fileName[$value] = data_uri($value.".mp3");
  63.             }
  64.             foreach ($fileName as $myFile => $encodedValue)
  65.             {
  66.                 $fh = fopen($myFile.".txt", 'w') or die("can't open file");
  67.                 fwrite($fh, $encodedValue);
  68.                 fclose($fh);
  69.             }
  70.             /*
  71.              * $myFile = "06_what%20good%20luck.txt";
  72.              * $fh = fopen($myFile, 'r');
  73.              * $theData = fread($fh,filesize($myFile));
  74.              * fclose($fh);
  75.              * */
  76.         }
  77.         function data_uri($file)
  78.         {
  79.           $contents = file_get_contents($file);
  80.           $base64   = base64_encode($contents);
  81.          // echo 'data:audio/mp3;base64,' . $base64;
  82.          // die();
  83.           return ('data:audio/mp3;base64,' . $base64);
  84.         }
  85.     ?>
  86.     <script type="text/javascript">
  87.        
  88.         var http = createRequestObject();
  89.         function createRequestObject() {
  90.             var objAjax;
  91.             var browser = navigator.appName;
  92.             if(browser == "Microsoft Internet Explorer"){
  93.                 objAjax = new ActiveXObject("Microsoft.XMLHTTP");
  94.             }else{
  95.                 objAjax = new XMLHttpRequest();
  96.             }
  97.             return objAjax;
  98.         }
  99.         function getNewContent(file){
  100.             ////alert(file);
  101.             http.open('get',file,false);
  102.             http.onreadystatechange = updateNewContent;
  103.             http.send();
  104.             //return http.responseText;
  105.         }
  106.  
  107.         function updateNewContent(){
  108.             if(http.readyState == 4){
  109.                 ////alert(http.responseText);
  110.                 localStorage.setItem("EncodedValue",http.responseText);
  111.                 //alert(http.responseText);
  112.                 return http.responseText;
  113.                 //au.play();
  114.             }
  115.         }
  116.        
  117.     </script>
  118.    
  119.     <script type="text/javascript">
  120.         window.pages = ['home', 'usage', 'usage', 'get', 'get', 'reference', 'reference', 'credits'];      
  121.         $(document).ready(function() {
  122.             initial = 1;
  123.             flag = "";
  124.             audio = $('audio').get(0);
  125.             indexVal = 0;
  126.             slide = 0;
  127.             indexSlideVal = 0;
  128.             slideFlag = "";
  129.             playFlag = "";
  130.             pauseFlag = "";
  131.             nextPlayFlag = "";
  132.             $(audio).bind('pause', function() {
  133.                 if(pauseFlag == "Pause")
  134.                 {
  135.                     audio.currentTime=0;
  136.                     index = index+1;
  137.                     pageNumber = parseInt(localStorage.pageNum)+1;
  138.                     localStorage.pageNum = pageNumber;
  139.                     if(($("#divPart"+pageNumber+" ul li:nth-child("+index+") span").attr("class")))
  140.                     {
  141.                         $("ul li span").css("background-color","");
  142.                         $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").css("background-color","yellow");
  143.                         first = $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").attr("class");
  144.                         getNewContent(first);
  145.                         first = localStorage.getItem("EncodedValue");
  146.                         //alert(first);
  147.                         $("audio").attr("src",first);
  148.                         audio.play();
  149.                         indexVal = 0;
  150.                         pauseFlag = "";
  151.                     }
  152.                 }
  153.                 else
  154.                 {
  155.                     //alert("Pause function");
  156.                     pauseFlag = "";
  157.                 }
  158.             });
  159.             $(audio).bind('ended', function() {
  160.                 if(flag != "Click" && playFlag != "Play")
  161.                 {
  162.                     audio.currentTime=0;
  163.                     index = index+1;
  164.                     pageNumber = localStorage.pageNum;
  165.                     if(($("#divPart"+pageNumber+" ul li:nth-child("+index+") span").attr("class")))
  166.                     {
  167.                         $("ul li span").css("background-color","");
  168.                         $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").css("background-color","yellow");
  169.                         first = $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").attr("class");
  170.                         getNewContent(first);
  171.                         first = localStorage.getItem("EncodedValue");
  172.                         //alert(first);
  173.                         $("audio").attr("src",first);
  174.                         audio.play();
  175.                         indexVal = 0;
  176.                         slide = 1;
  177.                     }
  178.                     else if(slideFlag == "Slideshow" && slide == 0)
  179.                     {
  180.                         slide = 1;
  181.                         indexVal = 1;
  182.                         //$('#magazine').delay(3000).turn('next');
  183.                         if(parseInt(pageNumber) != 1)
  184.                             pageNumber = parseInt(pageNumber)+2;
  185.                         else
  186.                             pageNumber = parseInt(pageNumber)+1;
  187.                         localStorage.pageNum = pageNumber;
  188.                         if(($("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").attr("class")))
  189.                         {
  190.                             $("ul li span").css("background-color","");
  191.                             $("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").css("background-color","yellow");
  192.                             first = $("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").attr("class");
  193.                             getNewContent(first);
  194.                             first = localStorage.getItem("EncodedValue");
  195.                             //alert(first);
  196.                             $("audio").attr("src",first);
  197.                             audio.play();
  198.                         }
  199.                     }
  200.                     else if(slide != 1)
  201.                     {
  202.                         pageNumber = localStorage.pageNum;
  203.                         indexVal = indexVal+1;
  204.                         pageNumber = parseInt(pageNumber)+1;
  205.                         if(pageNumber % 2 != 0)
  206.                         {
  207.                             if(($("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").attr("class")))
  208.                             {
  209.                                 $("ul li span").css("background-color","");
  210.                                 $("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").css("background-color","yellow");
  211.                                 first = $("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").attr("class");
  212.                                 getNewContent(first);
  213.                                 first = localStorage.getItem("EncodedValue");
  214.                                 //alert(first);
  215.                                 $("audio").attr("src",first);
  216.                                 audio.play();
  217.                             }
  218.                             else
  219.                             {
  220.                                 audio.pause();
  221.                             }
  222.                         }
  223.                         else
  224.                         {
  225.                             audio.pause();
  226.                         }
  227.                     }
  228.                     else
  229.                     {
  230.                         pageNumber = parseInt(localStorage.pageNum) + 1;
  231.                         indexSlideVal = indexSlideVal+1;
  232.                         if(pageNumber % 2 != 0)
  233.                         {
  234.                             if(($("#divPart"+pageNumber+" ul li:nth-child("+indexSlideVal+") span").attr("class")))
  235.                             {
  236.                                 $("ul li span").css("background-color","");
  237.                                 $("#divPart"+pageNumber+" ul li:nth-child("+indexSlideVal+") span").css("background-color","yellow");
  238.                                 first = $("#divPart"+pageNumber+" ul li:nth-child("+indexSlideVal+") span").attr("class");
  239.                                 getNewContent(first);
  240.                                 first = localStorage.getItem("EncodedValue");
  241.                                 //alert(first);
  242.                                 $("audio").attr("src",first);
  243.                                 audio.play();
  244.                             }
  245.                             else if(!($("#divPart"+pageNumber+" ul li:nth-child("+indexSlideVal+") span").attr("class")))
  246.                             {
  247.                                 indexSlideVal = 0;
  248.                                 slide = 1;
  249.                                 index = 0;
  250.                                 pauseFlag = "Pause";
  251.                                 //$('#magazine').delay(3000).turn('next');
  252.                                 localStorage.pageNum = parseInt(localStorage.pageNum) + 1;
  253.                                 audio.play();
  254.                                 audio.pause();
  255.                             }
  256.                         }
  257.                         else
  258.                         {
  259.                             if(($("#divPart"+pageNumber+" ul li:nth-child("+indexSlideVal+") span").attr("class")))
  260.                             {
  261.                                 $("ul li span").css("background-color","");
  262.                                 $("#divPart"+pageNumber+" ul li:nth-child("+indexSlideVal+") span").css("background-color","yellow");
  263.                                 first = $("#divPart"+pageNumber+" ul li:nth-child("+indexSlideVal+") span").attr("class");
  264.                                 getNewContent(first);
  265.                                 first = localStorage.getItem("EncodedValue");
  266.                                 //alert(first);
  267.                                 $("audio").attr("src",first);
  268.                                 audio.play();
  269.                             }
  270.                             else
  271.                             {
  272.                                 indexSlideVal = 0;
  273.                                 localStorage.pageNum = parseInt(localStorage.pageNum) + 1;
  274.                                 audio.pause();
  275.                             }
  276.                         }
  277.                     }
  278.                     /*else {
  279.                         index = 1;
  280.                         first = $("ul li span").attr("class");
  281.                         $("audio").attr("src",first);
  282.                     }*/
  283.                 }
  284.                 else if(playFlag == "Play")
  285.                 {
  286.                     audio.currentTime=0;
  287.                     index = index+1;
  288.                     if(($("#divPart"+pageNumber+" ul li:nth-child("+index+") span").attr("class")))
  289.                     {
  290.                         $("ul li span").css("background-color","");
  291.                         $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").css("background-color","yellow");
  292.                         first = $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").attr("class");
  293.                         getNewContent(first);
  294.                         first = localStorage.getItem("EncodedValue");
  295.                         //alert(first);
  296.                         $("audio").attr("src",first);
  297.                         audio.play();
  298.                         indexVal = 0;
  299.                     }
  300.                     else
  301.                     {
  302.                         indexVal = indexVal+1;
  303.                         pageNumber = parseInt(pageNumber)+1;
  304.                         if(pageNumber % 2 != 0)
  305.                         {
  306.                             if(($("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").attr("class")))
  307.                             {
  308.                                 $("ul li span").css("background-color","");
  309.                                 $("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").css("background-color","yellow");
  310.                                 first = $("#divPart"+pageNumber+" ul li:nth-child("+indexVal+") span").attr("class");
  311.                                 getNewContent(first);
  312.                                 first = localStorage.getItem("EncodedValue");
  313.                                 //alert(first);
  314.                                 $("audio").attr("src",first);
  315.                                 index = 1;
  316.                                 audio.play();
  317.                             }
  318.                             else
  319.                             {
  320.                                 audio.pause();
  321.                             }
  322.                         }
  323.                         else
  324.                         {
  325.                             audio.pause();
  326.                         }
  327.                     }
  328.                 }
  329.             });
  330.             $("#stopBtn").click(function() {
  331.                
  332.                 flag = "";
  333.                 playFlag = "";
  334.                 slideFlag = "";
  335.                 pauseFlag = "";
  336.                 audio = $('audio').get(0);
  337.                 audio.pause();
  338.             });
  339.             $(audio).bind('stoped', function() {
  340.                 //alert("Stoped");
  341.             });
  342.             $("#StartBtn").click(function() {
  343.                
  344.                 audio = $('audio').get(0);
  345.                 pauseFlag = "";
  346.                 audio.pause();
  347.                 $("ul li span").css("background-color","");
  348.                 for(i=0;i<(localStorage.pageNum/2);i++)
  349.                 //$('#magazine').turn('previous');
  350.                 return false;
  351.             });
  352.             $("#playBtn").click(function(){
  353.                
  354.                 flag = "";
  355.                 playFlag = "Play";
  356.                 audio = $('audio').get(0);
  357.                 pageNumber = localStorage.pageNum;
  358.                 first = $("#divPart"+pageNumber+" ul li span").attr('class');
  359.                 getNewContent(first);
  360.                 first = localStorage.getItem("EncodedValue");
  361.                 //alert(first);
  362.                 $("audio").attr("src",first);
  363.                 index = 1;
  364.                 slideFlag = "";
  365.                 pauseFlag = "";
  366.                 $("ul li span").css("background-color","");
  367.                 $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").css("background-color","yellow");
  368.                 //$("#audio-player").attr("src");
  369.                 audio.play();
  370.                 //$("audio").play();
  371.                 //$("audio").attr("autoplay","autoplay");
  372.             });
  373.             $("#slideShowBtn").click(function(){
  374.                 //alert("Hi");
  375.                 flag = "";
  376.                 playFlag = "";
  377.                 slideFlag = "Slideshow";
  378.                 slide = 0;
  379.                 audio = $('audio').get(0);
  380.                 if(parseInt(localStorage.pageNum) > pages.length)
  381.                     localStorage.pageNum = pages.length;
  382.                 pageNumber = 4;
  383.                 localStorage.pageNum = 4;
  384.                 first = $("#divPart4 ul li span").attr('class');
  385.                 getNewContent(first);
  386.                 first = localStorage.getItem("EncodedValue");
  387.                 $("audio").attr("src",first);
  388.                 index = 1;
  389.                 pauseFlag = "";
  390.                 $("ul li span").css("background-color","");
  391.                 $("#divPart"+pageNumber+" ul li:nth-child("+index+") span").css("background-color","yellow");
  392.                 audio.play();
  393.             });
  394.             $("ul li span").click(function() {
  395.                
  396.                 index = parseInt($(this).parent().index()+1);
  397.                 nodeVal = $(this).parents(".divPart").attr("id");
  398.                 audio = $('audio').get(0);
  399.                 audio.play();
  400.                 audio.pause();
  401.                 audio.currentTime = 0;
  402.                 pageNumber = localStorage.pageNum;
  403.                 $("ul li span").css("background-color","");
  404.                 $("#"+nodeVal+" ul li:nth-child("+index+") span").css("background-color","yellow");
  405.                 first = $(this).attr('class');
  406.                 getNewContent(first);
  407.                 first = localStorage.getItem("EncodedValue");
  408.                 $("audio").attr("src",first);
  409.                 flag = "Click";
  410.                 audio.play();
  411.                 pauseFlag = "";
  412.                 playFlag = "";
  413.             });
  414.            
  415.         });
  416.     </script>
  417.    
  418. </body>
  419. </html>
Add Comment
Please, Sign In to add comment