/*---------------------------------------------------------------------------- * JavaScript for webhelp search *---------------------------------------------------------------------------- This file is part of the webhelpsearch plugin for DocBook WebHelp Copyright (c) 2007-2008 NexWave Solutions All Rights Reserved. www.nexwave.biz Nadege Quaine http://kasunbg.blogspot.com/ Kasun Gajasinghe */ //string initialization var htmlfileList = "htmlFileInfoList.js"; var htmlfileinfoList = "htmlFileInfoList.js"; var useCJKTokenizing = false; var w = new Object(); var scoring = new Object(); var searchTextField = ''; var no = 0; var noWords = 0; var partialSearch = "There is no page containing all the search terms.
Partial results:
"; var warningMsg = '
'; warningMsg+='Please note that due to security settings, Google Chrome does not highlight'; warningMsg+=' the search results in the right frame.
'; warningMsg+='This happens only when the WebHelp files are loaded from the local file system.
'; warningMsg+='Workarounds:'; warningMsg+='
'; txt_filesfound = 'Results'; txt_enter_at_least_1_char = "You must enter at least one character."; txt_enter_more_than_10_words = "Only first 10 words will be processed."; txt_browser_not_supported = "Your browser is not supported. Use of Mozilla Firefox is recommended."; txt_please_wait = "Please wait. Search in progress..."; txt_results_for = "Results for: "; /* This function verify the validity of search input by the user Cette fonction verifie la validite de la recherche entrre par l utilisateur */ function Verifie(searchForm) { // Check browser compatibility if (navigator.userAgent.indexOf("Konquerer") > -1) { alert(txt_browser_not_supported); return; } searchTextField = trim(document.searchForm.textToSearch.value); searchTextField = searchTextField.replace(/['"]/g,''); var expressionInput = searchTextField; $.cookie('textToSearch', expressionInput); if (expressionInput.length < 1) { // expression is invalid alert(txt_enter_at_least_1_char); // reactive la fenetre de search (utile car cadres) document.searchForm.textToSearch.focus(); } else { var splitSpace = searchTextField.split(" "); var splitWords = []; for (var i = 0 ; i < splitSpace.length ; i++) { var splitDot = splitSpace[i].split("."); if(!(splitDot.length == 1)){ splitWords.push(splitSpace[i]); } for (var i1 = 0; i1 < splitDot.length; i1++) { var splitColon = splitDot[i1].split(":"); for (var i2 = 0; i2 < splitColon.length; i2++) { var splitDash = splitColon[i2].split("-"); for (var i3 = 0; i3 < splitDash.length; i3++) { if (splitDash[i3].split("").length > 0) { splitWords.push(splitDash[i3]); } } } } } noWords = splitWords; if (noWords.length > 9){ // Allow to search maximum 10 words alert(txt_enter_more_than_10_words); expressionInput = ''; for (var x = 0 ; x < 10 ; x++){ expressionInput = expressionInput + " " + noWords[x]; } Effectuer_recherche(expressionInput); document.searchForm.textToSearch.focus(); } else { // Effectuer la recherche expressionInput = ''; for (var x = 0 ; x < noWords.length ; x++) { expressionInput = expressionInput + " " + noWords[x]; } Effectuer_recherche(expressionInput); // reactive la fenetre de search (utile car cadres) document.searchForm.textToSearch.focus(); } } } var stemQueryMap = new Array(); // A hashtable which maps stems to query words /* This function parses the search expression, loads the indices and displays the results*/ function Effectuer_recherche(expressionInput) { /* Display a waiting message */ //DisplayWaitingMessage(); /*data initialisation*/ var searchFor = ""; // expression en lowercase et sans les caracte res speciaux //w = new Object(); // hashtable, key=word, value = list of the index of the html files scriptLetterTab = new Scriptfirstchar(); // Array containing the first letter of each word to look for var wordsList = new Array(); // Array with the words to look for var finalWordsList = new Array(); // Array with the words to look for after removing spaces var linkTab = new Array(); var fileAndWordList = new Array(); var txt_wordsnotfound = ""; // -------------------------------------- // Begin Thu's patch /*nqu: expressionInput, la recherche est lower cased, plus remplacement des char speciaux*/ //The original replacement expression is: //searchFor = expressionInput.toLowerCase().replace(/<\//g, "_st_").replace(/\$_/g, "_di_").replace(/\.|%2C|%3B|%21|%3A|@|\/|\*/g, " ").replace(/(%20)+/g, " ").replace(/_st_/g, " 0){ var searchedWords = noWords.length; var foundedWords = fileAndWordList[0][0].motslisteDisplay.split(",").length; //console.info("search : " + noWords.length + " found : " + fileAndWordList[0][0].motslisteDisplay.split(",").length); if (searchedWords != foundedWords){ linkTab.push(partialSearch); } } for (var i = 0; i < cpt; i++) { var hundredProcent = fileAndWordList[i][0].scoring + 100 * fileAndWordList[i][0].motsnb; var ttScore_first = fileAndWordList[i][0].scoring; var numberOfWords = fileAndWordList[i][0].motsnb; if (fileAndWordList[i] != undefined) { linkTab.push("

" + txt_results_for + " " + "" + fileAndWordList[i][0].motslisteDisplay + "" + "

"); linkTab.push(""); } } } var results = ""; if (linkTab.length > 0) { /*writeln ("

" + txt_results_for + " " + "" + cleanwordsList + "" + "
"+"

");*/ results = "

"; //write("