Skip to content

Commit

Permalink
Merge pull request #39 from ograycode/master
Browse files Browse the repository at this point in the history
Formatted application code to follow JSLint
  • Loading branch information
ograycode committed Jun 23, 2013
2 parents 19abfbc + 7731d89 commit 7a4db7e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
38 changes: 21 additions & 17 deletions resources/js/main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
'use strict';
/* global Handlebars: false, google: false, $ : false */

/**
* Sets up the application
*/
var jb = function () {
jb.simpleRender('#header-template', '#header', {applicationName: jb._APP_NAME}, 'html');
jb.feed.get(jb.feed._OGG_FEED, function(results){
jb.feed.render(results);
});
'use strict';
jb.simpleRender('#header-template', '#header', {applicationName: jb.APP_NAME}, 'html');
jb.feed.get(jb.feed.OGG_FEED, function(results) {
jb.feed.render(results);
});
};

//The application's name
jb._APP_NAME = 'Jupiter Broadcasting Community Edition';
jb.APP_NAME = 'Jupiter Broadcasting Community Edition';

/**
* Renders the template on the page
Expand All @@ -21,17 +22,19 @@ jb._APP_NAME = 'Jupiter Broadcasting Community Edition';
* @method: The way to render, e.g. 'html' or 'append'
*/
jb.simpleRender = function(template, target, object, method) {
var source = $(template).html();
var template = Handlebars.compile(source);
$(target)[method](template(object));
'use strict';
var source, compiledSource;
source = $(template).html();
compiledSource = Handlebars.compile(source);
$(target)[method](compiledSource(object));
};


//Feed namespace
jb.feed = {};

//Ogg feed url
jb.feed._OGG_FEED = 'http://feeds.feedburner.com/AllJupiterBroadcastingShowsOgg';
jb.feed.OGG_FEED = 'http://feeds.feedburner.com/AllJupiterBroadcastingShowsOgg';

//Default number of feed entries
jb.feed.numEntries = 10;
Expand All @@ -42,16 +45,17 @@ jb.feed.numEntries = 10;
* @callback: a callback function for the feed -- function(results)
*/
jb.feed.get = function(url, callback) {
var feed;
feed = new google.feeds.Feed(url);
feed.setNumEntries(this.numEntries);
feed.load(callback);
}
'use strict';
var feed = new google.feeds.Feed(url);
feed.setNumEntries(this.numEntries);
feed.load(callback);
};

/**
* Renders the feed list
* @feed: The feed to render
*/
jb.feed.render = function(feed) {
jb.simpleRender('#feedlist-template', '#body', feed, 'html');
}
'use strict';
jb.simpleRender('#feedlist-template', '#body', feed, 'html');
};
6 changes: 3 additions & 3 deletions tests/spec/JbSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ describe("JB", function(){

it("Should set the header upon first launch", function() {
var applicationName = $('#header > center > h1').text()
expect(applicationName).toBe(jb._APP_NAME);
expect(applicationName).toBe(jb.APP_NAME);
});

describe("The rss feed.", function(){
it("Should not return an error", function() {
jb.feed.get(jb.feed._OGG_FEED, function(results){
jb.feed.get(jb.feed.OGG_FEED, function(results){
expect(results.status.code).toBe(200);
});
});
it("Should contain 10 results.", function(){
jb.feed.get(jb.feed._OGG_FEED, function(results){
jb.feed.get(jb.feed.OGG_FEED, function(results){
expect(results.feed.entries.length).toBe(10);
});
});
Expand Down

0 comments on commit 7a4db7e

Please sign in to comment.