Appendix B. Sample Gadgets Code

In this appendix you will find the complete, uninterrupted source code for the gadgets covered in Chapters 5 and 7.

Wave Mood Gadget

You can browse or check out the source code at http://code.google.com/p/gwave-mood-gadget.

Code

<?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="Wave Mood Gadget" height="160"> <Require feature="wave" /> </ModulePrefs> <Content type="html"> <![CDATA[ <div id="wrapper" style="height: 160px;"> <img id="mood_chart" src="http://chart.apis.google.com/chart?chs=200x100& cht=gom&chd=t:50&chl=Luke+Warm" alt="Wave Mood" /> <br/> This wave is: <input type="radio" value="10" name="radio_mood" id="radio_10" onClick="moodSelected(this.value)"> Cold &nbsp;| <input type="radio" value="50" name="radio_mood" id="radio_50" onClick="moodSelected(this.value)" checked> Luke Warm &nbsp;| <input type="radio" value="90" name="radio_mood" id="radio_90" onClick="moodSelected(this.value)"> Hot <br/> <span id="lastChanged"></span> </div> <script type="text/javascript"> var moodImage = document.getElementById('mood_chart'); var moodLabels = []; moodLabels[10] = 'Cold'; moodLabels[50] = 'Luke+Warm'; moodLabels[90] = 'Hot'; function moodSelected(mood) { wave.getState().submitDelta({'mood': mood}); var viewer = wave.getViewer().getDisplayName(); wave.getState().submitDelta({'lastChanged': viewer}); } function stateUpdated() { if(!wave.getState().get('mood')) { var moodSrc = 'http://chart.apis.google.com/chart?'; moodSrc += 'chs=200x100&cht=gom&chd=t:50&chl=Luke+Warm'; ...

Get Google Wave: Up and Running now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.