?? search.js
字號(hào):
//============================================================================
function GetSelectedFields()
{
var optionArray = document.getElementById("selectedFields").options;
var returnString = "";
if( optionArray != null && optionArray[0] != null )
{
returnString = optionArray[0].text;
for( var i = 1; i < optionArray.length; i++ ) {
returnString = returnString + "*$*" + optionArray[i].text;
}
}
return returnString;
}
function addOnToFormula( strFieldToBeAdded )
{
var tempStr = document.all.DesignPane.innerText;
document.all.DesignPane.innerText = tempStr + " " + strFieldToBeAdded;
}
function moveOptionsFromListToList( fromListName, toListName, selectedOnly )
{
var fromList = document.getElementById( fromListName );
var fromOptions = fromList.options;
var toList = document.getElementById( toListName );
for( var i=0; i < fromOptions.length; i++ )
{
if( !selectedOnly || fromOptions[i].selected )
{
var newElem = document.createElement("OPTION");
newElem.text = fromOptions[i].text;
//Netscape requires a null argument to add to the end of the list - IE doesn't support null
//so we do the correct one - using document.all as an IE detecter
if( document.all )
{
toList.add( newElem );
}
else
{
toList.add( newElem, null );
}
fromList.remove(i);
i--;
}
}
}
function addToSelected()
{
moveOptionsFromListToList( "unselectedFields", "selectedFields", true );
}
function addAllToSelected()
{
moveOptionsFromListToList( "unselectedFields", "selectedFields", false );
}
function addToUnselected()
{
moveOptionsFromListToList( "selectedFields", "unselectedFields", true );
}
function addAllToUnselected()
{
moveOptionsFromListToList( "selectedFields", "unselectedFields", false );
}
function moveSelectedFieldUp()
{
var selectedList = document.getElementById( "selectedFields" );
var selectedOptions = selectedList.options;
var size = selectedOptions.length;
for( var i=0; i < size; i++ )
{
if( selectedOptions[i].selected && i > 0 )
{
//If we want to move i, then we remove the element before it (i moves up a space) and then put a copy of the
//the removed element in position i
var downElement = document.createElement( "OPTION" );
downElement.text = selectedOptions[i-1].text;
downElement.selected = selectedOptions[i-1].selected;
selectedList.remove( i-1 );
//IE doesn't support the DOM definition of selectList.add - it takes an index rather than the item to put the
//element before - so we use the existence of document.all to decide if we use IE's method or the DOM method
if( document.all )
{
selectedList.add( downElement, i );
}
else
{
selectedList.add( downElement, selectedOptions[i] );
}
}
}
}
function moveSelectedFieldDown()
{
var selectedList = document.getElementById( "selectedFields" );
var selectedOptions = selectedList.options;
for( var i=selectedOptions.length-1; i >= 0; i-- )
{
if( selectedOptions[i].selected && i < selectedOptions.length-1 )
{
//We do the same thing here as we did moving up - we want to move i+1 up - so we remove i (i+1 moves up) and then
//put a copy of the removed element in position i+1
var downElement = document.createElement( "OPTION" );
downElement.text = selectedOptions[i].text;
downElement.selected = selectedOptions[i].selected;
selectedList.remove( i );
//Again, IE doesn't support the DOM definition of selectList.add - it takes an index rather than the item to put
//the element before - so we use the existence of document.all to decide if we use IE's method or the DOM method
if( document.all )
{
selectedList.add( downElement, i+1 );
}
else
{
selectedList.add( downElement, selectedOptions[i+1] );
}
}
}
}
function addRowToFormulaTable( isIEOnMac, selectedField, selectedOp, givenValue, selectedJoin )
{
//Find out how many formula components there are
var nextNumber = new Number( document.getElementById("NumberOfRows").value );
//Get the table for the structured formula
var table = document.getElementById( "FormulaTable" );
var initialLength = table.rows.length;
if( isIEOnMac )
{
//The last row contains the add-more-rows and freefrom buttons - we'll need to
//move it down soon, so hold on to it
var lastRow = table.rows[table.rows.length-1];
var row = document.createElement( "tr" );
//Append the new row on, move the last row back to last position
table.appendChild( row );
table.appendChild( lastRow );
}
else
{
//Insert new row
var row = table.insertRow(table.rows.length-1);
}
//Add the blank spacing cell -- may turn into the join cell later
var blankCell = document.createElement( "td" );
row.appendChild( blankCell );
//Add the field cell
var fieldCell = document.createElement( "td" );
row.appendChild( fieldCell );
//We may need to add a where cell
var whereCell;
if( document.getElementById( "Where" ) != null )
{
whereCell = document.createElement( "td" );
row.appendChild( whereCell );
}
//The order of the ops and value cells depends on the language/culture
var opsCell = document.createElement( "td" );
var valueCell = document.createElement( "td" );
if( document.getElementById( "OpsFirst" ).value == "true" )
{
row.appendChild( opsCell );
row.appendChild( valueCell );
}
else
{
row.appendChild( valueCell );
row.appendChild( opsCell );
}
//Start filling cells -- do this later because otherwise the sizing is wrong
//If we had two rows, this is the first formula row, so we don't need a join
//(1st row -- headings; 2nd row -- buttons)
if( initialLength > 2 )
{
fillJoinCell( blankCell, nextNumber, selectedJoin );
}
fillFieldsCell( fieldCell, nextNumber, selectedField );
if( whereCell != null )
{
var txtNode = document.createTextNode( document.getElementById( "Where" ).value );
whereCell.appendChild( txtNode );
}
fillOpsCell( opsCell, nextNumber, selectedOp );
fillValueCell( valueCell, nextNumber, givenValue );
if( !isIEOnMac )
{
//The fill in the fillValueCell method doesn't work for NN6.2 -- so do it again here
//However, IE on the Mac doesn't like this call
if( givenValue != null )
{
document.getElementById( "ValueInFormula" + nextNumber).value = givenValue;
}
}
//Set the number for the next formula row
document.getElementById( "NumberOfRows" ).value = nextNumber+1;
}
function fillJoinCell( cell, number, selectedJoin )
{
var selectBox = document.createElement( "select" );
selectBox.name = "JoinInFormula" + number;
selectBox.id = "JoinInFormula" + number;
var joins = document.getElementById( "Joins" ).value.split( "*|*|" );
for( var i = 0; i < joins.length; i++ )
{
var nextOption = document.createElement( "option" );
nextOption.value = i;
nextOption.text = joins[i];
appendOption( selectBox, nextOption );
}
cell.align = "right";
cell.appendChild( selectBox );
if( selectedJoin > -1 && selectedJoin < joins.length )
{
selectBox.options[selectedJoin].selected = true;
}
}
function fillFieldsCell( cell, number, selectedField )
{
var selectBox = document.createElement( "select" );
selectBox.name = "FieldInFormula" + number;
selectBox.id = "FieldInFormula" + number;
var fields = document.getElementById( "FormulaFields" ).value.split( "*|*|" );
for( var i = 0; i < fields.length; i++ )
{
var nextOption = document.createElement( "option" );
nextOption.text = fields[i];
nextOption.value = fields[i];
appendOption( selectBox, nextOption );
}
cell.appendChild( selectBox );
if( selectedField > -1 && selectedField < fields.length )
{
selectBox.options[selectedField].selected = true;
}
}
function fillOpsCell( cell, number, selectedOp )
{
var selectBox = document.createElement( "select" );
selectBox.name = "OpInFormula" + number;
selectBox.id = "OpInFormula" + number;
var ops = document.getElementById( "FormulaOps" ).value.split( "*|*|" );
for( var i = 0; i < ops.length; i++ )
{
var nextOption = document.createElement( "option" );
nextOption.value = i;
nextOption.text = ops[i];
appendOption( selectBox, nextOption );
}
cell.appendChild( selectBox );
if( selectedOp > -1 && selectedOp < ops.length )
{
selectBox.options[selectedOp].selected = true;
}
}
function fillValueCell( cell, number, givenValue )
{
var textInput = document.createElement( "input" );
textInput.name = "ValueInFormula" + number;
textInput.id = "ValueInFormula" + number;
if( givenValue != null )
{
textInput.value = givenValue;
}
cell.appendChild( textInput );
}
function appendOption( selectBox, optionToAppend )
{
//This function works around the browser incompatibility of the select.add() method
if( document.all != null )
{
selectBox.add( optionToAppend );
}
else
{
selectBox.add( optionToAppend, null );
}
}
function getNeedsQuotes( index )
{
if( index >= 0 )
{
var needsQuotes = document.getElementById( "NeedsQuotes" );
if( needsQuotes != null )
{
var needsArray = needsQuotes.value.split( "*|*|" );
if( needsArray.length > index )
{
return needsArray[index];
}
}
}
return "false";
}
function CreateFormula()
{
var formula = "";
//We'll only have number of rows in structured
if( document.getElementById( "NumberOfRows" ) )
{
var numberOfRows = document.getElementById( "NumberOfRows" ).value;
for( var i =0; i < numberOfRows; i++ )
{
var joinSelect = document.getElementById( "JoinInFormula" + i );
var joinOperator = null;
if( joinSelect != null )
{
joinOperator = getJoinOperator( joinSelect.options[joinSelect.selectedIndex].value );
}
var fieldSelect = document.getElementById( "FieldInFormula" + i );
var fieldName = fieldSelect.options[fieldSelect.selectedIndex].text;
var fieldNeedsQuotes = getNeedsQuotes( fieldSelect.selectedIndex );
var opsSelect = document.getElementById( "OpInFormula" + i );
var opSymbol = getComparisonOperator( opsSelect.options[opsSelect.selectedIndex].value );
var value = document.getElementById( "ValueInFormula" + i ).value;
if( value != "" )
{
if( joinOperator != null )
{
formula += " " + joinOperator + " ";
}
formula += fieldName + " " + opSymbol + " "
if( fieldNeedsQuotes == "true" )
{
formula += "\"" + value + "\"";
}
else
{
formula += value;
}
}
}
}
else if( document.getElementById( "FormulaText" ) )
{
formula += document.getElementById( "FormulaText" ).value;
}
return formula;
}
function getComparisonOperator( opNumber )
{
var returnSymbol
if( opNumber == 0 )
{
returnSymbol = "=";
}
else if( opNumber == 1 )
{
returnSymbol = ">";
}
else if( opNumber == 2 )
{
returnSymbol = "<";
}
else if( opNumber == 3 )
{
returnSymbol = ">=";
}
else if( opNumber == 4 )
{
returnSymbol = "<=";
}
else if( opNumber == 5 )
{
returnSymbol = "<>";
}
return returnSymbol;
}
function getJoinOperator( joinNumber )
{
var returnOperator = null;
if( joinNumber == 0 )
{
returnOperator = "and";
}
else if( joinNumber == 1 )
{
returnOperator = "or";
}
return returnOperator;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -