Server : Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6
System : Windows NT USER-PC 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64
User : User ( 0)
PHP Version : 7.4.6
Disable Function : NONE
Directory :  C:/Program Files/CyberLink/PowerDirector/web/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : C:/Program Files/CyberLink/PowerDirector/web/FreeSoundAction.js
var m_strSearchText;
var m_strApiKey;
var m_strSecret;
var m_strFrob;
var m_strToken;
var m_nPhotosPrePage = 50;
var m_nCurrentPageIndex = 1;
var m_nTotalPageNum = 0;
var m_nListSize;
var m_ListID = null;

var m_ListUsed_sound_id = null;
var m_ListUsed_strUrl = null;
var m_ListUsed_strName = null;
var m_ListUsed_strPrevieURL = null;
var m_ListUsed_nFileSize = null;
var m_ListUsed_nDuration = null;
var m_ListUsed_nDescription = null;
var m_ListUsed_strUserName = null;
var m_ListUsed_strTags = null;

var m_nUsedItemCount;
var xmlHttp;
var m_nProcessIndex = 0;
var m_nProcessCount = 0;
var m_nTotalCount = 0;
var m_strSkinPath;
var m_nStartIndex = 0;
var nSoundNum = 0;
var m_bProcess = false;
var m_strSoundText="";

var m_nSearchUsernames=0;
var m_bSearchFilenames = 0;
var m_bSearchDescriptions = 1;
var m_nSearchTags = 1;
var m_strServerURL = "";
var m_nSearchOrder = 1; //0 = ORDER_DEFAULT
              		//1 = ORDER_DOWNLOADS_DESC
			//2 = ORDER_DOWNLOADS_ASC
			//3 = ORDER_USERNAME_DESC
			//4 = ORDER_USERNAME_ASC
			//5 = ORDER_DATE_DESC
			//6 = ORDER_DATE_ASC
			//7 = ORDER_DURATION_DESC
			//8 = ORDER_DURATION_ASC
			//9 = ORDER_FILEFORMAT_DESC
			//10 = ORDER_FILEFORMAT_ASC
var BASE_URL = "http://freesound.iua.upf.edu/";

function EnableSearchTag(bEnable)
{
	
	if(bEnable==true)
		m_nSearchTags = 1;
	else
		m_nSearchTags = 0;
}

function EnableSearchFilenames(bEnable)
{
	if(bEnable==true)
		m_bSearchFilenames = 1;
	else
		m_bSearchFilenames = 0;
}

function EnableSearchDescriptions(bEnable)
{
	if(bEnable==true)
		m_bSearchDescriptions = 1;
	else
		m_bSearchDescriptions = 0;
}

function EnableSearchUserName(bEnable)
{
	if(bEnable==true)
		m_nSearchUsernames = 1;
	else
		m_nSearchUsernames = 0;
}

function SetServerURL(strServerURL)
{
	m_strServerURL = strServerURL;
	BASE_URL = "http://"+m_strServerURL+"/";
}

function SetSkinPath(strSKinPath)
{
	//alert(strSKinPath);
	m_strSkinPath = strSKinPath;
}

function NewAccount()
{
	var strURL="http://"+m_strServerURL+"/forum/profile.php?mode=register";
	window.open(strURL);
}

function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponentNew(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}

function URLEncode(fld)
{
 if (fld == "") return false;
 var encodedField = "";
 var s = fld;
 if (typeof encodeURIComponent == "function")
 {
  // Use javascript built-in function
  // IE 5.5+ and Netscape 6+ and Mozilla
  encodedField = encodeURIComponent(s);
 }
 else 
 {
  // Need to mimic the javascript version
  // Netscape 4 and IE 4 and IE 5.0
  encodedField = encodeURIComponentNew(s);
 }
 //alert ("New encoding: " + encodeURIComponentNew(fld) +
 //  "\n           escape(): " + escape(fld));
 return encodedField;
}


function FreeSoundLogin(strUserName,strPassWord)
{
	var URL_Login = BASE_URL+"forum/login.php";
	var strParam = "&username="+URLEncode(strUserName)+"&password="+URLEncode(strPassWord)+"&login="+URLEncode("login")+"&autologin="+URLEncode("0")+"&redirect="+URLEncode("../index.php");

	try
	{    // Firefox, Opera 8.0+, Safari 
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{    // Internet Explorer    
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		}
		catch (e)
		{      
			try
			{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;        
			}      
		}    
	}
	
	//define async response handler
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{		
			var textHTML = xmlHttp.responseText;
			if(textHTML.match("logged")!=null)
			{	
				var ref = "Login:SUCCESS";
				location = ref; 
			}
			else
			{
				var ref = "Login:FAIL";
				location = ref; 
			}
		}
	} 
	
	xmlHttp.open("POST",URL_Login,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   	xmlHttp.setRequestHeader("Content-length", strParam.length);
   	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(strParam);	
}

function FreeSoundLogOut()
{
	var URL_Search = "http://"+m_strServerURL+"/index.php?";
	var strParam = "&logout=true";
	var URL_SearchTemp = URL_Search+strParam;
	try
	{    // Firefox, Opera 8.0+, Safari 
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{    // Internet Explorer    
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		}
		catch (e)
		{      
			try
			{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;        
			}      
		}    
	}
	
	//define async response handler
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{			
			var textHTML = xmlHttp.responseText;
			
			if(textHTML.match("login")!=null)
			{
				var ref = "LogOut:SUCCESS";
				location = ref; 
			}
			else
			{
				var ref = "LogOut:FAIL";
				location = ref; 
			}
		}
		else
		{
			//alert("Logoff:FAIL");
			
			//alert(xmlHttp.readyState);
		}
			//alert("ng");
	} 
	
	xmlHttp.open("GET",URL_SearchTemp,true);
	xmlHttp.send(null);
}

function ProcessGetThumbnail()
{
	if(m_nProcessIndex>=m_nTotalCount)
	{
		return;
	}
	else
	{
		if(!m_bProcess)
		{
			FreeSoundViewSingle(m_ListID[m_nProcessIndex],m_strSoundText);
			m_nProcessIndex++;
		}
		setTimeout('ProcessGetThumbnail()', 10);
    }
}

function FreeSoundSearch(strText, strCountLimit)
{
	m_strSoundText = strText;
	var URL_Search = BASE_URL+"searchTextXML.php?";
	var strParam = "search="+URLEncode(strText)+"&searchDescriptions="+m_bSearchDescriptions+"&searchTags="+m_nSearchTags+"&searchFilenames="+m_bSearchFilenames+"&searchUsernames="+m_nSearchUsernames + "&order=" + m_nSearchOrder + "&start=0&limit=" + strCountLimit;
	var URL_SearchTemp = URL_Search+strParam;
	
	m_nProcessIndex = 0;
	m_nTotalCount = 0;
	m_nListSize = 0
	if(m_ListID)
		delete m_ListID;
	if(m_ListUsed_sound_id)
		delete m_ListUsed_sound_id;
	if(m_ListUsed_strUrl)
		delete m_ListUsed_strUrl;
	if(m_ListUsed_strName)
		delete m_ListUsed_strName;
	if(m_ListUsed_strPrevieURL)
		delete m_ListUsed_strPrevieURL;
	
	if(m_ListUsed_nFileSize)
		delete m_ListUsed_nFileSize;
	if(m_ListUsed_nDuration)
		delete m_ListUsed_nDuration;
	if(m_ListUsed_nDescription)
		delete m_ListUsed_nDescription;
	if(m_ListUsed_strUserName)
		delete m_ListUsed_strUserName;
	if(m_ListUsed_strTags)
		delete m_ListUsed_strTags;
	
	m_ListID = null;
	m_ListUsed_sound_id = null;
	m_ListUsed_strUrl = null;
	m_ListUsed_strName = null;
	m_ListUsed_strPrevie = null;
	m_ListUsed_nFileSize = null;
	m_ListUsed_nDuration = null;
	m_ListUsed_nDescription = null;
	m_ListUsed_strUserName = null;
	m_ListUsed_strTags = null;

	m_nUsedItemCount = 0;
	m_nProcessIndex = 0;
	m_nProcessCount = 0;
	m_nTotalCount = 0;
	nSoundNum = 0;	
	
	DrawWaitAnimation();			 
	try
	{    // Firefox, Opera 8.0+, Safari 
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{    // Internet Explorer    
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		}
		catch (e)
		{      
			try
			{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;        
			}      
		}    
	}
	
	//define async response handler
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{			
			if(xmlHttp.responseXML == null)
				return;
			var text = xmlHttp.responseXML.xml;
			var body = document.getElementById("resultArea");
			
			// code for IE
			if (window.ActiveXObject)
			{
				var doc=new ActiveXObject("Microsoft.XMLDOM");
				doc.async="false";
				
				doc.loadXML(text);
			}
			// code for Mozilla, Firefox, Opera, etc.
			else
			{
				var parser=new DOMParser();
				var doc=parser.parseFromString(text,"text/xml");
			}

			CleanPage();
			
			
			var x = doc.documentElement;
			if(x==null)
			{
				ShowNothingResult();
				return;
			}
			
			if(x.childNodes.length == 0)
			{
				ShowNothingResult();
				return;
			}
			
			m_ListID = new Array(x.childNodes.length);
			m_ListUsed_sound_id = new Array(x.childNodes.length);
			m_ListUsed_strUrl = new Array(x.childNodes.length);
			m_ListUsed_strName = new Array(x.childNodes.length);
			m_ListUsed_nFileSize = new Array(x.childNodes.length);
			m_ListUsed_nDuration = new Array(x.childNodes.length);
			m_ListUsed_nDescription = new Array(x.childNodes.length);
			m_ListUsed_strUserName = new Array(x.childNodes.length);
			m_ListUsed_strTags = new Array(x.childNodes.length);
			m_ListUsed_strPreviewURL = new Array(x.childNodes.length);
			
			m_nProcessCount = m_nPhotosInWidth*m_nPhotosInHeight;
			for(var i = 0;i<x.childNodes.length;i++)
			{
				m_ListID[i] = x.getElementsByTagName("sample")[i].attributes[0].nodeValue;	
			}
			
			m_nProcessCount = x.childNodes.length;
			m_nTotalCount = x.childNodes.length;
			ResetTable();
			//CreateTable(m_nProcessCount);
			m_nProcessIndex = 0;
			m_bProcess = false;
			GoToPage(1);
			ProcessGetThumbnail();
			return;
		}
	} 
	
	xmlHttp.open("GET",URL_SearchTemp,true);
	xmlHttp.send(null);	
}

function FreeSoundViewSingle(sound_id,strSearchText)
{
	if(strSearchText!=m_strSoundText)
		return;
	m_bProcess = true;
			
	var URL_Search = BASE_URL+"samplesViewSingleXML.php?";
	var strParam = "id="+URLEncode(sound_id);
	var URL_SearchTemp = URL_Search+strParam; 
				 
	try
	{    // Firefox, Opera 8.0+, Safari 
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{    // Internet Explorer    
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		}
		catch (e)
		{      
			try
			{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;        
			}      
		}    
	}
	
	//define async response handler
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{			
			if(xmlHttp.responseXML == null)
				return;
			var text = xmlHttp.responseXML.xml;
			var body = document.getElementById("resultArea");
			
			// code for IE
			if (window.ActiveXObject)
			{
				var doc=new ActiveXObject("Microsoft.XMLDOM");
				doc.async="false";
				doc.loadXML(text);
			}
			// code for Mozilla, Firefox, Opera, etc.
			else
			{
				var parser=new DOMParser();
				var doc=parser.parseFromString(text,"text/xml");
			}
			
			var x=doc.documentElement;
			if(x==null)
				return;
			if(x.getElementsByTagName("sample")==null)
				return;
			
			var strextension = x.getElementsByTagName("sample")[0].getElementsByTagName("extension")[0].text;
			
			if(strextension=="wav" || strextension == "mp3")
			{	
				//alert(text);
				var nCellCount = m_nPhotosInWidth*m_nPhotosInHeight;
				m_nListSize++;
				var oldPageNum = m_nTotalPageNum;
				m_nTotalPageNum = parseInt(m_nListSize/nCellCount);
				
				if(m_nListSize>(m_nTotalPageNum*nCellCount))
					m_nTotalPageNum++;
				
				//if(m_nTotalPageNum!=oldPageNum)
				UpdateTotalPageInfo();
				
				if(x.getElementsByTagName("sample")[0] != null)
				{
					m_ListUsed_sound_id[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].attributes[0].nodeValue;
					m_ListUsed_strUrl[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].childNodes[4].text;
					m_ListUsed_strName[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].getElementsByTagName("originalFilename")[0].text;
					m_ListUsed_strPreviewURL[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].getElementsByTagName("preview")[0].text;
					m_ListUsed_nFileSize[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].getElementsByTagName("filesize")[0].text;
					m_ListUsed_nDuration[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].getElementsByTagName("duration")[0].text;
					
					//alert(m_ListUsed_nDuration[m_nUsedItemCount]);
					if(x.getElementsByTagName("sample")[0].getElementsByTagName("descriptions")[0].getElementsByTagName("description")[0] != null)
					{
						m_ListUsed_nDescription[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].getElementsByTagName("descriptions")[0].getElementsByTagName("description")[0].getElementsByTagName("text")[0].text;
						m_ListUsed_strUserName[m_nUsedItemCount] = x.getElementsByTagName("sample")[0].getElementsByTagName("descriptions")[0].getElementsByTagName("description")[0].getElementsByTagName("user")[0].getElementsByTagName("username")[0].text;
					}
					else
					{
						m_ListUsed_nDescription[m_nUsedItemCount] = "";
						m_ListUsed_strUserName[m_nUsedItemCount] = "";
					}
					
					var strTags = "";
					var tagOnj = x.getElementsByTagName("sample")[0].getElementsByTagName("tags")[0].getElementsByTagName("tag");
					for(var nIndex = 0;nIndex <tagOnj.length;nIndex++)
					{
						//alert(tagOnj[nIndex].text);
						if(nIndex>0)
							strTags = strTags + " ";
						strTags = strTags + tagOnj[nIndex].text;
					}
					m_ListUsed_strTags[m_nUsedItemCount] = strTags;
					
					
					AddItemIntoPage(m_nUsedItemCount - m_nStartIndex,
					x.getElementsByTagName("sample")[0].attributes[0].nodeValue,
					x.getElementsByTagName("sample")[0].childNodes[4].text,
					x.getElementsByTagName("sample")[0].getElementsByTagName("originalFilename")[0].text,
					x.getElementsByTagName("sample")[0].getElementsByTagName("preview")[0].text,
					x.getElementsByTagName("sample")[0].getElementsByTagName("filesize")[0].text,
					m_ListUsed_nDuration[m_nUsedItemCount],
					m_ListUsed_nDescription[m_nUsedItemCount],
					m_ListUsed_strUserName[m_nUsedItemCount],
					m_ListUsed_strTags[m_nUsedItemCount]);
					
					
					m_nUsedItemCount++;
				}
			}
			m_bProcess = false;
			return;
		}
	} 
	
	xmlHttp.open("GET",URL_SearchTemp,true);
	xmlHttp.send(null);
}