Developing Feather-Weight Webservices with JavaScript

WhiskerBiscuit in action

The following is sample usage from the WhiskerBiscuit.js code covered in the previous chapter, On target with WhiskerBiscuit. See that chapter for the API. The samples are dynamically generated by the service.

NB that Amazon.com serves plain graphical advertisements through their service a portion of the time whether or not there are sensible keywords present.

size=468x60, keyword=birds, debug=1

The debug gets the arguments dumped to the screen so you can verify it’s acting the way it should.

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=468x60;keyword=birds;debug=1">
</script>

That one has a keyword which will be used if nothing sensible can be found in the query. Try this link scuba diving (will probably take 2 consecutive clicks to make the link become the referrer) to change the referrer query value used.

Some error cases from misuse

Again, what a service should do for the failure case is a judgement call. It can deliver a reasonable default like, “Amazon.com and you’re done,” or an error message, or fail without output. Since money is involved, we’ve chosen a diagnostic error message. If you misuse WhiskerBiscuit, it will tell you so.

Misused: size=missing_size_or_bad

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?keyword=pebkac">
</script>

Misused: store=no_such_store

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=160x600;store=pets">
</script>

Misused: keyword=way+too+long+to+the+point+of+absurdity

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=160x600;keyword=way+too+long+
 to+the+point+of+being+completely+without+value+for+searching">
</script>

More correctly used

size=120x450, keyword=JavaScript, override=1

This one will always choose “JavaScript” for its keyword. This sort of defeats the purpose but it’s nice to have when you’re sure or just testing ads.

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=120x450;keyword=JavaScript;override=1">
</script>

size=text, keyword=JavaScript

When there are no keywords (none found and no backup given) the text ad will write nothing.

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=text;keyword=JavaScript">
</script>

size=180x150, store=garden, keyword=hummingbird

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=180x150;store=garden;keyword=hummingbird">
</script>

size=468x60, store=music

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=468x60;store=music">
</script>

size=468x60, store=magazines, keyword=harper’s

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=468x60;keyword=harper's;store=magazines">
</script>

size=468x60, store=dvd, keyword=dinosaur

<script type="text/javascript"
src="http://elektrum.org/js/WhiskerBiscuit.js?size=468x60;store=dvd;keyword=dinosaur">
</script>

Congratulations!

You’ve made it to the end of the manual proper. If you’ve landed on this chapter, please consider reading from the beginning.

From here there are several interesting class extensions and unfinished and proof of concept services to demonstrate further possibilities.

« On target with WhiskerBiscuit · Appendix »
Google
 
Web Developing Featherweight Web Services with JavaScript
This is version 0.57b of this manual. It is a beta version with some gaps. We are grateful for feedback.

The code is the manual has not yet been fully tested against Internet Explorer. Bug reports are welcome.
An Elektrum Press Online