friendica-addons/widgets/widgets.js

38 lines
1013 B
JavaScript
Raw Permalink Normal View History

2011-09-25 08:56:03 +00:00
/**
* @author Fabio Comuni
*/
var f9a_widget_$widget_id = {
width: "$width",
height: "$height",
2011-09-25 08:56:03 +00:00
entrypoint : "$entrypoint",
key : "$key",
widgetid: "$widget_id",
argstr: "$args",
load : function() {
var args = new Array();
2011-09-25 08:56:03 +00:00
args['k']=this.key;
args['s']=window.location.href;
2011-09-25 08:56:03 +00:00
args['a']=this.argstr;
var urlencodedargs = new Array();
for(k in args){
if (typeof args[k] != 'function')
urlencodedargs.push( encodeURIComponent(k)+"="+encodeURIComponent(args[k]) );
}
2011-09-25 08:56:03 +00:00
var url = this.entrypoint + "?"+ urlencodedargs.join("&");
console.log(this.widgetid);
console.log(document.getElementById(this.widgetid));
document.getElementById(this.widgetid).innerHTML = '<iframe style="border:0px; width: '+this.width+'; height:'+this.height+'" src="'+url+'"></iframe>';
2011-09-25 08:56:03 +00:00
}
};
document.writeln("<div id='$widget_id' class='f9k_widget $type'>");
document.writeln("<img id='$widget_id_ld' src='$loader'>");
document.writeln("</div>");
2011-09-25 08:56:03 +00:00
(function() {
f9a_widget_$widget_id.load();
})();