X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=widgets%2Fwidgets.js;h=f7b7ac9e9aa39955cea0fcd9ae2b8175d2972dff;hb=a3eb7268aeafbc12e081f94c41c4e08b6e3b7ccc;hp=45d36c4d7d184aa120ea6e001a3ec59856e45bfc;hpb=056921b1e8d64702535f03e238bc2e451ddca646;p=friendica-addons.git diff --git a/widgets/widgets.js b/widgets/widgets.js index 45d36c4d..f7b7ac9e 100644 --- a/widgets/widgets.js +++ b/widgets/widgets.js @@ -1,64 +1,37 @@ /** * @author Fabio Comuni */ - var f9a_widget_$widget_id = { + width: "$width", + height: "$height", entrypoint : "$entrypoint", key : "$key", widgetid: "$widget_id", argstr: "$args", - xmlhttp : null, - - getXHRObj : function(){ - if (window.XMLHttpRequest) { - // code for IE7+, Firefox, Chrome, Opera, Safari - this.xmlhttp = new XMLHttpRequest(); - } else { - // code for IE6, IE5 - this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); - } - }, - - dorequest : function(args, cb) { - if (args===null) args = new Array(); + + load : function() { + var args = new Array(); args['k']=this.key; - args['s']=window.location; + args['s']=window.location.href; args['a']=this.argstr; var urlencodedargs = new Array(); - for(k in args){ urlencodedargs.push( encodeURIComponent(k)+"="+encodeURIComponent(args[k]) ); } - + for(k in args){ + if (typeof args[k] != 'function') + urlencodedargs.push( encodeURIComponent(k)+"="+encodeURIComponent(args[k]) ); + } var url = this.entrypoint + "?"+ urlencodedargs.join("&"); - this.xmlhttp.open("GET", url ,true); - this.xmlhttp.send(); - this.xmlhttp.obj = this; - this.xmlhttp.onreadystatechange=function(){ - if (this.readyState==4){ - if (this.status==200) { - cb(this.obj, this.responseText); - } else { - document.getElementById(this.obj.widgetid).innerHTML="Error loading widget."; - } - } - } - - }, - - requestcb: function(obj, responseText) { - document.getElementById(obj.widgetid).innerHTML=responseText; - }, - - load : function (){ - this.getXHRObj(); - this.dorequest(null, this.requestcb); + console.log(this.widgetid); + console.log(document.getElementById(this.widgetid)); + document.getElementById(this.widgetid).innerHTML = ''; } }; +document.writeln("
"); +document.writeln(""); +document.writeln("
"); (function() { f9a_widget_$widget_id.load(); })(); -document.writeln("
"); -document.writeln(""); -document.writeln("
");