This server will be upgraded at 3pm Sydney time on December 3rd (December 2nd, 8pm PST) and will be down for up to 30 minutes.

Typewriter text effect - User Macro

This user macro allows you to add a typewriter text effect to your content, adding one letter at a time until the text is fully displayed...

Version Notes Author
0.1 Initial release Guy Fraser
0.2 Simplified span tag Guy Fraser

Installation

Go in to your Administration panel, choose "User Macros", then add a new user macro called "typewriter" (or anything else for that matter).

Make sure you tick "Macro has body".

Paste the following code in to the text area:

#if ($action.isPrintableVersion())
$body
#else
<script type="text/javascript">
var text = String("$body").split("");
var tid = 0;

if (document.typewriters==null) {
document.typewriters = [text];
document.doTypewriter = function() {
var x,c,s;
var more = false;
x = document.typewriters.length;
while (-1<--x) {
s = document.getElementById("typewriter"+x);
c = document.typewriters[x].shift();
if (c!=null) {
more = true;
s.innerHTML = s.innerHTML+c;
}
}
if (more==true) {
setTimeout("document.doTypewriter()",200);
}
}
setTimeout("document.doTypewriter()",2000);
} else {
tid = document.typewriters.length;
document.typewriters.push(text);
}

document.write('<span id="'+"typewriter"+tid+'" />');
</script>
#end

Poke the "Add" button with your mouse and you're ready to go!

License

This user macro is released under the BSD License - (c) 2005 2005 Adaptavist.com Limited

Example of use

Throw this in to one of your pages:

{typewriter}Well, this is my simple typewriter user macro, notice the dot moving along after this text{typewriter}.

Hyperlink: [{typewriter}Although it won't work handle wiki text, you can at least wrap wiki text around it such as this link{typewriter}|Plugin Index]

You can also {typewriter}use it to insert text in to existing text{typewriter} if desired?

{color:red}{typewriter}You can change the colour and plenty of other things by wrapping other macros around it.{typewriter}{color}

Save the page and sit back and watch!

I also took the time to make it instantly display the text when in printable view (you don't want to print a page that's mid way through a typewriter effect do you?)

Wishlist

There seems to be no way that a User Macro can find out if it's already been used on a page - as such I had to output the doTypewriter method each time it gets used, and to try and make up for this shortfall I only actuall attach it to document if it's not already there.

Being remarkably lazy, I set a 2 second (2000 milliseconds) trigger to start the typewriter effect. Obviously, if you page takes more than 2 seconds to load and has loads of uses of this macro, things could start going pyriform. If your page loads really quick, then you will be waiting for 2 seconds before anything happens!

Feel free to dive in and improve this script, it's just a little plaything and I'd be interested to see what improvements can be made

Guy

Labels

confluence14 confluence14 Delete
plugin plugin Delete
repository_excluded repository_excluded Delete
repository_excluded_by_user_macro repository_excluded_by_user_macro Delete
user-macro user-macro Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.