lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject cvs commit: jakarta-lucene-sandbox/contributions/javascript/queryConstructor luceneQueryConstructor.js
Date Tue, 03 Dec 2002 11:48:17 GMT
kelvint     2002/12/03 03:48:17

  Modified:    contributions/javascript/queryConstructor
                        luceneQueryConstructor.js
  Log:
  Supports radio buttons and text fields as modifiers, instead of boring old select lists.
  
  Revision  Changes    Path
  1.3       +28 -4     jakarta-lucene-sandbox/contributions/javascript/queryConstructor/luceneQueryConstructor.js
  
  Index: luceneQueryConstructor.js
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene-sandbox/contributions/javascript/queryConstructor/luceneQueryConstructor.js,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- luceneQueryConstructor.js	9 May 2002 02:39:26 -0000	1.2
  +++ luceneQueryConstructor.js	3 Dec 2002 11:48:17 -0000	1.3
  @@ -1,15 +1,15 @@
   // Lucene Search Query Constructor
  -// Author:  Kelvin Tan  (kelvin@relevanz.com)
  +// Author:  Kelvin Tan  (kelvin at relevanz.com)
   
   // Change this according to what you use to name the field modifiers in your form.
   // e.g. with the field "name", the modifier will be called "nameModifier"
   var modifierSuffix = 'Modifier';
   
   // Do you wish the query to be displayed as an alert box?
  -var debug = true;
  +var debug = false;
   
   // Do you wish the function to submit the form upon query construction?
  -var submitOnConstruction = true;
  +var submitOnConstruction = false;
   
   // prefix modifier for boolean AND queries
   var AND_MODIFIER = '+';
  @@ -42,7 +42,31 @@
           var subElement = formElements[j];
           if(subElement.name == (elementName + modifierSuffix))
           {
  -          var subElementValue = subElement.options[subElement.selectedIndex].value;
  +          var subElementValue;
  +          
  +          // support drop-down select lists, radio buttons and text fields
  +          if(subElement.type == "select")
  +          {
  +            subElementValue = subElement.options[subElement.selectedIndex].value;
  +          }
  +          else if(subElement.type == "radio")
  +          {
  +            // radio button elements often have the same element name, 
  +            // so ensure we have the right one
  +            if(subElement.checked)
  +            {
  +              subElementValue = subElement.value;              
  +            }
  +            else
  +            {
  +              continue;
  +            }
  +          }
  +          else
  +          {
  +            subElementValue = subElement.value;
  +          }
  +          
             if(subElementValue == 'And')
             {
               addFieldWithModifier(query, AND_MODIFIER, elementName, elementValue);
  
  
  

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message