All Downloads are FREE. Search and download functionalities are using the official Maven repository.

content.search.nwSearchFnt.js Maven / Gradle / Ivy

/*----------------------------------------------------------------------------
 * 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.replace(/\(\)\<\>["',;]/g,' ');
    //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);

	//Track with Google Analytics:
	_gaq.push(['_trackEvent', 'Search', expressionInput, 'null', 1]);


        // reactive la fenetre de search (utile car cadres)
        document.ditaSearch_Form.textToSearch.focus();

        var highlightChecked=$('#searchCheckBox').is(':checked');
        //the highlight button is checked
        if(highlightChecked){
            //first remove the previous highlight
            searchUnhighlight();
            //Now highlight the new search term
            toggleHighlight(highlightChecked);
        }
    }
}

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*/
    //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; i--) {
            if (fileAndWordList[i] != undefined) {
                linkTab.push("

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

"); linkTab.push("
    "); for (t in fileAndWordList[i]) { //DEBUG: alert(": "+ fileAndWordList[i][t].filenb+" " +fileAndWordList[i][t].motsliste); //linkTab.push("
  • "+fl[fileAndWordList[i][t].filenb]+"
  • "); 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 + ""; // var linkString = "
  • " + tempTitle + ""; if ((tempShortdesc != "null")) { linkString += "\n
    " + tempShortdesc + "
    "; } linkString += "
  • "; linkTab.push(linkString); } linkTab.push("
"); } } } var results = ""; if (linkTab.length > 0) { /*writeln ("

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

");*/ results = "

"; //write("

    "); for (t in linkTab) { results += linkTab[t].toString(); } results += "

    "; } else { results = "

    " + "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=0;j"; return this.input.substring(this.offset,this.offset+2); } function getAllTokens(){ while(this.incrementToken()){ var tmp = this.tokenize(); this.tokens.push(tmp); } return this.unique(this.tokens); // document.getElementById("content").innerHTML += tokens+" "; // document.getElementById("content").innerHTML += "
    dada"+sortedTokens+" "; // console.log(tokens.length+"dsdsds"); /*for(i=0;i t2.length) { return 1; } else { return -1; } //return t1.length - t2.length); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy