X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/793149f04ce52bf75dc4efb7b83a3f8ed30d1fff..35ec793690104efdd610964d255302a0310a2daf:/doc/xslt/webhelp/docs/content/search/nwSearchFnt.js diff --git a/doc/xslt/webhelp/docs/content/search/nwSearchFnt.js b/doc/xslt/webhelp/docs/content/search/nwSearchFnt.js deleted file mode 100644 index 0111559c..00000000 --- a/doc/xslt/webhelp/docs/content/search/nwSearchFnt.js +++ /dev/null @@ -1,513 +0,0 @@ -/*---------------------------------------------------------------------------- - * 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 = "htmlFileList.js"; -var htmlfileinfoList = "htmlFileInfoList.js"; -var useCJKTokenizing = false; - -/* Cette fonction verifie la validite de la recherche entrre par l utilisateur */ -function Verifie(ditaSearch_Form) { - - // Check browser compatibitily - if (navigator.userAgent.indexOf("Konquerer") > -1) { - - alert(txt_browser_not_supported); - return; - } - - - var expressionInput = document.ditaSearch_Form.textToSearch.value; - //Set a cookie to store the searched keywords - $.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.ditaSearch_Form.textToSearch.focus(); - } - else { - - // Effectuer la recherche - Effectuer_recherche(expressionInput); - - // reactive la fenetre de search (utile car cadres) - document.ditaSearch_Form.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 = ""; - - - /*nqu: expressionInput, la recherche est lower cased, plus remplacement des char speciaux*/ - searchFor = expressionInput.toLowerCase().replace(/<\//g, "_st_").replace(/\$_/g, "_di_").replace(/\.|%2C|%3B|%21|%3A|@|\/|\*/g, " ").replace(/(%20)+/g, " ").replace(/_st_/g, "").replace(/_di_/g, "%24_"); - - searchFor = searchFor.replace(/ +/g, " "); - searchFor = searchFor.replace(/ $/, "").replace(/^ /, ""); - - wordsList = searchFor.split(" "); - wordsList.sort(); - - //set the tokenizing method - if(typeof indexerLanguage != "undefined" && (indexerLanguage=="zh" || indexerLanguage=="ja" ||indexerLanguage=="ko")){ - useCJKTokenizing=true; - } else { - useCJKTokenizing=false; - } - //If Lucene CJKTokenizer was used as the indexer, then useCJKTokenizing will be true. Else, do normal tokenizing. - // 2-gram tokenizinghappens in CJKTokenizing, - if(useCJKTokenizing){ - finalWordsList = cjkTokenize(wordsList); - } else { - finalWordsList = tokenize(wordsList); - } - - //load the scripts with the indices: the following lines do not work on the server. To be corrected - /*if (IEBrowser) { - scriptsarray = loadTheIndexScripts (scriptLetterTab); - } */ - - /** - * Compare with the indexed words (in the w[] array), and push words that are in it to tempTab. - */ - var tempTab = new Array(); - for (var t in finalWordsList) { - if (w[finalWordsList[t].toString()] == undefined) { - txt_wordsnotfound += finalWordsList[t] + " "; - } else { - tempTab.push(finalWordsList[t]); - } - } - finalWordsList = tempTab; - - if (finalWordsList.length) { - - //search 'and' and 'or' one time - fileAndWordList = SortResults(finalWordsList); - - var cpt = fileAndWordList.length; - for (var i = cpt - 1; i >= 0; i--) { - if (fileAndWordList[i] != undefined) { - linkTab.push("
" + txt_results_for + " " + "" + fileAndWordList[i][0].motslisteDisplay + "" + "
"); - - linkTab.push("" + txt_results_for + " " + "" + cleanwordsList + "" + "
"+"
"; - //write("
" + "Your search returned no results for " + "" + txt_wordsnotfound + "" + "
"; - } - //alert(results); - document.getElementById('searchResults').innerHTML = results; -} - -function tokenize(wordsList){ - var stemmedWordsList = new Array(); // Array with the words to look for after removing spaces - var cleanwordsList = new Array(); // Array with the words to look for - for(var j in wordsList){ - var word = wordsList[j]; - if(typeof stemmer != "undefined" ){ - stemQueryMap[stemmer(word)] = word; - } else { - stemQueryMap[word] = word; - } - } - //stemmedWordsList is the stemmed list of words separated by spaces. - for (var t in wordsList) { - wordsList[t] = wordsList[t].replace(/(%22)|^-/g, ""); - if (wordsList[t] != "%20") { - scriptLetterTab.add(wordsList[t].charAt(0)); - cleanwordsList.push(wordsList[t]); - } - } - - if(typeof stemmer != "undefined" ){ - //Do the stemming using Porter's stemming algorithm - for (var i = 0; i < cleanwordsList.length; i++) { - var stemWord = stemmer(cleanwordsList[i]); - stemmedWordsList.push(stemWord); - } - } else { - stemmedWordsList = cleanwordsList; - } - return stemmedWordsList; -} - -//Invoker of CJKTokenizer class methods. -function cjkTokenize(wordsList){ - var allTokens= new Array(); - var notCJKTokens= new Array(); - var j=0; - for(j=0;j