// hoverize.js // Based on hoverintent plugin for jQuery (function( $ ) { var opt = { slop: 7, interval: 200 }; function start() { if( ! timer ) { timer = setInterval( check, opt.interval ); $(document.body).bind( 'mousemove', move ); } } function clear() { if( timer ) { clearInterval( timer ); timer = null; $(document.body).unbind( 'mousemove', move ); } } function check() { if ( ( Math.abs( cur.x - last.x ) + Math.abs( cur.y - last.y ) ) < opt.slop ) { clear(); for( var i = 0, n = functions.length; i < n; ++i ) functions[i](); } else { last = cur; } } function move( e ) { cur = { x:e.screenX, y:e.screenY }; } var timer, last = { x:0, y:0 }, cur = { x:0, y:0 }, functions = []; hoverize = function( fn ) { function fire() { clear(); return fn.apply( null, args ); } functions.push( fire ); var args; return { clear: clear, now: function() { args = arguments; fire(); }, hover: function() { args = arguments; start(); } }; } })( jQuery ); (function( $ ) { var opt = window.GoogleElectionMapOptions || {}; //var imgBaseUrl = 'http://mg.to/iowa/server/images/'; var imgBaseUrl = 'http://gmaps-samples.googlecode.com/svn/trunk/elections/2008/images/icons/'; function loadScript( url ) { var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.charset = 'utf-8'; var seq = (new Date).getTime(); script.src = url + '?q=' + seq; script.title = 'jsonresult'; $('head')[0].appendChild( script ); } if( ! Array.prototype.forEach ) { Array.prototype.forEach = function( fun /*, thisp*/ ) { if( typeof fun != 'function' ) throw new TypeError(); var thisp = arguments[1]; for( var i = 0, n = this.length; i < n; ++i ) { if( i in this ) fun.call( thisp, this[i], i, this ); } }; } if( ! Array.prototype.map ) { Array.prototype.map = function( fun /*, thisp*/ ) { var len = this.length; if( typeof fun != 'function' ) throw new TypeError(); var res = new Array( len ); var thisp = arguments[1]; for( var i = 0; i < len; ++i ) { if( i in this ) res[i] = fun.call( thisp, this[i], i, this ); } return res; }; } if( ! Array.prototype.index ) { Array.prototype.index = function( field ) { this.by = {}; var by = this.by[field] = {}; for( var i = 0, n = this.length; i < n; ++i ) { var obj = this[i]; by[obj[field]] = obj; obj.index = i; } return this; }; } String.prototype.trim = function() { return this.replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); }; String.prototype.words = function( fun ) { this.split(' ').forEach( fun ); }; var parties = [ { name: 'democrat', shortName: 'Democratic', fullName: 'Democratic Party', url:'http://www.iowademocrats.org/' }, { name: 'republican', shortName: 'Republican', fullName: 'Republican Party', url:'http://www.iowagop.net/' } ].index('name'); var candidates = { all: [], democrat: [ { name: 'biden', lastName: 'Biden', fullName: 'Joe Biden', color: '#20FF1F' }, { name: 'clinton', lastName: 'Clinton', fullName: 'Hillary Clinton', color: '#FFFA00' }, { name: 'dodd', lastName: 'Dodd', fullName: 'Chris Dodd', color: '#E4Af95' }, { name: 'edwards', lastName: 'Edwards', fullName: 'John Edwards', color: '#FF1300' }, { name: 'gravel', lastName: 'Gravel', fullName: 'Mike Gravel', color: '#8A5C2E' }, { name: 'kucinich', lastName: 'Kucinich', fullName: 'Dennis Kucinich', color: '#EE00B5' }, { name: 'obama', lastName: 'Obama', fullName: 'Barack Obama', color: '#1700E8' }, { name: 'richardson', lastName: 'Richardson', fullName: 'Bill Richardson', color: '#336633' } ], republican: [ { name: 'giuliani', lastName: 'Giuliani', fullName: 'Rudy Giuliani', color: '#336633' }, { name: 'huckabee', lastName: 'Huckabee', fullName: 'Mike Huckabee', color: '#1700E8' }, { name: 'hunter', lastName: 'Hunter', fullName: 'Duncan Hunter', color: '#8A5C2E' }, { name: 'keyes', lastName: 'Keyes', fullName: 'Alan Keyes', color: '#8080FF' }, { name: 'mccain', lastName: 'McCain', fullName: 'John McCain', color: '#FFFA00' }, { name: 'paul', lastName: 'Paul', fullName: 'Ron Paul', color: '#E4Af95' }, { name: 'romney', lastName: 'Romney', fullName: 'Mitt Romney', color: '#FF1300' }, { name: 'tancredo', lastName: 'Tancredo', fullName: 'Tom Tancredo', color: '#EE00B5' }, { name: 'thompson', lastName: 'Thompson', fullName: 'Fred Thompson', color: '#20FF1F' } ] }; //var preloadCandidates = candidates.all.forEach( function( candidate ) { // var img = new Image( 16, 16 ); // img.src = imgUrl( candidate.name ); // return img; //}); var candidateNameList = []; parties.forEach( function( party ) { var list = candidates[party.name]; list.forEach( function( candidate ) { candidate.party = party; candidates.all.push( candidate ); candidateNameList.push( candidate.name ); }); list.index( 'name' ); }); candidates.all.index( 'name' ); var reCandidates = new RegExp( candidateNameList.join('|'), 'g' ); function candidateIcon( name ) { var icon = new GIcon; icon.image = imgUrl( name + '-border' ); icon.shadow = ''; icon.iconSize = new GSize( 18, 18 ); icon.shadowSize = new GSize( 0, 0 ); icon.iconAnchor = new GPoint( 9, 9 ); icon.infoWindowAnchor = new GPoint( 9, 9 ); return icon; } function loadCandidateIcons() { parties.forEach( function( party ) { candidates[party.name].forEach( function( candidate ) { candidate.icon = candidateIcon( candidate.name ); }); }); } // GAsync v2 by Michael Geary // Commented version and description at: // http://mg.to/2007/06/22/write-the-same-code-for-google-mapplets-and-maps-api // Free beer and free speech license. Enjoy! function GAsync( obj ) { function callback() { args[nArgs].apply( null, results ); } function queue( iResult, name, next ) { function ready( value ) { results[iResult] = value; if( ! --nCalls ) callback(); } var a = []; if( next.join ) a = a.concat(next), ++iArg; if( mapplet ) { a.push( ready ); obj[ name+'Async' ].apply( obj, a ); } else { results[iResult] = obj[name].apply( obj, a ); } } var mapplet = ! window.GBrowserIsCompatible; var args = arguments, nArgs = args.length - 1; var results = [], nCalls = 0; for( var iArg = 1; iArg < nArgs; ++iArg ) { var name = args[iArg]; if( typeof name == 'object' ) obj = name; else queue( nCalls++, name, args[iArg+1] ); } if( ! mapplet ) callback(); } //var mapplet = location.host == 'gmodules.com'; var mapplet = ! window.GBrowserIsCompatible; var partyButtons = opt.party ? '' : [ '
| ',
' ',
' ',
' | ',
'',
partyButtons,
' ',
' ',
'Primary Results', 'Statewide Results ',
'',
'Loading…',
' ',
'',
'Roll the mouse over the map for town-by-town results ',
'', //'Scroll down for statewide details', ' | ',
'
| Address: | ', '', ( event.venueaddress ? event.venueaddress + ', ' : '' ), event.venuecity, ' | ', '
| When: | ', '', event.eventdate, ' at ', event.eventtimestart, ' | ', '
| ', 'LIVE: Leading candidates by county', ' | ', '', precincts.reporting, ' of ', precincts.total, ' precincts reporting', ' | ', '