Jump to content

User:TheTechie/textsize.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
const html = `
<button onclick="decreaseSize();">Decrease size</button><span id="size">Current size: </span><button onclick="increaseSize();">Increase size</button>
`;

default_size = "0.9em";

$('#bodyContent').prepend(html);
$('#bodyContent').css('fontSize', default_size);

var current_size_label = "Current size: " + document.getElementById("bodyContent").style.fontSize;
var current_size = parseFloat(document.getElementById("bodyContent").style.fontSize);
var label = document.getElementById("size").innerHTML;
label = current_size_label;
var minimum = 0.7;
var maximum = 1.4;

label = current_size_label;

function decreaseSize(){
	current_size = current_size - 0.1;
	let size_string = String(current_size) + "em";
	$('#bodyContent').css('fontSize', size_string);
	label = current_size_label;
}

function increaseSize(){
	current_size = current_size + 0.1;
	let size_string = String(current_size) + "em";
	$('#bodyContent').css('fontSize', size_string);
	label = current_size_label;
}