Adding javascript to phpbb

This is a discussion on "Adding javascript to phpbb" within the JavaScript Forum section. This forum, and the thread "Adding javascript to phpbb are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 25th, 2007, 15:43
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Daniel
Adding javascript to phpbb

I'm trying to add a piece of javascript code - it's meant to go just above the <body> tag so I added it in the overall_header template below the </head> tag as this would be before the body tag but it doesnt work.

Any ideas to get it to work.

HTML: Select all
<SCRIPT TYPE="text/javascript">
 
if(!window.Halloween) Halloween=new Object();
Halloween.ghostImages = new Array( 
    "<img src='ghost3.gif'>",
    "<img src='ghost1.gif'>",
    "<img src='ghost2.gif'>",
    "<img src='ghost2.gif'>"
);
var ns4 = document.layers;
var ie4 = document.all;
Halloween.makeLayer = function(id)
{
    var el =     document.getElementById    ? document.getElementById(id) :
            document.all         ? document.all[id] :
                              document.layers[id];
    if(ns4) el.style=el;
    el.sP=function(x,y){this.style.left = x;this.style.top=y;};
    el.show=function(){ this.style.visibility = "visible"; } 
    el.hide=function(){ this.style.visibility = "hidden"; } 
    if(ns4 || window.opera) 
        el.sO = function(pc){return 0;};
    else if(ie4)
        el.sO = function(pc)
        {
            if(this.style.filter=="")
                this.style.filter="alpha(opacity=100);";
            this.filters.alpha.opacity=pc;
        }
    else
        el.sO = function(pc){this.style.MozOpacity=pc/100;}

    return el;
}

if(window.innerWidth)
{
    gX=function(){return innerWidth;};
    gY=function(){return innerHeight;};
}
else
{
    gX=function(){return document.body.clientWidth-30;};
    gY=function(){return document.body.clientHeight-30;};
}
Halloween.ghostOutput=function()
{
    for(var i=0 ; i<Halloween.ghostImages.length ; i++)
        document.write(ns4 ? "<LAYER  NAME='gh"+i+"'>"+Halloween.ghostImages[i]+"</LAYER>" : 
                       "<DIV id='gh"+i+"' style='position:absolute'>"+Halloween.ghostImages[i]+"</DIV>" );
    
}
Halloween.ghostSprites = new Array();
Halloween.ghostStartAni = function()
{
    for(var i=0 ;i<Halloween.ghostImages.length;i++)
    {
        var el=Halloween.makeLayer("gh"+i);
        el.x=Math.random()*gX();
        el.y=Math.random()*gY();
        el.tx=Math.random()*gX();
        el.ty=Math.random()*gY();
        el.dx=-5+Math.random()*10;
        el.dy=-5+Math.random()*10;
        el.state="off";
        el.op=0;
        el.sO(el.op);
        el.hide();
        Halloween.ghostSprites[i] = el;
    }
    setInterval("Halloween.ghostAni()", 40);
}
Halloween.ghostAni = function()
{
    for(var i=0 ;i<Halloween.ghostSprites.length;i++)
    {
        el=Halloween.ghostSprites[i];

        if(el.state == "off")
        {
            if(Math.random() > .99)
            {
                el.state="up";
                el.show();
            }
        }
        else if(el.state == "on")
        {
            if(Math.random() > .98)
                el.state="down";
        }
        else if(el.state == "up")
        {
            el.op += 2;
            el.sO(el.op);
            if(el.op==100)
                el.state = "on";
        }
        else if(el.state == "down")
        {
            el.op -= 2;
            if(el.op==0)
            {
                el.hide();
                el.state = "off";
            }
            else
                el.sO(el.op);
        }

        var X = (el.tx - el.x);
        var Y = (el.ty - el.y);
        var len = Math.sqrt(X*X+Y*Y);
        if(len < 1) len = 1;
        var dx = 20 * (X/len);
        var dy = 20 * (Y/len);
        var ddx = (dx - el.dx)/10;
        var ddy = (dy - el.dy)/10;
        el.dx += ddx;
        el.dy += ddy;
        el.sP(el.x+=el.dx,el.y+=el.dy);

        if(Math.random() >.95 )
        {
            el.tx = Math.random()*gX();
            el.ty = Math.random()*gY();
        }

    }
}
Halloween.ghostStart = function()
{
    if(Halloween.ghostLoad)Halloween.ghostLoad();
    Halloween.ghostStartAni();
}
Halloween.ghostOutput();
Halloween.ghostLoad=window.onload;
window.onload=Halloween.ghostStart;

</SCRIPT>
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote

  #2 (permalink)  
Old Oct 25th, 2007, 20:01
Up'n'Coming Member
Join Date: Jun 2007
Location: Germany
Age: 23
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Lucleonhart Send a message via MSN to Lucleonhart
Re: Adding javascript to phpbb

Between head and body?! What is the, never neverland?! ^^
I would try to add it in head OR body.. Prefering HEAD!
Reply With Quote
  #3 (permalink)  
Old Oct 25th, 2007, 20:26
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Daniel
Re: Adding javascript to phpbb

What?
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
  #4 (permalink)  
Old Oct 25th, 2007, 20:37
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Adding javascript to phpbb

lol, let me translate:

Between head and body?! That's never never land?! ^^
Put it in the head or in the body. Most scripts go in the head.
Reply With Quote
  #5 (permalink)  
Old Oct 25th, 2007, 20:42
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Daniel
Re: Adding javascript to phpbb

I tried that - neither seemed to work (is this yuor friend?)
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
  #6 (permalink)  
Old Oct 25th, 2007, 21:28
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Adding javascript to phpbb

yep

Well, check your javascript error console. Are you getting any errors?
Reply With Quote
  #7 (permalink)  
Old Oct 25th, 2007, 21:59
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Daniel
Re: Adding javascript to phpbb

What?
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
  #8 (permalink)  
Old Oct 26th, 2007, 04:30
Up'n'Coming Member
Join Date: Jun 2007
Location: Germany
Age: 23
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Lucleonhart Send a message via MSN to Lucleonhart
Re: Adding javascript to phpbb

Oh, i am sorry, i thought it would be readable. ^^
To check Javascript errors, first you need Firefox.
Then go to "Extras -> Error Console". Hit the Delete Buton there to wipe the list.
Than, open your page, and look inside the error list... anything there?
Reply With Quote
  #9 (permalink)  
Old Oct 26th, 2007, 08:17
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Adding javascript to phpbb

Hi Daniel,

The actual javascript is fine ( I just tested for you in IE & FF)... You need to place the script before the </head>.

With PHPBB, how is the template printed to the screen? Is it echo'd or printed? If it is, you will need to escape all of your data ie. add backslashes to all single/double quotes

Also, in the page you are adding this script to, does it already have a window.onload = something?

Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #10 (permalink)  
Old Oct 26th, 2007, 14:35
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Daniel
Re: Adding javascript to phpbb

I dunno - I'm not gonna bother with this script cause it was only a couple of ghosts.
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
phpBB alexgeek Website Planning 34 Oct 2nd, 2007 23:30
Help with Phpbb forum Ofear Scripts and Online Services 8 Jul 24th, 2007 13:00
Free PHPBB? collinsc PHP Forum 13 Mar 12th, 2007 18:01
phpbb Forums mod saltedm8 PHP Forum 10 May 9th, 2006 22:27
PHPbb forum help RSStites PHP Forum 5 Aug 8th, 2005 00:10


All times are GMT. The time now is 04:42.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43