String.prototype.format = function() { a = this; for ( k in arguments ) { a = a.replace("{" + k + "}", arguments[k]); } return a; }; window.gmAPI = { 'version': '3.0-rc1', 'ga': '', 'primaryUrl': 'http://code.google.com/p/jquery-ui-map/', 'url': 'http://jquery-ui-map.googlecode.com/', 'forum': 'http://groups.google.com/group/jquery-ui-map-discuss/feed/rss_v2_0_msgs.xml', 'subscribe': 'http://groups.google.com/group/jquery-ui-map-discuss/boxsubscribe', 'exception': 'Unable to load due to either poor internet connection or some CDN\'s aren\'t as responsive as we would like them to be. Try refreshing the page :D.', 'init': function() { //window._gaq = [['_setAccount', this.ga], ['_trackPageview'], ['_trackPageLoadTime']]; //Modernizr.load({ 'test': ( location.href.indexOf(this.url) > -1 ), 'yep': 'http://www.google-analytics.com/ga.js' }); this.test('Backbone', function() { $('#forum').append('

Forum

Subscribe

'); ForumCollection = Backbone.Collection.extend({ 'url': 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q={0}'.format(encodeURIComponent(gmAPI.forum)), 'parse': function(response) { return response.responseData.feed.entries; } }); ForumPost = Backbone.View.extend({ 'tagName': 'li', 'className': 'group-item', 'template': _.template('<%=title%>'), 'render': function() { $(this.el).html(this.template(this.model.toJSON())); return this; } }); Forum = Backbone.View.extend({ 'el': $("#forum"), 'initialize': function() { this.col = new ForumCollection(); this.col.bind('reset', this.load, this); this.col.fetch(); }, 'add': function(post) { var view = new ForumPost({'model': post}); $('#forum_posts').append(view.render().el); }, 'load': function () { this.col.each(this.add); $('#forum_subscribe').attr('action', gmAPI.subscribe); $(this.el).show(); } }); var app = new Forum(); }); this.test('prettyPrint', function() { prettyPrint(); }); $('#version').text(this.version); }, 'redirect': function(url) { alert('This page is deprecated. Please update your URL. Redirecting to new page.'); window.location = url; }, 'col': [], 'tests': [], 'test': function(a, b) { if ( window[a] ) { b(); } }, 'add': function(a, b) { if (b) { this.col[a] = b; } else { this.col.push(a); } return this; }, 'load': function(a) { var self = this; if (a) { self.col[a](); } else { $.each(self.col, function(i,d) { try { d(); } catch (err) { alert(self.exception); } }); } }, 'timeStart': function(key, desc) { this.tests[key] = { 'start': new Date().getTime(), 'desc': desc }; }, 'timeEnd': function(key) { this.tests[key].elapsed = new Date().getTime(); }, 'report': function(id) { var i = 1; for ( var k in this.tests ) { var t = this.tests[k]; $(id).append('
' + (t.elapsed - t.start) + ' ms

Benchmark case ' + i + '

' + t.desc + '

'); i++; }; } }; gmAPI.init();