User:V111P/js/Sum numbers

< User:V111P‎ | js

Sum numbers is a user script for adding up numbers you selected on the page with the mouse. You should be able to select a row in a table to get the row totals in all recent browsers. However, only in Firefox you can select multiple text ranges, and therefore multiple numbers, by holding down Ctrl while selecting text, and you can select a table column by holding Ctrl while dragging the mouse across the cells in the column.

The script does not work in the text box where you edit the wiki source of the article, only outside of it. If you are source-editing an article, you can click the Show preview button to get the numbers on the page and then use this tool to add them.

To use this tool, first install it, as described below. Then on any page, click the Sum numbers link in the Tools section in the sidebar. Buttons will appear after level 1 and level 2 headings and before and after tables. Select some numbers on the page as explained in the introduction and click any of the + buttons on the page, the added numbers and their sum will appear under the pressed button, along with any strings that were not recognized as valid numbers and were ignored when calculating the sum.

See also my other user scripts. Thank you.

Installation edit

For the English Wikipedia, add this code to your common.js (or vecor.js, or monobook.js, whichever you are using) file:

importScript('User:V111P/js/SumNumbers.js'); // [[User:V111P/js/SumNumbers.js]]

In other Wikipedias:

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:V111P/js/SumNumbers.js'
			+ '&action=raw&ctype=text/javascript');

Note that currently the decimal marker is assumed to be comma (,) for all Wikipedias other than the English Wikipedia, where the decimal marker is the period (.) and all commas are ignored. If you need to change that, let me know, or just set the global string variable decimalMark.

See also edit