// 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, fast ) { function now() { fast && fast.apply( null, args ); } function fire() { clear(); return fn.apply( null, args ); } functions.push( fire ); var args; return { clear: clear, now: function() { args = arguments; now(); fire(); }, hover: function() { args = arguments; now(); 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 ); }; function percent( n ) { n = Math.round( n * 100 ); return n ? n + '%' : ''; } 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'); // calendar.google.com feed template: // http://www.google.com/calendar/feeds/{candidate.feed}@group.calendar.google.com/public/basic var candidates = { 'all': [], 'democrat': [ { 'name': 'biden', 'lastName': 'Biden', 'fullName': 'Joe Biden', 'color': '#20FF1F', 'feed': '' }, { 'name': 'clinton', 'lastName': 'Clinton', 'fullName': 'Hillary Clinton', 'color': '#FFFA00', 'feed': '2jmb4ula0um5138qnfk621nagg' }, { 'name': 'dodd', 'lastName': 'Dodd', 'fullName': 'Chris Dodd', 'color': '#E4Af95', 'feed': 'l06f7eei6qfjns5a4pd5nv6erg' }, { 'name': 'edwards', 'lastName': 'Edwards', 'fullName': 'John Edwards', 'color': '#FF1300', 'feed': '46uusesnavfh045mmfjje0fflo' }, { 'name': 'gravel', 'lastName': 'Gravel', 'fullName': 'Mike Gravel', 'color': '#8A5C2E', 'feed': '47r7phlvf8e07lga3poj0ntv8g' }, { 'name': 'kucinich', 'lastName': 'Kucinich', 'fullName': 'Dennis Kucinich', 'color': '#EE00B5', 'feed': '7c9gellom85djmbl6664s9cclc' }, { 'name': 'obama', 'lastName': 'Obama', 'fullName': 'Barack Obama', 'color': '#1700E8', 'feed': 'nkt5atdq7cdbes3ehdfpendpnc' }, { 'name': 'richardson', 'lastName': 'Richardson', 'fullName': 'Bill Richardson', 'color': '#336633', 'feed': 'mdgiev7eul12rt1lo6eohg55q0' }, { 'name': 'uncommitted-d', 'lastName': 'Uncommitted', 'fullName': 'Uncommitted', 'color': '#DDDDDD', 'feed': '' } ], 'republican': [ { 'name': 'brownback', 'lastName': 'Brownback', 'fullName': 'Sam Brownback', 'color': '#8080FF', 'feed': 'lm63qmbqunob5gbvratl1bo974' }, { 'name': 'cort', 'lastName': 'Cort', 'fullName': 'Hugh Cort', 'color': '#8080FF' }, { 'name': 'cox', 'lastName': 'Cox', 'fullName': 'John Cox', 'color': '#808040' }, { 'name': 'fendig', 'lastName': 'Fendig', 'fullName': 'Cap Fendig', 'color': '#408080' }, { 'name': 'giuliani', 'lastName': 'Giuliani', 'fullName': 'Rudy Giuliani', 'color': '#336633', 'feed': 'g0tkl52ft6nhrlm2e6v6his400' }, { 'name': 'huckabee', 'lastName': 'Huckabee', 'fullName': 'Mike Huckabee', 'color': '#1700E8', 'feed': 'h32i31ojgo9vvb3vnggmq1qrh8' }, { 'name': 'hunter', 'lastName': 'Hunter', 'fullName': 'Duncan Hunter', 'color': '#8A5C2E', 'feed': '' }, { 'name': 'keyes', 'lastName': 'Keyes', 'fullName': 'Alan Keyes', 'color': '#8080FF', 'feed': '' }, { 'name': 'mccain', 'lastName': 'McCain', 'fullName': 'John McCain', 'color': '#FFFA00', 'feed': 'q1du1ju69m8jecsjkhjr538kbs' }, { 'name': 'paul', 'lastName': 'Paul', 'fullName': 'Ron Paul', 'color': '#E4Af95', 'feed': '7p20d17uil4ft2qhvattqrjdgg' }, { 'name': 'romney', 'lastName': 'Romney', 'fullName': 'Mitt Romney', 'color': '#FF1300', 'feed': '3mv48r8us0rou62c356om8groc' }, { 'name': 'tancredo', 'lastName': 'Tancredo', 'fullName': 'Tom Tancredo', 'color': '#EE00B5', 'feed': '' }, { 'name': 'thompson', 'lastName': 'Thompson', 'fullName': 'Fred Thompson', 'color': '#20FF1F', 'feed': 'fhg9gjvi7459qaf0ki43ij1g78' }, { 'name': 'uncommitted-r', 'lastName': 'Uncommitted', 'fullName': 'Uncommitted', 'color': '#DDDDDD', 'feed': '' } ] }; //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,
' ',
' ',
'',
' ',
'Statewide Results ',
'',
'Loading…',
' ',
'',
'Roll the mouse over the map for county-by-county 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', ' | ', '
| ', '', party.fullName, '', ' | ', '', attrib, ' | ', '