cvs: phpweb / index.php userprefs.js /include layout.inc prepend.inc

From: Date: Thu, 15 May 2003 13:27:40 +0000
Subject: cvs: phpweb / index.php userprefs.js /include layout.inc prepend.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17690@lists.php.net to get a copy of this message
goba Thu May 15 09:27:40 2003 EDT Added files: /phpweb userprefs.js Modified files: /phpweb index.php /phpweb/include layout.inc prepend.inc Log: Adding client side JS to make events in the user's country bold. This JS file will be expanded in the future to add features like last search keyword / last selected search option remembering This JS was tested in Mozilla, Galeon and Konqueror with success and the code was human checked against MSDN for Internet Explorer questions. It also includes a BC check for browsers without DOM support. Index: phpweb/index.php diff -u phpweb/index.php:1.376 phpweb/index.php:1.377 --- phpweb/index.php:1.376 Thu May 15 09:08:02 2003 +++ phpweb/index.php Thu May 15 09:27:40 2003 @@ -198,6 +198,9 @@ fclose($fp); } +// Run the boldEvents() function on page load +$ONLOAD = "boldEvents()"; + // Write out common header commonHeader("Hypertext Preprocessor"); Index: phpweb/include/layout.inc diff -u phpweb/include/layout.inc:1.151 phpweb/include/layout.inc:1.152 --- phpweb/include/layout.inc:1.151 Wed May 14 16:21:14 2003 +++ phpweb/include/layout.inc Thu May 15 09:27:40 2003 @@ -1,6 +1,6 @@ <?php -/* $Id: layout.inc,v 1.151 2003/05/14 20:21:14 goba Exp $ */ +/* $Id: layout.inc,v 1.152 2003/05/15 13:27:40 goba Exp $ */ // Print an image for a sized spacer function spacer($width = 1, $height = 1, $return = false, $align = false, $extras = false) @@ -189,21 +189,19 @@ # function commonHeader($title="",$dont_enclose=0,$headers_gone=0) { - global $MYSITE, $base, $enclosed, $EXPL_LANG, $SIDEBAR_DATA, $SEARCH_BASE; + global $MYSITE, $base, $enclosed, $EXPL_LANG, $SIDEBAR_DATA, $SEARCH_BASE, $ONLOAD; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>PHP<?php if ($title) echo ": $title";?></title> <link rel="stylesheet" href="/style.css" /> - <?php - if (i2c_valid_country()) { - echo "<style>\n.event_$COUNTRY { font-weight: bold; }\</style>"; - } - ?> <link rel="shortcut icon" href="/favicon.ico" /> + <script language="Javascript" type="text/javascript" src="/userprefs.js"></script> <?php echo (isset($SEARCH_BASE) ? '<base href="' . $SEARCH_BASE . '" />' : ''); ?> </head> -<body bgcolor="#ffffff" text="#000000" link="#000099" alink="#0000ff" vlink="#000099"> +<body bgcolor="#ffffff" text="#000000" + link="#000099" alink="#0000ff" vlink="#000099" + <?php if (!empty($ONLOAD)) { echo 'onload="' . $ONLOAD . '"'; } ?>> <!--UdmComment--> <table border="0" cellspacing="0" cellpadding="0" width="100%"> Index: phpweb/include/prepend.inc diff -u phpweb/include/prepend.inc:1.23 phpweb/include/prepend.inc:1.24 --- phpweb/include/prepend.inc:1.23 Sat May 3 11:33:16 2003 +++ phpweb/include/prepend.inc Thu May 15 09:27:40 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: prepend.inc,v 1.23 2003/05/03 15:33:16 goba Exp $ +// $Id: prepend.inc,v 1.24 2003/05/15 13:27:40 goba Exp $ // Start measuring time spent on page $page_creation_start = getmicrotime(); @@ -19,6 +19,7 @@ unset($SEARCH_BASE); unset($LANG); unset($COUNTRY); +unset($ONLOAD); // Backward compatible array creation. After this point, the // PHP 4.1.0+ arrays can be used to access variables coming Index: phpweb/userprefs.js +++ phpweb/userprefs.js // Get a value of one cookie set by it's name // Impmentation from the JS 1.3 Client Guide by Netscape function getCookie(Name) { var search = Name + "="; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) { end = document.cookie.length; } return unescape(document.cookie.substring(offset, end)); } } return null; } // Make events in the user's country bold function boldEvents() { // Get cookie if possible country = getCookie("COUNTRY"); if (typeof(country) == "string") { // Get country code from cookie country = country.substring(0, 3); // If DOM is supported, get <span>s if (document.getElementsByTagName) { spans = document.getElementsByTagName("span"); // Style every span bold which is for this country for (var i = 0; i < spans.length; i++) { if (spans[i].className == "event_" + country) { spans[i].style.fontWeight = "bold"; } } } } }

« previous php.mirrors (#17690) next »