From d9848a297d0dfc76091bb3f5c94c035a5eba7a6f Mon Sep 17 00:00:00 2001 From: Kasun Gajasinghe Date: Sat, 14 Aug 2010 11:10:15 +0000 Subject: [PATCH] Clean up of the search js code and some small modifications. --- xsl/webhelp/template/common/main.js | 6 +- .../template/content/search/nwSearchFnt.js | 119 ++++++------------ 2 files changed, 43 insertions(+), 82 deletions(-) diff --git a/xsl/webhelp/template/common/main.js b/xsl/webhelp/template/common/main.js index c38951d4c..246ecde30 100755 --- a/xsl/webhelp/template/common/main.js +++ b/xsl/webhelp/template/common/main.js @@ -1,7 +1,7 @@ /** - * main.js - * - * Developed by: Kasun Gajasinghe, David Cramer + * Miscellaneous js functions for WebHelp + * Kasun Gajasinghe, http://kasunbg.blogspot.com + * David Cramer, http://www.thingbag.net * */ diff --git a/xsl/webhelp/template/content/search/nwSearchFnt.js b/xsl/webhelp/template/content/search/nwSearchFnt.js index f34ffcf3d..0111559cc 100755 --- a/xsl/webhelp/template/content/search/nwSearchFnt.js +++ b/xsl/webhelp/template/content/search/nwSearchFnt.js @@ -1,10 +1,10 @@ /*---------------------------------------------------------------------------- - * NexWave javascript for NSI search + * JavaScript for webhelp search *---------------------------------------------------------------------------- - This file is part of the htmlsearch plugin for the DITA-OT - adapted for NSI documentation. + 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 @@ -23,14 +23,14 @@ function Verifie(ditaSearch_Form) { } - expressionInput = document.ditaSearch_Form.textToSearch.value + var expressionInput = document.ditaSearch_Form.textToSearch.value; //Set a cookie to store the searched keywords $.cookie('textToSearch', expressionInput); if (expressionInput.length < 1) { - // expression invalide (vide) + // expression is invalid alert(txt_enter_at_least_1_char); // reactive la fenetre de search (utile car cadres) document.ditaSearch_Form.textToSearch.focus(); @@ -54,22 +54,18 @@ function Effectuer_recherche(expressionInput) { //DisplayWaitingMessage(); /*data initialisation*/ - searchFor = ""; // expression en lowercase et sans les caracte res speciaux + 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 scriptsarray = new Array(); // Array with the name of the scripts to load + 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 listNumerosDesFicStr = ""; - var ou_recherche = true; var linkTab = new Array(); - var et_recherche = false; 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, "= 0; i--) { if (fileAndWordList[i] != undefined) { linkTab.push("

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

"); @@ -123,12 +119,12 @@ function Effectuer_recherche(expressionInput) { for (t in fileAndWordList[i]) { //DEBUG: alert(": "+ fileAndWordList[i][t].filenb+" " +fileAndWordList[i][t].motsliste); //linkTab.push("
  • "+fl[fileAndWordList[i][t].filenb]+"
  • "); - tempInfo = fil[fileAndWordList[i][t].filenb]; - pos1 = tempInfo.indexOf("@@@"); - pos2 = tempInfo.lastIndexOf("@@@"); - tempPath = tempInfo.substring(0, pos1); - tempTitle = tempInfo.substring(pos1 + 3, pos2); - tempShortdesc = tempInfo.substring(pos2 + 3, tempInfo.length); + var tempInfo = fil[fileAndWordList[i][t].filenb]; + var pos1 = tempInfo.indexOf("@@@"); + var pos2 = tempInfo.lastIndexOf("@@@"); + var tempPath = tempInfo.substring(0, pos1); + var tempTitle = tempInfo.substring(pos1 + 3, pos2); + var tempShortdesc = tempInfo.substring(pos2 + 3, tempInfo.length); //file:///home/kasun/docbook/WEBHELP/webhelp-draft-output-format-idea/src/main/resources/web/webhelp/installation.html var linkString = "
  • " + tempTitle + ""; @@ -172,8 +168,8 @@ function tokenize(wordsList){ } } //stemmedWordsList is the stemmed list of words separated by spaces. - for (t in wordsList) { - wordsList[t] = wordsList[t].replace(/(%22)|^-/g, "") + 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]); @@ -192,6 +188,7 @@ function tokenize(wordsList){ return stemmedWordsList; } +//Invoker of CJKTokenizer class methods. function cjkTokenize(wordsList){ var allTokens= new Array(); var notCJKTokens= new Array(); @@ -214,7 +211,7 @@ function cjkTokenize(wordsList){ function getAvgAsciiValue(word){ var tmp = 0; var num = word.length < 5 ? word.length:5; - for(i=0;i\n"); - writeln(""); - //writeln("") ; - //writeln(""); - writeln(""); - writeln("" + txt_please_wait + ""); - writeln(""); - writeln("

    " + txt_please_wait + "

    "); - close(); - } - -} +} \ No newline at end of file -- 2.40.0