MediaWiki

Difference between revisions of "Common.js"

From MusicTechWiki

 
(No difference)

Latest revision as of 19:43, 20 May 2021

/* Any JavaScript here will be loaded for all users on every page load. */

function popupvideo(url, width, height)
{  
  

  mediaplayerPopup = window.open(url, 'VideoWin','location=no,scrollbars=no,width=' + width + ',height=' + height);
  mediaplayerPopup.focus();
  return false;
}

function playpopupvideo(id)
{  
    // remove the false later
  if (typeof mediaplayerPopup != "undefined" )
  {
     
     playnextvideo(popplaylist[id][0], popplaylist[id][1], popplaylist[id][2]);
  }
  else
  {
    
    popupvideo(popplaylist[id][0], popplaylist[id][1], popplaylist[id][2]);

  }
  currentlyplaying = id;
}

function playnextvideo(url, width, height)
{  if ((typeof mediaplayerPopup == "undefined") || mediaplayerPopup.closed || (typeof mediaplayerPopup.updateWindow=="undefined"))
  {  popupvideo(url, width, height);
  }
  else
  {
     mediaplayerPopup.updateWindow(url, width, height);      
  }
}

function popupplay()
{
  mediaplayerPopup.player.sendEvent('PLAY');
  return false;
}

function popupListener(msg)
{
   if (currentlyplaying < playlistcounter)
   {
      playpopupvideo(currentlyplaying + 1);
   }
}

function popupClosed()
{
   mediaplayerPopup = false;
}

if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Movepage' ) { $( function () { i= $( 'input[name=wpLeaveRedirect]' ); if ( i.length ) { i[0].checked = false; } } ) }


if (typeof jwplayer !== 'undefined') {
    checkURLforTimestamp();
}

function checkURLforTimestamp()
{
   var url_string = window.location.href
   var url = new URL(url_string);
   if (!url) { return; }
   var timestamp = url.searchParams.get("timestamp");

   //const queryString = window.location.search;
   //const urlParams = new URLSearchParams(queryString);
   //timestamp = urlParams.get('timestamp');

   if (!timestamp) { return; }
   timeArr = timestamp.split(":");

   if (timeArr.length == 2)
   {
      alert(timeArr[0] * 60);  
      alert(timeArr[1]);
      timestamp = (parseInt(timeArr[0]) * 60) + parseInt(timeArr[1]);
    
   }
   else if (timeArr.length == 3)
   {
      timestamp = (parseInt(timeArr[0]) * 3600) + (parseInt(timeArr[1]) * 60) + parseInt(timeArr[2]);
   }

   
  if (timestamp) { jwplayer().seek(timestamp); }
}