|
1
|
|
|
$(function() { |
|
2
|
|
|
var newData; |
|
3
|
|
|
|
|
4
|
|
|
$('.tools-table').on('click', '.tools-toggle', function () { |
|
5
|
|
|
if (!newData) { |
|
6
|
|
|
// countsByTool must be cloned |
|
7
|
|
|
newData = Object.assign({}, window.countsByTool); |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
var index = $(this).data('index'), |
|
11
|
|
|
tool = $(this).data('tool'), |
|
12
|
|
|
$row = $(this).parents('tr'); |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
// must use .attr instead of .prop as sorting script will clone DOM elements |
|
15
|
|
|
if ($(this).attr('data-disabled') === 'true') { |
|
16
|
|
|
newData[tool] = window.countsByTool[tool]; |
|
17
|
|
|
window.toolsChart.data.datasets[0].data[index] = parseInt(newData[tool], 10); |
|
18
|
|
|
$(this).attr('data-disabled', 'false'); |
|
19
|
|
|
} else { |
|
20
|
|
|
delete newData[tool]; |
|
21
|
|
|
window.toolsChart.data.datasets[0].data[index] = null; |
|
22
|
|
|
$(this).attr('data-disabled', 'true'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
// gray out row in table |
|
26
|
|
|
$(this).parents('tr').toggleClass('excluded'); |
|
27
|
|
|
|
|
28
|
|
|
// change the hover icon from a 'x' to a '+' |
|
29
|
|
|
$(this).find('.glyphicon').toggleClass('glyphicon-remove').toggleClass('glyphicon-plus'); |
|
30
|
|
|
|
|
31
|
|
|
// update stats |
|
32
|
|
|
var total = 0; |
|
33
|
|
|
Object.keys(newData).forEach(function (tool) { |
|
34
|
|
|
total += parseInt(newData[tool], 10); |
|
35
|
|
|
}); |
|
36
|
|
|
var toolsCount = Object.keys(newData).length; |
|
37
|
|
|
$('.tools--tools').text( |
|
38
|
|
|
toolsCount.toLocaleString() + " " + |
|
39
|
|
|
$.i18n('num-tools', toolsCount) |
|
40
|
|
|
); |
|
41
|
|
|
$('.tools--count').text(total.toLocaleString()); |
|
42
|
|
|
|
|
43
|
|
|
window.toolsChart.update(); |
|
44
|
|
|
}); |
|
45
|
|
|
|
|
46
|
|
|
if ($('.non-auto-edits-container')[0]) { |
|
47
|
|
|
$.getJSON('/api/nonautomated_edits/en.wikipedia.org/L235/all/0').then(function (data) { |
|
48
|
|
|
$('.non-auto-edits-container').html(data.markup); |
|
49
|
|
|
}); |
|
50
|
|
|
} |
|
51
|
|
|
}); |
|
52
|
|
|
|