MediaWiki:Gadget-minih2.js
Piezīme: Lai redzētu izmaiņas, pēc publicēšanas var nākties iztīrīt sava pārlūka kešatmiņu.
- Firefox / Safari: Pieturi Shift un klikšķini uz Pārlādēt vai nospied Ctrl-F5 vai Ctrl-R (⌘-R uz Mac)
- Google Chrome: Nospied Ctrl-Shift-R (⌘-Shift-R uz Mac)
- Internet Explorer / Edge: Pieturi Ctrl un klikšķini uz Pārlādēt vai nospied Ctrl-F5
- Opera: Nospied Ctrl-F5.
// [[pl:MediaWiki:Gadget-minih2.js]]
$(document).ready(function()
{
if (typeof(wp_minih2_max_size) === 'undefined') {
window.wp_minih2_max_size = 10000;
}
if (typeof(wp_minih2_max_average) === 'undefined' ) {
window.wp_minih2_max_average = 2000;
}
var textSize = $("#bodyContent").text().length;
var sections = $("body.ns-0 #bodyContent h2, body.ns-2 #bodyContent h2").length;
var average = textSize/(sections+1);
var suggestion = (sections > 0) && (textSize < wp_minih2_max_size) && (average < wp_minih2_max_average);
if (suggestion)
{
// disable the bottom line in the second level heading sections
// let know that there is <h2> tag in toc section,
// but it does not consits of the line so the code does not hurt it
$("h2").css("border-bottom-width", "0");
// make the font size of the heading text smaller (default is 21px)
$("h2 span.mw-headline").css("font-size", "18px");
}
if (typeof(wp_minih2_debug) !== 'undefined' ) {
var before = document.getElementById( 'pt-userpage' );
var inside = before.parentNode;
var textSize = $("#bodyContent").text().length;
var indicator1 = document.createElement( 'li' );
indicator1.innerHTML = 'text size: ' + textSize + ' limit: ' + wp_minih2_max_size;
inside.insertBefore( indicator1, before );
var sections = $("body.ns-0 #bodyContent h2, body.ns-2 #bodyContent h2").length;
var indicator2 = document.createElement( 'li' );
indicator2.innerHTML = 'sections: ' + (1+sections);
inside.insertBefore( indicator2, before );
var indicator3 = document.createElement( 'li' );
var average = Math.round(textSize/(sections+1));
indicator3.innerHTML = 'average: ' + average + ' limit: ' + wp_minih2_max_average;
inside.insertBefore( indicator3, before );
var indicator4 = document.createElement( 'li' );
var suggestion = (sections > 0) && (textSize > 0) && (textSize < wp_minih2_max_size) && (average < wp_minih2_max_average);
indicator4.innerHTML = 'suggestion: ' + (suggestion ? "<img src=https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/Crystal_Clear_app_clean.svg/15px-Crystal_Clear_app_clean.svg.png>" : "<img src=https://upload.wikimedia.org/wikipedia/commons/thumb/7/7d/Crystal_Clear_action_button_cancel.svg/10px-Crystal_Clear_action_button_cancel.svg.png>");
inside.insertBefore( indicator4, before );
}
});