You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 547 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Javascript functions in javascript.php

21.9.1. Javascript functions in javascript.php

PHP-Nuke come with its own Javascript functions included in the file javascript.php, located under the includes folder. You can add your own Javascript code there, if you follow some simple rules:

  • Use a decent text editor (see Chapter 11) to edit the file.

  • Append your code after the code already there, but before the ending ?> line.

  • "echo" each line of your Javascript script. Example: Instead of entering directly the script code:

    <script type="text/javascript">
    <!--
    function openwindow(){
     window.open
    ("modules/$name/copyright.php","Copyright","toolbar=no,location=no,directories=no,
    status=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=200")
    }
    //-->
    </script>
    
  • enter it with "echo"s as:

    echo "<script type=\"text/javascript\">\n";
    echo "<!--\n";
    echo "function openwindow(){\n";
    echo " window.open(\"modules/$name/copyright.php\",\"Copyright\",
    \"toolbar=no,location=no,directories=no,status=no,
    scrollbars=yes,resizable=no,copyhistory=no,width=400,height=200\");\n";
    echo "}\n";
    echo "//-->\n";
    echo "</script>\n\n";
    
  • Enclose each line in double quotes, like a string, and escape (with a backslash \) any double quote inside that string.

  • Add a newline character (\n) to the string, before the closing double quote[1].

  • End each line, like every PHP line, with a semicolon (;).

If you use vi (see Section 11.1), the following sequence of vi commands, applied to a Javascript file, will produce the right PHP code to append in the javascript.php file:

1,$s/"/\\"/g (1)
1,$s/^/echo "/ (2)
1,$s/$/";/ (3)
1,$s/";$/\\n";/ (4)
(1)
Escape all double quotes.
(2)
Add 'echo "' at the start of every line.
(3)
Add '";' at the end of every line.
(4)
Add a newline '\n' at the end of each Javascript line.

You can then include calls to your Javascript functions in the HTML code of your module. You echo the Javascript code, just like any other HTML code.

Notes

[1]

the "window.open" line in the example above is actually a long line that has been broken to 3 lines only for layout purposes, that's why there are no newlines (\n) at the ends of two lines (just as there is no semicolon for the same reason).

Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.068 Seconds - 221 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::