javascript - There is something wrong with my if statement as when I press play, subtitles play with the video but when i press pause, subtitles don't stop -


here main javascript code have:

 var hour = parseint(js_arr[j].substring(0,1));         var min = parseint(js_arr[j].substring(3,4));         var seconds = parseint(js_arr[j].substring(6,7));         var mil_sec = parseint(js_arr[j].substring(9,11));         var time = (hour*3600000)+(min*60000)+(seconds*1000)+mil_sec;         var bool = false;         var =0;           function timeout(status){         settimeout(function()         {         if(status)       {           document.getelementbyid('subs').innerhtml = js_arr[i];                 i=i+4;                 j=j+4;                 hour = parseint(js_arr[j].substring(0,1));                 min = parseint(js_arr[j].substring(3,4));                 seconds = parseint(js_arr[j].substring(6,7));                 mil_sec = parseint(js_arr[j].substring(9,11));                 time = (hour*3600000)+(min*60000)+(seconds*1000)+mil_sec;                 timeout(status);        }          else{             timeout(status);             }          },time); }             (function(){                  // listen ready event vimeo video players on page                 var vimeoplayers = document.queryselectorall('iframe'),                     player;                  (var = 0, length = vimeoplayers.length; < length; i++) {                     player = vimeoplayers[i];                     $f(player).addevent('ready', ready);                 }                   function addevent(element, eventname, callback) {                     if (element.addeventlistener) {                         element.addeventlistener(eventname, callback, false);                     }                     else {                         element.attachevent('on' + eventname, callback);                     }                 }                   function ready(player_id) {                     // keep reference froogaloop player                     var container = document.getelementbyid(player_id).parentnode.parentnode,                         froogaloop = $f(player_id);                       function setupsimplebuttons() {                         var buttons = container.queryselector('div dl.simple'),                             playbtn = buttons.queryselector('.play'),                             pausebtn = buttons.queryselector('.pause')                          // call play when play button clicked                         addevent(playbtn, 'click', function() {                              froogaloop.api('play');                             timeout(status);                          }, false);                          // call pause when pause button clicked                         addevent(pausebtn, 'click', function() {                              froogaloop.api('pause');                             timeout(status=false);                          }, false);                       }                      function setupgetterbuttons() {                         var buttons = container.queryselector('div dl.getters'),                             timebtn = buttons.queryselector('.time'),                             pausedbtn = buttons.queryselector('.paused'),                             widthbtn = buttons.queryselector('.width'),                             heightbtn = buttons.queryselector('.height');                          // current time , log api console when time button clicked                         addevent(timebtn, 'click', function(e) {                             froogaloop.api('getcurrenttime', function (value, player_id) {                                 // log out value in api console                                 apilog('getcurrenttime : ' + value);                             });                         }, false);                          // paused state , log api console when time button clicked                         addevent(pausedbtn, 'click', function(e) {                             froogaloop.api('paused', function (value, player_id) {                                 // log out value in api console                                 apilog('paused : ' + value);                             });                         }, false);                          // paused state , log api console when time button clicked                         addevent(widthbtn, 'click', function(e) {                             froogaloop.api('getvideowidth', function (value, player_id) {                                 // log out value in api console                                 apilog('getvideowidth : ' + value);                             });                         }, false);                          // paused state , log api console when time button clicked                         addevent(heightbtn, 'click', function(e) {                             froogaloop.api('getvideoheight', function (value, player_id) {                                 // log out value in api console                                 apilog('getvideoheight : ' + value);                             });                         }, false);                     }                       function setupeventlisteners() {                         var checkboxes = container.queryselector('.listeners'),                             loadprogresschk = checkboxes.queryselector('.loadprogress'),                             playprogresschk = checkboxes.queryselector('.playprogress'),                             playchk = checkboxes.queryselector('.play'),                             pausechk = checkboxes.queryselector('.pause'),                             finishchk = checkboxes.queryselector('.finish');                           function onloadprogress() {                             if (loadprogresschk.checked) {                                 froogaloop.addevent('loadprogress', function(data) {                                     apilog('loadprogress event : ' + data.percent + ' : ' + data.bytesloaded + ' : ' + data.bytestotal + ' : ' + data.duration);                                 });                             }                             else {                                 froogaloop.removeevent('loadprogress');                             }                         }                          function onplayprogress() {                             if (playprogresschk.checked) {                                 froogaloop.addevent('playprogress', function(data) {                                     apilog('playprogress event : ' + data.seconds + ' : ' + data.percent + ' : ' + data.duration);                                 });                             }                             else {                                 froogaloop.removeevent('playprogress');                             }                         }                           function onplay()                          {                             status = true;                         }                           function onpause()                          {                             status = false;                          }                            function onfinish() {                             if (finishchk.checked) {                                 froogaloop.addevent('finish', function(data) {                                     apilog('finish');                                 });                             }                             else {                                 froogaloop.removeevent('finish');                             }                         }                           // listens checkboxes change                         addevent(loadprogresschk, 'change', onloadprogress, false);                         addevent(playprogresschk, 'change', onplayprogress, false);                         addevent(playchk, 'change', onplay, false);                         addevent(pausechk, 'change', onpause, false);                         addevent(finishchk, 'change', onfinish, false);                          // calls change event if option checked                         // (this makes sure checked events attached on page load on changed)                         onloadprogress();                         onplayprogress();                         onplay();                         onpause();                         onfinish();                      }                    function setupaddclip() {                         var button = container.queryselector('.addclip'),                             newcontainer;                          addevent(button, 'click', function(e) {                             // don't if clicking on button (such input field)                             if (e.target != this) {                                 return false;                             }                              // gets index of current player grabbing number after underscore                             var currentindex = parseint(player_id.split('_')[1]),                                 clipid = button.queryselector('input').value;                              newcontainer = resetcontainer(container.clonenode(true), currentindex+1, clipid);                              container.parentnode.appendchild(newcontainer);                             $f(newcontainer.queryselector('iframe')).addevent('ready', ready);                         });                            function resetcontainer(element, index, clipid) {                            var newheading = element.queryselector('h2'),                                 newiframe = element.queryselector('iframe'),                                 newcheckboxes = element.queryselectorall('.listeners input[type="checkbox"]'),                                 newaddbtn = element.queryselector('.addclip');                              // set heading text                             newheading.innertext = 'vimeo player ' + index;                              // set correct source of new clip id                             newiframe.src = 'http://player.vimeo.com/video/' + clipid + '?api=1&player_id=player_' + index;                             newiframe.id = 'player_' + index;                              // reset checkboxes listeners checked on                             (var = 0, length = newcheckboxes.length, checkbox; < length; i++) {                                 checkbox = newcheckboxes[i];                                 checkbox.setattribute('checked', 'checked');                             }                              // clear out api console                             newapiconsole.innerhtml = '';                              // update clip id of add clip button                              return element;                         }                     }                      setupsimplebuttons();                     setupmodifierbuttons();                     setupgetterbuttons();                     setupeventlisteners();                     setupaddclip();                      // setup clear console button                     var clearbtn = container.queryselector('.console button');                     addevent(clearbtn, 'click', function(e) {                         apiconsole.innerhtml = '';                     }, false);                      apilog(player_id + 'ready!');                 }             })();         </script> 

most of javascript @ bottom may not of use; got source code different website. it's not compatible code , think it's if statement @ beginning should change. appreciate if me out! thank you


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -