Skip to content

Commit 58e1835

Browse files
committed
Address eslint across all JS files
Previously it was just looking at war/
1 parent 89cf977 commit 58e1835

File tree

37 files changed

+346
-227
lines changed

37 files changed

+346
-227
lines changed

core/src/main/resources/hudson/PluginManager/_table.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
403403
}
404404
}
405405

406-
for (var i = 0; i < pluginTRs.length; i++) {
407-
initPluginRowHandling(pluginTRs[i]);
406+
for (let j = 0; j < pluginTRs.length; j++) {
407+
initPluginRowHandling(pluginTRs[j]);
408408
}
409409

410410
setEnableWidgetStates();

core/src/main/resources/hudson/model/BuildTimelineWidget/build-timeline-widget.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global Timeline */
2+
13
var targetDiv = document.querySelector('#build-timeline-div');
24
var tz = targetDiv.getAttribute('data-hour-local-timezone');
35
var tl = null;
@@ -96,7 +98,7 @@ function doLoad() {
9698
window.onresize = doResize;
9799
}
98100

99-
};
101+
}
100102

101103
if (window.addEventListener) {
102104
window.addEventListener("load", doLoad, false);
@@ -108,13 +110,10 @@ if (window.addEventListener) {
108110

109111
//add resize handle
110112
(function () {
111-
var Dom = YAHOO.util.Dom,
112-
Event = YAHOO.util.Event;
113-
114113
var resize = new YAHOO.util.Resize('resizeContainer', {
115114
handles: 'b',
116115
minHeight: 300 // this should be the same as the height of the container div,
117-
// to fix a issue when it's resized to be smaller than the original height
116+
// to fix an issue when it's resized to be smaller than the original height
118117
});
119118

120119
//update timeline after resizing

core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Public method to be called by progressiveRendering's callback
33
*/
4-
function buildTimeTrend_displayBuilds(data) {
4+
window.buildTimeTrend_displayBuilds = function(data) {
55
var p = document.getElementById('trend');
66
var isDistributedBuildsEnabled = 'true' === p.getAttribute("data-is-distributed-build-enabled");
77
var rootURL = document.head.getAttribute('data-rooturl');
8-
8+
99
for (var x = 0; data.length > x; x++) {
1010
var e = data[x];
1111
var tr = new Element('tr');
@@ -91,4 +91,4 @@ function generateSVGIcon(iconName, iconSizeClass) {
9191
insert(svg2);
9292

9393
return span;
94-
}
94+
}

core/src/main/resources/hudson/model/UpdateCenter/update-center.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function submitScheduleForm(el) {
1+
window.submitScheduleForm = function(el) {
22
var form = document.getElementById("scheduleRestart");
33
form.action = el.checked ? "safeRestart" : "cancelRestart";
44
crumb.appendToForm(form);
@@ -35,4 +35,4 @@ function refresh() {
3535
}, 5000);
3636
}
3737
window.scrollTo(0,10000);
38-
refresh();
38+
refresh();

core/src/main/resources/hudson/model/View/AsynchPeople/people-resources.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function display(data) {
1+
window.display = function(data) {
22
var p = document.getElementById('people');
33
p.show();
44
var rootURL = document.head.getAttribute('data-rooturl');

core/src/main/resources/hudson/views/BuildButtonColumn/icon.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Behaviour.specify(".build-button-column-icon-reference-holder", 'build-button-co
44
var id = e.getAttribute('data-id');
55
var icon = document.getElementById(id);
66

7-
icon.onclick = function(el) {
7+
icon.onclick = function() {
88
new Ajax.Request(url);
99
hoverNotification(message, this, -100);
1010
return false;

core/src/main/resources/jenkins/diagnostics/URICheckEncodingMonitor/adjunct.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Behaviour.specify('#URICheckEncodingMonitor-message', 'URICheckEncodingMonitor', 0, function(element) {
22
var url = element.getAttribute('data-url');
33
var params = {value : '\u57f7\u4e8b'};
4-
var checkAjax = new Ajax.Updater(
4+
new Ajax.Updater(
55
'URICheckEncodingMonitor-message', url,
66
{
77
method: 'get', parameters: params

core/src/main/resources/jenkins/formelementpath/form-element-path.js

+45-34
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ document.addEventListener("DOMContentLoaded", function(){
1616
function addProperty(parent, name, value) {
1717
name = shortenName(name);
1818
if (parent[name] != null) {
19-
if (parent[name].push == null) // is this array?
20-
parent[name] = [parent[name]];
19+
// is this array?
20+
if (parent[name].push == null) {
21+
parent[name] = [parent[name]];
22+
}
2123
parent[name].push(value);
2224
} else {
2325
parent[name] = value;
@@ -28,7 +30,9 @@ document.addEventListener("DOMContentLoaded", function(){
2830
// then return the corresponding object in the map
2931
function findParent(e) {
3032
var p = findFormParent(e, form);
31-
if (p == null) return {};
33+
if (p == null) {
34+
return {};
35+
}
3236

3337
var m = p.formDom;
3438
if (m == null) {
@@ -40,24 +44,24 @@ document.addEventListener("DOMContentLoaded", function(){
4044
return m;
4145
}
4246

43-
var jsonElement = null;
44-
45-
for (var i = 0; i < form.elements.length; i++) {
47+
for (let i = 0; i < form.elements.length; i++) {
4648
var e = form.elements[i];
4749
if (e.name == "json") {
48-
jsonElement = e;
4950
continue;
5051
}
51-
if (e.tagName == "FIELDSET")
52+
if (e.tagName == "FIELDSET") {
5253
continue;
54+
}
5355
if (e.tagName == "SELECT" && e.multiple) {
5456
addProperty(findParent(e), e.name, e);
5557
continue;
5658
}
5759

5860
var p;
5961
var type = e.getAttribute("type");
60-
if (type == null) type = "";
62+
if (type == null) {
63+
type = "";
64+
}
6165
switch (type.toLowerCase()) {
6266
case "button":
6367
var element
@@ -124,37 +128,43 @@ document.addEventListener("DOMContentLoaded", function(){
124128
function annotate(e, path) {
125129
e.setAttribute("path", path);
126130
var o = e.formDom || {};
127-
for (var key in o) {
128-
var v = o[key];
129131

130-
function child(v, i) {
131-
var suffix = null;
132-
var newKey = key;
133-
if (v.parentNode.className && v.parentNode.className.indexOf("one-each") > -1 && v.parentNode.className.indexOf("honor-order") > -1) {
134-
suffix = v.getAttribute("descriptorId").split(".").pop()
135-
} else if (v.getAttribute("type") == "radio") {
136-
suffix = v.value
137-
while (newKey.substring(0, 8) == 'removeme')
138-
newKey = newKey.substring(newKey.indexOf('_', 8) + 1);
139-
} else if (v.getAttribute("suffix") != null) {
140-
suffix = v.getAttribute("suffix")
141-
} else {
142-
if (i > 0)
143-
suffix = i;
144-
}
145-
if (suffix == null) suffix = "";
146-
else suffix = '[' + suffix + ']';
132+
function child(v, i, key) {
133+
var suffix = null;
134+
var newKey = key;
135+
if (v.parentNode.className && v.parentNode.className.indexOf("one-each") > -1 && v.parentNode.className.indexOf("honor-order") > -1) {
136+
suffix = v.getAttribute("descriptorId").split(".").pop()
137+
} else if (v.getAttribute("type") == "radio") {
138+
suffix = v.value
139+
while (newKey.substring(0, 8) == "removeme") {
140+
newKey = newKey.substring(newKey.indexOf("_", 8) + 1);
141+
}
142+
} else if (v.getAttribute("suffix") != null) {
143+
suffix = v.getAttribute("suffix")
144+
} else {
145+
if (i > 0) {
146+
suffix = i;
147+
}
148+
}
149+
if (suffix == null) {
150+
suffix = "";
151+
} else {
152+
suffix = "[" + suffix + "]";
153+
}
147154

148-
annotate(v, path + "/" + newKey + suffix);
149-
}
155+
annotate(v, path + "/" + newKey + suffix);
156+
}
157+
158+
for (let key in o) {
159+
var v = o[key];
150160

151161
if (v instanceof Array) {
152162
var i = 0;
153163
v.forEach(function (v) {
154-
child(v, i++)
164+
child(v, i++, key)
155165
})
156166
} else {
157-
child(v, 0)
167+
child(v, 0, key)
158168
}
159169
}
160170

@@ -163,8 +173,9 @@ document.addEventListener("DOMContentLoaded", function(){
163173
annotate(form, "");
164174

165175
// clean up
166-
for (i = 0; i < doms.length; i++)
167-
doms[i].formDom = null;
176+
for (let i = 0; i < doms.length; i++) {
177+
doms[i].formDom = null;
178+
}
168179

169180
return true;
170181
}

core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/resources.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
function initializeAmMonitor(amMonitorRoot, options) {
33
var button = amMonitorRoot.querySelector('.am-button');
44
var amList = amMonitorRoot.querySelector('.am-list');
5-
if (button === null || amList === null) return null;
5+
if (button === null || amList === null) {
6+
return null;
7+
}
68

79
var url = button.getAttribute('data-href');
810

@@ -25,7 +27,9 @@
2527
}
2628

2729
function show() {
28-
if (options.closeAll) options.closeAll();
30+
if (options.closeAll) {
31+
options.closeAll();
32+
}
2933

3034
new Ajax.Request(url, {
3135
method: "GET",

core/src/main/resources/jenkins/security/ApiTokenProperty/resources.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,38 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
function revokeToken(anchorRevoke){
24+
window.revokeToken = function(anchorRevoke){
2525
var repeatedChunk = anchorRevoke.up('.repeated-chunk');
2626
var tokenList = repeatedChunk.up('.token-list');
2727
var confirmMessage = anchorRevoke.getAttribute('data-confirm');
2828
var targetUrl = anchorRevoke.getAttribute('data-target-url');
29-
29+
3030
var inputUuid = repeatedChunk.querySelector('input.token-uuid-input');
3131
var tokenUuid = inputUuid.value;
3232

3333
if(confirm(confirmMessage)){
3434
new Ajax.Request(targetUrl, {
3535
method: "post",
3636
parameters: {tokenUuid: tokenUuid},
37-
onSuccess: function(rsp,_) {
37+
onSuccess: function() {
3838
if(repeatedChunk.querySelectorAll('.legacy-token').length > 0){
3939
// we are revoking the legacy token
4040
var messageIfLegacyRevoked = anchorRevoke.getAttribute('data-message-if-legacy-revoked');
41-
41+
4242
var legacyInput = document.getElementById('apiToken');
4343
legacyInput.value = messageIfLegacyRevoked;
4444
}
4545
repeatedChunk.remove();
4646
adjustTokenEmptyListMessage(tokenList);
47-
47+
4848
}
4949
});
5050
}
5151

5252
return false;
5353
}
5454

55-
function saveApiToken(button){
55+
window.saveApiToken = function(button){
5656
if(button.hasClassName('request-pending')){
5757
// avoid multiple requests to be sent if user is clicking multiple times
5858
return;
@@ -63,11 +63,11 @@ function saveApiToken(button){
6363
var tokenList = repeatedChunk.up('.token-list');
6464
var nameInput = repeatedChunk.querySelector('[name="tokenName"]');
6565
var tokenName = nameInput.value;
66-
66+
6767
new Ajax.Request(targetUrl, {
6868
method: "post",
6969
parameters: {"newTokenName": tokenName},
70-
onSuccess: function(rsp,_) {
70+
onSuccess: function(rsp) {
7171
var json = rsp.responseJSON;
7272
var errorSpan = repeatedChunk.querySelector('.error');
7373
if(json.status === 'error'){
@@ -77,11 +77,11 @@ function saveApiToken(button){
7777
button.removeClassName('request-pending');
7878
}else{
7979
errorSpan.removeClassName('visible');
80-
80+
8181
var tokenName = json.data.tokenName;
8282
// in case the name was empty, the application will propose a default one
8383
nameInput.value = tokenName;
84-
84+
8585
var tokenValue = json.data.tokenValue;
8686
var tokenValueSpan = repeatedChunk.querySelector('.new-token-value');
8787
tokenValueSpan.innerText = tokenValue;
@@ -101,15 +101,15 @@ function saveApiToken(button){
101101

102102
// we do not want to allow user to create twice a token using same name by mistake
103103
button.remove();
104-
104+
105105
var revokeButton = repeatedChunk.querySelector('.token-revoke');
106106
revokeButton.removeClassName('hidden-button');
107-
107+
108108
var cancelButton = repeatedChunk.querySelector('.token-cancel');
109109
cancelButton.addClassName('hidden-button')
110-
110+
111111
repeatedChunk.addClassName('token-list-fresh-item');
112-
112+
113113
adjustTokenEmptyListMessage(tokenList);
114114
}
115115
}

0 commit comments

Comments
 (0)