Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

# Unix-style newlines with a newline ending every file
[*]
indent_style = tab
indent_size = tab
tab_width = 4
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# 4 space indentation
[*.{php,js,twig}]
# Tabs may not be valid YAML
# @see https://yaml.org/spec/1.2/spec.html#id2777534
[*.{yml,yaml}]
indent_style = space
indent_size = 4
indent_size = 2
50 changes: 25 additions & 25 deletions assets/js/adminstats.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
xtools.adminstats = {};

$(function () {
var $projectInput = $('#project_input'),
lastProject = $projectInput.val();
var $projectInput = $('#project_input'),
lastProject = $projectInput.val();

// Don't do anything if this isn't an Admin Stats page.
if ($('body.adminstats, body.patrollerstats, body.stewardstats').length === 0) {
return;
}
// Don't do anything if this isn't an Admin Stats page.
if ($('body.adminstats, body.patrollerstats, body.stewardstats').length === 0) {
return;
}

xtools.application.setupMultiSelectListeners();
xtools.application.setupMultiSelectListeners();

$('.group-selector').on('change', function () {
$('.action-selector').addClass('hidden');
$('.action-selector--' + $(this).val()).removeClass('hidden');
$('.group-selector').on('change', function () {
$('.action-selector').addClass('hidden');
$('.action-selector--' + $(this).val()).removeClass('hidden');

// Update title of form.
$('.xt-page-title--title').text($.i18n('tool-' + $(this).val() + 'stats'));
$('.xt-page-title--desc').text($.i18n('tool-' + $(this).val() + 'stats-desc'));
var title = $.i18n('tool-' + $(this).val() + 'stats') + ' - ' + $.i18n('xtools-title');
document.title = title;
history.replaceState({}, title, '/' + $(this).val() + 'stats');
// Update title of form.
$('.xt-page-title--title').text($.i18n('tool-' + $(this).val() + 'stats'));
$('.xt-page-title--desc').text($.i18n('tool-' + $(this).val() + 'stats-desc'));
var title = $.i18n('tool-' + $(this).val() + 'stats') + ' - ' + $.i18n('xtools-title');
document.title = title;
history.replaceState({}, title, '/' + $(this).val() + 'stats');

// Change project to Meta if it's Steward Stats.
if ('steward' === $(this).val()) {
lastProject = $projectInput.val();
$projectInput.val('meta.wikimedia.org');
} else {
$projectInput.val(lastProject);
}
// Change project to Meta if it's Steward Stats.
if ('steward' === $(this).val()) {
lastProject = $projectInput.val();
$projectInput.val('meta.wikimedia.org');
} else {
$projectInput.val(lastProject);
}

xtools.application.setupMultiSelectListeners();
});
xtools.application.setupMultiSelectListeners();
});
});
22 changes: 11 additions & 11 deletions assets/js/authorship.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
$(function () {
if (!$('body.authorship').length) {
return;
}
if (!$('body.authorship').length) {
return;
}

const $showSelector = $('#show_selector');
const $showSelector = $('#show_selector');

$showSelector.on('change', e => {
$('.show-option').addClass('hidden')
.find('input').prop('disabled', true);
$(`.show-option--${e.target.value}`).removeClass('hidden')
.find('input').prop('disabled', false);
});
$showSelector.on('change', e => {
$('.show-option').addClass('hidden')
.find('input').prop('disabled', true);
$(`.show - option--${e.target.value}`).removeClass('hidden')
.find('input').prop('disabled', false);
});

window.onload = () => $showSelector.trigger('change');
window.onload = () => $showSelector.trigger('change');
});
126 changes: 63 additions & 63 deletions assets/js/autoedits.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
xtools.autoedits = {};

$(function () {
if (!$('body.autoedits').length) {
return;
}
if (!$('body.autoedits').length) {
return;
}

var $contributionsContainer = $('.contributions-container'),
$toolSelector = $('#tool_selector');
var $contributionsContainer = $('.contributions-container'),
$toolSelector = $('#tool_selector');

// For the form page.
if ($toolSelector.length) {
xtools.autoedits.fetchTools = function (project) {
$toolSelector.prop('disabled', true);
$.get('/api/project/automated_tools/' + project).done(function (tools) {
if (tools.error) {
$toolSelector.prop('disabled', false);
return; // Abort, project was invalid.
}
// For the form page.
if ($toolSelector.length) {
xtools.autoedits.fetchTools = function (project) {
$toolSelector.prop('disabled', true);
$.get('/api/project/automated_tools/' + project).done(function (tools) {
if (tools.error) {
$toolSelector.prop('disabled', false);
return; // Abort, project was invalid.
}

// These aren't tools, just metadata in the API response.
delete tools.project;
delete tools.elapsed_time;
// These aren't tools, just metadata in the API response.
delete tools.project;
delete tools.elapsed_time;

$toolSelector.html(
'<option value="none">' + $.i18n('none') + '</option>' +
'<option value="all">' + $.i18n('all') + '</option>'
);
Object.keys(tools).forEach(function (tool) {
$toolSelector.append(
'<option value="' + tool + '">' + (tools[tool].label || tool) + '</option>'
);
});
$toolSelector.html(
'<option value="none">' + $.i18n('none') + '</option>' +
'<option value="all">' + $.i18n('all') + '</option>'
);
Object.keys(tools).forEach(function (tool) {
$toolSelector.append(
'<option value="' + tool + '">' + (tools[tool].label || tool) + '</option>'
);
});

$toolSelector.prop('disabled', false);
});
};
$toolSelector.prop('disabled', false);
});
};

$(document).ready(function () {
$('#project_input').on('change.autoedits', function () {
xtools.autoedits.fetchTools($('#project_input').val());
});
});
$(document).ready(function () {
$('#project_input').on('change.autoedits', function () {
xtools.autoedits.fetchTools($('#project_input').val());
});
});

xtools.autoedits.fetchTools($('#project_input').val());
xtools.autoedits.fetchTools($('#project_input').val());

// All the other code below only applies to result pages.
return;
}
// All the other code below only applies to result pages.
return;
}

// For result pages only...
// For result pages only...

xtools.application.setupToggleTable(window.countsByTool, window.toolsChart, 'count', function (newData) {
var total = 0;
Object.keys(newData).forEach(function (tool) {
total += parseInt(newData[tool].count, 10);
});
var toolsCount = Object.keys(newData).length;
/** global: i18nLang */
$('.tools--tools').text(
toolsCount.toLocaleString(i18nLang) + " " +
$.i18n('num-tools', toolsCount)
);
$('.tools--count').text(total.toLocaleString(i18nLang));
});
xtools.application.setupToggleTable(window.countsByTool, window.toolsChart, 'count', function (newData) {
var total = 0;
Object.keys(newData).forEach(function (tool) {
total += parseInt(newData[tool].count, 10);
});
var toolsCount = Object.keys(newData).length;
/** global: i18nLang */
$('.tools--tools').text(
toolsCount.toLocaleString(i18nLang) + " " +
$.i18n('num-tools', toolsCount)
);
$('.tools--count').text(total.toLocaleString(i18nLang));
});

if ($contributionsContainer.length) {
// Load the contributions browser, or set up the listeners if it is already present.
var initFunc = $('.contributions-table').length ? 'setupContributionsNavListeners' : 'loadContributions';
xtools.application[initFunc](
function (params) {
return `${params.target}-contributions/${params.project}/${params.username}` +
`/${params.namespace}/${params.start}/${params.end}`;
},
$contributionsContainer.data('target')
);
}
if ($contributionsContainer.length) {
// Load the contributions browser, or set up the listeners if it is already present.
var initFunc = $('.contributions-table').length ? 'setupContributionsNavListeners' : 'loadContributions';
xtools.application[initFunc](
function (params) {
return `${params.target} - contributions / ${params.project} / ${params.username}` +
` / ${params.namespace} / ${params.start} / ${params.end}`;
},
$contributionsContainer.data('target')
);
}
});
70 changes: 35 additions & 35 deletions assets/js/blame.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
xtools.blame = {};

$(function () {
if (!$('body.blame').length) {
return;
}
if (!$('body.blame').length) {
return;
}

if ($('.diff-empty').length === $('.diff tr').length - 1) {
$('.diff-empty').eq(0)
.text(`(${$.i18n('diff-empty').toLowerCase()})`)
.addClass('text-muted text-center')
.prop('width', '20%');
}
if ($('.diff-empty').length === $('.diff tr').length - 1) {
$('.diff-empty').eq(0)
.text(`(${$.i18n('diff-empty').toLowerCase()})`)
.addClass('text-muted text-center')
.prop('width', '20%');
}

$('.diff-addedline').each(function () {
// Escape query to make regex-safe.
const escapedQuery = xtools.blame.query.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
$('.diff-addedline').each(function () {
// Escape query to make regex-safe.
const escapedQuery = xtools.blame.query.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');

const highlightMatch = selector => {
const regex = new RegExp(`(${escapedQuery})`, 'gi');
$(selector).html(
$(selector).html().replace(regex, `<strong>$1</strong>`)
);
};
const highlightMatch = selector => {
const regex = new RegExp(`(${escapedQuery})`, 'gi');
$(selector).html(
$(selector).html().replace(regex, ` < strong > $1 < / strong > `)
);
};

if ($(this).find('.diffchange-inline').length) {
$('.diffchange-inline').each(function () {
highlightMatch(this);
});
} else {
highlightMatch(this);
}
});
if ($(this).find('.diffchange-inline').length) {
$('.diffchange-inline').each(function () {
highlightMatch(this);
});
} else {
highlightMatch(this);
}
});

// Handles the "Show" dropdown, show/hiding the associated input field accordingly.
const $showSelector = $('#show_selector');
$showSelector.on('change', e => {
$('.show-option').addClass('hidden')
.find('input').prop('disabled', true);
$(`.show-option--${e.target.value}`).removeClass('hidden')
.find('input').prop('disabled', false);
});
window.onload = () => $showSelector.trigger('change');
// Handles the "Show" dropdown, show/hiding the associated input field accordingly.
const $showSelector = $('#show_selector');
$showSelector.on('change', e => {
$('.show-option').addClass('hidden')
.find('input').prop('disabled', true);
$(`.show - option--${e.target.value}`).removeClass('hidden')
.find('input').prop('disabled', false);
});
window.onload = () => $showSelector.trigger('change');
});
Loading
Loading