Home
About
Blog
Media Gallery

Digitize Text


JavaScript code and working example below.

Code:
Example Usage:
==============
- HTML: <a href="javascript:DigitizeExampleLink()" id="dzExample">Click on me for a working example!</a>

// Configuration.
var DigitizeSpeed = 50;
var isRunning = false;

// Text 1
var Digitize1Text = "Click on me for a working example!";
var Digitize1TextA = Digitize1Text.split('');

// void Digitize(string elem);
function Digitize(elem) {
	var colors = ['Black','Lime','Gray'];
	
	switch (elem) {
		case 'Digitize1':
			Digitize1TextA[Math.floor(Math.random()*Digitize1TextA.length)] = 
				'<span style="color:'+ colors[Math.floor(Math.random()*colors.length)] +'">'+ 
				Math.floor(Math.random()*2) +
				'</span>';
			document.getElementById('dzExample').innerHTML = Digitize1TextA.join('');
		break;
	}
}

function DigitizeExampleLink() {
	if (!isRunning) {
		setInterval("Digitize('Digitize1')", DigitizeSpeed);
		isRunning = true;
	}
}

Working example:
Click on me for a working example!

You can use clearInterval() to stop the interval if you need to.

Original Post: Jan 28th, '22 00:54 CET.
Updated: Jan 28th, '22 00:58 CET.

Tags: JS Script