User:Ohconfucius/script/tometricunits

From Wikipedia, the free encyclopedia

Objectives[edit]

Main objectives, as applied to mainspace articles, are as follows:

  1. ensure the most commonly used "bare" measures, notably imperial, have corrresponding SI units of measure in accordance with WP:MOS.

General principles[edit]

The rationale and principles applied are as follows:

  • insert {{convert}} template to the following numerical non-metric units of measure (for ranges and individual measures)
    • inches, feet, yards, miles
    • pounds
    • feet per second, miles per hour
    • acres, square feet, square yards, square miles

Installing the script[edit]

  1. Open your common.js in edit mode (alternatively, go to your user page and append "/common.js" to the end of the URL and open the page in edit mode).
    • If you prefer to load this only on a specific skin, such as monobook, open your monobook.js in edit mode.
    • If you make a straight copy of this script, instead of "importing" it, you may not benefit from the enhancements and bug-fixes that are made from time to time. In the latter case, you may choose to watchlist this page so you will know when to update your copy for modifications to this script.
  2. Copy the following code onto the JavaScript page you have chosen in the previous step:
    importScript('User:Ohconfucius/script/tometricunits.js'); // [[User:Ohconfucius/script/tometricunits.js]]
    
  3. Save the page and (re-)load it – refresh the cache by following the instructions at the top of your JavaScript page.
  4. Bookmark the script page. This will be your cue to purge the cache on your browser for any updates to take effect.

Actions and test[edit]

Link to script code: User:Ohconfucius/script/tometricunits.js

Speed of script execution may vary depending on browser.

Should the script stall when working on large articles, press <continue> on the pop-up menu – once is usually sufficient.

Known limitations or contraindications[edit]

  1. The following are not supported:
    • insertion of templates to convert away from metric measures
    • The list of measures is limited and is not exhaustive: PSI (pounds per square inch), FPS, nautical miles are not within the scope of the script.
    • two-dimensional measures as given by x times y (e.g. 8 ft x 6 ft), x by y (e.g. 8 ft by 6 ft);
    • three-dimensional measures as given by x times y times z, (e.g. 3 ft x 5 ft x 7 ft), x by y by z, (e.g. 2 ft by 8 ft x è ft),
  2. Some situations may give rise to false positives where simply the last unit is tagged with a convert template. This will be the case for the two- and three-dimensional measures
  3. Where manual converted measures are already in place in an article, the script may cause appearance of an additional converted unit such as 11 lb (5kg) becoming {{convert|11|lb|kg}} (5kg)
  4. There are no protected strings. Anything in the open edit window is susceptible to change. Be aware of false positives with article names, titles, file names.

Disclaimer[edit]

Users are expected to exercise careful judgement in the context of each article in which they run this script. Use at your own risk and make sure you check the edit changes before you save. It's not my fault if someone misuses this script.

Test page[edit]

See also[edit]