<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Flash: HTML to XHTML"
title_url="http://www.donatofurlani.it/ideas"
author_link="http://www.donatofurlani.it"
description="Converts the standard embeddable Flash objects code into valid XHTML 1.0 Strict code. Supported code from: YouTube, GoogleVideo, Hulu, Dailymotion, Revver, Metacafe, Brightcove, Veoh, Yahoo, Megavideo, Libero, Deezer."
thumbnail="http://htmltoxhtml.googlepages.com/thumb.png"
screenshot="http://htmltoxhtml.googlepages.com/screenshot.png"
author_email="htmlToXhtml@gmail.com" category="tools" category2="technology"
 height="200" scrolling="false"
author="Donato Furlani" />
<Content type="html"><![CDATA[
<div style="text-align:center; width: 100%;">
<div style="margin:0 auto; padding:4px 0; width: 100%;">

<script type="text/javascript">

function hToX(divId) {

var hToXdiv = document.getElementById(divId);
var hToXcontainerDiv = document.createElement('div');
hToXcontainerDiv.setAttribute('id','container'+divId);
hToXcontainerDiv.style.margin = '0 auto';
hToXdiv.appendChild(hToXcontainerDiv);
var tarea = document.createElement('textarea');
tarea.setAttribute('id','tarea'+divId);
tarea.setAttribute('rows','9');
tarea.style.fontSize = '12px';
tarea.style.width = '100%';
tarea.setAttribute('onfocus','hToX_check(\''+divId+'\');');
tarea.onfocus = new Function('hToX_check(\''+divId+'\');');
tarea.style.marginTop = "3px";
tarea.style.marginBottom = "3px";
tarea.value = 'Paste here your HTML code.\n\nSupported code:\n\nYouTube, GoogleVideo, Hulu, Veoh, DailyMotion, Yahoo, Revver, Metacafe, Brightcove, MegaVideo, Libero, Deezer';
hToXcontainerDiv.appendChild(tarea);
var buttDiv = document.createElement('div');
buttDiv.setAttribute('id','buttDiv'+divId);

hToXcontainerDiv.appendChild(buttDiv);
var convButton = document.createElement('input');
convButton.setAttribute('id','convButton'+divId);
convButton.setAttribute('type','button');
convButton.style.marginRight = "4px";
convButton.setAttribute('value','Convert');
convButton.setAttribute('onclick','hToX_convert(\''+divId+'\');');
convButton.onclick = new Function('hToX_convert(\''+divId+'\');');
buttDiv.appendChild(convButton);
var clearButton = document.createElement('input');
clearButton.style.marginLeft = "4px";
clearButton.setAttribute('id','clearButton'+divId);
clearButton.setAttribute('type','button');
clearButton.setAttribute('value','Clear');
clearButton.setAttribute('onclick','hToX_clear(\''+divId+'\');');
clearButton.onclick = new Function('hToX_clear(\''+divId+'\');');
buttDiv.appendChild(clearButton);
}


function hToX_check(whichone) {
var focuscheck = document.getElementById('tarea'+whichone);
if (focuscheck.value.indexOf('Supported code') > 0) focuscheck.value = "";
}

function hToX_clear(whichone) {
var wtarea = document.getElementById('tarea'+whichone);
wtarea.value = "";
}

function hToX_convert(whichone) {
var ctarea = document.getElementById('tarea'+whichone);
var toConvert = ctarea.value;
var codeType = "none";
	if(toConvert.indexOf("deezer.com") != -1) { codeType = "deezer";}
	if(toConvert.indexOf("youtube.com") != -1) { codeType = "youtube";}
	if(toConvert.indexOf("video.google") != -1) { codeType = "google";}
	if(toConvert.indexOf("dailymotion.") != -1) { codeType = "dailymotion";}
	if(toConvert.indexOf("metacafe.com") != -1) { codeType = "metacafe";}
	if(toConvert.indexOf("veoh.com") != -1) { codeType = "veoh";}
	if(toConvert.indexOf("revver.com") != -1) { codeType = "revver";}
	if(toConvert.indexOf("brightcove.tv") != -1) { codeType = "brightcove";}
	if(toConvert.indexOf("yahoo.com/") != -1) { codeType = "yahoo";}
	if(toConvert.indexOf("hulu.com") != -1) { codeType = "hulu";}
	if(toConvert.indexOf("megavideo.com") != -1) { codeType = "megavideo";}
	if(toConvert.indexOf("video.libero") != -1) { codeType = "libero";}
var xhtmlcode = "Sorry,\nHTML code could not be recognized";

toConvert = toConvert.replace(/&/g,"&amp;");
switch(codeType)
{

		case 'deezer':
			xhtmlcode = rule1(toConvert);
			xhtmlcode = xhtmlcode.replace(/border="0"/g,'');
		break;

		case 'youtube':
			xhtmlcode = rule1(toConvert);
		break;

		case 'dailymotion':
			xhtmlcode = rule1(toConvert);
		break;
		
		case 'google':
			var valuepatt = /src="[^\s]*"/;
			var valueres = valuepatt.exec(toConvert);
			var objdata = valueres[0].replace(/src/,'data');
			var heipatt = /height:[0-9]*/;
			var widpatt = /width:[0-9]*/;
			var heires = heipatt.exec(toConvert);
			var widres = widpatt.exec(toConvert);
			var newh = heires[0].replace(/height:/,'height="');
			var neww = widres[0].replace(/width:/,'width="');
			var dimensions = newh + '" ' + neww + '" ';
			xhtmlcode = '<object type="application/x-shockwave-flash" ' + dimensions + objdata + ' >';
			var pardata = objdata.replace(/data/,'value');
			xhtmlcode += '<param name="movie" ' + pardata + ' />';
			xhtmlcode += '<param name="flashvars" value="" /> </object>';
		break;


		case 'metacafe':
			var valuepatt = /src="[^\s]*"/;
			var valueres = valuepatt.exec(toConvert);
			var objdata = valueres[0].replace(/src/,'data');
			var heipatt = /height="[0-9]*"/;
			var widpatt = /width="[0-9]*"/;
			var heires = heipatt.exec(toConvert);
			var widres = widpatt.exec(toConvert);
			xhtmlcode = '<object type="application/x-shockwave-flash" ' + heires[0] + ' ' + widres[0] + ' ' + objdata + ' >';
			var pardata = objdata.replace(/data/,'value');
			xhtmlcode += '<param name="movie" ' + pardata + ' /> ';
			xhtmlcode += '<param name="wmode" value="transparent" /> ';
			var flashpatt = /flashVars="[^\s]*"/;
			var flashres = flashpatt.exec(toConvert);
			if (flashres != null) {
			var flashvars = flashres[0].replace(/flashVars/,'value');
			xhtmlcode += '<param name="flashvars" ' + flashvars + ' />'; }
			xhtmlcode += ' </object>';
			toConvert = toConvert.replace(/<embed[\s\S]*embed>/,'');
			toConvert = toConvert.replace(/<br>/g,'<br />');
			toConvert = toConvert.replace(/font>/g,'span>');
			toConvert = toConvert.replace(/<font [^>]*>/m,'<span style="font-size: x-small;">');
			xhtmlcode += toConvert;
		break;
		
		case 'veoh':
			var valuepatt = /src="[^\s]*"/;
			var valueres = valuepatt.exec(toConvert);
			var objdata = valueres[0].replace(/src/,'data');
			var heipatt = /height="[0-9]*"/;
			var widpatt = /width="[0-9]*"/;
			var heires = heipatt.exec(toConvert);
			var widres = widpatt.exec(toConvert);
			xhtmlcode = '<object type="application/x-shockwave-flash" ' + heires[0] + ' ' + widres[0] + ' ' + objdata + ' >';
			var pardata = objdata.replace(/data/,'value');
			xhtmlcode += '<param name="movie" ' + pardata + ' /> ';
			xhtmlcode += '<param name="allowFullScreen" value="true" /> ';
			xhtmlcode += ' </object>';
			toConvert = toConvert.replace(/<embed[\s\S]*embed>/,'');
			xhtmlcode += toConvert;
		break;

		case 'revver':
			toConvert = toConvert.replace(/<embed[\s\S]*embed>/,'');
			xhtmlcode = toConvert;
		break;
		
		case 'brightcove':
			var valuepatt = /src='[^']*/;
			var valueres = valuepatt.exec(toConvert);
			var objdata = valueres[0].replace(/src='/,'data="');
			
			var flashpatt = /flashVars='[^']*/;
			var flashres = flashpatt.exec(toConvert);
			var flashvars = flashres[0].replace(/flashVars='/,'?');
			
			objdata += flashvars + '"';
			
			var heipatt = /height='[0-9]*/;
			var widpatt = /width='[0-9]*/;
			var heires = heipatt.exec(toConvert);
			var widres = widpatt.exec(toConvert);
			var newh = heires[0].replace(/height='/,'height="');
			var neww = widres[0].replace(/width='/,'width="');
			var dimensions = newh + '" ' + neww + '" ';
			xhtmlcode = '<object type="application/x-shockwave-flash" ' + dimensions + objdata + ' >';
			var pardata = objdata.replace(/data/,'value');
			xhtmlcode += '<param name="movie" ' + pardata + ' />';	
			xhtmlcode += '<param name="base" value="http://admin.brightcove.com" />';
			xhtmlcode += '<param name="name" value="bcPlayer" />';
			xhtmlcode += '<param name="allowFullScreen" value="true" />';
			xhtmlcode += '<param name="allowScriptAccess" value="always" />';
			xhtmlcode += '<param name="seamlesstabbing" value="false" />';
			xhtmlcode += '<param name="swLiveConnect" value="true" />';
			xhtmlcode += '<param name="swLiveConnect" value="true" />';
			xhtmlcode += '<param name="bgcolor" value="#FFFFFF" />';		
			xhtmlcode += '</object>';
		break;


  	        case 'yahoo':
			xhtmlcode = rule1(toConvert);
		break;

		case 'hulu':
			xhtmlcode = rule1(toConvert);
		break;
		
		case 'megavideo':
			xhtmlcode = rule1(toConvert);
		break;

		case 'libero':
			xhtmlcode = rule1(toConvert);
		break;

default:
}


ctarea.value = xhtmlcode ;
if(codeType != "none") ctarea.select();
}

function rule1(htmlinput) {
var htmlcode = htmlinput;
var valuepatt = /movie" value="[^"]*"/;
var valueres = valuepatt.exec(htmlcode);
var objdata = valueres[0].replace(/movie" value/,'data');
var objrepl = 'object type="application/x-shockwave-flash" ' + objdata + ' ';
htmlcode = htmlcode.replace(/object /, objrepl);
htmlcode = htmlcode.replace(/<embed[\s\S]*embed>/,'');
var xhtmloutput = htmlcode;
return xhtmloutput;
}


var randNum = Math.round(1209*Math.random());
var randId = "htox" + randNum;
document.writeln('<div style=\'width:100%;\' id=\'' + randId + '\'></div>');
var startXTOX = new hToX(randId);

</script>

</div>
</div>


]]></Content>
</Module>











