Custom widget

I've been googling for a manual or something on how to make a widget. Haven't find any good stuff.

I would like to insert a script in widget. People are requesting to use this one script in a widget and I don't want to allow them to add scripts into the html widget.

Is there a code I can use to create a widget, and just customize title and content? I think it'd be real good for future use as well.

Thanks.