Project

General

Profile

« Previous | Next » 

Revision 2774

Added by Duane Costa over 18 years ago

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.)

View differences:

lib/style/skins/default/include_advancedsearch.jsp
2 2
<!--
3 3
/**
4 4
  *  '$RCSfile$'
5
  *      Authors: Duane Costa
6
  *    Copyright: 2000 Regents of the University of California and the
7
  *               National Center for Ecological Analysis and Synthesis
8
  *  For Details: http://www.nceas.ucsb.edu/
5
  *      Authors:     Duane Costa
6
  *      Copyright:   2005 University of New Mexico and
7
  *                   Regents of the University of California and the
8
  *                   National Center for Ecological Analysis and Synthesis
9
  *      For Details: http://www.nceas.ucsb.edu/
9 10
  *
10 11
  *   '$Author$'
11 12
  *     '$Date$'
......
42 43

  
43 44
  <script language="javascript" type="text/javascript">
44 45

  
45
    function trim(stringToTrim) {
46
      return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
47
    }
46
      function trim(stringToTrim) {
47
        return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
48
      }
48 49

  
49
    function allowSearch(formObj) {
50
      var canSearch = true;
51
      var searchString = trim(formObj.elements["anyfield"].value);
52
      if (searchString=="") {
53
        if (confirm("Show *all* data in the Catalog?\n(this may take some time!)            ")) {
54
	      formObj.elements["anyfield"].value = "%";
55
	      canSearch = true;
56
	      } else {
57
	        formObj.elements["anyfield"].focus();
58
	        canSearch = false;
59
	      }
60
      } 
61
      return canSearch;
62
    }
63

  
64 50
      function submitRequest(form) {
51
        var canSearch = true;
65 52
        var x_range = document.map.get_x_range();
66 53
        var y_range = document.map.get_y_range();
67 54
        var x_index = x_range.indexOf(' ');
......
72 59
        var x_hi = x_range.substring(x_index + 1, x_length);
73 60
        var y_lo = y_range.substring(0, y_index);
74 61
        var y_hi = y_range.substring(y_index + 1, y_length);
75
        
76
        // Re-initialize the hidden form values prior to submitting
77
        document.advancedSearchForm.northBound.value = "";
78
        document.advancedSearchForm.southBound.value = "";
79
        document.advancedSearchForm.eastBound.value = "";
80
        document.advancedSearchForm.westBound.value = "";
81 62

  
82
        if ((x_range != "-180.0 180.0") && (y_range != "-90.0 90.0")) {     
83
          document.advancedSearchForm.northBound.value = y_hi;
84
          document.advancedSearchForm.southBound.value = y_lo;
85
          document.advancedSearchForm.eastBound.value = x_hi;
86
          document.advancedSearchForm.westBound.value = x_lo;
63
        if (trim(form.subjectValue.value) == "" &&
64
            trim(form.creatorSurname.value) == "" &&
65
            trim(form.creatorOrganization.value) == "" &&
66
            trim(form.locationName.value) == "" &&
67
            (x_range == "-180.0 180.0") &&
68
            (y_range == "-90.0 90.0") &&            
69
            trim(form.taxon.value) == "" &&
70
            form.siteValue.value == "ALLSITES"
71
           ) {              
72
          canSearch = 
73
             confirm("Show *all* data in the catalog?\n(This may take some time!)");
87 74
        }
75

  
76
        if (canSearch) {        
77
          // Re-initialize the hidden form values prior to submitting
78
          form.northBound.value = "";
79
          form.southBound.value = "";
80
          form.eastBound.value = "";
81
          form.westBound.value = "";
82

  
83
          if ((x_range != "-180.0 180.0") && (y_range != "-90.0 90.0")) {     
84
            form.northBound.value = y_hi;
85
            form.southBound.value = y_lo;
86
            form.eastBound.value = x_hi;
87
            form.westBound.value = x_lo;
88
          }
89
          
90
          return(validateAdvancedSearchForm(form));
91
        }
92
        else {
93
          return false;
94
        }
88 95
      }
89 96
  </script>
90 97
</head>
......
116 123
    <form name="advancedSearchForm"
117 124
          method="POST"
118 125
          action="advancedsearchforward.jsp"
119
          onsubmit="return validateAdvancedSearchForm(this)"
126
          onsubmit="return submitRequest(this)"
120 127
          target="_top">
121 128
      <table width="100%" border="0" cellpadding="0" cellspacing="0" >
122 129
        <tr>
......
341 348
        </tr>
342 349
        <tr>
343 350
          <td>&nbsp;</td>
344
          <td>&nbsp;</td>
351
          <td>&nbsp;
352
            <input type="hidden" name="siteValue" value="ALLSITES"/>
353
          </td>
345 354
        </tr>
346
        
355

  
347 356
<!--   
348 357
    Un-comment the following section to include an input box that allows the
349 358
    user to restrict the search to a specific LTER site. Obviously, this is
350
    probably useful only within LTER.
359
    probably useful only within LTER. If uncommenting this section, 
360
    be sure to comment-out the hidden siteValue input above.
351 361
-->
352 362
       
353 363
<!--
......
437 447
        </tr>
438 448
        <tr>
439 449
          <td colspan="2" align="center">
440
            <input type="submit" value="Search" onClick="submitRequest(this.form)">&nbsp;&nbsp;
450
            <input type="submit" value="Search">&nbsp;&nbsp;
441 451
            <!-- <input type="reset" value="Reset"> -->
442 452
          </td>
443 453
        </tr>
......
447 457
      <input type="hidden" name="eastBound" value=""/>
448 458
      <input type="hidden" name="westBound" value=""/>
449 459
    </form>
460
    
450 461
    <script type="text/javascript" language="Javascript1.1"> 
451 462

  
452 463
    <!-- Begin JavaScript input validation checking code.
453

  
454 464
    var bCancel = false; 
455 465

  
456 466
    function validateAdvancedSearchForm(form) {                                                                   

Also available in: Unified diff