Krinkle has submitted this change and it was merged.
Change subject: JSHint: Add config file and enforce it
......................................................................
JSHint: Add config file and enforce it
Change-Id: I5c270056f44d7da42009bddf33a9687bc9ae7233
---
A .jshintignore
A .jshintrc
M org/wikimedia/integration/zuul/status.js
3 files changed, 87 insertions(+), 54 deletions(-)
Approvals:
Krinkle: Verified; Looks good to me, approved
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..57f0cf1
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,4 @@
+shared/bootstrap
+org/mediawiki/integration/bootstrap
+org/wikimedia/integration/bootstrap
+org/wikimedia/doc/bootstrap
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..7367cd3
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,29 @@
+{
+ "predef": [
+ "jQuery"
+ ],
+
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "forin": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": true,
+ "nonew": true,
+ "quotmark": "single",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+ "trailing": true,
+
+ "browser": true,
+
+ "nomen": true,
+ "onevar": true,
+ "white": true
+}
diff --git a/org/wikimedia/integration/zuul/status.js
b/org/wikimedia/integration/zuul/status.js
index d7009a1..79c22a2 100644
--- a/org/wikimedia/integration/zuul/status.js
+++ b/org/wikimedia/integration/zuul/status.js
@@ -17,34 +17,34 @@
// under the License.
/*jshint eqnull:true */
-( function ( $ ) {
+(function ($) {
var updateCount = 0,
enableStatusUpdates = true;
- function format_pipeline(data) {
- var html = '<div class="pipeline"><h3 class="subhead">'+
- data.name+'</h3>';
+ function formatPipeline(data) {
+ var html = '<div class="pipeline"><h3 class="subhead">' +
+ data.name + '</h3>';
if (data.description != null) {
- html += '<p>'+data.description+'</p>';
+ html += '<p>' + data.description + '</p>';
}
- $.each(data.change_queues, function(change_queue_i, change_queue) {
- $.each(change_queue.heads, function(head_i, head) {
- if (data.change_queues.length > 1 && head_i === 0) {
+ $.each(data.change_queues, function (queueNum, changeQueue) {
+ $.each(changeQueue.heads, function (headNum, head) {
+ if (data.change_queues.length > 1 && headNum === 0) {
html += '<div> Change queue: ';
- var name = change_queue.name;
+ var name = changeQueue.name;
html += '<a title="' + name + '">';
if (name.length > 32) {
- name = name.substr(0,32) + '...';
+ name = name.substr(0, 32) + '...';
}
html += name + '</a></div>';
}
- $.each(head, function(change_i, change) {
- if (change_i > 0) {
+ $.each(head, function (changeNum, change) {
+ if (changeNum > 0) {
html += '<div class="arrow">↑</div>';
}
- html += format_change(change);
+ html += formatChange(change);
});
});
});
@@ -53,18 +53,18 @@
return html;
}
- function format_change(change) {
- var html = '<div class="change"><div class="header">';
+ function formatChange(change) {
+ var html = '<div class="change"><div class="header">',
+ id = change.id,
+ url = change.url;
- html += '<span class="project">'+change.project+'</span>';
- var id = change.id;
- var url = change.url;
- if (id.length == 40) {
- id = id.substr(0,7);
+ html += '<span class="project">' + change.project + '</span>';
+ if (id.length === 40) {
+ id = id.substr(0, 7);
}
html += '<span class="changeid">';
if (url != null) {
- html += '<a href="'+url+'">';
+ html += '<a href="' + url + '">';
}
html += id;
if (url != null) {
@@ -72,33 +72,33 @@
}
html += '</span></div><div class="jobs">';
- $.each(change.jobs, function(i, job) {
- var result = job.result;
- var result_class = 'result';
+ $.each(change.jobs, function (i, job) {
+ var result = job.result,
+ resultClass = 'result';
if (result == null) {
if (job.url != null) {
result = 'in progress';
} else {
result = 'queued';
}
- } else if (result == 'SUCCESS') {
- result_class += ' result_success';
- } else if (result == 'FAILURE') {
- result_class += ' result_failure';
- } else if (result == 'LOST') {
- result_class += ' result_unstable';
- } else if (result == 'UNSTABLE') {
- result_class += ' result_unstable';
+ } else if (result === 'SUCCESS') {
+ resultClass += ' result_success';
+ } else if (result === 'FAILURE') {
+ resultClass += ' result_failure';
+ } else if (result === 'LOST') {
+ resultClass += ' result_unstable';
+ } else if (result === 'UNSTABLE') {
+ resultClass += ' result_unstable';
}
html += '<span class="job">';
if (job.url != null) {
- html += '<a href="'+job.url+'">';
+ html += '<a href="' + job.url + '">';
}
html += job.name;
if (job.url != null) {
html += '</a>';
}
- html += ': <span class="'+result_class+'">'+result+'</span>';
+ html += ': <span class="' + resultClass + '">' + result +
'</span>';
if (job.voting === false) {
html += ' (non-voting)';
}
@@ -109,9 +109,9 @@
return html;
}
- function update_timeout() {
+ function updateTimeout() {
if (!enableStatusUpdates) {
- setTimeout(update_timeout, 5000);
+ setTimeout(updateTimeout, 5000);
return;
}
@@ -121,15 +121,15 @@
/* Only update graphs every minute */
if (updateCount > 11) {
updateCount = 0;
- update_graphs();
+ updateGraphs();
}
- setTimeout(update_timeout, 5000);
+ setTimeout(updateTimeout, 5000);
}
function update() {
- $.getJSON('/zuul/status.json', function(data) {
+ $.getJSON('/zuul/status.json', function (data) {
data = data || {};
var html = '';
if ('message' in data) {
@@ -144,48 +144,48 @@
html += '<br style="clear:both"/>';
- $.each(data.pipelines, function(i, pipeline) {
- html = html + format_pipeline(pipeline);
+ $.each(data.pipelines, function (i, pipeline) {
+ html = html + formatPipeline(pipeline);
});
html += '<br style="clear:both"/>';
$('#pipeline-container').html(html);
$('#trigger_event_queue_length').text(
- ( data.trigger_event_queue || [] ).length
+ (data.trigger_event_queue || []).length
);
$('#result_event_queue_length').text(
- ( data.result_event_queue || [] ).length
+ (data.result_event_queue || []).length
);
});
}
- function update_graphs() {
- $('.graph').each(function(i, img) {
- var newimg = new Image();
- var parts = img.src.split('#');
+ function updateGraphs() {
+ $('.graph').each(function (i, img) {
+ var newimg = new Image(),
+ parts = img.src.split('#');
newimg.src = parts[0] + '#' + new Date().getTime();
- $(newimg).load(function (x) {
+ $(newimg).load(function () {
img.src = newimg.src;
});
});
}
- $(document).ready(function() {
- update_timeout();
+ $(document).ready(function () {
+ updateTimeout();
$(document).on({
- 'show.visibility': function() {
+ 'show.visibility': function () {
enableStatusUpdates = true;
update();
- update_graphs();
+ updateGraphs();
},
- 'hide.visibility': function() {
+ 'hide.visibility': function () {
enableStatusUpdates = false;
}
});
});
-}( jQuery ) );
+}(jQuery));
--
To view, visit https://gerrit.wikimedia.org/r/57898
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5c270056f44d7da42009bddf33a9687bc9ae7233
Gerrit-PatchSet: 1
Gerrit-Project: integration/docroot
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits