[metacat-cvs] metacat/lib/style/skins/default include_advancedsearch.jsp
Duane Costa
costa at ecoinformatics.org
Tue Nov 22 14:53:24 PST 2005
costa 05/11/22 14:53:24
Modified: lib/style/skins/default include_advancedsearch.jsp
Log:
Add a client-side check: if user does not enter any search values, prompt the user with a dialog box to confirm that the user wishes to go ahead with a search for all documents. This is equivalent to the behavior in the simple search box.
Added a hidden input field for siteValue with a value of "ALLSITES". This is a substitute for the siteValue drop-down list that is used at LTER whose default value is also "ALLSITES". Either the hidden input field or the drop-down list should be commented-out, but not both. (This is documented in the internal comments.)
Revision Changes Path
1.3 +51 -41 metacat/lib/style/skins/default/include_advancedsearch.jsp
Index: include_advancedsearch.jsp
===================================================================
RCS file: /cvs/metacat/lib/style/skins/default/include_advancedsearch.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- include_advancedsearch.jsp 17 Nov 2005 23:21:40 -0000 1.2
+++ include_advancedsearch.jsp 22 Nov 2005 22:53:24 -0000 1.3
@@ -2,14 +2,15 @@
<!--
/**
* '$RCSfile: include_advancedsearch.jsp,v $'
- * Authors: Duane Costa
- * Copyright: 2000 Regents of the University of California and the
- * National Center for Ecological Analysis and Synthesis
- * For Details: http://www.nceas.ucsb.edu/
+ * Authors: Duane Costa
+ * Copyright: 2005 University of New Mexico and
+ * Regents of the University of California and the
+ * National Center for Ecological Analysis and Synthesis
+ * For Details: http://www.nceas.ucsb.edu/
*
* '$Author: costa $'
- * '$Date: 2005/11/17 23:21:40 $'
- * '$Revision: 1.2 $'
+ * '$Date: 2005/11/22 22:53:24 $'
+ * '$Revision: 1.3 $'
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,26 +43,12 @@
<script language="javascript" type="text/javascript">
- function trim(stringToTrim) {
- return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
- }
-
- function allowSearch(formObj) {
- var canSearch = true;
- var searchString = trim(formObj.elements["anyfield"].value);
- if (searchString=="") {
- if (confirm("Show *all* data in the Catalog?\n(this may take some time!) ")) {
- formObj.elements["anyfield"].value = "%";
- canSearch = true;
- } else {
- formObj.elements["anyfield"].focus();
- canSearch = false;
- }
- }
- return canSearch;
- }
+ function trim(stringToTrim) {
+ return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
+ }
function submitRequest(form) {
+ var canSearch = true;
var x_range = document.map.get_x_range();
var y_range = document.map.get_y_range();
var x_index = x_range.indexOf(' ');
@@ -72,18 +59,38 @@
var x_hi = x_range.substring(x_index + 1, x_length);
var y_lo = y_range.substring(0, y_index);
var y_hi = y_range.substring(y_index + 1, y_length);
-
- // Re-initialize the hidden form values prior to submitting
- document.advancedSearchForm.northBound.value = "";
- document.advancedSearchForm.southBound.value = "";
- document.advancedSearchForm.eastBound.value = "";
- document.advancedSearchForm.westBound.value = "";
- if ((x_range != "-180.0 180.0") && (y_range != "-90.0 90.0")) {
- document.advancedSearchForm.northBound.value = y_hi;
- document.advancedSearchForm.southBound.value = y_lo;
- document.advancedSearchForm.eastBound.value = x_hi;
- document.advancedSearchForm.westBound.value = x_lo;
+ if (trim(form.subjectValue.value) == "" &&
+ trim(form.creatorSurname.value) == "" &&
+ trim(form.creatorOrganization.value) == "" &&
+ trim(form.locationName.value) == "" &&
+ (x_range == "-180.0 180.0") &&
+ (y_range == "-90.0 90.0") &&
+ trim(form.taxon.value) == "" &&
+ form.siteValue.value == "ALLSITES"
+ ) {
+ canSearch =
+ confirm("Show *all* data in the catalog?\n(This may take some time!)");
+ }
+
+ if (canSearch) {
+ // Re-initialize the hidden form values prior to submitting
+ form.northBound.value = "";
+ form.southBound.value = "";
+ form.eastBound.value = "";
+ form.westBound.value = "";
+
+ if ((x_range != "-180.0 180.0") && (y_range != "-90.0 90.0")) {
+ form.northBound.value = y_hi;
+ form.southBound.value = y_lo;
+ form.eastBound.value = x_hi;
+ form.westBound.value = x_lo;
+ }
+
+ return(validateAdvancedSearchForm(form));
+ }
+ else {
+ return false;
}
}
</script>
@@ -116,7 +123,7 @@
<form name="advancedSearchForm"
method="POST"
action="advancedsearchforward.jsp"
- onsubmit="return validateAdvancedSearchForm(this)"
+ onsubmit="return submitRequest(this)"
target="_top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
@@ -341,13 +348,16 @@
</tr>
<tr>
<td> </td>
- <td> </td>
+ <td>
+ <input type="hidden" name="siteValue" value="ALLSITES"/>
+ </td>
</tr>
-
+
<!--
Un-comment the following section to include an input box that allows the
user to restrict the search to a specific LTER site. Obviously, this is
- probably useful only within LTER.
+ probably useful only within LTER. If uncommenting this section,
+ be sure to comment-out the hidden siteValue input above.
-->
<!--
@@ -437,7 +447,7 @@
</tr>
<tr>
<td colspan="2" align="center">
- <input type="submit" value="Search" onClick="submitRequest(this.form)">
+ <input type="submit" value="Search">
<!-- <input type="reset" value="Reset"> -->
</td>
</tr>
@@ -447,10 +457,10 @@
<input type="hidden" name="eastBound" value=""/>
<input type="hidden" name="westBound" value=""/>
</form>
+
<script type="text/javascript" language="Javascript1.1">
<!-- Begin JavaScript input validation checking code.
-
var bCancel = false;
function validateAdvancedSearchForm(form) {
More information about the Metacat-cvs
mailing list