Election Gadget

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

Code

<?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="Election Gadget" height="300"> <Require feature="wave" /> <Require feature="dynamic-height" /> </ModulePrefs> <Content type="html"> <![CDATA[ <div id="winner" style="margin: 5px; padding: 5px; border: 1px solid #dddddd;"> <h3 style="margin: 3px;">Election Winner:</h3> <img id="winnerAvatar" src="http://gadget-doc-examples.googlecode.com/svn/trunk/images/unknown.gif" width="50" height="50"/> <br/> <span id="winnerName" style="color: #337FE5;"></span> <br/> Number of votes: <span id="numberVotes">0</span> </div> <div id="electionStats" style="margin: 5px; padding: 5px; border: 1px solid #dddddd;"> Number of participants in this election: <span id="participants">1</span> </div> <div style="margin: 5px; padding: 5px; border: 1px solid #dddddd;"> Please vote for one of the participants: <br/> <div id="voteSelection"></div> </div> <script type="text/javascript"> function participantVoted(electedId) { var viewerId = wave.getViewer().getId(); var state = wave.getState(); delta = {}; delta[viewerId] = electedId; state.submitDelta(delta); } function renderInfo() { if (!wave.getState()) { return; } var state = wave.getState(); var keys = state.getKeys(); var electedKeys = []; for (var i = 0; i < keys.length; i++) { var electedId = null; var voter = keys[i]; var electedId = state.get(voter); electedKeys.push(electedId); ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.