How something like that is created... Well, I've created a number of these and the process is fairly simple. Sorry I don't have an article to reference. Create a 'widget creation/builder' page with input parameters, when submitted either store those in the database and return an ID to associate with those settings, or generate a list of param's for those settings, or both. Simply output the <script>
tag into a textbox. Like so (inside an AJAX callback):
$("#results").html("<script type='text/javascript' src='" + widget_path + params + "'></script>");
Where widget_path is the absolute path to the widget ASP script, and params is either something like key=454
or theme=sunny&source=34&count=50
etc. Either manually or using something like jQuery.param to serialize the form. An alternative would be two <script>
tags with settings in the 2nd and calling a widget initialize function.
They can copy and paste that into their site, and that ASP script should output only JavaScript, which you can either document.write()
or use a JS library (such as jQuery) to operate on the DOM (.click()
etc). If using a database the ASP script would check the key param and grab the widget settings, if not then simply process the params. It's important to mention if you want to communicate back and forth with an API, you need cross-domain enabled or you could simply use JSON (in ASP script check for a 'callback' parameter, wrap JSON in that function name, and use jQuery.getJSON with &callback=?
at the end); there are other methods of course.
If you use a database, make sure to take security into account (SQL injection, etc.)
WidgetBox looks like a good, mainline method as well.