User:Bobblewik/monobook.js/unitformatter.js: Difference between revisions

Content deleted Content added
Bobblewik (talk | contribs)
mNo edit summary
Bobblewik (talk | contribs)
mNo edit summary
Line 33:
txt.value = txt.value.replace(/(\d) K(g|s|m|A|K|mol|cd|rad|sr|Hz|N|J|W|Pa|lm|lx|C|V|Ω|F|Wb|T|H|S|Bq|Gy|Sv|kat|M)([\s,.;:\)\(\\/)])/g, '$1 k$2$3');
 
// Hertz
txt.value = txt.value.replace(/(\d)\s?(Y|Z|E|P|T|G|M|k|K|h|da|d|c|m|µ|μ|µ|n|p|f|a|z|y)?hz/gi, '$1 $2Hz');
txt.value = txt.value.replace(/(\d)\-(Y|Z|E|P|T|G|M|k|K|h|da|d|c|m|µ|μ|µ|n|p|f|a|z|y)?hz/gi, '$1 $2Hz');
 
// Fix kilometres
txt.value = txt.value.replace(/(\d)\s?kms?([\s,.;:\)\(\\/)])/gi, '$1 km$2');
txt.value = txt.value.replace(/(\d)\-kms?([\s,.;:\)\(\\/)])/gi, '$1 km$2');
txt.value = txt.value.replace(/(\d) kms?([\s,.;:\)\(\\/)])/gi, '$1 km$2');
 
txt.value = txt.value.replace(/(\d)\s?sq\.?\s?kms?/gi, '$1 km²');
txt.value = txt.value.replace(/sq\.?\s?kms?/gi, 'km²');
txt.value = txt.value.replace(/(\d)\s?sq\.?\s?m([^i])/gi, '$1 m²$2');
txt.value = txt.value.replace(/m²\.\)/gi, 'm²)');
 
// Standardise kilometres per hour
txt.value = txt.value.replace(/km\/hr/gi, 'km/h');
txt.value = txt.value.replace(/kph/gi, 'km/h');
txt.value = txt.value.replace(/kmph/gi, 'km/h');
txt.value = txt.value.replace(/(\d)\s?kmh/gi, '$1 km/h');
txt.value = txt.value.replace(/km\/h/gi, 'km/h');
txt.value = txt.value.replace(/(\d)\s?km\/h/gi, '$1 km/h');
txt.value = txt.value.replace(/(\d)\-km\/h/gi, '$1 km/h');
txt.value = txt.value.replace(/(\d) km\/h/gi, '$1 km/h');
 
// Standardise 'per second'
txt.value = txt.value.replace(/(\d)\s?ft\/second/gi, '$1 ft/s');
txt.value = txt.value.replace(/(\d)\s?ft\/sec/gi, '$1 ft/s');
txt.value = txt.value.replace(/(\d)\s?m\/second/gi, '$1 m/s');
txt.value = txt.value.replace(/(\d)\s?m\/sec/gi, '$1 m/s');
txt.value = txt.value.replace(/(\d)\s?km\/sec/gi, '$1 km/s');
 
// Space before horsepower symbol
txt.value = txt.value.replace(/(\d)\s?hp\W/gi, '$1 hp');
txt.value = txt.value.replace(/(\d)\s?bhp/gi, '$1 bhp');
txt.value = txt.value.replace(/(\d)\s?shp/gi, '$1 shp');
 
// Space before units