Skip to content

Commit

Permalink
Address eslint across all JS files
Browse files Browse the repository at this point in the history
Previously it was just looking at war/
  • Loading branch information
timja committed Aug 25, 2022
1 parent 16f0d3b commit f033a61
Show file tree
Hide file tree
Showing 37 changed files with 346 additions and 227 deletions.
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/PluginManager/_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
}
}

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

setEnableWidgetStates();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global Timeline */

var targetDiv = document.querySelector('#build-timeline-div');
var tz = targetDiv.getAttribute('data-hour-local-timezone');
var tl = null;
Expand Down Expand Up @@ -96,7 +98,7 @@ function doLoad() {
window.onresize = doResize;
}

};
}

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

//add resize handle
(function () {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;

var resize = new YAHOO.util.Resize('resizeContainer', {
handles: 'b',
minHeight: 300 // this should be the same as the height of the container div,
// to fix a issue when it's resized to be smaller than the original height
// to fix an issue when it's resized to be smaller than the original height
});

//update timeline after resizing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Public method to be called by progressiveRendering's callback
*/
function buildTimeTrend_displayBuilds(data) {
window.buildTimeTrend_displayBuilds = function(data) {
var p = document.getElementById('trend');
var isDistributedBuildsEnabled = 'true' === p.getAttribute("data-is-distributed-build-enabled");
var rootURL = document.head.getAttribute('data-rooturl');

for (var x = 0; data.length > x; x++) {
var e = data[x];
var tr = new Element('tr');
Expand Down Expand Up @@ -91,4 +91,4 @@ function generateSVGIcon(iconName, iconSizeClass) {
insert(svg2);

return span;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function submitScheduleForm(el) {
window.submitScheduleForm = function(el) {
var form = document.getElementById("scheduleRestart");
form.action = el.checked ? "safeRestart" : "cancelRestart";
crumb.appendToForm(form);
Expand Down Expand Up @@ -35,4 +35,4 @@ function refresh() {
}, 5000);
}
window.scrollTo(0,10000);
refresh();
refresh();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function display(data) {
window.display = function(data) {
var p = document.getElementById('people');
p.show();
var rootURL = document.head.getAttribute('data-rooturl');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Behaviour.specify(".build-button-column-icon-reference-holder", 'build-button-co
var id = e.getAttribute('data-id');
var icon = document.getElementById(id);

icon.onclick = function(el) {
icon.onclick = function() {
new Ajax.Request(url);
hoverNotification(message, this, -100);
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Behaviour.specify('#URICheckEncodingMonitor-message', 'URICheckEncodingMonitor', 0, function(element) {
var url = element.getAttribute('data-url');
var params = {value : '\u57f7\u4e8b'};
var checkAjax = new Ajax.Updater(
new Ajax.Updater(
'URICheckEncodingMonitor-message', url,
{
method: 'get', parameters: params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ document.addEventListener("DOMContentLoaded", function(){
function addProperty(parent, name, value) {
name = shortenName(name);
if (parent[name] != null) {
if (parent[name].push == null) // is this array?
parent[name] = [parent[name]];
// is this array?
if (parent[name].push == null) {
parent[name] = [parent[name]];
}
parent[name].push(value);
} else {
parent[name] = value;
Expand All @@ -28,7 +30,9 @@ document.addEventListener("DOMContentLoaded", function(){
// then return the corresponding object in the map
function findParent(e) {
var p = findFormParent(e, form);
if (p == null) return {};
if (p == null) {
return {};
}

var m = p.formDom;
if (m == null) {
Expand All @@ -40,24 +44,24 @@ document.addEventListener("DOMContentLoaded", function(){
return m;
}

var jsonElement = null;

for (var i = 0; i < form.elements.length; i++) {
for (let i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if (e.name == "json") {
jsonElement = e;
continue;
}
if (e.tagName == "FIELDSET")
if (e.tagName == "FIELDSET") {
continue;
}
if (e.tagName == "SELECT" && e.multiple) {
addProperty(findParent(e), e.name, e);
continue;
}

var p;
var type = e.getAttribute("type");
if (type == null) type = "";
if (type == null) {
type = "";
}
switch (type.toLowerCase()) {
case "button":
var element
Expand Down Expand Up @@ -124,37 +128,43 @@ document.addEventListener("DOMContentLoaded", function(){
function annotate(e, path) {
e.setAttribute("path", path);
var o = e.formDom || {};
for (var key in o) {
var v = o[key];

function child(v, i) {
var suffix = null;
var newKey = key;
if (v.parentNode.className && v.parentNode.className.indexOf("one-each") > -1 && v.parentNode.className.indexOf("honor-order") > -1) {
suffix = v.getAttribute("descriptorId").split(".").pop()
} else if (v.getAttribute("type") == "radio") {
suffix = v.value
while (newKey.substring(0, 8) == 'removeme')
newKey = newKey.substring(newKey.indexOf('_', 8) + 1);
} else if (v.getAttribute("suffix") != null) {
suffix = v.getAttribute("suffix")
} else {
if (i > 0)
suffix = i;
}
if (suffix == null) suffix = "";
else suffix = '[' + suffix + ']';
function child(v, i, key) {
var suffix = null;
var newKey = key;
if (v.parentNode.className && v.parentNode.className.indexOf("one-each") > -1 && v.parentNode.className.indexOf("honor-order") > -1) {
suffix = v.getAttribute("descriptorId").split(".").pop()
} else if (v.getAttribute("type") == "radio") {
suffix = v.value
while (newKey.substring(0, 8) == "removeme") {
newKey = newKey.substring(newKey.indexOf("_", 8) + 1);
}
} else if (v.getAttribute("suffix") != null) {
suffix = v.getAttribute("suffix")
} else {
if (i > 0) {
suffix = i;
}
}
if (suffix == null) {
suffix = "";
} else {
suffix = "[" + suffix + "]";
}

annotate(v, path + "/" + newKey + suffix);
}
annotate(v, path + "/" + newKey + suffix);
}

for (let key in o) {
var v = o[key];

if (v instanceof Array) {
var i = 0;
v.forEach(function (v) {
child(v, i++)
child(v, i++, key)
})
} else {
child(v, 0)
child(v, 0, key)
}
}

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

// clean up
for (i = 0; i < doms.length; i++)
doms[i].formDom = null;
for (let i = 0; i < doms.length; i++) {
doms[i].formDom = null;
}

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
function initializeAmMonitor(amMonitorRoot, options) {
var button = amMonitorRoot.querySelector('.am-button');
var amList = amMonitorRoot.querySelector('.am-list');
if (button === null || amList === null) return null;
if (button === null || amList === null) {
return null;
}

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

Expand All @@ -25,7 +27,9 @@
}

function show() {
if (options.closeAll) options.closeAll();
if (options.closeAll) {
options.closeAll();
}

new Ajax.Request(url, {
method: "GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,38 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
function revokeToken(anchorRevoke){
window.revokeToken = function(anchorRevoke){
var repeatedChunk = anchorRevoke.up('.repeated-chunk');
var tokenList = repeatedChunk.up('.token-list');
var confirmMessage = anchorRevoke.getAttribute('data-confirm');
var targetUrl = anchorRevoke.getAttribute('data-target-url');

var inputUuid = repeatedChunk.querySelector('input.token-uuid-input');
var tokenUuid = inputUuid.value;

if(confirm(confirmMessage)){
new Ajax.Request(targetUrl, {
method: "post",
parameters: {tokenUuid: tokenUuid},
onSuccess: function(rsp,_) {
onSuccess: function() {
if(repeatedChunk.querySelectorAll('.legacy-token').length > 0){
// we are revoking the legacy token
var messageIfLegacyRevoked = anchorRevoke.getAttribute('data-message-if-legacy-revoked');

var legacyInput = document.getElementById('apiToken');
legacyInput.value = messageIfLegacyRevoked;
}
repeatedChunk.remove();
adjustTokenEmptyListMessage(tokenList);

}
});
}

return false;
}

function saveApiToken(button){
window.saveApiToken = function(button){
if(button.hasClassName('request-pending')){
// avoid multiple requests to be sent if user is clicking multiple times
return;
Expand All @@ -63,11 +63,11 @@ function saveApiToken(button){
var tokenList = repeatedChunk.up('.token-list');
var nameInput = repeatedChunk.querySelector('[name="tokenName"]');
var tokenName = nameInput.value;

new Ajax.Request(targetUrl, {
method: "post",
parameters: {"newTokenName": tokenName},
onSuccess: function(rsp,_) {
onSuccess: function(rsp) {
var json = rsp.responseJSON;
var errorSpan = repeatedChunk.querySelector('.error');
if(json.status === 'error'){
Expand All @@ -77,11 +77,11 @@ function saveApiToken(button){
button.removeClassName('request-pending');
}else{
errorSpan.removeClassName('visible');

var tokenName = json.data.tokenName;
// in case the name was empty, the application will propose a default one
nameInput.value = tokenName;

var tokenValue = json.data.tokenValue;
var tokenValueSpan = repeatedChunk.querySelector('.new-token-value');
tokenValueSpan.innerText = tokenValue;
Expand All @@ -101,15 +101,15 @@ function saveApiToken(button){

// we do not want to allow user to create twice a token using same name by mistake
button.remove();

var revokeButton = repeatedChunk.querySelector('.token-revoke');
revokeButton.removeClassName('hidden-button');

var cancelButton = repeatedChunk.querySelector('.token-cancel');
cancelButton.addClassName('hidden-button')

repeatedChunk.addClassName('token-list-fresh-item');

adjustTokenEmptyListMessage(tokenList);
}
}
Expand Down
Loading

0 comments on commit f033a61

Please sign in to comment.