cvs: phpweb / index.php userprefs.js /include layout.inc
| From: | Gabor Hojtsy | Date: | Thu, 05 Jun 2003 19:41:55 +0000 |
| Subject: | cvs: phpweb / index.php userprefs.js /include layout.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-18522@lists.php.net to get a copy of this message | ||
goba Thu Jun 5 15:41:55 2003 EDT
Modified files:
/phpweb index.php userprefs.js
/phpweb/include layout.inc
Log:
Define the new searchHistory() JS function to restore
the last search done by a user
Include this in the onload event handler of the index page,
and in all other pages, where an onload handler is not already
defined
Add name to form, so we can call it by it's name
JS tested with Mozilla. As the functions and objects used
are rather old, it should work with all browsers. In case someone
knows a better way, go and fix it ;)
Index: phpweb/index.php
diff -u phpweb/index.php:1.389 phpweb/index.php:1.390
--- phpweb/index.php:1.389 Thu Jun 5 14:46:22 2003
+++ phpweb/index.php Thu Jun 5 15:41:55 2003
@@ -205,7 +205,7 @@
}
// Run the boldEvents() function on page load
-$ONLOAD = "boldEvents()";
+$ONLOAD = "boldEvents(); searchHistory();";
// Write out common header
commonHeader("Hypertext Preprocessor");
Index: phpweb/userprefs.js
diff -u phpweb/userprefs.js:1.1 phpweb/userprefs.js:1.2
--- phpweb/userprefs.js:1.1 Thu May 15 09:27:40 2003
+++ phpweb/userprefs.js Thu Jun 5 15:41:55 2003
@@ -21,11 +21,15 @@
// 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) {
@@ -34,4 +38,30 @@
}
}
}
-}
\ No newline at end of file
+}
+
+// Restore the last search as stored in a cookie
+function searchHistory()
+{
+ // Try to get the lastsearch cookie
+ lastSearch = getCookie("LAST_SEARCH");
+ if (typeof(lastSearch) == "string") {
+
+ // Get pattern and show information from cookie
+ pattern = lastSearch.substr(0, lastSearch.indexOf(","));
+ option = lastSearch.substr(lastSearch.indexOf(",") + 1);
+
+ // Set pattern in form
+ document.forms["topsearch"].pattern.value = pattern;
+
+ // Set the last selected search method in the dropdown
+ with (document.forms["topsearch"]) {
+ for (var i = 0; i < show.length; i++) {
+ if (show[i].value == option) {
+ show[i].selected = true;
+ break;
+ }
+ }
+ }
+ }
+}
Index: phpweb/include/layout.inc
diff -u phpweb/include/layout.inc:1.163 phpweb/include/layout.inc:1.164
--- phpweb/include/layout.inc:1.163 Sun Jun 1 15:16:54 2003
+++ phpweb/include/layout.inc Thu Jun 5 15:41:55 2003
@@ -1,5 +1,5 @@
<?php
-/* $Id: layout.inc,v 1.163 2003/06/01 19:16:54 rasmus Exp $ */
+/* $Id: layout.inc,v 1.164 2003/06/05 19:41:55 goba Exp $ */
$www_static_root = ($HTTP_SERVER_VARS['SERVER_NAME'] == 'www.php.net') ?
'http://static.php.net/www.php.net'
: '';
@@ -200,6 +200,9 @@
global $MYSITE, $base, $enclosed, $EXPL_LANG, $SIDEBAR_DATA,
$SEARCH_BASE, $ONLOAD, $www_static_root, $BASE_FOR_MANPAGE;
+ // If no onload event is specified, restore the last search
+ if (empty($ONLOAD)) { $ONLOAD = "searchHistory();"; }
+
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
@@ -212,7 +215,7 @@
</head>
<body bgcolor="#ffffff" text="#000000"
link="#000099" alink="#0000ff" vlink="#000099"
- <?php if (!empty($ONLOAD)) { echo 'onload="' . $ONLOAD .
'"'; } ?>>
+ onload="<?php echo $ONLOAD; ?>">
<!--UdmComment-->
<table border="0" cellspacing="0" cellpadding="0"
width="100%">
@@ -247,7 +250,7 @@
<tr bgcolor="#333366"><td colspan="2"><?php spacer();
?></td></tr>
<tr bgcolor="#666699">
<td align="right" valign="top" colspan="2"
class="quicksearch">
- <form method="post" action="/search.php" class="thin">
+ <form method="post" action="/search.php" class="thin"
name="topsearch">
<?php
if (isset($EXPL_LANG)) {
echo '<input type="hidden" name="lang" value="'.
$EXPL_LANG . '" />';