geke hand
E Z B O A R D
ezURL: Determine the Board's ID, ForumID, etc. With Code

<< updated: 8/21/2003

Summary: Determine the board's URL with code instead of editing variables in the script. Store the other page information in variables instead of using document.location.indexOf throughout your scripts.

Details:

A lot of scripts have variables you have to change to put in your board's name or some other value which is in the URL of each board page.

A lot of scripts look at document.location.href to determine whether to do something.

For example, if you want something only on the main board page, or only on a specific forum, or only on topic pages, etc.

Most of these scripts use the method "indexOf" to determine if a particular string is contained within the current page's URL. This can be imprecise. For example, when you want to put a specific banner or other item on your "frm1" and a different specific item on your "frm11" you will run into trouble....

The solution is to use this code to deconstruct the ezboard page's URL into it's component parts:

ezPub -- what pub server are we on
ezFullPub -- full hostname of pub, i.e. pub99, beta, inbox, etc.
ezIsBoard -- am I on the main board page or a sub-page?
ezBoardID -- what is the "id" of the board?
ezForum -- what forum am I in (in the form of "frmXX")
ezPage -- what page am I on? "showMessage"? "addReply"?
ezQuery -- what variables were passed to this page? "topicID=XX.topic"?

Thus, code such as this:

if ( document.location.href.indexOf("http://pub11.ezboard.com/fcooltipsntricksfrm4") != -1 ) {
...
}

can be replaced with:

if ( ezForum == "frm4" ) {
...
}

For this page, http://beta.ezboard.com/fcooltipsntricksfrm4.showMessage?topicID=973.topic, it would do this:

ezPub would be "beta"
ezIsBoard would be false
ezBoardID would be "cooltipsntricks"
ezForum would be "frm4"
ezPage would be "showMessage"
ezQuery would be "topicID=973.topic"

HEAD: (box #1)

<script type="text/javascript">
/* BEGIN EZURL */
ezURL = document.location.href.match("http:\/\/((?:pub|b|p)([0-9]+)|beta|vanchau|inbox)\.ezboard\.com\/(b|f)([a-zA-Z0-9]+(?=frm[0-9]+)|[a-zA-Z0-9]+(?!frm[0-9]+))(frm[0-9]+|)(?:(?:[\.]{1})([a-zA-Z0-9\=\+\&\.]+)|)(?:(?:[\x3F]{1})([a-zA-Z0-9\=\+\&\.]+)|)(?:.*)");
try {
if (ezURL.length > 0) {
ezPub = ezURL[2].length > 0 ? ezURL[2] : ezURL[1];
ezFullPub = ezURL[1];
ezIsBoard = ezURL[3] == "b" ? true : false;
ezBoardID = ezURL[4];
ezForum = ezURL[5];
ezPage = ezURL[6];
ezQuery = ezURL[7];
}
} catch (e) { }
ezURL = null;
/* END EZURL */
</script>

HEAD Notes:

This script is used in many of the other scripts offered here. Only one copy should be installed.

History:

8/21/2003 - regular expression rewritten to be more efficient
7/27/2003 - fixed bug with multi-page forums
4/1/2003 - fixed bugs with .boardStats pages, etc.
3/31/2003 - completely re-written by phalen180.

Credits:

phalen180

E Z B O A R D

design by G E K E . N E T
best viewed in 1024x768 screen resolution using a standards compliant browser
logo based on a public domain drawing of a hand making the sign of the cross, no disrespect is intended
all other contents and code copyright © 2002-2005 jonathan cook

Valid HTML 4.01! Valid CSS!