Project

General

Profile

« Previous | Next » 

Revision 2214

Added by Matt Jones over 20 years ago

Modifications to make JS search functions work in the knb2 skin.

View differences:

lib/style/skins/knb2/portalpages.js
1
// JavaScript Document
2

  
3
var popupMsg = "If you need to create a new account, \n"
4
			  +"click the \"create new account\" link \n"
5
			  +"beneath the password text-box";
6

  
7
function allowSubmit(formObj) {
8

  
9
  if (trim(formObj.elements["loginAction"].value)!="Login") return true;
10

  
11
  //trim username & passwd:
12
  var username = trim(formObj.elements["username"].value);
13
  var organization  = trim(formObj.elements["organization"].value);
14
  var password      = trim(formObj.elements["password"].value);
15

  
16
  if (username=="") {
17
    alert("You must type a username. \n"+popupMsg);
18
	formObj.elements["username"].focus();
19
    return false;
20
  } 
21
  
22
  if (organization=="") {
23
    alert("You must select an organization. \n"+popupMsg);
24
	formObj.elements["organization"].focus();
25
    return false;
26
  } 
27
  
28
  if (password=="") {
29
    alert("You must type a password. \n"+popupMsg);
30
	formObj.elements["password"].focus();
31
    return false;
32
  }
33
  return true;
34
}	
35

  
36
function allowSearch(formObj) {
37

  
38
  var canSearch = true;
39
  var searchString = trim(formObj.elements["anyfield"].value);
40
  if (searchString=="") {
41
    if (confirm("Show *all* data in the KNB?\n(this may take some time!)")) {
42
	  formObj.elements["anyfield"].value = "%";
43
	  canSearch = true;
44
	} else {
45
	  formObj.elements["anyfield"].focus();
46
	  canSearch = false;
47
	}
48
  } 
49
  return canSearch;
50
}
51

  
52

  
53
function allowAdvancedSearch(inputFormObj, submitFormObj) {
54

  
55
  var searchString = trim(inputFormObj.elements["searchValue"].value);
56
  
57
  if (searchString=="") searchString="%";
58
  
59
  if (inputFormObj.searchField.value=='anyfield') {
60
    
61
    submitFormObj.anyfield.value=searchString;
62
      
63
  } else if (inputFormObj.searchField.value=='title') {
64
    
65
    submitFormObj.title.value=searchString;
66
      
67
  } else if (inputFormObj.searchField.value=='surname') {
68
    
69
    submitFormObj.surName.value=searchString;
70
  }
71
  return true;
72
}
73

  
74
function keywordSearch(formObj, searchKeyword) {
75

  
76
  var searchString = trim(searchKeyword);
77
  
78
  if (searchString=="") searchString="%";
79
  
80
  formObj.anyfield.value=searchString;
81

  
82
  formObj.submit();
83

  
84
  return true;
85
}
86

  
87
function trim(stringToTrim) {
88

  
89
  return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
90
}
0 91

  
lib/style/skins/knb2/index.jsp
261 261
        <tr>
262 262
          <td class="text_plain"><table width="100%" border="0" cellspacing="0" cellpadding="0">
263 263
              <tr> 
264
                <td width="10" align="right" valign="top"><img src="<%=relativeRoot%>/images/panelhead_bg_lcorner.gif" width="10" height="21"></td>
264
                <td width="10" align="right" valign="top"><img src="images/panelhead_bg_lcorner.gif" width="10" height="21"></td>
265 265
                <td width="720" class="sectionheader">about the KNB project</td>
266
                <td width="10" align="left" valign="top"><img src="<%=relativeRoot%>/images/panelhead_bg_rcorner.gif" width="10" height="21"></td>
266
                <td width="10" align="left" valign="top"><img src="images/panelhead_bg_rcorner.gif" width="10" height="21"></td>
267 267
              </tr>
268 268
              <tr> 
269 269
                <td colspan="3"><table width="740" border="0" cellpadding="2" cellspacing="0" class="subpanel">
lib/style/skins/knb2/include_searchbox_page.jsp
38 38
<head>
39 39
  <title>KNB :: The Knowledge Network for Biocomplexity</title>
40 40
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
41
  <link href="<%=relativeRoot%>/portalpages.css" rel="stylesheet" type="text/css">
42
  <script language="JavaScript" type="text/JavaScript" src="<%=relativeRoot%>/portalpages.js"></script>
41
  <link href="portalpages.css" rel="stylesheet" type="text/css">
42
  <script language="JavaScript" type="text/JavaScript" src="portalpages.js"></script>
43 43
  </head>
44 44

  
45 45
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
46 46
  <table width="740" border="0" cellspacing="0" cellpadding="0" align="center">
47 47
    <tr> 
48
      <td><img src="<%=relativeRoot%>/images/transparent1x1.gif" width="20" height="20"/></td>
48
      <td><img src="images/transparent1x1.gif" width="20" height="20"/></td>
49 49
    </tr>
50 50
    <tr> 
51 51
      <td align="center"><%@ include file="include_searchbox.jsp" %></td>
lib/style/skins/knb2/include_searchbox.jsp
32 32
<!-- *********************** START SEARCHBOX TABLE ************************* -->
33 33
<table width="740" border="0" cellspacing="0" cellpadding="0">
34 34
  <tr> 
35
    <td width="10" align="right" valign="top"><img src="<%=relativeRoot%>/images/panelhead_bg_lcorner.gif" width="10" height="21"></td>
35
    <td width="10" align="right" valign="top"><img src="images/panelhead_bg_lcorner.gif" width="10" height="21"></td>
36 36
    <td width="720" class="sectionheader">search for data on the 
37 37
      KNB</td>
38
    <td width="10" align="left" valign="top"><img src="<%=relativeRoot%>/images/panelhead_bg_rcorner.gif" width="10" height="21"></td>
38
    <td width="10" align="left" valign="top"><img src="images/panelhead_bg_rcorner.gif" width="10" height="21"></td>
39 39
  </tr>
40 40
  <tr> 
41 41
    <td colspan="3"> <table width="740" border="0" cellpadding="0" cellspacing="0" class="subpanel">
......
48 48
              <%=sessionidField%> <%=SIMPLE_SEARCH_METACAT_POST_FIELDS%> 
49 49
              <table width="100%" border="0" cellpadding="5" cellspacing="0">
50 50
                <tr> 
51
                  <td width="94" rowspan="2" align="left" valign="top"><img src="<%=relativeRoot%>/images/search.jpg" width="94" height="80"></td>
52
                  <td colspan="2" valign="middle" class="text_example"><p> <%= loginStatus %>&nbsp&nbsp;(<a href="<%=relativeRoot%>/index.jsp#loginanchor" target="_top"><%=loginButtonLabel%></a>).&nbsp; You may search the KNB without 
51
                  <td width="94" rowspan="2" align="left" valign="top"><img src="images/search.jpg" width="94" height="80"></td>
52
                  <td colspan="2" valign="middle" class="text_example"><p> <%= loginStatus %>&nbsp&nbsp;(<a href="index.jsp#loginanchor" target="_top"><%=loginButtonLabel%></a>).&nbsp; You may search the KNB without 
53 53
                      being logged into your account, but will have access only 
54 54
                      to &quot;public&quot; data (see &quot;login &amp; registration&quot;)<br></br> 
55 55
                      Enter a search phrase (e.g. biodiversity) to search for 
......
61 61
                  <td align="right" class="searchcat"> <input type="text" name="anyfield"  size="30" maxlength="200"> 
62 62
                    &nbsp;&nbsp;</td>
63 63
                  <td width="365" align="left" class="searchcat"> <input type="submit" value="Search KNB"> 
64
                    &nbsp;&nbsp;&nbsp;<a href="<%=relativeRoot%>/advancedsearch.jsp" target="_top"> 
64
                    &nbsp;&nbsp;&nbsp;<a href="advancedsearch.jsp" target="_top"> 
65 65
                    &raquo;&nbsp;advanced&nbsp;search&nbsp;&laquo;</a></td>
66 66
                </tr>
67 67
              </table>

Also available in: Unified diff