Otagowane jako... html
7 sierpnia 2014 15:08:52 - Codziennik

jQuery…

To dziś bez jQuery nic się nie zrobi?

<script src=”js/libs/jquery-1.11.0.min.js”></script>

<script>

function updateText(txt)
{
$(’#siteheader1 strong’).html(txt);
}

var things = [’Programming’, 'Writing’, 'Drawing’, 'Painting’];
var t = -1;
var thing = ”;
var message = ”;
var mode = 'delete’;
var delay = 0;

function tick()
{
if($(’#siteheader1 strong’).html().length == 0)
{
t++;
if(t > things.length-1) {t = 0;}
thing = things[t];
message = ”;
mode = 'write’;
}

switch(mode)
{
case 'write’ :
message += thing.slice(0, 1);
thing = thing.substr(1);

updateText(message);

if(thing.length == 0)
{
mode = 'delete’;
delay = 7000;
} else {
delay = 32 + Math.round(Math.random() * 230);
}
break;

case 'delete’ :
message = message.slice(0, -1);
updateText(message);

if(message.length == 0)
{
mode = 'write’;
delay = 500;
} else {
delay = 32 + Math.round(Math.random() * 128);
}
break;
}

window.setTimeout(tick, delay);
}

tick();

</script>

Ot ciekawostka dnia dzisiejszego…. :)

źródło kodu: http://musicforprogramming.net/

Strony:«12