PDA

View Full Version : javascripting help :3


amn3sys
14-06-2010, 06:45 PM
i have this code

<script type="text/javascript">
writeContent(true);
</script>
it types the text,
example on this site of me(the green text that like types)
http://members.multimania.nl/amn3sys/konrules.html

but here come's the question,
is there a way to speed up the "typing" of the text,
eg. by another script or some thing ??

IcyTouch
15-06-2010, 03:45 PM
You've got more than that code me love.

The other code to go along with that is

<script type="text/javascript">
var charIndex = -1;
var stringLength = 0;
var inputText;
function writeContent(init)
{
if(init)
{
inputText = document.getElementById('contentToWrite').innerHTM L;
}
if(charIndex==-1)
{
charIndex = 0;
stringLength = inputText.length;
}
var initString = document.getElementById('myContent').innerHTML;
initString = initString.replace(/<SPAN.*$/gi,"");

var theChar = inputText.charAt(charIndex);
var nextFourChars = inputText.substr(charIndex,4);
if(nextFourChars=='<BR>' || nextFourChars=='<br>')
{
theChar = '<BR>';
charIndex+=3;
}
initString = initString + theChar + "<SPAN id='blink'>></SPAN>";
document.getElementById('myContent').innerHTML = initString;

charIndex = charIndex/1 +1;
if(charIndex%2==1)
{
document.getElementById('blink').style.display='no ne';
}
else
{
document.getElementById('blink').style.display='in line';
}
if(charIndex<=stringLength)
{
setTimeout('writeContent(false)',100);
}
else
{
blinkSpan();
}
}
var currentStyle = 'inline';
function blinkSpan()
{
if(currentStyle=='inline')
{
currentStyle='none';
}
else
{
currentStyle='inline';
}
document.getElementById('blink').style.display = currentStyle;
setTimeout('blinkSpan()',400);
}</script>

look for around line 133 the code

if(charIndex<=stringLength)
{
setTimeout('writeContent(false)',100);
}

try dropping that down to around 50, see if thats quick enough for you.

If you go much lower than that then it might start to lag the browser and jump words.

also the little > is in another part of the script, find the timeout somehwer that says 100 also should look like

document.getElementById('blink').style.display = currentStyle;
setTimeout('blinkSpan()',100);

make that the same -0-0-

see how that helps you out?!?!?!

amn3sys
15-06-2010, 07:16 PM
yes but thats the "code" for the effect XDD

but, maby dumb question but were do i put the text XDD

IcyTouch
15-06-2010, 07:47 PM
open the file konrules.html view thew source code, then scroll down untill you see all the text. it shud be pretty obvious where it is.

If you know exactly what you want u can put the changes on here, i'll make them and paste the exact content of that file so u can just overwrite it all unless ya all good.

good tip if u want to find something specificlally view the source, then do Ctrl + F and do a search for the text u wanna edit then u can find it easier.

amn3sys
15-06-2010, 07:50 PM
^^ i not realy "good" @ javascripting only know lil basics XD
but do i need to replace that code whit my own?
cuz i tried but..
then it wouldnt do anythign :S
it would just stop working so i'd rekon i am doing somethign wrong?

IcyTouch
15-06-2010, 08:01 PM
no no u dont need to replace anything.

Simply open your file

then where it says timeout is 100 change the 100 to a different (smaller the quicker) number, then it shud be fine.

amn3sys
15-06-2010, 08:08 PM
AH now i get it :)

Thanks it worked :)

IcyTouch
16-06-2010, 02:02 AM
lol no worries :P