Friday, November 28, 2008

Super-Sharable, Self-Installing Widget

There are not many people that will appreciate this, but I just finished coding up a widget form that will install itself on other blogger blogs automatically. Then after it's been installed on someone else's blog it contains the same form so that their readers can add the widget. See it in action on my sidebar for the petit elefant. Here's the code:

<form id="supersharingwidget" action="http://www.blogger.com/add-widget" method="post"><!-- This is the beginning of the real widget content /--><a href="http://petitelefant.blogspot.com"><img border="0" src="http://img81.imageshack.us/img81/5783/elefantsc0.gif"/></a><br/>
<div>To add this button to your blog, copy and paste the text below into the HTML/JavaScript page element on your blog or simply press the button below.<br/><textarea onclick="this.select()">&lt;a href="http://petitelefant.blogspot.com"&gt;&lt;img border="0" src="http://img81.imageshack.us/img81/5783/elefantsc0.gif"/&gt;&lt;/a&gt;&lt;br/&gt;</textarea> </div><!-- This is the end of the real widget content /--><input value="http://petitelefant.blogspot.com/" name="infoUrl" type="hidden"/> <input name="widget.title" type="hidden"/> <!-- Do Not Change anything below this line /--><input id="pewc" name="widget.content" type="hidden"/> <input value="&lt;data:content/&gt;" name="widget.template" type="hidden"/> <input style="border: 0px none ; background: rgb(255, 255, 255) url(http://www.blogger.com/img/add/add2blogger_sm_b.gif) repeat scroll center center; width: 104px; height: 17px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" value=" " onclick="var wc = (document.getElementById('supersharingwidget').outerHTML)?document.getElementById('supersharingwidget').outerHTML + '<!--endssw/-->':document.getElementById('supersharingwidget').parentNode.innerHTML.match(/<form id=\u0022supersharingwidget\u0022(.|\n)+<\!--endssw\/-->/)[0].toString();document.getElementById('pewc').value = wc" type="submit"/> </form><!--endssw/-->

No comments: