Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7 KiB

  1. //filler text on demand
  2. // http://web-graphics.com/mtarchive/001667.php
  3. var words=new Array('lorem','ipsum','dolor','sit','amet','consectetuer','adipiscing','elit','suspendisse','eget','diam','quis','diam','consequat','interdum');
  4. function AddFillerLink(){
  5. if(!document.getElementById || !document.createElement) return;
  6. var i,l;
  7. for(i=0;i<arguments.length;i++){
  8. if (document.getElementById(arguments[i])) { /* Check elements exists - add Reinhard Hiebl */
  9. l=document.createElement("a");
  10. l.href="#";
  11. l.appendChild(document.createTextNode("Add Text"));
  12. l.onclick=function(){AddText(this);return(false)};
  13. document.getElementById(arguments[i]).appendChild(l);
  14. b=document.createTextNode(" | ");
  15. document.getElementById(arguments[i]).appendChild(b);
  16. r=document.createElement("a");
  17. r.href="#";
  18. r.appendChild(document.createTextNode("Remove Text"));
  19. r.onclick=function(){RemoveText(this);return(false)};
  20. document.getElementById(arguments[i]).appendChild(r);
  21. }
  22. }
  23. }
  24. function AddText(el){
  25. var s="",n,i;
  26. n=RandomNumber(20,80);
  27. for(i=0;i<n;i++)
  28. s+=words[RandomNumber(0,words.length-1)]+" ";
  29. var t=document.createElement("p");
  30. t.setAttribute('class','added');
  31. t.appendChild(document.createTextNode(s));
  32. el.parentNode.insertBefore(t,el);
  33. }
  34. function RemoveText(el){
  35. var parent = el.parentNode;
  36. for(var i=0;i<parent.childNodes.length;i++) {
  37. var para = parent.childNodes[i];
  38. if(para.nodeName == "P" && para.getAttribute('class')=='added') {
  39. parent.removeChild(para);
  40. break;
  41. }
  42. }
  43. }
  44. function RandomNumber(n1,n2){
  45. return(Math.floor(Math.random()*(n2-n1))+n1);
  46. }