PHP beginner |
|
Hallo allemaal,
Ik zou graag het Youtube embed url willen parsen uit een een stuk tekst met een youtube url daarin. Daarvoor heb ik alvast de onderstaande code geschreven, echter werkt deze niet. Er ontbreekt ook nog een regex die filtert op Youtube url's. Iemand een oplossing?
Dank alvast voor je hulp!
Martijn
function Youtube(identifier, text)
{
this.embedCode = '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/<!embedUrl>&hl=nl&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/<!embedUrl>&hl=nl&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>'; //Youtube embed source
this.identifier = identifier;
this.text = text;
}
Youtube.prototype.GetEmbedCode = function()
{
var arrResult = this.split('=');
return this.embedCode.replace('<!embedUrl>', arrResult[1]).replace('<!embedUrl>', arrResult[1]);
}
Youtube.prototype.Render = function()
{
this.GetEmbedCode();
document.getElementById(this.identifier).innerHTML = this.embedCode;
}
function Youtube(identifier, text) { this.embedCode = '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/<!embedUrl>&hl=nl&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/<!embedUrl>&hl=nl&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>'; //Youtube embed source this.identifier = identifier; this.text = text; } Youtube.prototype.GetEmbedCode = function() { var arrResult = this.split('='); return this.embedCode.replace('<!embedUrl>', arrResult[1]).replace('<!embedUrl>', arrResult[1]); } Youtube.prototype.Render = function() { this.GetEmbedCode(); document.getElementById(this.identifier).innerHTML = this.embedCode; }
|