if(!SAPO.Widget||typeof(SAPO.Widget)=='undefined'){SAPO.namespace('Widget');} SAPO.Widget.Videos=function(options){this.init(options);};this.options={};SAPO.Widget.Videos.prototype={init:function() {var options=SAPO.extendObj({user:false,playlist:false,total:false,visible:false,divid:false,widgetWidth:140,useImageButtons:true,showThumbs:true,showLabels:true,playLabel:'Play',stopLabel:'Stop',autoplay:true,refreshRate:5000,cssURI:'http://js.sapo.pt/Assets/Images/WidgetThemes/black.styles.css'},arguments[0]||{});this.options=options;try{if(this.options.user===false){alert('Por favor defina um utilizador.');return;} this.divId='divid_'+(Math.random()*1000000);var url=false;if(this.options.user!==false&&this.options.playlist===false){this.syndication=new SAPO.Communication.Syndication();url='http://services.sapo.pt/Videos/JSON/Query?user='+ encodeURIComponent(this.options.user);if(this.options.total!==false){url+='&limit='+this.options.total;} this.jsonId=this.syndication.push(url,{onComplete:this._writeContent.bindObj(this)});} if(this.options.playlist!==false){url="http://videos.sapo.pt/"+ encodeURIComponent(this.options.user)+"/playajax/"+this.options.playlist;this._createScriptTag(url);} this._writeLayout();}catch(e){this.debug('init',e);}},_addCss:function() {if(this.options.cssURI){var link=document.createElement('link');link.rel='stylesheet';link.href=this.options.cssURI;link.media='all';var aHead=document.getElementsByTagName('HEAD');if(aHead.length>0){aHead[0].appendChild(link);}}},_writeLayout:function() {try{this._addCss();var str='';str+='
Canal de ';}else{str+='
Últimos vídeos de ';} str=str+''+this.options.user+''+'
';str+='';str+='