User:Alex 21/script-tablecolour.js
$(function($) {
setTimeout(function() {
$.when( mw.loader.using( ['mediawiki.util']), $.ready ).then(function() {
var portletlink = mw.util.addPortletLink('p-tv', '#', 'Table colours');
$(portletlink).click( function(e) {
e.preventDefault();
// Default parameters and determine if we need to go to the editing page
var loc = window.location.href; var wpTextbox1 = document.getElementById('wpTextbox1');
if (loc.indexOf('action=edit') < 0 && loc.indexOf('action=submit') < 0) {
alert("Go to the edit page to use this script.");
} else {
// Gather colours from text of tables
var s = wpTextbox1.value.split("\n");
for (var i = 0; i < s.length; i++) {
// Regex for any number of parameters that use colours
var reg = /\s*\|\s*(bgcolour|bgcolor|bg_color|bg_colour|headercolour|headercolor|colour|color|fgcolour|fgcolor|background)[\s\=\#]*([0-9A-Za-z]*)/g;
var t = reg.exec(s[i]);
if (!t) continue;
// Add colour to saved colours if its not already added
var fontColor = t[2];
// Gather colour, and individually adjust to AAA compliancy
var newcolour = colourCompliance(fontColor,false);
var reg2 = new RegExp('('+fontColor+')','gi');
// Update if the original colour has been changed to be compliant, check for minus error
if (newcolour.indexOf("-") < 0) wpTextbox1.value = wpTextbox1.value.replace(reg2,newcolour);
else alert("Error fixing colour code "+fontColor+" - please fix manually.");
}
// Done
document.getElementById('wpSummary').value += "Adjusted color contrasts via [[User:Alex 21/script-tablecolour|script]] per [[WP:COLOR]] and [[Template talk:Infobox television season/Archive 3]].";
}
});
});
},700);
});
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.