any column longest struggle - helper script

Post non-phpwcms related topics here - but I don't want to see "hey check this or that other cms". Post if you have a point or worthwhile comment, don't post just to increase you post count!
Post Reply
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

any column longest struggle - helper script

Post by update »

Put into your page's head:

Code: Select all

<script type="text/javascript" src="flod.js"></script>
<script type="text/javascript">
window.onload=function(){
AddFillerLink("content-right","content-left","contentmain-right","contentmain-left","innerbox2-content","navigation-left");
}
</script>
The AddFillerLink (is it an array?) contains the names of your div ids (eg #content-right becomes "content-right" then)
It doesn't work with classes...
Save the following (beeing referenced within page head) as "flod.js"

Code: Select all

//filler text on demand
// http://web-graphics.com/mtarchive/001667.php

var words=new Array("filler","text","silly","very","fill","make","short","long","column","test","dasauchnoch");

function AddFillerLink(){
if(!document.getElementById || !document.createElement) return;
var i,l;
for(i=0;i<arguments.length;i++){
    l=document.createElement("a");
    l.href="#";
    l.appendChild(document.createTextNode("Add Text to this section"));
    l.onclick=function(){AddText(this);return(false)};
    document.getElementById(arguments[i]).appendChild(l);
    }
}

function AddText(el){
var s="",n,i;
n=RandomNumber(200,800);
for(i=0;i<n;i++)
    s+=words[RandomNumber(0,words.length-1)]+" ";
var t=document.createElement("p");
t.appendChild(document.createTextNode(s));
el.parentNode.insertBefore(t,el);
}

function RandomNumber(n1,n2){
return(Math.floor(Math.random()*(n2-n1))+n1);
}
At the top of the script is the source of it :) for further reading.
I find this extremly useful (had a real fight recently to get a construction working but this one has been a real helper :D

claus
User avatar
Heiko H.
Posts: 868
Joined: Thu 27. Oct 2005, 11:41
Location: Dresden
Contact:

Post by Heiko H. »

Hi claus,

Not bad, not bad!!!

I'm fighting with the same problem at the moment...
But the viewer must have JS enabled... :roll:


THX, Heiko...
Not longer here - sorry...

Haubner-IT GbR Dresden
Post Reply