Code: Select all
[Vid]{TEXT}[/Vid]
Code: Select all
<div>
<iframe class="mediaContentBox" width="560" height="315" src="hop" allowfullscreen ></iframe>
<script>
var chaine = '{TEXT}';
var foundat=-1;
if((foundat=chaine.toUpperCase().indexOf("https://odysee.com".toUpperCase())) != -1)
{
var adresse="none";
var stringend = chaine.toUpperCase().indexOf('"',foundat);
if(foundat==0 && stringend==-1)
adresse = ""+chaine;
else
adresse = ""+chaine.substring(foundat,stringend);
// grab the current element ( as there might be several of them in the page )
var daddyElem = document.currentScript.parentElement;
// now get the iframe thingie ( there's only one per bbcode )
var theThingToChange = daddyElem.getElementsByClassName("mediaContentBox")[0];
// and finally change its src
theThingToChange.src = adresse;
// alert("base="+chaine+"\nstart="+foundat+" end ="+stringend+" url = "+adresse+" voila");
}
</script>
</div>
Code: Select all
<div id="test">
<iframe class="mediaContentBox" width="560" height="315" src="hop" allowfullscreen ></iframe>
<script>
var stringToParse='https://vimeo.com/565225040#t=60s';
var convTable = [
// str to find , str to set , from , from
// this end
// char to
// till this
// end char
["https://odysee.com" ,"" ,'' ,''],
["https://crowdbunker.com/embed/" ,"" ,'' ,''],
["https://www.youtube.com/watch" ,"https://www.youtube-nocookie.com/embed/" ,'=' ,''],
["https://youtu.be/" ,"https://www.youtube-nocookie.com/embed/" ,'' ,'/'],
["https://www.youtube.com/embed/" ,"https://www.youtube-nocookie.com/embed/" ,'' ,'/'],
["https://www.youtube-nocookie.com/embed/" ,"https://www.youtube-nocookie.com/embed/" ,'' ,'/'],
["https://vimeo.com/" ,"https://player.vimeo.com/video/" ,'' ,'/']
];
function ParseAndConvert(str,tabl)
{
var foundAt = -1;
var retour = "";
// lets extract the actual url from passed str...
if((foundAt=str.toUpperCase().indexOf(tabl[0].toUpperCase())) != -1)
{
var url = "";
var stringEnd = str.toUpperCase().indexOf('"',foundAt);
if(stringEnd == -1)
url = ""+str;
else
url = ""+str.substring(foundAt,stringEnd);
// okay here, we should have url containing the whole link...
// lets rework it...
// 1st check for the replacement string
if(tabl[1]!="")
{
// here we should have chars to search for...
if(tabl[2]!='')// starting char
{ // okay, let's find the starting char
var startCharPos=-1;
if((startCharPos=url.toUpperCase().indexOf(tabl[2].toUpperCase()))!=-1)
{
// the char was found lets build the return string
retour = ""+tabl[1]+url.substring(startCharPos+1);
}
}
else // no start char to search... maybe a char from string end ?
if(tabl[3]!='')
{ // let's find the ending char
var endCharPos=-1;
if((endCharPos=url.toUpperCase().lastIndexOf(tabl[3].toUpperCase()))!=-1)
{
// the char was found lets build the return string
retour = ""+tabl[1]+url.substring(endCharPos+1);
}
}
}
else
{ // no replacement string.... we'll return the whole url
retour = ""+url;
}
}
return(retour);
}
var address="none";
var idx=0;
var found=false;
while(found==false && idx < convTable.length)
{
address = ParseAndConvert(stringToParse,convTable[idx]);
if(address!="")
found=true;
idx++;
}
if(found==false)
{
// lets copy the full string to address even if it don't work...
address = ""+stringToParse;
}
// grab the current element's parent ( as there might be several of them in the page )
var daddyElem = document.currentScript.parentElement;
// now get the iframe thingie ( there's only one per bbcode )
var theThingToChange = daddyElem.getElementsByClassName("mediaContentBox")[0];
// and finally change its src
theThingToChange.src = address;
//alert("URL = "+address);
</script>
</div>
var stringToParse='https://vimeo.com/565225040#t=60s';
direct link to a video...""+str;
append or prepend. Seems pointless. ZzzzCode: Select all
var stringToParse='https://vimeo.com/565225040#t=60s';
Code: Select all
var stringToParse='{TEXT}';