/* Banddirector.com's Video Direct Specific Javascript Function Declarations Suffix used: v_* */ var liveInterval,liveContentInterval,liveChatInterval,vdAddress = 'http://www.banddirector.com/videodirect/'; var checkDoneInterval = 1000*60; // check if the broadcast is DONE (door man is now closed) every X seconds var checkStartInterval = 1000*15; // check if the broadcast is starting yet (door man just opened) every X seconds var checkNewContentInterval = 1000*600; // check if live video content has been updated every X seconds var checkChatInterval = 1000*600; // check if chat is enabled every X seconds var cookieExpires = 1000*60*60*24; // cookie expires in X hours /* js equiv of php's "sleep" */ function nap (m) {var then = new Date(new Date().getTime() + m); while (new Date() < then) {}} /* onload initialize function */ function v_init(w,h,b,g,i,c) { v_cl(); popup_windowResizeTrue(w,h,b); v_sc(g,i,c); window.focus(); } /* init live */ function v_live_init(w,h,b) { v_cl(); v_onBeforeUnload(); v_sco(); //popup_windowResizeTrue(w,h,b); v_glv(); liveInterval = window.setInterval('v_live_dmc(\'no\')',checkDoneInterval); window.focus(); } /* live init door man */ function v_live_idm(w,h,b) { v_cl(); v_onBeforeUnload(); v_sco(); //popup_windowResizeTrue(w,h,b); v_live_dmc('yes'); // initial check liveInterval = window.setInterval('v_live_dmc(\'yes\')',checkStartInterval); window.focus(); } /* live door man check */ function v_live_dmc(sResult) { // sResult = 'yes' | 'no' if ( _gei('v-sandbox').innerHTML == sResult ) { if ( liveInterval != undefined ) window.clearInterval(liveInterval); window.location = vdAddress+'live/'; } else { var postVars = new Array(); rr_doRequest('v-sandbox','POST',vdAddress+'live-door-man-check/',postVars,true); } } /* check location */ function v_cl() { var re = new RegExp("^(http:\/\/banddirector\.com\/videodirect\/)(.*)","g"); if ( window.location.toString().match(re) ) window.location = window.location.toString().replace(re,"http://www.banddirector.com/videodirect/$2"); } /* swap content */ function v_sc(groupId,videoId,videoChar) { if ( groupId.length > 0 && videoId.length > 0 ) { // sync content area with requested video var postVars = new Array(); rr_doRequest('v-data','POST',vdAddress+'fetch-video/'+groupId+'/'+videoId+'/',postVars,true); rr_doRequest('playerObjectParent','POST',vdAddress+'replace-video/'+groupId+'/'+videoId+'/',postVars,true); rr_doRequest('v-banner','POST',vdAddress+'fetch-header/'+groupId+'/'+videoId+'/',postVars,true); } return false; } /* get live video */ function v_glv() { var postVars = new Array(); rr_doRequest('v-data','POST',vdAddress+'fetch-video/live/',postVars,true); rr_doRequest('v-data-sandbox','POST',vdAddress+'fetch-video/live/',postVars,true); rr_doRequest('playerObjectParent','POST',vdAddress+'live-player/',postVars,true); rr_doRequest('v-banner','POST',vdAddress+'fetch-header/live/',postVars,true); rr_doRequest('v-bandwidth','POST',vdAddress+'live-get-bandwidth/',postVars,true); liveContentInterval = window.setInterval('v_uvd()',checkNewContentInterval); liveChatInterval = window.setInterval('v_ucb()',checkChatInterval); } /* update chat box */ function v_ucb() { if ( _gei('v-chat-sandbox') && _gei('v-chat') ) { var content = _gei('v-chat-sandbox').innerHTML.trim(); if ( content.length == 0 || _gei('v-chat').innerHTML.trim().length == 0 ) _gei('v-chat').innerHTML = content; var postVars = new Array(); rr_doRequest('v-chat-sandbox','POST',vdAddress+'live-chat/',postVars,true); } } /* send chat data */ function v_scd() { if ( _gei('v-chat-textarea') && _gei('v-chat') ) { var postVars = new Array(); postVars['msg'] = _gei('v-chat-textarea').value; rr_doRequest('v-chat','POST',vdAddress+'live-chat/',postVars,true); } } /* update v-data */ function v_uvd() { var content = _gei('v-data-sandbox').innerHTML.trim(),postVars = new Array(); if ( content != '' && content != 'FALSE' ) _gei('v-data').innerHTML = content; rr_doRequest('v-data-sandbox','POST',vdAddress+'fetch-video/live/',postVars,true); } /* set live bandwidth */ function v_slb(sBandwidth) { var postVars = new Array(); postVars['live_bandwidth'] = sBandwidth; rr_doRequest('playerObjectParent','POST',vdAddress+'live-set-bandwidth/',postVars,true); rr_doRequest('v-bandwidth','POST',vdAddress+'live-get-bandwidth/',postVars,true); return false; } /* toggle tab */ function v_tt(elementUniqueId,t) { t.blur(); if ( (_gei('v-info').style.display == 'none' && elementUniqueId == 'v-info') || (_gei('v-related').style.display == 'none' && elementUniqueId == 'v-related') ) { _tiid('v-info','block'); _tiid('v-related','block'); } } /* exit */ function v_e() { var message = "Are you sure you want to exit Banddirector.com's Video Direct?\nThis will close the current window."; if ( confirm(message) ) { if ( window.opener && !window.opener.closed ) window.opener.focus(); self.opener = window; window.close(); } return false; } /* open parent window */ function v_opw(url) { if ( window.opener && !window.opener.closed ) { window.opener.location = url; window.opener.focus(); } else { _onw(url); } return false; } function v_onBeforeUnload() { window.onbeforeunload = v_cou; } /* catch onUnload */ function v_cou() { document.cookie = 'liveOpen=1;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/'; // delete cookie } /* set cookie onload */ function v_sco() { // var today = new Date(); var expires = new Date(today.getTime()+cookieExpires); document.cookie = 'liveOpen=1;expires='+expires.toGMTString()+';path=/'; // set cookie }