User:Krinkle/sandboxRenderer.js

function renderGrains(sb, grains) { var $p = $(' '); $p.text(grains + ' gains: ' + ('x'.repeat(grains))); $p.appendTo(sb); } function init { var sb = document.querySelector('div.tpl-krinkle-boxofsand'); if (!sb) { console.log('No sands here (still)'); return; }	renderGrains(sb, sb.dataset.grains || 0); var $btn = $(' '); $btn.text('Click me'); $btn.appendTo(sb); $btn.on('click', function {		console.log('Clicked!');			var rnd = Math.ceil(Math.random * 100);		renderGrains(sb, rnd);	}); } init;