function sc(identifier) { function widgetClass(identifier) { // private vars var options = new Array(); var dialog_init = false; // member functions this.init = function() { if (this.getOption('name')) this.setOption('url','http://www.bridgewaymedia.org/widgets/src_video/' + this.getOption('name') + '.flv'); if (! document.getElementById(options["container"].val)) doCreateDiv(doPrintHTML); return true; } setFile = function(filename, filetype) { if (filetype=="js") { var fileref=document.createElement('script'); fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src",filename); } else if (filetype=="css") { var fileref=document.createElement('link'); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", filename); } if (typeof fileref != "undefined") { document.getElementsByTagName("head")[0].appendChild(fileref); return fileref; } } this.setOption = function (key, value) { if (options[key] && options[key].writable) { options[key].val = value; return true; } return false; } this.getOption = function (key) { if (options[key] && options[key].readable) return options[key].val; return false; } this.show = function () { var checkFinished = function (obj) { alert("now " + obj.newstate); if (obj.newstate == 'COMPLETED') { $("#sc_container").dialog('close'); } } if (dialog_init == true) { $("#sc_container").dialog('open'); //document.getElementById(options['id'].val).addModelListener('STATE',"widgetClass.checkFinished"); //var that = this; //document.getElementById(that.getOption('id')).addModelListener('STATE','that.checkFinished'); } else widgetClass.play(); } this.play = function () { //document.getElementById(options['id'].val).sendEvent("PLAY","true"); } this.stop = function () { document.getElementById(options['id'].val).sendEvent("PLAY","false"); } // private functions var doInitialize = function () { options["container"] = new Object; options["container"].writable = true; options["container"].readable = true; options["container"].val = "sc_widget"; options["height"] = new Object; options["height"].readable = true; options["height"].val = 360; options["width"] = new Object; options["width"].readable = true; options["width"].val = 510; options["name"] = new Object; options["name"].readable = true; options["name"].writable = true; options["url"] = new Object; options["url"].readable = true; options["url"].writable = true; options["title"] = new Object; options["title"].readable = true; options["title"].writable = true; options["title"].val = "Video Clip"; } var doCreateDiv = function(callback) { var complete = setFile("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js","js"); var setDialog = function() { $("body").prepend('
'); // $("#"+widgetClass.getOption('container')).css('height','270px'); $("#sc_container").dialog({ width:widgetClass.getOption('width'), // height:widgetClass.getOption('height'), autoOpen:false, minWidth:widgetClass.getOption('width'), minHeight:widgetClass.getOption('height'), title:widgetClass.getOption('title'), beforeclose:widgetClass.stop //open:widgetClass.play }); dialog_init = true; callback(); }; complete.onload = setDialog; complete.onreadystatechange = function() { var state = this.readyState; if (state == 'complete' || state == 'loaded') { setDialog(); } } } doPrintHTML = function() { var url = widgetClass.getOption('url'); var playerFlv = new SWFObject('http://www.bcctv.org/widgets/player.swf',widgetClass.getOption('id'),'480','295','9'); playerFlv.addParam('allowscriptaccess','always'); playerFlv.addParam('flashvars','file='+url+'&autostart=true&controlbar=none&stretching=fill'); playerFlv.write(widgetClass.getOption('container')); } // main setFile("http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js","js"); setFile("http://www.bcctv.org/widgets/swfobject.js","js"); var widgetClass = this; options["id"] = new Object; options["id"].val = identifier; options["id"].readable = true; doInitialize(); } this.widget = new widgetClass(identifier); }