123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886 |
- 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 = "<font class=\"highlightText\">There is no page containing all the search terms.<br>Partial results:</font>";
- var warningMsg = '<div style="padding: 5px;margin-right:5px;;background-color:#FFFF00;">';
- warningMsg+='<b>Please note that due to security settings, Google Chrome does not highlight';
- warningMsg+=' the search results in the right frame.</b><br>';
- warningMsg+='This happens only when the WebHelp files are loaded from the local file system.<br>';
- warningMsg+='Workarounds:';
- warningMsg+='<ul>';
- warningMsg+='<li>Try using another web browser.</li>';
- warningMsg+='<li>Deploy the WebHelp files on a web server.</li>';
- warningMsg+='</div>';
- 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: ";
- function Verifie(searchForm) {
-
- 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) {
-
- alert(txt_enter_at_least_1_char);
-
- 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){
-
- 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 {
-
- expressionInput = '';
- for (var x = 0 ; x < noWords.length ; x++) {
- expressionInput = expressionInput + " " + noWords[x];
- }
- Effectuer_recherche(expressionInput);
-
- document.searchForm.textToSearch.focus();
- }
- }
- }
- var stemQueryMap = new Array();
- function Effectuer_recherche(expressionInput) {
-
-
-
- var searchFor = "";
-
- scriptLetterTab = new Scriptfirstchar();
- var wordsList = new Array();
- var finalWordsList = new Array();
- var linkTab = new Array();
- var fileAndWordList = new Array();
- var txt_wordsnotfound = "";
-
-
-
-
-
-
-
-
- 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(/[.]$/,"");
-
-
- searchFor = searchFor.replace(/ +/g, " ");
- searchFor = searchFor.replace(/ $/, "").replace(/^ /, "");
- wordsList = searchFor.split(" ");
- wordsList.sort();
-
- useCJKTokenizing = typeof indexerLanguage != "undefined" && (indexerLanguage == "zh" || indexerLanguage == "ja" || indexerLanguage == "ko");
-
-
-
- var finalArray;
- if (doStem){
- if(useCJKTokenizing){
- finalWordsList = cjkTokenize(wordsList);
- finalArray = finalWordsList;
- } else {
- finalWordsList = tokenize(wordsList);
- finalArray = finalWordsList;
- }
- } else if(useCJKTokenizing){
- finalWordsList = cjkTokenize(wordsList);
- finalArray = finalWordsList;
- } else{
-
-
-
- var tempTab = new Array();
-
-
-
-
-
-
-
- for(var t=0;t<finalWordsList.length;++t){
- var aWord=finalWordsList[t];
-
- if(w[aWord] == undefined){
- txt_wordsnotfound += aWord + " ";
- }
- else{
- tempTab.push(aWord);
- }
- }
- finalWordsList = tempTab;
-
- var inputs = expressionInput.split(' ');
-
-
-
- txt_wordsnotfound = expressionInput;
- finalWordsList = removeDuplicate(finalWordsList);
-
- }
- if (finalWordsList.length) {
-
- fileAndWordList = SortResults(finalWordsList);
-
- if (fileAndWordList == undefined){
- var cpt = 0;
- } else {
- var cpt = fileAndWordList.length;
- var maxNumberOfWords = fileAndWordList[0][0].motsnb;
- }
- if (cpt > 0){
- var searchedWords = noWords.length;
- var foundedWords = 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("<p>" + txt_results_for + " " + "<span class=\"searchExpression\">" + fileAndWordList[i][0].motslisteDisplay + "</span>" + "</p>");
- linkTab.push("<ul class='searchresult'>");
- for (t in fileAndWordList[i]) {
-
-
- var ttInfo = fileAndWordList[i][t].filenb;
-
- var ttScore = fileAndWordList[i][t].scoring;
- var tempInfo = fil[ttInfo];
-
- 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);
-
-
- if (tempPath == 'toc.html'){
- continue;
- }
-
- var split = fileAndWordList[i][t].motsliste.split(",");
-
-
-
- arrayString = 'Array(';
- for(var x in finalArray){
- if (finalArray[x].length > 2 || useCJKTokenizing){
- arrayString+= "'" + finalArray[x] + "',";
- }
- }
- arrayString = arrayString.substring(0,arrayString.length - 1) + ")";
- var idLink = 'foundLink' + no;
- var linkString = '<li><a id="' + idLink + '" href="' + tempPath + '" class="foundResult">' + tempTitle + '</a>';
- var starWidth = (ttScore * 100/ hundredProcent)/(ttScore_first/hundredProcent) * (numberOfWords/maxNumberOfWords);
- starWidth = starWidth < 10 ? (starWidth + 5) : starWidth;
-
- if (starWidth > 85){
- starWidth = 85;
- }
-
-
- if ((tempShortdesc != "null" && tempShortdesc != '...')) {
-
- linkString += "\n<div class=\"shortdesclink\">" + tempShortdesc + "</div>";
- }
- linkString += "</li>";
-
-
- linkString += "<div id=\"rightDiv\">";
- linkString += "<div id=\"star\">";
-
-
- linkString += "<ul id=\"star0\" class=\"star\">";
- linkString += "<li id=\"starCur0\" class=\"curr\" style=\"width: " + starWidth + "px;\"></li>";
- linkString += "</ul>";
-
- linkString += "<br style=\"clear: both;\">";
- linkString += "</div>";
- linkString += "</div>";
-
-
- linkTab.push(linkString);
- no++;
- }
- linkTab.push("</ul>");
- }
- }
- }
- var results = "";
- if (linkTab.length > 0) {
-
- results = "<p>";
-
- for (t in linkTab) {
- results += linkTab[t].toString();
- }
- results += "</p>";
- } else {
- results = "<p>" + localeresource.search_no_results + " <span class=\"searchExpression\">" + txt_wordsnotfound + "</span>" + "</p>";
- }
-
-
-
-
-
- if (verifyBrowser()){
- document.getElementById('searchResults').innerHTML = results;
- } else {
- document.getElementById('searchResults').innerHTML = warningMsg + results;
- }
-
- }
- function verifyWord(word, arr){
- for (var i = 0 ; i < arr.length ; i++){
- if (word[0] == arr[i][0]
- && word[1] == arr[i][1]
-
- ){
- return true;
- }
- }
- return false;
- }
- function wordsStartsWith(searchedValue){
- var toReturn = '';
- for (var sv in w){
- if (searchedValue.length < 3){
- continue;
- } else {
- if (sv.toLowerCase().indexOf(searchedValue.toLowerCase()) == 0){
- toReturn+=sv + ",";
- }
- }
- }
- return toReturn.length > 0 ? toReturn : undefined;
- }
- function tokenize(wordsList){
- var stemmedWordsList = new Array();
- var cleanwordsList = new Array();
-
-
- for(var j=0;j<wordsList.length;++j){
- var word = wordsList[j];
- var originalWord=word;
- if(typeof stemmer != "undefined" ){
- var stemmedWord=stemmer(word);
- if(w[stemmedWord]!=undefined){
- stemQueryMap[stemmer(word)] = word;
- }
- else{
- stemQueryMap[originalWord]=originalWord;
- }
- } else {
- if(w[word]!=undefined){
- stemQueryMap[word] = word;
- }
- else{
- stemQueryMap[originalWord]=originalWord;
- }
- }
- }
-
- for (var t=0;t<wordsList.length;++t) {
- 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" ){
-
- for (var i = 0; i < cleanwordsList.length; i++) {
- var stemWord = stemmer(cleanwordsList[i]);
- if(w[stemWord]!=undefined){
- stemmedWordsList.push(stemWord);
- }
- else{
- stemmedWordsList.push(cleanwordsList[i]);
- }
- }
-
-
- } else {
- stemmedWordsList = cleanwordsList;
- }
- return stemmedWordsList;
- }
- function cjkTokenize(wordsList){
- var allTokens= new Array();
- var notCJKTokens= new Array();
- var j=0;
- for(j=0;j<wordsList.length;j++){
- var word = wordsList[j];
- if(getAvgAsciiValue(word) < 127){
- notCJKTokens.push(word);
- } else {
- var tokenizer = new CJKTokenizer(word);
- var tokensTmp = tokenizer.getAllTokens();
- allTokens = allTokens.concat(tokensTmp);
- }
- }
- allTokens = allTokens.concat(tokenize(notCJKTokens));
- return allTokens;
- }
- function getAvgAsciiValue(word){
- var tmp = 0;
- var num = word.length < 5 ? word.length:5;
- for(var i=0;i<num;i++){
- if(i==5) break;
- tmp += word.charCodeAt(i);
- }
- return tmp/num;
- }
- function CJKTokenizer(input){
- this.input = input;
- this.offset=-1;
- this.tokens = new Array();
- this.incrementToken = incrementToken;
- this.tokenize = tokenize;
- this.getAllTokens = getAllTokens;
- this.unique = unique;
- function incrementToken(){
- if(this.input.length - 2 <= this.offset){
-
- return false;
- }
- else {
- this.offset+=1;
- return true;
- }
- }
- function tokenize(){
-
- 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);
-
- }
- function unique(a)
- {
- var r = new Array();
- o:for(var i = 0, n = a.length; i < n; i++)
- {
- for(var x = 0, y = r.length; x < y; x++)
- {
- if(r[x]==a[i]) continue o;
- }
- r[r.length] = a[i];
- }
- return r;
- }
- }
- function Scriptfirstchar() {
- this.strLetters = "";
- this.add = addLettre;
- }
- function addLettre(caract) {
- if (this.strLetters == 'undefined') {
- this.strLetters = caract;
- } else if (this.strLetters.indexOf(caract) < 0) {
- this.strLetters += caract;
- }
- return 0;
- }
- function loadTheIndexScripts(tab) {
-
- var scriptsarray = new Array();
- for (var i = 0; i < tab.strLetters.length; i++) {
- scriptsarray[i] = "..\/search" + "\/" + tab.strLetters.charAt(i) + ".js";
- }
-
- i++;
- scriptsarray[i] = "..\/search" + "\/" + htmlfileList;
-
- for (var t in scriptsarray) {
-
- }
- tab = new ScriptLoader();
- for (t in scriptsarray) {
- tab.add(scriptsarray[t]);
- }
- tab.load();
-
- return (scriptsarray);
- }
- function ScriptLoader() {
- this.cpt = 0;
- this.scriptTab = new Array();
- this.add = addAScriptInTheList;
- this.load = loadTheScripts;
- this.onScriptLoaded = onScriptLoadedFunc;
- }
- function addAScriptInTheList(scriptPath) {
- this.scriptTab.push(scriptPath);
- }
- function loadTheScripts() {
- var script;
- var head;
- head = document.getElementsByTagName('head').item(0);
-
- for (var el in this.scriptTab) {
-
- script = document.createElement('script');
- script.src = this.scriptTab[el];
- script.type = 'text/javascript';
- script.defer = false;
- head.appendChild(script);
- }
- }
- function onScriptLoadedFunc(e) {
- e = e || window.event;
- var target = e.target || e.srcElement;
- var isComplete = true;
- if (typeof target.readyState != undefined) {
- isComplete = (target.readyState == "complete" || target.readyState == "loaded");
- }
- if (isComplete) {
- ScriptLoader.cpt++;
- if (ScriptLoader.cpt == ScriptLoader.scripts.length) {
- ScriptLoader.onLoadComplete();
- }
- }
- }
-
- function unique(tab) {
- var a = new Array();
- var i;
- var l = tab.length;
- if (tab[0] != undefined) {
- a[0] = tab[0];
- }
- else {
- return -1;
- }
- for (i = 1; i < l; i++) {
- if (indexof(a, tab[i], 0) < 0) {
- a.push(tab[i]);
- }
- }
- return a;
- }
- function indexof(tab, element, begin) {
- for (var i = begin; i < tab.length; i++) {
- if (tab[i] == element) {
- return i;
- }
- }
- return -1;
- }
- function SortResults(mots) {
- var fileAndWordList = new Object();
- if (mots.length == 0 || mots[0].length == 0) {
- return null;
- }
-
-
-
-
-
- var scoringArr = Array();
- for (var t in mots) {
-
- var listNumerosDesFicStr = w[mots[t].toString()];
- if (listNumerosDesFicStr != undefined) {
-
- var tab = listNumerosDesFicStr.split(",");
-
- for (var t2 in tab) {
- var tmp = '';
- var idx = '';
- var temp = tab[t2].toString();
- if (temp.indexOf('*') != -1) {
- idx = temp.indexOf('*');
- tmp = temp.substring(idx + 3, temp.length);
- temp = temp.substring(0, idx);
- }
- scoringArr.push(tmp);
- if (fileAndWordList[temp] == undefined) {
- fileAndWordList[temp] = "" + mots[t];
- } else {
- fileAndWordList[temp] += "," + mots[t];
- }
-
- }
- }
- }
- var fileAndWordListValuesOnly = new Array();
-
- var temptab = new Array();
- finalObj = new Array();
- for (t in fileAndWordList) {
- finalObj.push(new newObj(t,fileAndWordList[t]));
- }
- if ( finalObj.length == 0 ) {
- return null;
- }
- finalObj = removeDerivates(finalObj);
- for (t in finalObj) {
- tab = finalObj[t].wordList.split(',');
- var tempDisplay = new Array();
- for (var x in tab) {
- if(stemQueryMap[tab[x]] != undefined && doStem){
- tempDisplay.push(stemQueryMap[tab[x]]);
- } else {
- tempDisplay.push(tab[x]);
- }
- }
- var tempDispString = tempDisplay.join(", ");
- var index;
- for (x in fileAndWordList) {
- if (x === finalObj[t].filesNo) {
- index = x;
- break;
- }
- }
- var scoring = findRating(fileAndWordList[index], index);
- temptab.push(new resultPerFile(finalObj[t].filesNo, finalObj[t].wordList, tab.length, tempDispString, scoring));
- fileAndWordListValuesOnly.push(finalObj[t].wordList);
- }
- fileAndWordListValuesOnly = unique(fileAndWordListValuesOnly);
- fileAndWordListValuesOnly = fileAndWordListValuesOnly.sort(compare_nbMots);
- var listToOutput = new Array();
- for (var fawlvoIdx in fileAndWordListValuesOnly) {
- for (t in temptab) {
- if (temptab[t].motsliste == fileAndWordListValuesOnly[fawlvoIdx]) {
- if (listToOutput[fawlvoIdx] == undefined) {
- listToOutput[fawlvoIdx] = new Array(temptab[t]);
- } else {
- listToOutput[fawlvoIdx].push(temptab[t]);
- }
- }
- }
- }
-
- for (var ltoIdx in listToOutput) {
- listToOutput[ltoIdx].sort(function(a, b){
- return b.scoring - a.scoring;
- });
- }
-
-
- for (var i = 0; i < listToOutput.length - 1; i++) {
- for (var j = i + 1; j < listToOutput.length; j++) {
- if (listToOutput[i][0].motsnb < listToOutput[j][0].motsnb
- || (listToOutput[i][0].motsnb == listToOutput[j][0].motsnb
- && listToOutput[i][0].scoring < listToOutput[j][0].scoring)
- ) {
- var x = listToOutput[i];
- listToOutput[i] = listToOutput[j];
- listToOutput[j] = x;
- }
- }
- }
- return listToOutput;
- }
- function removeDerivates(obj){
- var toResultObject = new Array();
- for (i in obj){
- var filesNo = obj[i].filesNo;
- var wordList = obj[i].wordList;
- var wList = wordList.split(",");
- var searchedWords = searchTextField.toLowerCase().split(" ");
- for (var k = 0 ; k < searchedWords.length ; k++){
- for (var j = 0 ; j < wList.length ; j++){
- if (wList[j].startsWith(searchedWords[k])){
- wList[j] = searchedWords[k];
- }
- }
- }
- wList = removeDuplicate(wList);
- var recreateList = '';
- for(var x in wList){
- recreateList+=wList[x] + ",";
- }
- recreateList = recreateList.substr(0, recreateList.length - 1);
- toResultObject.push(new newObj(filesNo, recreateList));
- }
- return toResultObject;
- }
- function newObj(filesNo, wordList){
- this.filesNo = filesNo;
- this.wordList = wordList;
- }
- function resultPerFile(filenb, motsliste, motsnb, motslisteDisplay, scoring, group) {
-
- this.filenb = filenb;
- this.motsliste = motsliste;
- this.motsnb = motsnb;
- this.motslisteDisplay= motslisteDisplay;
-
- this.scoring = scoring;
-
- }
- function findRating(words, nr){
- var sum = 0;
- var xx = words.split(',');
- for (jj = 0 ; jj < xx.length ; jj++){
- var wrd = w[xx[jj]].split(',');
- for (var ii = 0 ; ii < wrd.length ; ii++){
- var wrdno = wrd[ii].split('*');
- if (wrdno[0] == nr){
- sum+=parseInt(wrdno[1]);
- }
- }
- }
- return sum;
- }
- function compare_nbMots(s1, s2) {
- var t1 = s1.split(',');
- var t2 = s2.split(',');
-
- if (t1.length == t2.length) {
- return 0;
- } else if (t1.length > t2.length) {
- return 1;
- } else {
- return -1;
- }
-
- }
- function verifyBrowser(){
- var returnedValue = true;
- var browser = BrowserDetect.browser;
- var addressBar = window.location.href;
- if (browser == 'Chrome' && addressBar.indexOf('file://') === 0){
- returnedValue = false;
- }
-
- return returnedValue;
- }
- function removeDuplicate(arr) {
- var r = new Array();
- o:for(var i = 0, n = arr.length; i < n; i++) {
- for(var x = 0, y = r.length; x < y; x++) {
- if(r[x]==arr[i]) continue o;
- }
- r[r.length] = arr[i];
- }
- return r;
- }
- String.prototype.startsWith = function(str) {
- return (this.match("^"+str)==str);
- }
- function trim(str, chars) {
- return ltrim(rtrim(str, chars), chars);
- }
-
- function ltrim(str, chars) {
- chars = chars || "\\s";
- return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
- }
-
- function rtrim(str, chars) {
- chars = chars || "\\s";
- return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
- }
|