<%@ language="javascript" %> Search <% var NumSearchKeys = 0; function ContainsPhotoURL(LineFromFile) { LineFromFile = LineFromFile.toLowerCase(); var Index = LineFromFile.lastIndexOf(".jpg"); return (Index > -1); } function ReplaceChars(Name, ReplaceWhat, ReplaceWith) { var Index = Name.indexOf(ReplaceWhat); var NewName = ""; if (Index > -1) { while (Index > -1) { NewName += Name.substr(0, Index); NewName += ReplaceWith; Name = Name.substring(Index + 1, Name.length); Index = Name.indexOf(ReplaceWhat); } NewName += Name; } else { NewName = Name; } return NewName; } function ReplaceEscapeChars(Name) { var Index = Name.indexOf("\\"); var NewName = ""; if (Index > -1) { while (Index > -1) { NewName += Name.substr(0, Index); Name = Name.substring(Index + 1, Name.length); Index = Name.indexOf("\\"); } NewName += Name; } else { NewName = Name; } return NewName; } function ProcessPlantItems(LineFromFile, FileName) { var Index = LineFromFile.indexOf("\'"); // Get the scientific name LineFromFile = LineFromFile.substr(Index + 1); Index = LineFromFile.indexOf(","); var ScientificName = LineFromFile.substr(0, Index - 1); LineFromFile = LineFromFile.substr(Index + 1, LineFromFile.length); // Get the common name Index = LineFromFile.indexOf("\'"); LineFromFile = LineFromFile.substring(Index + 1, LineFromFile.length); Index = LineFromFile.indexOf(","); var CommonName = LineFromFile.substring(0, Index - 1); ScientificName = ReplaceEscapeChars(ScientificName); CommonName = ReplaceEscapeChars(CommonName); ScientificName = ReplaceChars(ScientificName, " ", "_"); CommonName = ReplaceChars(CommonName, " ", "_"); NumSearchKeys++; Session("Search" + String(NumSearchKeys)) = ScientificName + "*" + FileName; NumSearchKeys++; Session("Search" + String(NumSearchKeys)) = CommonName + "*" + FileName; return Index; } function ProcessFile(FileName) { var ForReading = 1; var FSO = new ActiveXObject("Scripting.FileSystemObject"); var TextFileStream = FSO.OpenTextFile(Server.MapPath(FileName), ForReading); var LineFromFile = "" do { LineFromFile = TextFileStream.ReadLine(); } while ((LineFromFile != "") && !TextFileStream.AtEndOfStream); while ((LineFromFile != "") && !TextFileStream.AtEndOfStream) { LineFromFile = TextFileStream.ReadLine(); if (ContainsPhotoURL(LineFromFile)) { LineFromFile = TextFileStream.ReadLine(); ProcessPlantItems(LineFromFile, FileName); } } TextFileStream.Close(); } function DisplaySession() { var Index = 0; var Value = ""; Response.Write(NumSearchKeys + "****************************************************
"); for (Index = 1; Index <= NumSearchKeys; Index++) { Value = Session.Contents("Search" + String(Index)); Response.Write(Value + "
"); } Response.Write("****************************************************
"); } ProcessFile("SmallPlants.asp"); ProcessFile("GrassLike.asp"); ProcessFile("AquaticReedsRushes.asp"); ProcessFile("AquaticWetlandHerbs.asp"); ProcessFile("Climbers.asp"); ProcessFile("Grasses.asp"); ProcessFile("GroundCovers.asp"); ProcessFile("LargeShrubs.asp"); ProcessFile("LiliesIrises.asp"); ProcessFile("MediumShrubs.asp"); ProcessFile("SmallShrubs.asp"); ProcessFile("SmallTrees.asp"); ProcessFile("Ferns.asp"); //DisplaySession(); %>
Greg's Indigenous Plants & Landscapes

Environmentally friendly landscapes.

" The exotic vegetation that replaces indigenous plant communities in urbanising regions, disassociates us from the rhythms and diversity of the native landscape
and a sense of the place; and we are the poorer because of it."

Michael Hough, Professor of Landscape Architecture, York University, Canada

dot

 
In This Site
 

"; HitHTML += ""; HitHTML += ""; return HitHTML; } MaxNumSearchResults = 1000; var NumSearchHits = 0; var SearchResultArray = new CreateSearchResultArray(MaxNumSearchResults); var AddSearchHitIndex = 0; function IsDuplicateHit(SearchString, ItemName, Index) { var Result = 0; // New hit has an identical search string to that of existing hit or the search string of the new hit is a substring // of that of the existing hit.. if ((SearchResultArray[Index].ItemName == ItemName) && (SearchResultArray[Index].SearchString.indexOf(SearchString) > -1)) { // So ignore it. Result = 1; } // Existing hit has a search string that is substring of new hit. else if ((SearchResultArray[Index].ItemName == ItemName) && (SearchString.indexOf(SearchResultArray[Index].SearchString) > -1)) { // Replace the existing hit with the new hit. Result = 2; AddSearchHitIndex = Index; } // This hit is already in the list but the two search string are different else if (SearchResultArray[Index].ItemName == ItemName) { Result = 3; AddSearchHitIndex = Index; } // New hit. else { // Add it to the list. Result = 4; } return Result; } function GetAccuracy(SearchString, ItemName) { var Accuracy = 0; var StringPos = SearchString.indexOf("*"); if (StringPos > -1) { var SearchWord = ""; var AverageLength = 0; var Count = 0; do { SearchWord = SearchString.substring(0, StringPos); SearchString = SearchString.substring(StringPos + 1, SearchString.length); AverageLength += SearchWord.length; Count++; StringPos = SearchString.indexOf("*"); } while (StringPos > -1); AverageLength += SearchString.length; AverageLength = AverageLength / Count; Accuracy = (AverageLength / ItemName.length) * 100; } else { Accuracy = (SearchString.length / ItemName.length) * 100; } Accuracy = Accuracy.toFixed(0); return Accuracy; } function AddAccuracy(HitHTML, Accuracy) { var StringPos = HitHTML.indexOf("#"); var StartHitHTML = ""; var EndHitHTML = ""; var NewHitHTML = ""; // HitHTML has not already had its # marker replaced with the hit accuracy. if (StringPos > -1) { StartHitHTML = HitHTML.substring(0, StringPos); EndHitHTML = HitHTML.substring(StringPos + 1, HitHTML.length); NewHitHTML = StartHitHTML + Accuracy + EndHitHTML; } // HitHTML has already had its # marker replaced with the hit accuracy (no # marker). else { // "" // The # marker has already been replaced with an accuracy. // E.G. "" // So look for the '5%' for the column width which is unique within the entire table row. StringPos = HitHTML.indexOf("5%"); if (StringPos > -1) { // "" // StringPos is pointing to the 5 // Increment the string counter until we find the '2' of 'size=2'. var StringPosStart = StringPos; do { StringPosStart++; } while (HitHTML.charAt(StringPosStart) != "2"); // "" // StringPosStart is pointing to the '2' of 'size=2' // Now we know the next '>' character will be immediately before the accuracy. do { StringPosStart++; } while (HitHTML.charAt(StringPosStart) != ">"); // "" // StringPos is pointing to the '>' immediately before the accuracy // Split the HitHTML to remove the old percentage. StartHitHTML = HitHTML.substring(0, StringPosStart); EndHitHTML = HitHTML.substring(StringPos + 1, HitHTML.length); NewHitHTML = StartHitHTML + Accuracy + EndHitHTML; } } return NewHitHTML; } function AddSearchHit(SearchString, ItemName, HitHTML) { var Result = 4; var Index = 1; var Accuracy = ""; if (NumSearchHits > 0) { while ((Index <= NumSearchHits) && (Result == 4)) { Result = IsDuplicateHit(SearchString, ItemName, Index); Index++; } } else Result = 4; // This hit is indentical to one in the list or is a substring of it. // E.G. New hit is "Bracteantha" while the existing hit is "Bracteantha vis" if (Result == 1) { // So ignore it. } // This hit is indentical to one in the list but the existing one is a substring of the new one. // E.G. New hit is "Bracteantha vis" while the existing hit is "Bracteantha" else if (Result == 2) { // Replace it. Accuracy = GetAccuracy(SearchString, ItemName); SearchResultArray[AddSearchHitIndex] = new MakeSearchResult(SearchString, Accuracy, ItemName, AddAccuracy(HitHTML, Accuracy.toString() + "%")); } // This hit is already in the list but the two search string are different. else if (Result == 3) { // Modify the html code to be displayed. var HitHTML = ReplaceChars(SearchResultArray[AddSearchHitIndex].HitHTML, " " , "_"); var IndexStartBold = HitHTML.indexOf(SearchString); var IndexEndBold = IndexStartBold + SearchString.length; var HitHTMLStart = HitHTML.substring(0, IndexStartBold); var HitHTMLBold = HitHTML.substring(IndexStartBold, IndexEndBold); var HitHTMLEnd = HitHTML.substring(IndexEndBold, HitHTML.length); HitHTML = HitHTMLStart + "" + HitHTMLBold + "" + HitHTMLEnd; HitHTML = ReplaceChars(HitHTML, "_", " "); SearchString = SearchResultArray[AddSearchHitIndex].SearchString + "*" + SearchString Accuracy = GetAccuracy(SearchString, ItemName); SearchResultArray[AddSearchHitIndex] = new MakeSearchResult(SearchString, Accuracy, ItemName, AddAccuracy(HitHTML, Accuracy.toString() + "%")); } // New hit. else if (Result == 4) { // Add it. NumSearchHits++; Accuracy = GetAccuracy(SearchString, ItemName); SearchResultArray[NumSearchHits] = new MakeSearchResult(SearchString, Accuracy, ItemName, AddAccuracy(HitHTML, Accuracy.toString() + "%")); } } function SearchSession(SearchWord) { var Index = 0; var KeyValue = ""; var StringPos = 0; var LowerCaseSearchWord = SearchWord.toLowerCase(); var LowerCaseKeyValue = ""; var ItemURL = ""; var Result = false; for (Index = 1; Index <= NumSearchKeys; Index++) { KeyValue = Session("Search" + String(Index)); LowerCaseKeyValue = KeyValue.toLowerCase(); LowerCaseKeyValue = ReplaceChars(LowerCaseKeyValue, "_", " "); StringPos = LowerCaseKeyValue.indexOf(LowerCaseSearchWord); if (StringPos > -1) { StringPos = KeyValue.indexOf("*"); ItemURL = KeyValue.substring(StringPos + 1, KeyValue.length); KeyValue = KeyValue.substring(0, StringPos); LowerCaseKeyValue = KeyValue.toLowerCase(); LowerCaseKeyValue = ReplaceChars(LowerCaseKeyValue, "_", " "); StringPos = LowerCaseKeyValue.indexOf(LowerCaseSearchWord); KeyValue = ReplaceChars(KeyValue, "_", " "); AddSearchHit(SearchWord, KeyValue, String(FormatHit(KeyValue, StringPos, SearchWord.length, ItemURL))); Result = true; } } return Result; } function DoSearch(SearchString) { var Result = false; if (SearchSession(SearchString)) { Result = true; } else { // Didn't find the search string so lets see if we can break it apart into smaller search strings on space characters. var IndexFirst = SearchString.indexOf(" "); var IndexLast = SearchString.lastIndexOf(" "); var SearchString1 = ""; var SearchString2 = ""; if ((IndexFirst == -1) && (IndexLast == -1)) { // We have a whole string ("xxx") so terminate recursion. Result = false; } else if (IndexFirst == IndexLast) { // We have two search strings seperated by a space ("xxx yyy") so break it apart and recurse on each piece. SearchString1 = SearchString.substring(0, IndexFirst); SearchString2 = SearchString.substring(IndexFirst + 1, SearchString.length); Result = DoSearch(SearchString1); Result |= DoSearch(SearchString2); } else if (IndexFirst < IndexLast) { // We have three or more search strings seperated by a space ("xxx yyy zzz") so break it apart from the begining // and end and recurse on each piece. // Get "xxx yyy" SearchString1 = SearchString.substring(0, IndexLast); // Get "yyy zzz" SearchString2 = SearchString.substring(IndexFirst + 1, SearchString.length); // So process both "xxx yyy" or "yyy zzz". Result = DoSearch(SearchString1); Result |= DoSearch(SearchString2); } } return Result; } function SwapHits(Index1, Index2) { var SearchString1 = SearchResultArray[Index1].SearchString; var Accuracy1 = SearchResultArray[Index1].Accuracy; var ItemName1 = SearchResultArray[Index1].ItemName; var HitHTML1 = SearchResultArray[Index1].HitHTML; var SearchString2 = SearchResultArray[Index2].SearchString; var Accuracy2 = SearchResultArray[Index2].Accuracy; var ItemName2 = SearchResultArray[Index2].ItemName; var HitHTML2 = SearchResultArray[Index2].HitHTML; SearchResultArray[Index2] = new MakeSearchResult(SearchString1, Accuracy1, ItemName1, HitHTML1); SearchResultArray[Index1] = new MakeSearchResult(SearchString2, Accuracy2, ItemName2, HitHTML2); } function SortSearchResultOnAccuracy() { } function DisplaySearchResult() { Response.Write("

 

Type the scientific or common name of the plant you are looking for...


<% function MakeSearchResult(SearchString, Accuracy, ItemName, HitHTML) { this.SearchString = SearchString; this.Accuracy = Accuracy; this.ItemName = ItemName; this.HitHTML = HitHTML; } function InitSearchResultArray(Array, Size) { for (Index = 0; Index < Size; Index++) Array[Index] = new MakeSearchResult("", 0, "", ""); } function CreateSearchResultArray(Size) { this.Length = Size; var Index = 0; this.Length = Size; for (Index = 1 ; Index < Size ; Index++) this[Index] = null; InitSearchResultArray(this, Size); return this; } function FormatURL(ItemURL) { var FormatedURL = ""; if (ItemURL == "AquaticReedsRushes.asp") { FormatedURL += "Aquatic Reeds & Rushes"; } else if (ItemURL == "AquaticWetlandHerbs.asp") { FormatedURL += "Aquatic Herbs"; } else if (ItemURL == "Climbers.asp") { FormatedURL += "Climbers"; } else if (ItemURL == "Ferns.asp") { FormatedURL += "Ferns"; } else if (ItemURL == "Grasses.asp") { FormatedURL += "Ornamental Grasses"; } else if (ItemURL == "GrassLike.asp") { FormatedURL += "Grass Like Plants"; } else if (ItemURL == "GroundCovers.asp") { FormatedURL += "Ground Covers"; } else if (ItemURL == "LargeShrubs.asp") { FormatedURL += "Large Shrubs"; } else if (ItemURL == "LiliesIrises.asp") { FormatedURL += "Lilies & Irises"; } else if (ItemURL == "MediumShrubs.asp") { FormatedURL += "Medium Shrubs"; } else if (ItemURL == "SmallPlants.asp") { FormatedURL += "Small Plants"; } else if (ItemURL == "SmallShrubs.asp") { FormatedURL += "Small Shrubs"; } else if (ItemURL == "SmallTrees.asp") { FormatedURL += "Small Trees"; } FormatedURL += ""; return FormatedURL; } function FormatHit(SessionSearchString, HitPos, HitLength, ItemURL) { var SessionSearchString1 = ""; var SessionSearchString2 = ""; var SessionSearchString3 = ""; var HitHTML = "" SessionSearchString1 = SessionSearchString.substring(0, HitPos); SessionSearchString2 = SessionSearchString.substr(HitPos, HitLength); SessionSearchString3 = SessionSearchString.substring(HitPos + HitLength, SessionSearchString.length); HitHTML = "
" + SessionSearchString1 + "" + SessionSearchString2 + "" + SessionSearchString3 + "#" + FormatURL(ItemURL) + "
#10%10%10%10%
"); var Index = 0; for (Index = 1; Index <= NumSearchHits; Index++) { Response.Write(SearchResultArray[Index].HitHTML); } Response.Write("
"); } if (Request.QueryString != "") { var SearchString = String(Request.QueryString("search_for")); Response.Write("

Search results for: \'" + SearchString + "\'

"); // Clear the array of previous search hits. InitSearchResultArray(SearchResultArray, NumSearchHits); if (DoSearch(SearchString)) { SortSearchResultOnAccuracy(); DisplaySearchResult(); } else { Response.Write("No matching items found..."); } } %>

 

 
In This Section
 

  dot

dot

Footer information such as street addresses, email addresses, phone numbers, disclaimers, etc. goes here.