Skip to content

Commit 78b9b6c

Browse files
committed
auto format and cleanup javascript
1 parent bd72b41 commit 78b9b6c

10 files changed

Lines changed: 4554 additions & 3940 deletions

File tree

openid-connect-server-webapp/src/main/webapp/resources/js/admin.js

Lines changed: 436 additions & 382 deletions
Large diffs are not rendered by default.

openid-connect-server-webapp/src/main/webapp/resources/js/blacklist.js

Lines changed: 141 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -16,63 +16,64 @@
1616
*******************************************************************************/
1717
var BlackListModel = Backbone.Model.extend({
1818
idAttribute: 'id',
19-
19+
2020
urlRoot: 'api/blacklist'
2121
});
2222

2323
var BlackListCollection = Backbone.Collection.extend({
24-
initialize: function() { },
24+
initialize: function() {
25+
},
2526

2627
url: "api/blacklist"
2728
});
2829

2930
var BlackListListView = Backbone.View.extend({
3031
tagName: 'span',
31-
32-
initialize:function(options) {
33-
this.options = options;
32+
33+
initialize: function(options) {
34+
this.options = options;
35+
},
36+
37+
load: function(callback) {
38+
if (this.collection.isFetched) {
39+
callback();
40+
return;
41+
}
42+
43+
$('#loadingbox').sheet('show');
44+
$('#loading').html('<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> ');
45+
46+
$.when(this.collection.fetchIfNeeded({
47+
success: function(e) {
48+
$('#loading-blacklist').addClass('label-success');
49+
},
50+
error: app.errorHandlerView.handleError()
51+
})).done(function() {
52+
$('#loadingbox').sheet('hide');
53+
callback();
54+
});
3455
},
3556

36-
load:function(callback) {
37-
if (this.collection.isFetched) {
38-
callback();
39-
return;
40-
}
41-
42-
$('#loadingbox').sheet('show');
43-
$('#loading').html(
44-
'<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> '
45-
);
46-
47-
$.when(this.collection.fetchIfNeeded({success:function(e) {$('#loading-blacklist').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
48-
.done(function() {
49-
$('#loadingbox').sheet('hide');
50-
callback();
51-
});
52-
},
53-
5457
events: {
55-
"click .refresh-table":"refreshTable",
56-
"click .btn-add":"addItem",
57-
"submit #add-blacklist form":"addItem"
58+
"click .refresh-table": "refreshTable",
59+
"click .btn-add": "addItem",
60+
"submit #add-blacklist form": "addItem"
5861
},
5962

60-
refreshTable:function(e) {
61-
e.preventDefault();
62-
63-
var _self = this;
64-
$('#loadingbox').sheet('show');
65-
$('#loading').html(
66-
'<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> '
67-
);
68-
69-
$.when(this.collection.fetch()).done(function() {
70-
$('#loadingbox').sheet('hide');
71-
_self.render();
72-
});
73-
},
74-
75-
togglePlaceholder:function() {
63+
refreshTable: function(e) {
64+
e.preventDefault();
65+
66+
var _self = this;
67+
$('#loadingbox').sheet('show');
68+
$('#loading').html('<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> ');
69+
70+
$.when(this.collection.fetch()).done(function() {
71+
$('#loadingbox').sheet('hide');
72+
_self.render();
73+
});
74+
},
75+
76+
togglePlaceholder: function() {
7677
if (this.collection.length > 0) {
7778
$('#blacklist-table', this.el).show();
7879
$('#blacklist-table-empty', this.el).hide();
@@ -81,136 +82,143 @@ var BlackListListView = Backbone.View.extend({
8182
$('#blacklist-table-empty', this.el).show();
8283
}
8384
},
84-
85-
render:function (eventName) {
86-
85+
86+
render: function(eventName) {
87+
8788
$(this.el).html($('#tmpl-blacklist-table').html());
88-
89+
8990
var _self = this;
9091
_.each(this.collection.models, function(blacklist) {
91-
var view = new BlackListWidgetView({model: blacklist});
92+
var view = new BlackListWidgetView({
93+
model: blacklist
94+
});
9295
view.parentView = _self;
9396
$("#blacklist-table", _self.el).append(view.render().el);
9497
}, this);
95-
98+
9699
this.togglePlaceholder();
97-
98-
$(this.el).i18n();
100+
101+
$(this.el).i18n();
99102
return this;
100103
},
101-
102-
addItem:function(e) {
103-
e.preventDefault();
104-
105-
var input_value = $("#blacklist-uri", this.el).val().trim();
106-
107-
if (input_value === "") {
108-
return;
109-
}
110-
111-
// TODO: URI/pattern validation, check against existing clients
112-
113-
var item = new BlackListModel({
114-
uri: input_value
115-
});
116-
117-
var _self = this; // closures...
118-
119-
item.save({}, {
120-
success:function() {
121-
_self.collection.add(item);
122-
_self.render();
123-
},
124-
error:app.errorHandlerView.handleError()
125-
});
104+
105+
addItem: function(e) {
106+
e.preventDefault();
107+
108+
var input_value = $("#blacklist-uri", this.el).val().trim();
109+
110+
if (input_value === "") {
111+
return;
112+
}
113+
114+
// TODO: URI/pattern validation, check against existing clients
115+
116+
var item = new BlackListModel({
117+
uri: input_value
118+
});
119+
120+
var _self = this; // closures...
121+
122+
item.save({}, {
123+
success: function() {
124+
_self.collection.add(item);
125+
_self.render();
126+
},
127+
error: app.errorHandlerView.handleError()
128+
});
126129

127130
}
128131

129132
});
130133

131134
var BlackListWidgetView = Backbone.View.extend({
132-
135+
133136
tagName: 'tr',
134-
135-
initialize:function(options) {
137+
138+
initialize: function(options) {
136139
this.options = options;
137-
140+
138141
if (!this.template) {
139142
this.template = _.template($('#tmpl-blacklist-item').html());
140143
}
141144
},
142-
143-
render:function() {
145+
146+
render: function() {
144147

145148
this.$el.html(this.template(this.model.toJSON()));
146149

147-
return this;
148-
150+
return this;
151+
149152
},
150-
151-
events:{
152-
'click .btn-delete':'deleteBlacklist'
153+
154+
events: {
155+
'click .btn-delete': 'deleteBlacklist'
153156
},
154-
155-
deleteBlacklist:function (e) {
156-
e.preventDefault();
157-
158-
if (confirm($.t("blacklist.confirm"))) {
159-
var _self = this;
160-
161-
this.model.destroy({
162-
dataType: false, processData: false,
163-
success:function () {
164-
165-
_self.$el.fadeTo("fast", 0.00, function () { //fade
166-
$(this).slideUp("fast", function () { //slide up
167-
$(this).remove(); //then remove from the DOM
168-
_self.parentView.togglePlaceholder();
169-
});
170-
});
171-
},
172-
error:app.errorHandlerView.handleError()
173-
});
174-
175-
_self.parentView.delegateEvents();
176-
}
177-
178-
return false;
179-
}
157+
158+
deleteBlacklist: function(e) {
159+
e.preventDefault();
160+
161+
if (confirm($.t("blacklist.confirm"))) {
162+
var _self = this;
163+
164+
this.model.destroy({
165+
dataType: false,
166+
processData: false,
167+
success: function() {
168+
169+
_self.$el.fadeTo("fast", 0.00, function() { // fade
170+
$(this).slideUp("fast", function() { // slide up
171+
$(this).remove(); // then remove from the DOM
172+
_self.parentView.togglePlaceholder();
173+
});
174+
});
175+
},
176+
error: app.errorHandlerView.handleError()
177+
});
178+
179+
_self.parentView.delegateEvents();
180+
}
181+
182+
return false;
183+
}
180184

181185
});
182186

187+
ui.routes.push({
188+
path: "admin/blacklist",
189+
name: "blackList",
190+
callback: function() {
183191

184-
ui.routes.push({path: "admin/blacklist", name: "blackList", callback:
185-
function() {
186-
187192
if (!isAdmin()) {
188193
this.root();
189194
return;
190195
}
191-
196+
192197
this.breadCrumbView.collection.reset();
193-
this.breadCrumbView.collection.add([
194-
{text:$.t('admin.home'), href:""},
195-
{text:$.t('admin.manage-blacklist'), href:"manage/#admin/blacklist"}
196-
]);
197-
198-
this.updateSidebar('admin/blacklist');
199-
200-
var view = new BlackListListView({collection: this.blackListList});
201-
202-
view.load(
203-
function(collection, response, options) {
204-
$('#content').html(view.render().el);
205-
setPageTitle($.t('admin.manage-blacklist'));
206-
}
207-
);
198+
this.breadCrumbView.collection.add([{
199+
text: $.t('admin.home'),
200+
href: ""
201+
}, {
202+
text: $.t('admin.manage-blacklist'),
203+
href: "manage/#admin/blacklist"
204+
}]);
205+
206+
this.updateSidebar('admin/blacklist');
207+
208+
var view = new BlackListListView({
209+
collection: this.blackListList
210+
});
211+
212+
view.load(function(collection, response, options) {
213+
$('#content').html(view.render().el);
214+
setPageTitle($.t('admin.manage-blacklist'));
215+
});
208216
}
209217

210-
});
218+
});
211219

212220
ui.templates.push('resources/template/blacklist.html');
213221

214222
ui.init.push(function(app) {
215-
app.blackListList = new BlackListCollection();
223+
app.blackListList = new BlackListCollection();
216224
});

0 commit comments

Comments
 (0)