|
1 | 1 | xtools.autoedits = {}; |
2 | 2 |
|
3 | 3 | $(function () { |
4 | | - if (!$('body.autoedits').length) { |
5 | | - return; |
6 | | - } |
| 4 | + if (!$('body.autoedits').length) { |
| 5 | + return; |
| 6 | + } |
7 | 7 |
|
8 | | - var $contributionsContainer = $('.contributions-container'), |
9 | | - $toolSelector = $('#tool_selector'); |
| 8 | + var $contributionsContainer = $('.contributions-container'), |
| 9 | + $toolSelector = $('#tool_selector'); |
10 | 10 |
|
11 | | - // For the form page. |
12 | | - if ($toolSelector.length) { |
13 | | - xtools.autoedits.fetchTools = function (project) { |
14 | | - $toolSelector.prop('disabled', true); |
15 | | - $.get('/api/project/automated_tools/' + project).done(function (tools) { |
16 | | - if (tools.error) { |
17 | | - $toolSelector.prop('disabled', false); |
18 | | - return; // Abort, project was invalid. |
19 | | - } |
| 11 | + // For the form page. |
| 12 | + if ($toolSelector.length) { |
| 13 | + xtools.autoedits.fetchTools = function (project) { |
| 14 | + $toolSelector.prop('disabled', true); |
| 15 | + $.get('/api/project/automated_tools/' + project).done(function (tools) { |
| 16 | + if (tools.error) { |
| 17 | + $toolSelector.prop('disabled', false); |
| 18 | + return; // Abort, project was invalid. |
| 19 | + } |
20 | 20 |
|
21 | | - // These aren't tools, just metadata in the API response. |
22 | | - delete tools.project; |
23 | | - delete tools.elapsed_time; |
| 21 | + // These aren't tools, just metadata in the API response. |
| 22 | + delete tools.project; |
| 23 | + delete tools.elapsed_time; |
24 | 24 |
|
25 | | - $toolSelector.html( |
26 | | - '<option value="none">' + $.i18n('none') + '</option>' + |
27 | | - '<option value="all">' + $.i18n('all') + '</option>' |
28 | | - ); |
29 | | - Object.keys(tools).forEach(function (tool) { |
30 | | - $toolSelector.append( |
31 | | - '<option value="' + tool + '">' + (tools[tool].label || tool) + '</option>' |
32 | | - ); |
33 | | - }); |
| 25 | + $toolSelector.html( |
| 26 | + '<option value="none">' + $.i18n('none') + '</option>' + |
| 27 | + '<option value="all">' + $.i18n('all') + '</option>' |
| 28 | + ); |
| 29 | + Object.keys(tools).forEach(function (tool) { |
| 30 | + $toolSelector.append( |
| 31 | + '<option value="' + tool + '">' + (tools[tool].label || tool) + '</option>' |
| 32 | + ); |
| 33 | + }); |
34 | 34 |
|
35 | | - $toolSelector.prop('disabled', false); |
36 | | - }); |
37 | | - }; |
| 35 | + $toolSelector.prop('disabled', false); |
| 36 | + }); |
| 37 | + }; |
38 | 38 |
|
39 | | - $(document).ready(function () { |
40 | | - $('#project_input').on('change.autoedits', function () { |
41 | | - xtools.autoedits.fetchTools($('#project_input').val()); |
42 | | - }); |
43 | | - }); |
| 39 | + $(document).ready(function () { |
| 40 | + $('#project_input').on('change.autoedits', function () { |
| 41 | + xtools.autoedits.fetchTools($('#project_input').val()); |
| 42 | + }); |
| 43 | + }); |
44 | 44 |
|
45 | | - xtools.autoedits.fetchTools($('#project_input').val()); |
| 45 | + xtools.autoedits.fetchTools($('#project_input').val()); |
46 | 46 |
|
47 | | - // All the other code below only applies to result pages. |
48 | | - return; |
49 | | - } |
| 47 | + // All the other code below only applies to result pages. |
| 48 | + return; |
| 49 | + } |
50 | 50 |
|
51 | | - // For result pages only... |
| 51 | + // For result pages only... |
52 | 52 |
|
53 | | - xtools.application.setupToggleTable(window.countsByTool, window.toolsChart, 'count', function (newData) { |
54 | | - var total = 0; |
55 | | - Object.keys(newData).forEach(function (tool) { |
56 | | - total += parseInt(newData[tool].count, 10); |
57 | | - }); |
58 | | - var toolsCount = Object.keys(newData).length; |
59 | | - /** global: i18nLang */ |
60 | | - $('.tools--tools').text( |
61 | | - toolsCount.toLocaleString(i18nLang) + " " + |
62 | | - $.i18n('num-tools', toolsCount) |
63 | | - ); |
64 | | - $('.tools--count').text(total.toLocaleString(i18nLang)); |
65 | | - }); |
| 53 | + xtools.application.setupToggleTable(window.countsByTool, window.toolsChart, 'count', function (newData) { |
| 54 | + var total = 0; |
| 55 | + Object.keys(newData).forEach(function (tool) { |
| 56 | + total += parseInt(newData[tool].count, 10); |
| 57 | + }); |
| 58 | + var toolsCount = Object.keys(newData).length; |
| 59 | + /** global: i18nLang */ |
| 60 | + $('.tools--tools').text( |
| 61 | + toolsCount.toLocaleString(i18nLang) + " " + |
| 62 | + $.i18n('num-tools', toolsCount) |
| 63 | + ); |
| 64 | + $('.tools--count').text(total.toLocaleString(i18nLang)); |
| 65 | + }); |
66 | 66 |
|
67 | | - if ($contributionsContainer.length) { |
68 | | - // Load the contributions browser, or set up the listeners if it is already present. |
69 | | - var initFunc = $('.contributions-table').length ? 'setupContributionsNavListeners' : 'loadContributions'; |
70 | | - xtools.application[initFunc]( |
71 | | - function (params) { |
72 | | - return `${params.target}-contributions/${params.project}/${params.username}` + |
73 | | - `/${params.namespace}/${params.start}/${params.end}`; |
74 | | - }, |
75 | | - $contributionsContainer.data('target') |
76 | | - ); |
77 | | - } |
| 67 | + if ($contributionsContainer.length) { |
| 68 | + // Load the contributions browser, or set up the listeners if it is already present. |
| 69 | + var initFunc = $('.contributions-table').length ? 'setupContributionsNavListeners' : 'loadContributions'; |
| 70 | + xtools.application[initFunc]( |
| 71 | + function (params) { |
| 72 | + return `${params.target}-contributions/${params.project}/${params.username}` + |
| 73 | + `/${params.namespace}/${params.start}/${params.end}`; |
| 74 | + }, |
| 75 | + $contributionsContainer.data('target') |
| 76 | + ); |
| 77 | + } |
78 | 78 | }); |
0 commit comments