Skip to content

Commit

Permalink
Format all sources
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed Feb 18, 2012
1 parent 3030ec9 commit 32fd2fb
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 358 deletions.
20 changes: 10 additions & 10 deletions src/main/webapp/js/app.js
Expand Up @@ -3,16 +3,16 @@ define([
'router',
], function(Backbone, Router) {

var start = function(){
// Pass in our Router module and call it's initialize function
// Backbone.history.start({pushState: true});
// Router.navigate('');
Backbone.history.start();
console.log('EzWall started');
};
var start = function() {
// Pass in our Router module and call it's initialize function
// Backbone.history.start({pushState: true});
// Router.navigate('');
Backbone.history.start();
console.log('EzWall started');
};

return {
start: start
};
return {
start : start
};

});
98 changes: 52 additions & 46 deletions src/main/webapp/js/models/jenkins.js
Expand Up @@ -2,102 +2,108 @@ define([
'underscore',
'backbone'
], function(_, Backbone){

var Jenkins = {};

Jenkins.STATUS_OK = 'ok';
Jenkins.STATUS_KO = 'ko';
Jenkins.STATUS_INSTABLE = 'instable';
Jenkins.STATUS_NONE = 'none';

Jenkins.Model = Backbone.Model.extend({
url: function() {
url : function() {
return '%s/api/json'.replace('%s', this.get('url'));
}
});

Jenkins.EzWall = Jenkins.Model.extend({
defaults: {
url: "http://localhost:8080/ezwall",
pollInterval: 5
defaults : {
url : "http://localhost:8080/ezwall",
pollInterval : 5
}
});

Jenkins.config = new Jenkins.EzWall();

Jenkins.Job = Jenkins.Model.extend({
defaults: {
name: "My job",
status: Jenkins.STATUS_NONE,
building: false
defaults : {
name : "My job",
status : Jenkins.STATUS_NONE,
building : false
},
color_regex: /([A-Za-z]+)(_anime)?/,
parse: function(data) {

color_regex : /([A-Za-z]+)(_anime)?/,

parse : function(data) {
var m = this.color_regex.exec(data.color);

switch (m[1]) {
case 'blue':
data.status = Jenkins.STATUS_OK;
break;
case 'red':
data.status = Jenkins.STATUS_KO;
break;
case 'yellow':
data.status = Jenkins.STATUS_INSTABLE;
break;
default:
break;
case 'blue':
data.status = Jenkins.STATUS_OK;
break;
case 'red':
data.status = Jenkins.STATUS_KO;
break;
case 'yellow':
data.status = Jenkins.STATUS_INSTABLE;
break;
default:
break;
}
data.building = m[2] != undefined;
return data;
}
});

Jenkins.JobList = Backbone.Collection.extend({
model: Jenkins.Job,
fetchAll: function() {
this.each(function(job){
model : Jenkins.Job,

fetchAll : function() {
this.each(function(job) {
job.fetch()
});
}
}
});

Jenkins.View = Jenkins.Model.extend({
defaults: {
name: "All",
url: "http://localhost:8080/",
refresh: 10
defaults : {
name : "All",
url : "http://localhost:8080/",
refresh : 10
},
initialize: function() {

initialize : function() {
_.bindAll(this, 'poll', 'updateSettings');
Jenkins.config.on('change', this.updateSettings, this);
this.set({
jobs: new Jenkins.JobList()
jobs : new Jenkins.JobList()
});
this.poll();
},
parse: function(data, xhr) {
this.get('jobs').reset(data.jobs, {parse: true});

parse : function(data, xhr) {
this.get('jobs').reset(data.jobs, {
parse : true
});
delete data.jobs;
return data;
},
poll: function() {

poll : function() {
var interval = Jenkins.config.get('pollInterval');
if (interval > 0) {
this.get('jobs').fetchAll();
_.delay(this.poll, interval*1000);
_.delay(this.poll, interval * 1000);
}
},
updateSettings: function() {

updateSettings : function() {
if (Jenkins.config.hasChanged('url')) {
this.set('url', Jenkins.config.get('url') + '/..');
this.fetch();
}
}
}

});

return Jenkins;
Expand Down
125 changes: 62 additions & 63 deletions src/main/webapp/js/router.js
Expand Up @@ -6,75 +6,74 @@ define([
'views/about',
'models/jenkins'
], function(Backbone, Menu, Settings, Dashboard, About, Jenkins){
var AppRouter = Backbone.Router.extend({
routes: {
'settings': 'showSettings',
'about': 'showAbout',
// Default
'': 'showHome'
},
var AppRouter = Backbone.Router.extend({
routes : {
'settings' : 'showSettings',
'about' : 'showAbout',

initialize: function() {
console.log('AppRouter: initiliaze');

// Initialize menu
this.menu = new Menu;
this.menu.render();
this.menu.on('menu:refresh', function(){
this.view.fetch();
}, this);
this.menu.on('menu:settings', function(){
this.navigate('settings', true);
}, this);
this.menu.on('menu:about', function(){
this.navigate('about', true);
}, this);


// Inialize the jenkins View
this.view = new Jenkins.View();

// Initialize Dashboard
this.dashboard = new Dashboard.View({
model: this.view
});
this.dashboard.render();

// Bootstrap ezWall config
Jenkins.config.set('url', '.');
Jenkins.config.fetch();

// Default
'' : 'showHome'
},

console.log('AppRouter: initiliazed');
},
initialize : function() {
console.log('AppRouter: initiliaze');

showHome: function() {
console.log('AppRouter: home');
},
// Initialize menu
this.menu = new Menu;
this.menu.render();
this.menu.on('menu:refresh', function() {
this.view.fetch();
}, this);
this.menu.on('menu:settings', function() {
this.navigate('settings', true);
}, this);
this.menu.on('menu:about', function() {
this.navigate('about', true);
}, this);

showSettings: function(){
console.log('AppRouter: settings');
var popup = new Settings.Popup({
model: Jenkins.config
});
popup.render();
popup.on(Settings.CLOSE, function(){
this.navigate('', true);
}, this);
},
// Inialize the jenkins View
this.view = new Jenkins.View();

showAbout: function() {
console.log('AppRouter: about');
// Initialize Dashboard
this.dashboard = new Dashboard.View({
model : this.view
});
this.dashboard.render();

var popup = new About.Popup;
popup.render();
popup.on(About.CLOSE, function(){
this.navigate('', true);
}, this);
}

});
// Bootstrap ezWall config
Jenkins.config.set('url', '.');
Jenkins.config.fetch();

return new AppRouter();
console.log('AppRouter: initiliazed');
},

showHome : function() {
console.log('AppRouter: home');
},

showSettings : function() {
console.log('AppRouter: settings');
var popup = new Settings.Popup({
model : Jenkins.config
});
popup.render();
popup.on(Settings.CLOSE, function() {
this.navigate('', true);
}, this);
},

showAbout : function() {
console.log('AppRouter: about');

var popup = new About.Popup;
popup.render();
popup.on(About.CLOSE, function() {
this.navigate('', true);
}, this);
}

});

return new AppRouter();

});
56 changes: 28 additions & 28 deletions src/main/webapp/js/views/about.js
Expand Up @@ -5,33 +5,33 @@ define([
'text!templates/about.html'
], function($, _, Backbone, aboutTmpl){

var About = {};

About.CLOSE = 'about:close';

About.Popup = Backbone.View.extend({

render: function() {
_.bindAll(this, 'close');
$.tmpl(aboutTmpl, {}).appendTo(this.$el);
this.$el.dialog({
title:"EzWall",
modal: true,
close: this.close
});
console.log('AboutPopup: rendered');
return this;
},

close: function() {
console.log('AboutPopup: close');
this.$el.dialog('destroy');
this.remove();
this.trigger(About.CLOSE);
},

});

return About;
var About = {};

About.CLOSE = 'about:close';

About.Popup = Backbone.View.extend({

render : function() {
_.bindAll(this, 'close');
$.tmpl(aboutTmpl, {}).appendTo(this.$el);
this.$el.dialog({
title : "EzWall",
modal : true,
close : this.close
});
console.log('AboutPopup: rendered');
return this;
},

close : function() {
console.log('AboutPopup: close');
this.$el.dialog('destroy');
this.remove();
this.trigger(About.CLOSE);
},

});

return About;

});

0 comments on commit 32fd2fb

Please sign in to comment.