Produced by Araxis Merge on 1/2/2018 12:00:15 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Tue Jan 2 17:00:15 2018 UTC | ||
| 2 | HTRE_P2.zip\src.zip\output\ihta_admin.zip\hdi.zip | whfhost.js | Wed Feb 5 14:58:04 2014 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 3842 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | // We bHelp 5.10 .003 | |||||
| 2 | var gsNoTo pics="No T opics Foun d."; | |||||
| 3 | var gsLoad XmlFailed= "Error: Fa iled to lo ad xml fil e."; | |||||
| 4 | var gsInit DatabaseFa iled="Erro r: Failed to initial ize databa se."; | |||||
| 5 | var gsNotA llDatabase Inited="Wa rning: Not all datab ases have been loade d. Some to pics will not be fou nd."; | |||||
| 6 | var gsInva lidExpress ion_1="The words you typed is not a vali d expressi on."; | |||||
| 7 | var gsInva lidExpress ion_2="Cli ck"; | |||||
| 8 | var gsInva lidExpress ion_3="Hel p"; | |||||
| 9 | var gsInva lidExpress ion_4="to learn how to use que ry express ion.(To be finished) "; | |||||
| 10 | var gsSear ching="Sea rching..." ; | |||||
| 11 | var gsTitl e="Title"; | |||||
| 12 | var gsRank ="Rank"; | |||||
| 13 | var gsCanc el="Cancel "; | |||||
| 14 | var gsCanc eled="Canc eled"; | |||||
| 15 | ||||||
| 16 | var gsTota lNumberOfS earchResul ts = "Tota l Number o f Search R esults : % 1"; | |||||
| 17 | var gbShow TotalNumbe rOfSearchR esults=0; | |||||
| 18 | var gbEnab leAndSearc h =false; | |||||
| 19 | ||||||
| 20 | var gsSubs trSrch=0; | |||||
| 21 | var gsHide RankColumn =0; | |||||
| 22 | ||||||
| 23 | var g_Rune sVowels="\ u0061\u006 5\u0069\u0 06F\u0075\ u0079"; | |||||
| 24 | var g_Rune sWordBreak s="\u0001\ u0002\u000 3\u0004\u0 005\u0006\ u0007\u000 8\u0009\u0 00A\u000B\ u000C\u000 D\u000E\u0 00F\u0010\ u0011\u001 2\u0013\u0 014\u0015\ u0016\u001 7\u0018\u0 019\u001A\ u001B\u001 C\u001D\u0 01E\u001F\ u0022\u005 C\u0020\u0 02E\u002C\ u0021\u004 0\u0023\u0 024\u0025\ u005E\u002 6\u002A\u0 028\u0029\ u007E\u002 7\u0060\u0 03A\u003B\ u003C\u003 E\u003F\u0 02F\u007B\ u007D\u005 B\u005D\u0 07C\u002B\ u002D\u003 D\u0081\u0 082\u0083\ u0084\u008 5\u0086\u0 087\u0088\ u0089\u008 A\u008B\u0 08C\u008D\ u008E\u008 F\u0090\u0 091\u0092\ u0093\u009 4\u0095\u0 096\u0097\ u0098\u009 9\u009A\u0 09B\u009C\ u009D\u009 E\u009F\u0 0A1\u00A9\ u00AB\u00A E\u00B7\u0 0BB\u00BF\ u00A0\u200 0\u2001\u2 002\u2003\ u2004\u200 5\u2006\u2 007\u2008\ u2009\u200 A\u2028\u2 029\u202F\ u205F\u300 0"; | |||||
| 25 | var g_Rune sWhiteSpac es="\u0020 \u0009\u00 0D\u000A\u 00A0\u2000 \u2001\u20 02\u2003\u 2004\u2005 \u2006\u20 07\u2008\u 2009\u200A \u2028\u20 29\u202F\u 205F\u3000 "; | |||||
| 26 | var g_Rune sSpecialBr eaks = ",! @#$%^&*()~ '`:;<>?/{} []|+-=" ; | |||||
| 27 | var g_Rune sQuote='\x 22'; | |||||
| 28 | var g_Rune sHelSuffix es=new Arr ay("ed,0", "ingly,0", "ings,0"," ing,0","ly ,1","s,1", "e,1"); | |||||
| 29 | ||||||
| 30 | var gbHigh Light=true ; | |||||
| 31 | var gsHLCo lorFront=" #000000"; | |||||
| 32 | var gsHLCo lorBackgro und="#b2b4 bf"; | |||||
| 33 | var gsAsce ndFlag = " △"; | |||||
| 34 | var gsDesc endFlag = "▽"; | |||||
| 35 | ||||||
| 36 | var gAIRSe archObject ; | |||||
| 37 | var gsResu ltDivID="R esultDiv"; | |||||
| 38 | var gbRead y=false; | |||||
| 39 | var gbXML= false; | |||||
| 40 | var gsBgCo lor="#ffff ff"; | |||||
| 41 | var gsBgIm age=""; | |||||
| 42 | var gsMarg in="0pt"; | |||||
| 43 | var gsInde nt="0pt"; | |||||
| 44 | var goFont =null; | |||||
| 45 | var goErrF ont=null; | |||||
| 46 | var goHove rFont=null ; | |||||
| 47 | var gsABgC olor="#ccc ccc"; | |||||
| 48 | var gbWhFH ost=false; | |||||
| 49 | var gbAIRS earchResul tDisplayDo neFn=dummy SearchResu ltFn; | |||||
| 50 | var gbAIRS earchResul tDoneSteps =0; | |||||
| 51 | var gbAIRS earchResul tDone=fals e; | |||||
| 52 | ||||||
| 53 | var g_nSor tType = 0; | |||||
| 54 | var g_nX0 = 0; | |||||
| 55 | var g_nIni tWidth = 0 ; | |||||
| 56 | var g_bDra ging = fal se; | |||||
| 57 | var g_nRan kWidthMin = 20; | |||||
| 58 | ||||||
| 59 | var ECS_NO NE = 0; | |||||
| 60 | var ECS_FT SREADY = 1; | |||||
| 61 | var ECS_SE ARCHING = 2; | |||||
| 62 | var ECS_FA TALERROR = 3; | |||||
| 63 | var ECS_CA NCELED = 4; | |||||
| 64 | var ECS_SE ARCHFAILED = 5; | |||||
| 65 | var ECS_FO UND = 6; | |||||
| 66 | ||||||
| 67 | var g_CurS tate = nul l; | |||||
| 68 | var g_CurP age = 1; | |||||
| 69 | var g_nMax Pages = 3 ; | |||||
| 70 | var g_sQue stion=''; | |||||
| 71 | var g_bSer verResult= false; | |||||
| 72 | gbSearchPa ge=true; | |||||
| 73 | var gbAIRS ynonymStri ng=''; | |||||
| 74 | var gbAIRS earchStrin g=''; | |||||
| 75 | var g_nMax Result = 0 ; | |||||
| 76 | var gsSear chQuery = ''; | |||||
| 77 | var gbExtr aInfoInSea rchQuery = ''; | |||||
| 78 | var gChang edQuery=' '; | |||||
| 79 | ||||||
| 80 | function s etBackgrou nd(sBgImag e) | |||||
| 81 | { | |||||
| 82 | gs BgImage=sB gImage; | |||||
| 83 | } | |||||
| 84 | ||||||
| 85 | function s etBackgrou ndcolor(sB gColor) | |||||
| 86 | { | |||||
| 87 | gs BgColor=sB gColor; | |||||
| 88 | } | |||||
| 89 | ||||||
| 90 | function s etFont(sTy pe,sFontNa me,sFontSi ze,sFontCo lor,sFontS tyle,sFont Weight,sFo ntDecorati on) | |||||
| 91 | { | |||||
| 92 | va r vFont=ne w whFont(s FontName,s FontSize,s FontColor, sFontStyle ,sFontWeig ht,sFontDe coration); | |||||
| 93 | if (sType=="N ormal") | |||||
| 94 | goFo nt=vFont; | |||||
| 95 | el se if(sTyp e=="Error" ) | |||||
| 96 | goEr rFont=vFon t; | |||||
| 97 | el se if(sTyp e=="Hover" ) | |||||
| 98 | goHo verFont=vF ont; | |||||
| 99 | } | |||||
| 100 | ||||||
| 101 | function s etActiveBg Color(sBgC olor) | |||||
| 102 | { | |||||
| 103 | gs ABgColor=s BgColor; | |||||
| 104 | } | |||||
| 105 | ||||||
| 106 | function s etMargin(s Margin) | |||||
| 107 | { | |||||
| 108 | gs Margin=sMa rgin; | |||||
| 109 | } | |||||
| 110 | ||||||
| 111 | function s etIndent(s Indent) | |||||
| 112 | { | |||||
| 113 | gs Indent=sIn dent; | |||||
| 114 | } | |||||
| 115 | ||||||
| 116 | function w indow_OnLo ad() | |||||
| 117 | { | |||||
| 118 | if (gsBgImage &&gsBgImag e.length>0 ) | |||||
| 119 | { | |||||
| 120 | docu ment.body. background =gsBgImage ; | |||||
| 121 | } | |||||
| 122 | if (gsBgColor &&gsBgColo r.length>0 ) | |||||
| 123 | { | |||||
| 124 | docu ment.body. bgColor=gs BgColor; | |||||
| 125 | } | |||||
| 126 | wr iteResultD iv(); | |||||
| 127 | if (gbAIR) | |||||
| 128 | retu rn; | |||||
| 129 | if (gbAIRSSL) | |||||
| 130 | { | |||||
| 131 | var strProject Dir=_getPa th(documen t.location .href); | |||||
| 132 | SeeF orSearch(s trProjectD ir); | |||||
| 133 | retu rn; | |||||
| 134 | } | |||||
| 135 | ||||||
| 136 | lo adFts(); | |||||
| 137 | } | |||||
| 138 | ||||||
| 139 | function S earchPendi ngRequest( ) | |||||
| 140 | { | |||||
| 141 | var oM sg=new whM essage(WH_ MSG_SHOWFT S,null,nul l); | |||||
| 142 | no tify(oMsg) ; | |||||
| 143 | oM sg = new w hMessage(W H_MSG_GETS EARCHSTR, null, null ); | |||||
| 144 | re quest(oMsg , onGetSea rchStr); | |||||
| 145 | } | |||||
| 146 | ||||||
| 147 | function o nGetSearch Str(oMsg) | |||||
| 148 | { | |||||
| 149 | var st rTerms = " "; | |||||
| 150 | strTer ms = oMsg. oParam; | |||||
| 151 | if (strTerms != " " ) | |||||
| 152 | { | |||||
| 153 | oMsg = new whM essage(WH_ MSG_SEARCH THIS, strT erms, null ); | |||||
| 154 | noti fy(oMsg); | |||||
| 155 | } | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | function w riteResult Div() | |||||
| 159 | { | |||||
| 160 | va r sHTML= " <div id='" + gsResul tDivID+ "' style='po sition:abs olute; wid th:100%'>< /div>"; | |||||
| 161 | if (gbAIRSSL) | |||||
| 162 | docu ment.body. innerHTML = sHTML; | |||||
| 163 | el se docu ment.body. insertAdja centHTML(" beforeEnd" ,sHTML); | |||||
| 164 | } | |||||
| 165 | ||||||
| 166 | function r egistListe ner( a_Con text, a_th is ) | |||||
| 167 | { | |||||
| 168 | if (!gbAIRSSL ) | |||||
| 169 | regi sterListen er2(WH_MSG _SEARCHFTS KEY ); | |||||
| 170 | } | |||||
| 171 | ||||||
| 172 | function F tsWriteCla ssStyle() | |||||
| 173 | { | |||||
| 174 | va r sStyle=" <STYLE TYP E='text/cs s'>\n"; | |||||
| 175 | if (gsBgImag e) | |||||
| 176 | sSty le+="body {border-to p:"+gsBgCo lor+" 1px solid;}\n" ; | |||||
| 177 | el se if(gbAI R) | |||||
| 178 | sSty le+="body {border-to p:white 1p x solid;}\ n"; | |||||
| 179 | el se | |||||
| 180 | sStyle+= "body {bor der-top:bl ack 1px so lid;}\n"; | |||||
| 181 | sS tyle+="P.m sg {"+getF ontStyle(g oErrFont)+ "margin-le ft:"+gsInd ent+";marg in-top:"+g sMargin+"; }\n"; | |||||
| 182 | sS tyle+="dl {"+getFont Style(goFo nt)+"margi n-left:"+g sIndent+"; margin-top :"+gsMargi n+";}\n"; | |||||
| 183 | sS tyle+="A.f r_tc:link {"+getFont Style(goFo nt)+"font- weight:bol d;}\n"; | |||||
| 184 | sS tyle+="A.f r_tc:visit ed {"+getF ontStyle(g oFont)+"fo nt-weight: bold;}\n"; | |||||
| 185 | sS tyle+="A.f r_tc:hover {"+getFon tStyle(goH overFont)+ "font-weig ht:bold;}\ n"; | |||||
| 186 | sS tyle+="A.f r_act {bac kground-co lor:"+gsAB gColor+";} \n"; | |||||
| 187 | sS tyle+="A.f r_act:link {"+getFon tStyle(goF ont)+"}\n" ; | |||||
| 188 | sS tyle+="A.f r_act:visi ted {"+get FontStyle( goFont)+"} \n"; | |||||
| 189 | sS tyle+="A.f r_act:hove r {"+getFo ntStyle(go HoverFont) +"}\n"; | |||||
| 190 | sS tyle+="LI. sl_page{di splay:bloc k;display: inline-blo ck;float:l eft;cursor :pointer;t ext-decora tion:none; border:1px solid #cc c;padding: .3em .7em; margin:0 . 38em 0 0;t ext-align: center}\n" ; | |||||
| 191 | sS tyle+="LI. sl_pageC{b ackground: #f0f7e8;bo rder:1px s olid #83bc 46;display :block;dis play:inlin e-block;fl oat:left;c ursor:poin ter;text-d ecoration: none;paddi ng:.3em .7 em;margin: 0 .38em 0 0;text-ali gn:center} \n"; | |||||
| 192 | sS tyle+="LI. sl_pageN{c ursor:poin ter;paddin g:.2em .5e m;margin:0 .38em 0 0 ;border:no ne;text-de coration:u nderline}\ n"; | |||||
| 193 | sS tyle+="TD. fr_tt, TD. fr_tc, TD. fr_ts {"+g etFontStyl e(goFont)+ "height:au to;}\n"; | |||||
| 194 | if (gbAIRSSL) | |||||
| 195 | sStyle+= "TD.fr_ts {padding:0 .2em 0em;b order-styl e:solid so lid solid none;borde r-color:"+ gsABgColor +";border- width:1px; }\n"; | |||||
| 196 | el se | |||||
| 197 | sStyle+= "TD.fr_ts {padding:0 .2em 0em;b order-styl e:none sol id solid n one;border -color:"+g sABgColor+ ";border-w idth:1px;} \n"; | |||||
| 198 | if (gbAIRSSL) | |||||
| 199 | sStyle+= "TD.fr_tt {padding:0 .2em 0.5em ;border-st yle:solid none solid none;bord er-color:" +gsABgColo r+";border -width:1px ;}\n"; | |||||
| 200 | el se | |||||
| 201 | sStyle+= "TD.fr_tt {padding:0 .2em 0.5em ;border-st yle:none n one solid none;borde r-color:"+ gsABgColor +";border- width:1px; }\n"; | |||||
| 202 | sS tyle+="TD. fr_tc {pad ding:0.2em 0.5em;}\n "; | |||||
| 203 | sS tyle+="P.p b_tt {"+ge tFontStyle (goErrFont )+"padding :0;margin: 3px;}\n"; | |||||
| 204 | sS tyle+="P.p b_in {"+ge tFontStyle (goErrFont )+"positio n:relative ;padding:0 ;margin:0; left:0%;to p:0%;heigh t:10px;bor der-style: none;backg round-colo r:blue;}\n "; | |||||
| 205 | sS tyle+="DIV .pb_out {w idth:100%; border-sty le:solid;b order-widt h:1px;padd ing:0;marg in:0;backg round-colo r:"+gsABgC olor+";}\n "; | |||||
| 206 | sS tyle+="P.p b_cancel { "+getFontS tyle(goHov erFont)+"c ursor:poin ter;paddin g:0;margin :3px}\n"; | |||||
| 207 | sS tyle+="</S TYLE>"; | |||||
| 208 | do cument.wri te(sStyle) ; | |||||
| 209 | } | |||||
| 210 | ||||||
| 211 | function w indow_Unlo ad() | |||||
| 212 | { | |||||
| 213 | if (!gbAIRSSL ) | |||||
| 214 | { | |||||
| 215 | unre gisterList ener2(WH_M SG_PROJECT READY); | |||||
| 216 | unre gisterList ener2(WH_M SG_SEARCHF TSKEY); | |||||
| 217 | unre gisterList ener2(WH_M SG_SETMAXR SLT); | |||||
| 218 | } | |||||
| 219 | } | |||||
| 220 | ||||||
| 221 | function m rFindFTSKe y() | |||||
| 222 | { | |||||
| 223 | if ( goOdinHu nter.aProj Pathes.len gth<=0 ) | |||||
| 224 | retu rn; | |||||
| 225 | ||||||
| 226 | // request t he server | |||||
| 227 | va r sUrl=goO dinHunter. aProjPathe s[0].strOd bPath+'&qu estion='+e scape(g_sQ uestion)+' &log=1'; | |||||
| 228 | ||||||
| 229 | g_ bServerRes ult=true; | |||||
| 230 | lo adDataXML( sUrl,false ); | |||||
| 231 | }; | |||||
| 232 | ||||||
| 233 | function o nReceiveNo tification (oMsg) | |||||
| 234 | { | |||||
| 235 | if(gbA IRSSL) | |||||
| 236 | retu rn true; | |||||
| 237 | if (oMsg.msgI d == WH_MS G_SEARCHFT SKEY ) | |||||
| 238 | { | |||||
| 239 | if ( oMsg.iPara m) | |||||
| 240 | { | |||||
| 241 | // redirec t to roboe ngine sear ch if gbEn gine==true | |||||
| 242 | if( mr IsOnEngine ()==true ) | |||||
| 243 | { | |||||
| 244 | // this is server side fts | |||||
| 245 | g_sQuest ion=oMsg.i Param; | |||||
| 246 | mrFindFT SKey(); | |||||
| 247 | }else | |||||
| 248 | { | |||||
| 249 | // this is client side fts | |||||
| 250 | goOdinHu nter.strQu ery = oMsg .iParam.st rQuery; | |||||
| 251 | gbEx traInfoInS earchQuery = oMsg.iP aram.Extra Info; | |||||
| 252 | setTimeo ut( "Query ()", 1 ); | |||||
| 253 | }; | |||||
| 254 | } | |||||
| 255 | } | |||||
| 256 | el se if ( oM sg.msgId = = WH_MSG_P ROJECTREAD Y ) | |||||
| 257 | { | |||||
| 258 | loadFts( ); | |||||
| 259 | } | |||||
| 260 | else i f(oMsg.msg Id == WH_M SG_SETMAXR SLT) | |||||
| 261 | { | |||||
| 262 | if (oMsg.iPar am) | |||||
| 263 | { | |||||
| 264 | g_nMaxRe sult = oMs g.iParam; | |||||
| 265 | } | |||||
| 266 | } | |||||
| 267 | return true; | |||||
| 268 | } | |||||
| 269 | ||||||
| 270 | ////////// //// ODIN FULL-TEXT SEARCH---- ---------- ---------- ---------- ---- | |||||
| 271 | ||||||
| 272 | // Odin gl obal varia bles------ ---------- -------- | |||||
| 273 | ||||||
| 274 | var contex t = new Hu ginContext (); | |||||
| 275 | var goOdin Hunter = n ull; | |||||
| 276 | ||||||
| 277 | // XmlUtil ity.js---- ---------- ---------- -------- | |||||
| 278 | ||||||
| 279 | var theXml Reader = n ew XmlRead er(); | |||||
| 280 | ||||||
| 281 | function X mlNode() | |||||
| 282 | { | |||||
| 283 | th is.strTagN ame = null ; | |||||
| 284 | th is.aAttrs = new Arra y(); | |||||
| 285 | } | |||||
| 286 | ||||||
| 287 | function X mlData() | |||||
| 288 | { | |||||
| 289 | th is.strFile Path = nul l; | |||||
| 290 | th is.strRoot = null; | |||||
| 291 | th is.aNodes = new Arra y(); | |||||
| 292 | } | |||||
| 293 | ||||||
| 294 | function X mlReader() | |||||
| 295 | { | |||||
| 296 | th is.strFile Path = nul l; //in | |||||
| 297 | th is.funcCal lback = nu ll; //in | |||||
| 298 | ||||||
| 299 | th is.bSuccee d = false; //ou t | |||||
| 300 | ||||||
| 301 | th is.xmlDoc = null; | |||||
| 302 | th is.aCache = new Arra y(); | |||||
| 303 | th is.bCache = false; | |||||
| 304 | th is.curData = null; | |||||
| 305 | ||||||
| 306 | th is.loadFro mCache = f unction() | |||||
| 307 | { | |||||
| 308 | for ( var i = 0; i < thi s.aCache.l ength; i++ ) | |||||
| 309 | { | |||||
| 310 | if ( t his.aCache [i].strFil ePath == t his.strFil ePath ) | |||||
| 311 | { | |||||
| 312 | this.cur Data = thi s.aCache[i ]; | |||||
| 313 | return t rue; | |||||
| 314 | } | |||||
| 315 | } | |||||
| 316 | retu rn false; | |||||
| 317 | } | |||||
| 318 | ||||||
| 319 | th is.loadFro mFile = fu nction(a_C ontext, a_ funcCallba ck, a_bCac he ) | |||||
| 320 | { | |||||
| 321 | this .bSucc = f alse; | |||||
| 322 | this .funcCallb ack = a_fu ncCallback ; | |||||
| 323 | this .bCache = ( a_bCache == true ) ? true : false; | |||||
| 324 | if ( this.load FromCache( ) ) | |||||
| 325 | { | |||||
| 326 | this.f uncCallbac k(); | |||||
| 327 | return ; | |||||
| 328 | } | |||||
| 329 | //lo adDataXML( this.strF ilePath,fa lse ); | |||||
| 330 | ||||||
| 331 | var sCurrentDo cPath = _g etPath(doc ument.loca tion.href) ; | |||||
| 332 | var sdocPath = _getFullP ath(sCurre ntDocPath, this.strF ilePath); | |||||
| 333 | var fileName = _getRelat iveFileNam e(sCurrent DocPath, s docPath); | |||||
| 334 | ||||||
| 335 | a_Co ntext.paus e(); | |||||
| 336 | xmlJ sReader.lo adFile(fil eName, fun ction(a_xm lDoc, args ){ | |||||
| 337 | if(a _xmlDoc != null) | |||||
| 338 | putDataX ML(a_xmlDo c, sdocPat h); | |||||
| 339 | else { | |||||
| 340 | onLoadXMLE rror(); | |||||
| 341 | } | |||||
| 342 | if (gbAIRSSL) | |||||
| 343 | setTimeo ut( functi on() { con text.resum e();}, 1); | |||||
| 344 | el se | |||||
| 345 | se tTimeout(" context.re sume()", 1 ); | |||||
| 346 | }); | |||||
| 347 | } | |||||
| 348 | ||||||
| 349 | th is.receive Dom = func tion( a_Xm lDoc ) | |||||
| 350 | { | |||||
| 351 | this .curData = null; | |||||
| 352 | if ( a_XmlDoc. documentEl ement == n ull ) | |||||
| 353 | return ; | |||||
| 354 | ||||||
| 355 | this .curData = new XmlDa ta(); | |||||
| 356 | this .curData.s trFilePath = this.st rFilePath; | |||||
| 357 | with ( a_XmlDoc .documentE lement ) | |||||
| 358 | { | |||||
| 359 | this.c urData.str Root = tag Name; | |||||
| 360 | for ( var i = 0; i < child Nodes.leng th; i++ ) | |||||
| 361 | { | |||||
| 362 | with( a_ XmlDoc.doc umentEleme nt.childNo des.item( i ) ) | |||||
| 363 | { | |||||
| 364 | if( nodeTy pe == 3 ) | |||||
| 365 | co ntinue; | |||||
| 366 | var nLen = this.curD ata.aNodes .length; | |||||
| 367 | this.curDa ta.aNodes[ nLen] = ne w XmlNode( ); | |||||
| 368 | this.curDa ta.aNodes[ nLen].strT agName = t agName; | |||||
| 369 | for ( var j = 0; j < attribute s.length; j++ ) | |||||
| 370 | { | |||||
| 371 | th is.curData .aNodes[nL en].aAttrs [attribute s.item( j ).name] = attributes .item( j ) .value; | |||||
| 372 | } | |||||
| 373 | } | |||||
| 374 | } | |||||
| 375 | } | |||||
| 376 | if ( this.bCac he ) | |||||
| 377 | { | |||||
| 378 | this.a Cache[this .aCache.le ngth] = th is.curData ; | |||||
| 379 | } | |||||
| 380 | } | |||||
| 381 | ||||||
| 382 | th is.getNumO fNodes = f unction() | |||||
| 383 | { | |||||
| 384 | return t his.curDat a.aNodes.l ength ; | |||||
| 385 | } | |||||
| 386 | ||||||
| 387 | th is.getNumO fTopics = function(i ) | |||||
| 388 | { | |||||
| 389 | with( th is.curData ) | |||||
| 390 | { | |||||
| 391 | if( i < aNodes.l ength) | |||||
| 392 | { | |||||
| 393 | var num ; | |||||
| 394 | try | |||||
| 395 | { | |||||
| 396 | num = pars eInt(aNode s[i].aAttr s["num"]); | |||||
| 397 | } | |||||
| 398 | catch(e) | |||||
| 399 | { | |||||
| 400 | retu rn 0 ; | |||||
| 401 | } | |||||
| 402 | return n um ; | |||||
| 403 | } | |||||
| 404 | else | |||||
| 405 | return 0 ; | |||||
| 406 | } | |||||
| 407 | ||||||
| 408 | } | |||||
| 409 | ||||||
| 410 | th is.checkRo ot = funct ion( a_str RootName ) | |||||
| 411 | { | |||||
| 412 | retu rn this.cu rData.strR oot == a_s trRootName ; | |||||
| 413 | } | |||||
| 414 | ||||||
| 415 | th is.getSyno nyms = fun ction ( a_ strQuery ) | |||||
| 416 | { | |||||
| 417 | if ( gsSubstrSr ch) | |||||
| 418 | { | |||||
| 419 | var sy nonyms = " " ; | |||||
| 420 | with( this.curDa ta ) | |||||
| 421 | { | |||||
| 422 | for ( va r i = 0; i < aNodes. length; i+ + ) | |||||
| 423 | { | |||||
| 424 | if (aNodes [i].aAttrs ["nm"].ind exOf(a_str Query) != -1) | |||||
| 425 | sy nonyms += "," + aNod es[i].aAtt rs["sy"]; | |||||
| 426 | } | |||||
| 427 | } | |||||
| 428 | return synonyms ; | |||||
| 429 | } | |||||
| 430 | else | |||||
| 431 | { | |||||
| 432 | return this.getA ttr( "wd", "nm", a_s trQuery, " sy" ) ; | |||||
| 433 | } | |||||
| 434 | } | |||||
| 435 | ||||||
| 436 | th is.getWord Rec = func tion ( a_s trQuery , bPhraseSea rch) | |||||
| 437 | { | |||||
| 438 | var begin = 0 ; | |||||
| 439 | var end = this .curData.a Nodes.leng th ; | |||||
| 440 | var mid = Math .floor((en d -begin ) / 2) ; | |||||
| 441 | whil e (mid > 0 ) | |||||
| 442 | { | |||||
| 443 | mid = mid + begi n ; | |||||
| 444 | var te rm = this. curData.aN odes[mid]. aAttrs["nm "] ; | |||||
| 445 | if (a_ strQuery < term) | |||||
| 446 | end = mi d ; | |||||
| 447 | else i f (a_strQu ery > term ) | |||||
| 448 | begin = mid ; | |||||
| 449 | else | |||||
| 450 | break ; | |||||
| 451 | mid = Math.floor ((end -beg in ) / 2) ; | |||||
| 452 | } | |||||
| 453 | if ( ((end-begi n) == 1)&& (!this.mat chPrefix(a _strQuery, this.curDa ta.aNodes[ mid].aAttr s["nm"]))) | |||||
| 454 | { | |||||
| 455 | mid = end ; | |||||
| 456 | } | |||||
| 457 | if ( mid < this .curData.a Nodes.leng th) | |||||
| 458 | { | |||||
| 459 | if (!b PhraseSear ch && gsSu bstrSrch) | |||||
| 460 | { | |||||
| 461 | //get al l the reco rds with m atching pr efix | |||||
| 462 | var arrT opicRecs = new Array (); | |||||
| 463 | while( m id<this.cu rData.aNod es.length) | |||||
| 464 | { | |||||
| 465 | if (this.c urData.aNo des[mid].a Attrs["sp" ]) | |||||
| 466 | { | |||||
| 467 | mi d++ ; | |||||
| 468 | co ntinue ; | |||||
| 469 | } | |||||
| 470 | else if (t his.matchP refix(a_st rQuery,thi s.curData. aNodes[mid ].aAttrs[" nm"])) | |||||
| 471 | { | |||||
| 472 | ar rTopicRecs [arrTopicR ecs.length ] = this.c urData.aNo des[mid].a Attrs["rd" ] ; | |||||
| 473 | mi d++ ; | |||||
| 474 | } | |||||
| 475 | else | |||||
| 476 | br eak ; | |||||
| 477 | } | |||||
| 478 | if (arrT opicRecs.l ength == 0 ) | |||||
| 479 | return "" ; | |||||
| 480 | var merg edRec = ar rTopicRecs [0] ; | |||||
| 481 | for (var i = 1 ; i < arrTopi cRecs.leng th ; i++) | |||||
| 482 | { | |||||
| 483 | mergedRec = mergeTop icRec(merg edRec , ar rTopicRecs [i]); | |||||
| 484 | } | |||||
| 485 | return m ergedRec ; | |||||
| 486 | } | |||||
| 487 | else | |||||
| 488 | { | |||||
| 489 | //get th e one with exact mat ch | |||||
| 490 | if ((thi s.curData. aNodes[mid ].aAttrs[" nm"])==a_s trQuery) | |||||
| 491 | { | |||||
| 492 | if (bPhras eSearch || gsSubstrS rch) | |||||
| 493 | re turn this. curData.aN odes[mid]. aAttrs["rd "] ; | |||||
| 494 | else | |||||
| 495 | { | |||||
| 496 | // do not ret urn stop w ords | |||||
| 497 | if (this.cur Data.aNode s[mid].aAt trs["sp"]) | |||||
| 498 | retu rn "" ; | |||||
| 499 | el se | |||||
| 500 | retu rn this.cu rData.aNod es[mid].aA ttrs["rd"] ; | |||||
| 501 | } | |||||
| 502 | } | |||||
| 503 | else | |||||
| 504 | return "" ; | |||||
| 505 | } | |||||
| 506 | } | |||||
| 507 | } | |||||
| 508 | ||||||
| 509 | th is.getTopi cRec = fun ction ( a_ nTopicId) | |||||
| 510 | { | |||||
| 511 | if ( (a_nTopicI d >= 0)&&( a_nTopicId < this.cu rData.aNod es.length )) | |||||
| 512 | { | |||||
| 513 | var ob jResult = new Object () ; | |||||
| 514 | objRes ult.rd = t his.curDat a.aNodes[a _nTopicId] .aAttrs["r d"]; | |||||
| 515 | objRes ult.ct = t his.curDat a.aNodes[a _nTopicId] .aAttrs["c t"]; | |||||
| 516 | return objResult ; | |||||
| 517 | } | |||||
| 518 | else | |||||
| 519 | return null ; | |||||
| 520 | } | |||||
| 521 | ||||||
| 522 | th is.getPack ageIndex = function (a_strQuer y) | |||||
| 523 | { | |||||
| 524 | var begin = 0 ; | |||||
| 525 | var end = this .curData.a Nodes.leng th - 1 ; | |||||
| 526 | var mid; | |||||
| 527 | whil e (begin < = end) | |||||
| 528 | { | |||||
| 529 | mid = Math.floor ((begin+en d)/2); | |||||
| 530 | var st artWord = this.curDa ta.aNodes[ mid].aAttr s["fm"] ; | |||||
| 531 | var en dWord = th is.curData .aNodes[mi d].aAttrs[ "to"] ; | |||||
| 532 | if (en d == begin ) | |||||
| 533 | { | |||||
| 534 | if ((a_s trQuery >= startWord )&&(a_str Query <= e ndWord)) | |||||
| 535 | return mid ; | |||||
| 536 | else | |||||
| 537 | return -1 ; | |||||
| 538 | } | |||||
| 539 | if (a_ strQuery < startWord ) | |||||
| 540 | end = mi d - 1 ; | |||||
| 541 | else i f (a_strQu ery > endW ord ) | |||||
| 542 | begin = mid + 1; | |||||
| 543 | else | |||||
| 544 | return m id ; | |||||
| 545 | } | |||||
| 546 | retu rn -1 ; | |||||
| 547 | } | |||||
| 548 | ||||||
| 549 | th is.matchPr efix = fun ction (a_s trQuery , a_strTerm ) | |||||
| 550 | { | |||||
| 551 | if ( a_strQuery .length > a_strTerm. length ) | |||||
| 552 | return false ; | |||||
| 553 | var bPrefix = true ; | |||||
| 554 | var i ; | |||||
| 555 | for (i=0; i< a _strQuery. length;i++ ) | |||||
| 556 | { | |||||
| 557 | if (a_ strQuery.c harAt(i) ! = a_strTer m.charAt(i )) | |||||
| 558 | { | |||||
| 559 | bPrefix = false ; | |||||
| 560 | break ; | |||||
| 561 | } | |||||
| 562 | } | |||||
| 563 | retu rn bPrefix ; | |||||
| 564 | } | |||||
| 565 | ||||||
| 566 | th is.getAttr = functio n( a_strTa gName ) | |||||
| 567 | { | |||||
| 568 | var nArgsNum = this.getA ttr.argume nts.length ; | |||||
| 569 | if ( nArgsNum < 2 || nAr gsNum % 2 != 0 ) | |||||
| 570 | return ""; | |||||
| 571 | ||||||
| 572 | with ( this.cur Data ) | |||||
| 573 | { | |||||
| 574 | for ( var i = 0; i < aNode s.length; i++ ) | |||||
| 575 | { | |||||
| 576 | if ( utf 8Compare(a Nodes[i].s trTagName, a_strTagNa me) != 0 ) | |||||
| 577 | continue; | |||||
| 578 | for ( va r j = 1; j + 1 < nAr gsNum - 1; j += 2 ) | |||||
| 579 | { | |||||
| 580 | if ( utf8C ompare(aNo des[i].aAt trs[this.g etAttr.arg uments[j]] , this.get Attr.argum ents[j + 1 ]) != 0 ) | |||||
| 581 | br eak; | |||||
| 582 | } | |||||
| 583 | if ( j + 1 < nArgs Num - 1 ) | |||||
| 584 | continue; | |||||
| 585 | if ( aNo des[i].aAt trs[this.g etAttr.arg uments[j]] ) | |||||
| 586 | return aNo des[i].aAt trs[this.g etAttr.arg uments[j]] ; | |||||
| 587 | else | |||||
| 588 | continue; | |||||
| 589 | } | |||||
| 590 | return ""; | |||||
| 591 | } | |||||
| 592 | } | |||||
| 593 | ||||||
| 594 | th is.checkAt tr = funct ion( a_str TagName ) | |||||
| 595 | { | |||||
| 596 | var nArgsNum = this.chec kAttr.argu ments.leng th; | |||||
| 597 | if ( nArgsNum < 1 || nAr gsNum % 2 == 0 ) | |||||
| 598 | return false; | |||||
| 599 | ||||||
| 600 | with ( this.cur Data ) | |||||
| 601 | { | |||||
| 602 | for ( var i = 0; i < aNode s.length; i++ ) | |||||
| 603 | { | |||||
| 604 | if ( utf 8Compare(a Nodes[i].s trTagName, a_strTagN ame) != 0 ) | |||||
| 605 | continue; | |||||
| 606 | for ( va r j = 1; j < nArgsNu m - 1; j + = 2 ) | |||||
| 607 | { | |||||
| 608 | if ( utf8C ompare(aNo des[i].aAt trs[this.c heckAttr.a rguments[j ]], this.c heckAttr.a rguments[j + 1]) != 0 ) | |||||
| 609 | br eak; | |||||
| 610 | } | |||||
| 611 | if ( j < nArgsNum - 1 ) | |||||
| 612 | continue; | |||||
| 613 | return t rue; | |||||
| 614 | } | |||||
| 615 | return false; | |||||
| 616 | } | |||||
| 617 | } | |||||
| 618 | } | |||||
| 619 | ||||||
| 620 | function p utDataXML( xmlDoc, s docPath ) | |||||
| 621 | { | |||||
| 622 | if (g_bServer Result==tr ue) | |||||
| 623 | { | |||||
| 624 | g_bS erverResul t=false; | |||||
| 625 | ||||||
| 626 | // r eceived th e search r esult | |||||
| 627 | var cRoot=xmlD oc.lastChi ld; | |||||
| 628 | var cResult=ne w HuginQue ryResult() ; | |||||
| 629 | var nIndex=1; | |||||
| 630 | if(c Root) | |||||
| 631 | { | |||||
| 632 | var cN ode=cRoot. firstChild ; | |||||
| 633 | while( cNode) | |||||
| 634 | { | |||||
| 635 | if(cNode .nodeName= ="topic") | |||||
| 636 | { | |||||
| 637 | var cTopic =new Objec t(); | |||||
| 638 | cTopic.nIn dex=nIndex ; | |||||
| 639 | cTopic.str Title=cNod e.getAttri bute("name "); | |||||
| 640 | cTopic.str Url=cNode. getAttribu te("url"); | |||||
| 641 | cTopic.str Summary=cN ode.getAtt ribute("su mmary"); | |||||
| 642 | cTopic.nRa nk=cNode.g etAttribut e("rank"); | |||||
| 643 | ||||||
| 644 | cResult.aT opics[cRes ult.aTopic s.length]= cTopic; | |||||
| 645 | }; | |||||
| 646 | cNode=cN ode.nextSi bling; | |||||
| 647 | nIndex=n Index+1; | |||||
| 648 | }; | |||||
| 649 | }; | |||||
| 650 | ||||||
| 651 | disp layTopics( cResult) | |||||
| 652 | }e lse | |||||
| 653 | { | |||||
| 654 | theX mlReader.r eceiveDom( xmlDoc ); | |||||
| 655 | theX mlReader.b Succ = tru e; | |||||
| 656 | //th eXmlReader .funcCallb ack(); | |||||
| 657 | }; | |||||
| 658 | } | |||||
| 659 | ||||||
| 660 | function m ergeTopicR ec(a_strPa rentRec , a_strNewRe c) | |||||
| 661 | { | |||||
| 662 | va r arrOldRe cords = a_ strParentR ec.split(" |"); | |||||
| 663 | va r arrNewRe cords = a_ strNewRec. split("|") ; | |||||
| 664 | ||||||
| 665 | va r mergedRe c = "" ; | |||||
| 666 | va r i = 0 ; | |||||
| 667 | va r j = 0 ; | |||||
| 668 | va r arrFinal Rec = new Array(); | |||||
| 669 | wh ile ( i< a rrOldRecor ds.length && j < arr NewRecords .length) | |||||
| 670 | { | |||||
| 671 | var oldTopicRe cord = get TopicDetai ls(arrOldR ecords[i]) ; | |||||
| 672 | if ( oldTopicRe cord == nu ll) | |||||
| 673 | { | |||||
| 674 | i++; | |||||
| 675 | contin ue ; | |||||
| 676 | } | |||||
| 677 | var newTopicRe cord = get TopicDetai ls(arrNewR ecords[j]) ; | |||||
| 678 | if ( newTopicRe cord == nu ll) | |||||
| 679 | { | |||||
| 680 | j++; | |||||
| 681 | contin ue ; | |||||
| 682 | } | |||||
| 683 | if ( oldTopicRe cord.nTopi cId < newT opicRecord .nTopicId) | |||||
| 684 | { | |||||
| 685 | arrFin alRec[arrF inalRec.le ngth] = ar rOldRecord s[i] ; | |||||
| 686 | i++ ; | |||||
| 687 | } | |||||
| 688 | else if (oldTo picRecord. nTopicId > newTopicR ecord.nTop icId) | |||||
| 689 | { | |||||
| 690 | arrFin alRec[arrF inalRec.le ngth] = ar rNewRecord s[j] ; | |||||
| 691 | j++ ; | |||||
| 692 | } | |||||
| 693 | else | |||||
| 694 | { | |||||
| 695 | var te mp = arrOl dRecords[i ].split(": "); | |||||
| 696 | var uE mphasis = (oldTopic Record.uEm phasis > n ewTopicRec ord.uEmpha sis)?oldTo picRecord. uEmphasis: newTopicRe cord.uEmph asis; | |||||
| 697 | var st rRec = old TopicRecor d.nTopicId + "," + u Emphasis + ":" + tem p [1] ; // since this will not be called in case of phrase se arch, we c an ignore positions of other r ec | |||||
| 698 | arrFin alRec[arrF inalRec.le ngth] = st rRec ; | |||||
| 699 | j++ ; | |||||
| 700 | i++ ; | |||||
| 701 | } | |||||
| 702 | } | |||||
| 703 | wh ile (i< ar rOldRecord s.length) | |||||
| 704 | { | |||||
| 705 | arrF inalRec[ar rFinalRec. length] = arrOldReco rds[i] ; | |||||
| 706 | i++ ; | |||||
| 707 | } | |||||
| 708 | wh ile (j < a rrNewRecor ds.length) | |||||
| 709 | { | |||||
| 710 | arrF inalRec[ar rFinalRec. length] = arrNewReco rds[j] ; | |||||
| 711 | j++ ; | |||||
| 712 | } | |||||
| 713 | ||||||
| 714 | if (arrFinal Rec.length == 0) | |||||
| 715 | retu rn a_strPa rentRec ; | |||||
| 716 | me rgedRec = arrFinalRe c[0]; | |||||
| 717 | fo r ( i = 1 ; i < arrF inalRec.le ngth ; i++ ) | |||||
| 718 | merg edRec += " |" + arrFi nalRec[i] ; | |||||
| 719 | re turn merge dRec ; | |||||
| 720 | } | |||||
| 721 | ||||||
| 722 | function g etTopicDet ails( a_st rRecord ) | |||||
| 723 | { | |||||
| 724 | va r index = a_strRecor d.indexOf( ","); | |||||
| 725 | if (index == -1) | |||||
| 726 | retu rn null ; | |||||
| 727 | va r nTopicId = a_strRe cord.subst ring(0 , i ndex); | |||||
| 728 | va r strTopic Details = a_strRecor d.substrin g(index+1, a_strRecor d.length); | |||||
| 729 | va r aShapes = strTopic Details.sp lit( ":" ) ; | |||||
| 730 | if ( aShapes .length == 0 ) | |||||
| 731 | retu rn null; | |||||
| 732 | ||||||
| 733 | va r record = new Objec t(); | |||||
| 734 | re cord.nTopi cId = nTop icId ; | |||||
| 735 | re cord.uEmph asis = par seInt( aSh apes[0] ); | |||||
| 736 | re turn recor d ; | |||||
| 737 | } | |||||
| 738 | ||||||
| 739 | function o nLoadXMLEr ror() | |||||
| 740 | { | |||||
| 741 | // For Debug & Test---- -- | |||||
| 742 | if ( window. gbTesting ) | |||||
| 743 | retu rn; | |||||
| 744 | // ---------- ---------- -- | |||||
| 745 | ||||||
| 746 | th eXmlReader .bSucc = f alse; | |||||
| 747 | // theXmlRead er.funcCal lback(); | |||||
| 748 | } | |||||
| 749 | ||||||
| 750 | ////////// ////////// ////////// // | |||||
| 751 | ||||||
| 752 | function s plitPathNa me( a_strP ath ) //this uti lity funct ion only f it this pr oject. | |||||
| 753 | { | |||||
| 754 | va r rslt = n ew Object( ); | |||||
| 755 | rs lt.strDir = ""; | |||||
| 756 | rs lt.strFile = ""; | |||||
| 757 | rs lt.strExt = ""; | |||||
| 758 | ||||||
| 759 | va r rg1 = /^ (.*[\\\/]) ?([^\\\/]+ )(\.[^\\\/ \.]*)$/; | |||||
| 760 | va r rg2 = /^ (.*[\\\/]) ?([^\\\/.] +)$/; | |||||
| 761 | ||||||
| 762 | va r v = a_st rPath.matc h( rg1 ); | |||||
| 763 | if ( v != nu ll ) | |||||
| 764 | { | |||||
| 765 | rslt .strDir = v[1]; | |||||
| 766 | rslt .strFile = v[2]; | |||||
| 767 | rslt .strExt = v[3]; | |||||
| 768 | } | |||||
| 769 | el se | |||||
| 770 | { | |||||
| 771 | v = a_strPath. match( rg2 ); | |||||
| 772 | rslt .strDir = v[1]; | |||||
| 773 | rslt .strFile = v[2]; | |||||
| 774 | rslt .strExt = ""; | |||||
| 775 | } | |||||
| 776 | re turn rslt; | |||||
| 777 | } | |||||
| 778 | ||||||
| 779 | function g etAbsPath( a_strBase Path, a_st rRelPath ) | |||||
| 780 | { | |||||
| 781 | va r sf = spl itPathName ( a_strBas ePath ); | |||||
| 782 | re turn sf.st rDir + a_s trRelPath; | |||||
| 783 | } | |||||
| 784 | ||||||
| 785 | // HuginCo ntext.js-- ---------- ---------- -------- | |||||
| 786 | ||||||
| 787 | function H uginContex t() | |||||
| 788 | { | |||||
| 789 | th is.aTasks = new Arra y(); | |||||
| 790 | ||||||
| 791 | th is.bExecut ing = fals e; | |||||
| 792 | th is.bCallBa ck = false ; | |||||
| 793 | th is.bCallBa ckReady = false; | |||||
| 794 | ||||||
| 795 | th is.nLastTi me = 0; | |||||
| 796 | ||||||
| 797 | th is.bError = false; | |||||
| 798 | th is.bCancel = false; | |||||
| 799 | th is.strMsg = null; | |||||
| 800 | th is.bPause = false; | |||||
| 801 | ||||||
| 802 | th is.reset = function( ) | |||||
| 803 | { | |||||
| 804 | this .aTasks.le ngth = 0; | |||||
| 805 | ||||||
| 806 | this .bExecutin g = false; | |||||
| 807 | this .bCallBack = false; | |||||
| 808 | this .bCallBack Ready = fa lse; | |||||
| 809 | ||||||
| 810 | this .nLastTime = 0; | |||||
| 811 | ||||||
| 812 | this .bError = false; | |||||
| 813 | this .bCancel = false; | |||||
| 814 | this .strMsg = null; | |||||
| 815 | this .bPause = false; | |||||
| 816 | } | |||||
| 817 | ||||||
| 818 | th is.push = function() | |||||
| 819 | { | |||||
| 820 | var i = 0; | |||||
| 821 | var ttasks = n ew Array() ; | |||||
| 822 | whil e( i < con text.push. arguments. length ) | |||||
| 823 | { | |||||
| 824 | var nL en = ttask s.length; | |||||
| 825 | ttasks [nLen] = n ew Object( ); | |||||
| 826 | ttasks [nLen].fun c = contex t.push.arg uments[i]; | |||||
| 827 | ttasks [nLen].own er = conte xt.push.ar guments[i + 1]; | |||||
| 828 | i += 2 ; | |||||
| 829 | var bS uspend = f alse; | |||||
| 830 | if ( i < context .push.argu ments.leng th && | |||||
| 831 | context .push.argu ments[i].c onstructor .toString( ).search( /^\nfuncti on Boolean / ) == 0 ) | |||||
| 832 | { | |||||
| 833 | var bSus pend = con text.push. arguments[ i]; | |||||
| 834 | ++i; | |||||
| 835 | } | |||||
| 836 | ttasks [nLen].bSu spend = bS uspend; | |||||
| 837 | } | |||||
| 838 | for ( i = ttas ks.length - 1; i >= 0; --i ) | |||||
| 839 | contex t.aTasks[c ontext.aTa sks.length ] = ttasks [i]; | |||||
| 840 | } | |||||
| 841 | ||||||
| 842 | th is.pop = f unction() | |||||
| 843 | { | |||||
| 844 | if ( context.a Tasks.leng th == 0 ) | |||||
| 845 | return null; | |||||
| 846 | ||||||
| 847 | var task = con text.aTask s[context. aTasks.len gth - 1]; | |||||
| 848 | cont ext.aTasks .length--; | |||||
| 849 | retu rn task; | |||||
| 850 | } | |||||
| 851 | ||||||
| 852 | th is.initTim e = functi on() | |||||
| 853 | { | |||||
| 854 | cont ext.nLastT ime = ( ne w Date() ) .getTime() ; | |||||
| 855 | } | |||||
| 856 | ||||||
| 857 | th is.needBre athe = fun ction() | |||||
| 858 | { | |||||
| 859 | var nCurTime = ( new Dat e() ).getT ime(); | |||||
| 860 | retu rn nCurTim e - contex t.nLastTim e >= 100; | |||||
| 861 | } | |||||
| 862 | ||||||
| 863 | th is.resume = function () | |||||
| 864 | { | |||||
| 865 | if ( context.b Executing ) | |||||
| 866 | { | |||||
| 867 | if ( c ontext.bCa llBack ) | |||||
| 868 | context. bCallBackR eady = tru e; | |||||
| 869 | return ; | |||||
| 870 | } | |||||
| 871 | ||||||
| 872 | cont ext.bExecu ting = tru e; | |||||
| 873 | cont ext.bPause = false; | |||||
| 874 | cont ext.initTi me(); | |||||
| 875 | whil e ( true ) | |||||
| 876 | { | |||||
| 877 | if ( c ontext.bCa ncel ) | |||||
| 878 | { | |||||
| 879 | context. bExecuting = false; | |||||
| 880 | g_CurSta te = ECS_C ANCELED; | |||||
| 881 | updateRe sultView() ; | |||||
| 882 | return t rue; | |||||
| 883 | } | |||||
| 884 | ||||||
| 885 | var ta sk = conte xt.pop(); | |||||
| 886 | if ( t ask == nul l ) | |||||
| 887 | { //All ta sks were f inished. | |||||
| 888 | context. bExecuting = false; | |||||
| 889 | return t rue; | |||||
| 890 | } | |||||
| 891 | ||||||
| 892 | contex t.bCallBac k = task.b Suspend; | |||||
| 893 | task.f unc( conte xt, task.o wner, cont ext.resume ); //If it is not a sus pend task, the 3rd a rgument wi ll be igno red. | |||||
| 894 | if ( c ontext.bEr ror ) | |||||
| 895 | { //Failed . Stop exe cuting. | |||||
| 896 | context. bExecuting = false; | |||||
| 897 | g_CurSta te = ECS_F ATALERROR; | |||||
| 898 | updateRe sultView() ; | |||||
| 899 | return; | |||||
| 900 | } | |||||
| 901 | ||||||
| 902 | if ( c ontext.bCa llBack && !context.b CallBackRe ady ) | |||||
| 903 | { //Callba ck functio n not fini shed. Give the resum e right to it. | |||||
| 904 | context. bExecuting = false; | |||||
| 905 | return; | |||||
| 906 | } | |||||
| 907 | contex t.bCallBac k = false; | |||||
| 908 | contex t.bCallBac kReady = f alse; | |||||
| 909 | ||||||
| 910 | if( co ntext.bPau se ) | |||||
| 911 | { | |||||
| 912 | context. bExecuting = false; | |||||
| 913 | //update ResultView (); | |||||
| 914 | return; | |||||
| 915 | } | |||||
| 916 | ||||||
| 917 | if ( c ontext.nee dBreathe() ) | |||||
| 918 | { //Give G UI a chanc e to proce ss message s. | |||||
| 919 | context. bExecuting = false; | |||||
| 920 | updateRe sultView() ; | |||||
| 921 | if(gbAIR ) | |||||
| 922 | context.re sume(); | |||||
| 923 | else set Timeout( " context.re sume();", 1 ); | |||||
| 924 | return; | |||||
| 925 | } | |||||
| 926 | } | |||||
| 927 | } | |||||
| 928 | ||||||
| 929 | th is.pause = function( ) | |||||
| 930 | { | |||||
| 931 | cont ext.bPause = true; | |||||
| 932 | } | |||||
| 933 | ||||||
| 934 | th is.stop = function() | |||||
| 935 | { | |||||
| 936 | cont ext.bCance l = true; | |||||
| 937 | } | |||||
| 938 | } | |||||
| 939 | ||||||
| 940 | // Base64. js-------- ---------- ---------- -------- | |||||
| 941 | ||||||
| 942 | var XX = 1 27; //mark for not u sed | |||||
| 943 | ||||||
| 944 | var s_strB ase64 = "A BCDEFGHIJK LMNOPQRSTU VWXYZabcde fghijklmno pqrstuvwxy z012345678 9+/"; | |||||
| 945 | var s_aAsc iiToBase64 = new Arr ay | |||||
| 946 | ( | |||||
| 947 | XX , XX, XX, XX, XX, XX , XX, XX, XX, XX, XX , XX, XX, XX, XX, XX , // 00 ~0F | |||||
| 948 | XX , XX, XX, XX, XX, XX , XX, XX, XX, XX, XX , XX, XX, XX, XX, XX , // 10 ~1F | |||||
| 949 | XX , XX, XX, XX, XX, XX , XX, XX, XX, XX, XX , 62, XX, XX, XX, 63 , // 20 ~2F '+'=62, '/ '=63 | |||||
| 950 | 52 , 53, 54, 55, 56, 57 , 58, 59, 60, 61, XX , XX, XX, XX, XX, XX , // 30 ~3F '0'=52 to '9'=61 | |||||
| 951 | XX , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 , // 40 ~4F 'A'=0 to ' O'=14 | |||||
| 952 | 15 , 16, 17, 18, 19, 20 , 21, 22, 23, 24, 25 , XX, XX, XX, XX, XX , // 50 ~5F 'P'=15 to 'Z'=25 | |||||
| 953 | XX , 26, 27, 28, 29, 30 , 31, 32, 33, 34, 35 , 36, 37, 38, 39, 40 , // 60 ~6F 'a'=26 to 'o'=40 | |||||
| 954 | 41 , 42, 43, 44, 45, 46 , 47, 48, 49, 50, 51 , XX, XX, XX, XX, XX // 70 ~7F 'p'=41 to 'z'=51 | |||||
| 955 | ); | |||||
| 956 | var s_aOdi nToAscii = new Array | |||||
| 957 | ( // the first the char is '\0', s o that s_a OdinToAsci i[0] means end of st ring | |||||
| 958 | '\ 0', '0', ' 1', '2', ' 3', '4', ' 5', '6', | |||||
| 959 | '7 ', '8', '9 ', '|', ': ', ',', '\ 0', '\0' | |||||
| 960 | ); | |||||
| 961 | ||||||
| 962 | var s_aBas e64DecodeM ap = new A rray(); | |||||
| 963 | ||||||
| 964 | function _ decordBase 64ToStr( a _nA, a_nB ) | |||||
| 965 | { | |||||
| 966 | va r uBuf = ( s_aAsciiT oBase64[a_ nA] << 6 ) + s_aAsci iToBase64[ a_nB]; | |||||
| 967 | va r strRslt = ""; | |||||
| 968 | va r uCur = 0 ; | |||||
| 969 | fo r ( var i = 0; i <= 8; i += 4 ) | |||||
| 970 | { | |||||
| 971 | uCur = uBuf >> ( 8 - i ) & 0x000F; | |||||
| 972 | if ( uCur == 0 ) | |||||
| 973 | return strRslt; | |||||
| 974 | strR slt += s_a OdinToAsci i[uCur]; | |||||
| 975 | } | |||||
| 976 | re turn strRs lt; | |||||
| 977 | } | |||||
| 978 | ||||||
| 979 | // Decode a base64 f ormatted s tring into an odin f ormatted o ne (only c ontains ch aractors o ccur in s_ strBase64 | |||||
| 980 | // [in]a_s trBase64: Base64 formatted string; | |||||
| 981 | // RESULT: Odin for matted str ing; | |||||
| 982 | function d ecodeBase6 4ToOdin( a _strBase64 ) | |||||
| 983 | { | |||||
| 984 | va r nLen = a _strBase64 .length; | |||||
| 985 | va r strRslt = ""; | |||||
| 986 | va r str = 0; | |||||
| 987 | fo r ( var i = 0; i + 1 < nLen; i += 2 ) | |||||
| 988 | { | |||||
| 989 | str = s_aBase6 4DecodeMap [( a_strBa se64.charC odeAt( i ) << 8 ) + a_strBase6 4.charCode At( i + 1 )] | |||||
| 990 | if ( !str ) return str Rslt; | |||||
| 991 | strR slt += str ; | |||||
| 992 | } | |||||
| 993 | if ( i < nLe n ) | |||||
| 994 | { | |||||
| 995 | str = s_aBase6 4DecodeMap [( a_strBa se64.charC odeAt( i ) << 8 ) + s_strBase6 4.charCode At( 0 )] | |||||
| 996 | if ( !str ) return str Rslt; | |||||
| 997 | strR slt += str ; | |||||
| 998 | } | |||||
| 999 | re turn strRs lt; | |||||
| 1000 | } | |||||
| 1001 | ||||||
| 1002 | function i nitBase64D ecodeMap() | |||||
| 1003 | { | |||||
| 1004 | va r i, j; | |||||
| 1005 | fo r ( i = 0; i < 64; i ++ ) | |||||
| 1006 | for ( j = 0; j < 64; j++ ) | |||||
| 1007 | s_aBas e64DecodeM ap[( s_str Base64.cha rCodeAt( i ) << 8 ) + s_strBas e64.charCo deAt( j )] = _decord Base64ToSt r( s_strBa se64.charC odeAt( i ) , s_strBas e64.charCo deAt( j ) ); | |||||
| 1008 | fo r ( i = 0; i < 64; i ++ ) | |||||
| 1009 | s_aB ase64Decod eMap[s_str Base64.cha rCodeAt( i ) << 8] = _decordBa se64ToStr( s_strBase 64.charCod eAt( i ), s_strBase6 4.charCode At( 0 ) ); | |||||
| 1010 | } | |||||
| 1011 | ||||||
| 1012 | initBase64 DecodeMap( ); | |||||
| 1013 | ||||||
| 1014 | // HuginPa ckageReade r.js------ ---------- -------- | |||||
| 1015 | ||||||
| 1016 | function H uginStemRe cordTopicS hape() | |||||
| 1017 | { | |||||
| 1018 | th is.aPositi ons = null ; | |||||
| 1019 | } | |||||
| 1020 | ||||||
| 1021 | function H uginStemRe cordTopic( ) | |||||
| 1022 | { | |||||
| 1023 | th is.uEmphas is = null; | |||||
| 1024 | th is.aShapes = null; | |||||
| 1025 | } | |||||
| 1026 | ||||||
| 1027 | function H uginStemRe cord() | |||||
| 1028 | { | |||||
| 1029 | th is.aTopics = null; | |||||
| 1030 | } | |||||
| 1031 | ||||||
| 1032 | function H uginPackag eReaderRes ult() | |||||
| 1033 | { | |||||
| 1034 | th is.strNefS tem = null ; | |||||
| 1035 | th is.strReco rd = null; | |||||
| 1036 | th is.bStopWo rd = null ; | |||||
| 1037 | } | |||||
| 1038 | ||||||
| 1039 | function H uginPackag eReader() | |||||
| 1040 | { | |||||
| 1041 | th is.strPack agePath = null; //in | |||||
| 1042 | th is.strSyno nymPath = null ; // in | |||||
| 1043 | th is.recordR esult = nu ll; //ou t | |||||
| 1044 | th is.strQuer yWord = nu ll; //in | |||||
| 1045 | th is.bPhrase Search = f alse ; | |||||
| 1046 | th is.bSucc = true; | |||||
| 1047 | ||||||
| 1048 | th is.prepare Query = fu nction() | |||||
| 1049 | { | |||||
| 1050 | this .recordRes ult = null ; //out | |||||
| 1051 | this .bSucc = t rue; | |||||
| 1052 | this .strQueryW ord = null ; | |||||
| 1053 | this .bPhraseSe arch = fal se ; | |||||
| 1054 | } | |||||
| 1055 | ||||||
| 1056 | th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k ) | |||||
| 1057 | { | |||||
| 1058 | theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback, f alse ); | |||||
| 1059 | } | |||||
| 1060 | ||||||
| 1061 | th is.pickSyn onyms = fu nction( a_ strStem ) | |||||
| 1062 | { | |||||
| 1063 | retu rn theXmlR eader.getS ynonyms(a_ strStem).s plit( "," ); | |||||
| 1064 | } | |||||
| 1065 | ||||||
| 1066 | th is.setSyno nymForHigh lighting = function( a_Context , a_this ) | |||||
| 1067 | { | |||||
| 1068 | if ( !theXmlRe ader.bSucc ) | |||||
| 1069 | { | |||||
| 1070 | return ; | |||||
| 1071 | } | |||||
| 1072 | var strSyn = " "; | |||||
| 1073 | var arySynonym s = a_this .pickSynon yms( a_thi s.strQuery Word ); | |||||
| 1074 | for ( var i = 0; i < ary Synonyms.l ength; ++i ) | |||||
| 1075 | { | |||||
| 1076 | strSyn += " " + arySynonym s[i]; | |||||
| 1077 | } | |||||
| 1078 | if ( (strSyn == "")||(str Syn == " " )) | |||||
| 1079 | return ; | |||||
| 1080 | if(! gbAIRSSL) | |||||
| 1081 | { | |||||
| 1082 | var oR esMsg = ne w whMessag e( WH_MSG_ SETSYNSTR, strSyn, n ull ); | |||||
| 1083 | notify ( oResMsg ); | |||||
| 1084 | } | |||||
| 1085 | else | |||||
| 1086 | { | |||||
| 1087 | gbAIRSynon ymString = strSyn; | |||||
| 1088 | } | |||||
| 1089 | } | |||||
| 1090 | ||||||
| 1091 | ||||||
| 1092 | th is.doQuery WordRecord = functio n( a_Conte xt, a_this ) | |||||
| 1093 | { | |||||
| 1094 | if ( !theXmlRe ader.bSucc ) | |||||
| 1095 | { | |||||
| 1096 | a_Cont ext.strMsg = gsLoadX mlFailed; | |||||
| 1097 | a_Cont ext.bError = true; | |||||
| 1098 | return ; | |||||
| 1099 | } | |||||
| 1100 | ||||||
| 1101 | if ( !a_this.b Succ ) | |||||
| 1102 | return ; | |||||
| 1103 | ||||||
| 1104 | // By Lei n 4:59 PM 7/15/2004 | |||||
| 1105 | a_th is.recordR esult = ne w HuginPac kageReader Result(); | |||||
| 1106 | var strRecord = theXmlRe ader.getWo rdRec(a_th is.strQuer yWord,a_th is.bPhrase Search); | |||||
| 1107 | if ( strRecord == null ) | |||||
| 1108 | return ; | |||||
| 1109 | a_th is.recordR esult.bSto pWord = fa lse; | |||||
| 1110 | a_th is.recordR esult.strN efStem = a _this.strQ ueryWord; | |||||
| 1111 | a_th is.recordR esult.strR ecord = st rRecord; | |||||
| 1112 | if ( strRecord == "" ) | |||||
| 1113 | { | |||||
| 1114 | a_this .bSucc = f alse; | |||||
| 1115 | return ; | |||||
| 1116 | } | |||||
| 1117 | a_th is.bSucc = true; | |||||
| 1118 | theX mlReader.s trFilePath = a_this. strSynonym Path; | |||||
| 1119 | a_Co ntext.push ( a_this.l oadFromFil e, a_this, | |||||
| 1120 | a_ this.setSy nonymForHi ghlighting , a_this ) ; | |||||
| 1121 | } | |||||
| 1122 | ||||||
| 1123 | th is.query = function( a_Context , a_this ) | |||||
| 1124 | { | |||||
| 1125 | a_th is.bSucc = true; | |||||
| 1126 | theX mlReader.s trFilePath = a_this. strPackage Path; | |||||
| 1127 | a_Co ntext.push ( a_this.l oadFromFil e, a_this, | |||||
| 1128 | a_ this.doQue ryWordReco rd, a_this ); | |||||
| 1129 | } | |||||
| 1130 | } | |||||
| 1131 | ||||||
| 1132 | function H uginPackag eIndexRead er() | |||||
| 1133 | { | |||||
| 1134 | th is.queryWo rd = null; //in | |||||
| 1135 | th is.strPack ageIndexPa th = null; // in | |||||
| 1136 | th is.package Info = nul l; //ou t | |||||
| 1137 | th is.bSucc = true; | |||||
| 1138 | th is.strCurQ uery = nul l; | |||||
| 1139 | th is.strPack ageInfo = null; | |||||
| 1140 | ||||||
| 1141 | th is.prepare Query = fu nction() | |||||
| 1142 | { | |||||
| 1143 | this .packageIn fo = null; //out | |||||
| 1144 | this .bSucc = t rue; | |||||
| 1145 | this .strCurQue ry = null; | |||||
| 1146 | this .strPackag eInfo = nu ll; | |||||
| 1147 | } | |||||
| 1148 | ||||||
| 1149 | th is.getPack agePath = function( a_strSuffi x ) | |||||
| 1150 | { | |||||
| 1151 | var sf = split PathName( this.strPa ckageIndex Path ); | |||||
| 1152 | retu rn sf.strD ir + "pack age_" + a_ strSuffix + sf.strEx t; | |||||
| 1153 | } | |||||
| 1154 | ||||||
| 1155 | th is.getTopi cTablePath = functio n( a_strSu ffix ) | |||||
| 1156 | { | |||||
| 1157 | var sf = split PathName( this.strPa ckageIndex Path ); | |||||
| 1158 | retu rn sf.strD ir + "topi ctable_" + a_strSuff ix + sf.st rExt; | |||||
| 1159 | } | |||||
| 1160 | ||||||
| 1161 | th is.parsePa ckageInfo = function ( a_Contex t, a_this ) | |||||
| 1162 | { | |||||
| 1163 | if ( !theXmlRe ader.bSucc || | |||||
| 1164 | !theX mlReader.c heckRoot( "cki" ) ) | |||||
| 1165 | { | |||||
| 1166 | a_this .bSucc = f alse; | |||||
| 1167 | return ; | |||||
| 1168 | } | |||||
| 1169 | var nPackageIn dex = theX mlReader.g etPackageI ndex(a_thi s.strCurQu ery); | |||||
| 1170 | if ( nPackageI ndex == nu ll || nPac kageIndex < 0 ) | |||||
| 1171 | { | |||||
| 1172 | a_this .packageIn fo = null; | |||||
| 1173 | a_this .bSucc = f alse; | |||||
| 1174 | return ; | |||||
| 1175 | } | |||||
| 1176 | ||||||
| 1177 | a_th is.package Info = a_t his.getPac kagePath( nPackageIn dex ); | |||||
| 1178 | this .bSucc = t rue; | |||||
| 1179 | retu rn ; | |||||
| 1180 | } | |||||
| 1181 | ||||||
| 1182 | th is.parseTo picInfo = function( a_Context, a_this ) | |||||
| 1183 | { | |||||
| 1184 | if ( !theXmlRe ader.bSucc || | |||||
| 1185 | !theX mlReader.c heckRoot( "cki" ) ) | |||||
| 1186 | { | |||||
| 1187 | a_this .bSucc = f alse; | |||||
| 1188 | return ; | |||||
| 1189 | } | |||||
| 1190 | var nPackageIn dex = theX mlReader.g etPackageI ndex(a_thi s.strCurQu ery); | |||||
| 1191 | if ( nPackageI ndex == nu ll || nPac kageIndex < 0 ) | |||||
| 1192 | { | |||||
| 1193 | a_this .packageIn fo = null; | |||||
| 1194 | a_this .bSucc = f alse; | |||||
| 1195 | return ; | |||||
| 1196 | } | |||||
| 1197 | ||||||
| 1198 | a_th is.package Info = a_t his.getTop icTablePat h( nPackag eIndex ); | |||||
| 1199 | this .bSucc = t rue; | |||||
| 1200 | retu rn ; | |||||
| 1201 | } | |||||
| 1202 | ||||||
| 1203 | th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k ) | |||||
| 1204 | { | |||||
| 1205 | theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback , false); | |||||
| 1206 | } | |||||
| 1207 | ||||||
| 1208 | th is.queryPa ckageInfo = function ( a_Contex t, a_this ) | |||||
| 1209 | { | |||||
| 1210 | a_th is.bSucc = true; | |||||
| 1211 | theX mlReader.s trFilePath = a_this. strPackage IndexPath; | |||||
| 1212 | a_Co ntext.push ( a_this.l oadFromFil e, a_this, | |||||
| 1213 | a_ this.parse PackageInf o, a_this ); | |||||
| 1214 | } | |||||
| 1215 | ||||||
| 1216 | th is.queryTo picInfo = function( a_Context, a_this ) | |||||
| 1217 | { | |||||
| 1218 | a_th is.bSucc = true; | |||||
| 1219 | theX mlReader.s trFilePath = a_this. strPackage IndexPath; | |||||
| 1220 | a_Co ntext.push ( a_this.l oadFromFil e, a_this, | |||||
| 1221 | a_ this.parse TopicInfo, a_this ); | |||||
| 1222 | } | |||||
| 1223 | } | |||||
| 1224 | ||||||
| 1225 | function H uginTopicT ableReader () | |||||
| 1226 | { | |||||
| 1227 | th is.nQueryI d = null; //in | |||||
| 1228 | th is.strTopi cTablePath = null; // in | |||||
| 1229 | th is.lastInd ex = -1; | |||||
| 1230 | th is.topicIn fo = null; //ou t | |||||
| 1231 | th is.bSucc = true; | |||||
| 1232 | th is.strTopi cInfo = nu ll; | |||||
| 1233 | th is.strTopi cContext = null; | |||||
| 1234 | th is.topicMa p = null ; | |||||
| 1235 | th is.curTopi cIndex = n ull ; | |||||
| 1236 | ||||||
| 1237 | th is.prepare Query = fu nction() | |||||
| 1238 | { | |||||
| 1239 | this .bSucc = t rue; | |||||
| 1240 | this .strTopicI nfo = null ; | |||||
| 1241 | } | |||||
| 1242 | ||||||
| 1243 | th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k ) | |||||
| 1244 | { | |||||
| 1245 | theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback ); | |||||
| 1246 | } | |||||
| 1247 | ||||||
| 1248 | th is.process ReaderResu lt = funct ion( a_Con text, a_th is ) | |||||
| 1249 | { | |||||
| 1250 | if ( !theXmlRe ader.bSucc || | |||||
| 1251 | !theX mlReader.c heckRoot( "ck" ) ) | |||||
| 1252 | { | |||||
| 1253 | a_this .bSucc = f alse; | |||||
| 1254 | a_this .bInited = false; | |||||
| 1255 | return ; | |||||
| 1256 | } | |||||
| 1257 | var queryId = a_this.nQu eryId ; | |||||
| 1258 | if ( a_this.cur TopicIndex > 0 ) | |||||
| 1259 | queryId = queryId - a_this.top icMap[a_th is.curTopi cIndex -1 ] ; | |||||
| 1260 | var topicInfo = theXmlRe ader.getTo picRec(que ryId); | |||||
| 1261 | a_th is.strTopi cInfo = to picInfo.rd ; | |||||
| 1262 | a_th is.strTopi cContext = topicInfo .ct; | |||||
| 1263 | } | |||||
| 1264 | ||||||
| 1265 | th is.parseTo picInfo = function( a_Context, a_this ) | |||||
| 1266 | { | |||||
| 1267 | if ( !a_this.b Succ ) | |||||
| 1268 | return ; | |||||
| 1269 | ||||||
| 1270 | a_th is.topicIn fo = new O bject(); | |||||
| 1271 | var v = a_this .strTopicI nfo.split( "|" ); | |||||
| 1272 | if ( v.length < 2 || v[0 ] == "" || v[1] == " " ) | |||||
| 1273 | { | |||||
| 1274 | a_this .bSucc == false; | |||||
| 1275 | return ; | |||||
| 1276 | } | |||||
| 1277 | a_th is.topicIn fo.strUrl = v[0]; | |||||
| 1278 | a_th is.topicIn fo.strTitl e = v[1]; | |||||
| 1279 | } | |||||
| 1280 | ||||||
| 1281 | th is.queryTo picInfo = function( a_Context, a_this ) | |||||
| 1282 | { | |||||
| 1283 | for (var i = 0 ; i < a_t his.topicM ap.length ; i++) | |||||
| 1284 | { | |||||
| 1285 | if (a_ this.nQuer yId < a_th is.topicMa p[i] ) | |||||
| 1286 | break ; | |||||
| 1287 | } | |||||
| 1288 | if ( i >= a_thi s.topicMap .length) | |||||
| 1289 | { | |||||
| 1290 | a_this .bSucc == false; | |||||
| 1291 | return ; | |||||
| 1292 | } | |||||
| 1293 | a_th is.curTopi cIndex = i ; | |||||
| 1294 | var topictable filename = "topictab le_" + i + ".xml" ; | |||||
| 1295 | if (i != a_th is.lastInd ex) | |||||
| 1296 | { | |||||
| 1297 | a_this .lastIndex = i; | |||||
| 1298 | theXml Reader.str FilePath = getAbsPat h( a_this. strTopicTa blePath, t opictablef ilename ); | |||||
| 1299 | a_Cont ext.push( a_this.loa dFromFile, a_this, | |||||
| 1300 | a_ this.proce ssReaderRe sult, a_th is, | |||||
| 1301 | a_ this.parse TopicInfo, a_this ); | |||||
| 1302 | } | |||||
| 1303 | else | |||||
| 1304 | { | |||||
| 1305 | a_Cont ext.push( a_this.pro cessReader Result, a_ this, | |||||
| 1306 | a_ this.parse TopicInfo, a_this ); | |||||
| 1307 | } | |||||
| 1308 | } | |||||
| 1309 | ||||||
| 1310 | th is.makeInd exMap = fu nction( a_ Context, a _this ) | |||||
| 1311 | { | |||||
| 1312 | a_th is.topicMa p = new Ar ray() ; | |||||
| 1313 | var prev = 0 ; | |||||
| 1314 | for (var i = 0 ; i < theX mlReader.g etNumOfNod es() ; i++ ) | |||||
| 1315 | { | |||||
| 1316 | a_this .topicMap[ i] = theXm lReader.ge tNumOfTopi cs(i) + pr ev; | |||||
| 1317 | prev = a_this.to picMap[i] ; | |||||
| 1318 | } | |||||
| 1319 | } | |||||
| 1320 | ||||||
| 1321 | th is.prepare Map = fun ction( a_C ontext, a_ this ) | |||||
| 1322 | { | |||||
| 1323 | a_th is.bSucc = true; | |||||
| 1324 | theX mlReader.s trFilePath = a_this .strTopicT ablePath; | |||||
| 1325 | a_Co ntext.push ( a_this.l oadFromFil e, a_this, | |||||
| 1326 | a_ this.makeI ndexMap, a _this); | |||||
| 1327 | } | |||||
| 1328 | } | |||||
| 1329 | ||||||
| 1330 | // HuginDa tabase.js- ---------- ---------- -------- | |||||
| 1331 | ||||||
| 1332 | function H uginDataba se() | |||||
| 1333 | { | |||||
| 1334 | th is.strOdbP ath = ""; // in | |||||
| 1335 | ||||||
| 1336 | th is.queryWo rd = null; // in | |||||
| 1337 | th is.bNeedSt opWord = f alse; // in | |||||
| 1338 | th is.recordR esult = nu ll; // out | |||||
| 1339 | th is.eType = null ; //in | |||||
| 1340 | th is.aQueryT opics = nu ll; // in out | |||||
| 1341 | ||||||
| 1342 | th is.bSucc = false; | |||||
| 1343 | th is.bInited = false; | |||||
| 1344 | ||||||
| 1345 | th is.strTopi cTablePath = null; | |||||
| 1346 | th is.strPack ageIndexPa th = null; | |||||
| 1347 | th is.strSyno nymPath = null ; | |||||
| 1348 | th is.package Info = nul l; | |||||
| 1349 | ||||||
| 1350 | th is.iCurTop ic = null; | |||||
| 1351 | ||||||
| 1352 | th is.package IndexReade r = new Hu ginPackage IndexReade r(); | |||||
| 1353 | th is.package Reader = n ew HuginPa ckageReade r(); | |||||
| 1354 | th is.topicRe ader = new HuginTopi cTableRead er(); | |||||
| 1355 | ||||||
| 1356 | th is.prepare Query = fu nction() | |||||
| 1357 | { | |||||
| 1358 | this .recordRes ult = null ; | |||||
| 1359 | this .bSucc = t rue; | |||||
| 1360 | ||||||
| 1361 | this .packageIn fo = null; | |||||
| 1362 | ||||||
| 1363 | this .iCurTopic = 0; | |||||
| 1364 | ||||||
| 1365 | this .packageIn dexReader. prepareQue ry(); | |||||
| 1366 | this .packageRe ader.prepa reQuery(); | |||||
| 1367 | this .topicRead er.prepare Query(); | |||||
| 1368 | this .eType = E SNT_DEFAUL T ; | |||||
| 1369 | } | |||||
| 1370 | ||||||
| 1371 | th is.getInde xUrl = fun ction( a_s trIndexTyp e ) | |||||
| 1372 | { | |||||
| 1373 | var strRelPath = theXmlR eader.getA ttr( "inde x", "type" , a_strInd exType, "u rl" ); | |||||
| 1374 | if ( strRelPat h == "" ) | |||||
| 1375 | return ""; | |||||
| 1376 | ||||||
| 1377 | retu rn getAbsP ath( this. strOdbPath , strRelPa th ); | |||||
| 1378 | } | |||||
| 1379 | ||||||
| 1380 | th is.readOdb Info = fun ction( a_C ontext, a_ this ) | |||||
| 1381 | { | |||||
| 1382 | if ( !theXmlRe ader.bSucc || | |||||
| 1383 | !theX mlReader.c heckRoot( "odb" ) ) | |||||
| 1384 | { | |||||
| 1385 | a_this .bSucc = f alse; | |||||
| 1386 | a_this .bInited = false; | |||||
| 1387 | return ; | |||||
| 1388 | } | |||||
| 1389 | ||||||
| 1390 | a_th is.strTopi cTablePath = a_this. getIndexUr l( "TopicI ndex" ); | |||||
| 1391 | a_th is.strPack ageIndexPa th = a_thi s.getIndex Url( "Pack ageIndex" ); | |||||
| 1392 | a_th is.strSyno nymPath = a_this.get IndexUrl( "Synonym" ); | |||||
| 1393 | ||||||
| 1394 | if ( a_this.st rTopicTabl ePath == " " || a_thi s.strPacka geIndexPat h == "" | | a_this.s trSynonymP ath == "") | |||||
| 1395 | { | |||||
| 1396 | a_this .bSucc = f alse; | |||||
| 1397 | a_this .bInited = false; | |||||
| 1398 | return ; | |||||
| 1399 | } | |||||
| 1400 | else | |||||
| 1401 | { | |||||
| 1402 | a_this .bSucc = t rue; | |||||
| 1403 | a_this .bInited = true; | |||||
| 1404 | } | |||||
| 1405 | } | |||||
| 1406 | ||||||
| 1407 | th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k ) | |||||
| 1408 | { | |||||
| 1409 | theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback ); | |||||
| 1410 | } | |||||
| 1411 | ||||||
| 1412 | th is.queryRe cordInPack age = func tion( a_Co ntext, a_t his ) | |||||
| 1413 | { | |||||
| 1414 | if ( !a_this.p ackageInde xReader.bS ucc ) | |||||
| 1415 | return ; | |||||
| 1416 | ||||||
| 1417 | a_th is.package Info = a_t his.packag eIndexRead er.package Info; | |||||
| 1418 | a_th is.package Reader.str PackagePat h = a_this .packageIn fo; | |||||
| 1419 | a_th is.package Reader.str SynonymPat h = a_this .strSynony mPath ; | |||||
| 1420 | a_th is.package Reader.bPh raseSearch = (a_this .eType == ESNT_PHRAS E); | |||||
| 1421 | if ( gsSubstrSr ch) | |||||
| 1422 | a_this .packageRe ader.strQu eryWord = a_this.que ryWord.str Normalized Org; | |||||
| 1423 | else | |||||
| 1424 | a_this .packageRe ader.strQu eryWord = a_this.que ryWord.str HelStem; //use stem in ca se substri ng search is off | |||||
| 1425 | a_Co ntext.push ( a_this.p ackageRead er.query, a_this.pac kageReader ); | |||||
| 1426 | } | |||||
| 1427 | ||||||
| 1428 | th is.makeRes ult = func tion( a_Co ntext, a_t his ) | |||||
| 1429 | { | |||||
| 1430 | if ( !a_this.p ackageInde xReader.bS ucc || | |||||
| 1431 | !a_th is.package Reader.bSu cc ) | |||||
| 1432 | { | |||||
| 1433 | a_this .bSucc = f alse; | |||||
| 1434 | } | |||||
| 1435 | a_th is.recordR esult = a_ this.packa geReader.r ecordResul t; | |||||
| 1436 | if ( a_this.eTy pe == ESNT _NOT) | |||||
| 1437 | { | |||||
| 1438 | if ((typ eof(a_this .recordRes ult)=='und efined')|| (a_this.re cordResult ==null)) | |||||
| 1439 | { | |||||
| 1440 | a_th is.bSucc = true ; | |||||
| 1441 | a_th is.recordR esult = a_ this.makeD ummyResult Rec(a_this .queryWord .strNormal izedOrg,a_ this.query Word.strHe lStem) ; | |||||
| 1442 | } | |||||
| 1443 | theXmlRe ader.strFi lePath = a _this.strT opicTableP ath; | |||||
| 1444 | a_Contex t.push( a_ this.loadF romFile, a _this, | |||||
| 1445 | a_ this.makeN otResult, a_this ); | |||||
| 1446 | } | |||||
| 1447 | } | |||||
| 1448 | ||||||
| 1449 | th is.makeDum myResultRe c = functi on(strOrg, strStem) | |||||
| 1450 | { | |||||
| 1451 | var reco rdResult = new Objec t(); | |||||
| 1452 | recordRe sult.strRe cord = "" ; | |||||
| 1453 | recordRe sult.strNe fStem = st rStem ; | |||||
| 1454 | recordRe sult.bStop Word = fal se ; | |||||
| 1455 | return r ecordResul t ; | |||||
| 1456 | } | |||||
| 1457 | ||||||
| 1458 | th is.makeNot Result = f unction( a _Context, a_this ) | |||||
| 1459 | { | |||||
| 1460 | var topi cRecs = a_ this.recor dResult.st rRecord.sp lit( "|" ) ; | |||||
| 1461 | var bInc ludeAll = (a_this.re cordResult .strRecord == "" ); | |||||
| 1462 | va r arrTopic Ids = new Array(); | |||||
| 1463 | va r j ; | |||||
| 1464 | fo r(j=0;j<to picRecs.le ngth;j++) | |||||
| 1465 | { | |||||
| 1466 | var pos = topicRec s[j].index Of(","); | |||||
| 1467 | if(pos ! = -1) | |||||
| 1468 | arrT opicIds[ar rTopicIds. length] = topicRecs[ j].substri ng(0,pos); | |||||
| 1469 | } | |||||
| 1470 | va r bCheck = false ; | |||||
| 1471 | if (arrTopicI ds.length > 0) | |||||
| 1472 | bCheck = true ; | |||||
| 1473 | va r curIndex = 0 ; | |||||
| 1474 | va r sDummyTo picRec = " ,192:0,0,1 0" ; | |||||
| 1475 | va r i = 0; | |||||
| 1476 | va r numTopic s = 0 ; | |||||
| 1477 | for (var k =0 ; k < theX mlReader.g etNumOfNod es() ; k++ ) | |||||
| 1478 | { | |||||
| 1479 | numTop ics += the XmlReader. getNumOfTo pics(k); | |||||
| 1480 | } | |||||
| 1481 | a_ this.recor dResult.st rRecord = '' ; | |||||
| 1482 | wh ile(i < nu mTopics) | |||||
| 1483 | { | |||||
| 1484 | var bInc ludeTopic = true ; | |||||
| 1485 | if (bChe ck && (cur Index < ar rTopicIds. length)&&( arrTopicId s[curIndex ]==i) && ( !bIncludeA ll)) | |||||
| 1486 | { | |||||
| 1487 | curI ndex++ ; | |||||
| 1488 | bInc ludeTopic = false ; | |||||
| 1489 | } | |||||
| 1490 | if(bIncl udeTopic) | |||||
| 1491 | { | |||||
| 1492 | a_th is.bSucc = true ; | |||||
| 1493 | var topicRec = i + sDumm yTopicRec ; | |||||
| 1494 | if ( a_this.rec ordResult. strRecord == '') | |||||
| 1495 | a_this.rec ordResult. strRecord = topicRec ; | |||||
| 1496 | else | |||||
| 1497 | a_this.rec ordResult. strRecord += "|" + t opicRec ; | |||||
| 1498 | } | |||||
| 1499 | i++ ; | |||||
| 1500 | } | |||||
| 1501 | } | |||||
| 1502 | ||||||
| 1503 | th is.init = function( a_Context, a_this ) | |||||
| 1504 | { | |||||
| 1505 | theX mlReader.s trFilePath = a_this. strOdbPath ; | |||||
| 1506 | a_Co ntext.push ( a_this.l oadFromFil e, a_this, | |||||
| 1507 | a_ this.readO dbInfo, a_ this ); | |||||
| 1508 | } | |||||
| 1509 | ||||||
| 1510 | th is.queryRe cord = fun ction( a_C ontext, a_ this ) | |||||
| 1511 | { | |||||
| 1512 | if ( !a_this.b Inited ) | |||||
| 1513 | { | |||||
| 1514 | a_this .bSucc = f alse; | |||||
| 1515 | return ; | |||||
| 1516 | } | |||||
| 1517 | a_th is.bSucc = true; | |||||
| 1518 | ||||||
| 1519 | a_th is.package IndexReade r.strPacka geIndexPat h = a_this .strPackag eIndexPath ; | |||||
| 1520 | if ( gsSubstrSr ch) | |||||
| 1521 | a_this .packageIn dexReader. strCurQuer y = a_this .queryWord .strNormal izedOrg; | |||||
| 1522 | else | |||||
| 1523 | a_this .packageIn dexReader. strCurQuer y = a_this .queryWord .strHelSte m; //us e stem in case subst ring searc h is off | |||||
| 1524 | a_Co ntext.push ( a_this.p ackageInde xReader.qu eryPackage Info, a_th is.package IndexReade r, | |||||
| 1525 | a_ this.query RecordInPa ckage, a_t his, | |||||
| 1526 | a_ this.makeR esult, a_t his ) | |||||
| 1527 | } | |||||
| 1528 | ||||||
| 1529 | th is.process TopicInfo = function ( a_Contex t, a_this ) | |||||
| 1530 | { | |||||
| 1531 | if ( !a_this.t opicReader .bSucc ) | |||||
| 1532 | { | |||||
| 1533 | a_this .bSucc = f alse; | |||||
| 1534 | return ; | |||||
| 1535 | } | |||||
| 1536 | a_th is.aQueryT opics[a_th is.iCurTop ic].strUrl = a_this. topicReade r.topicInf o.strUrl; | |||||
| 1537 | a_th is.aQueryT opics[a_th is.iCurTop ic].strTit le = a_thi s.topicRea der.topicI nfo.strTit le; | |||||
| 1538 | a_th is.aQueryT opics[a_th is.iCurTop ic].strSum mary = a_t his.topicR eader.strT opicContex t; | |||||
| 1539 | } | |||||
| 1540 | ||||||
| 1541 | th is.incCurT opic = fun ction( a_C ontext, a_ this ) | |||||
| 1542 | { | |||||
| 1543 | a_th is.iCurTop ic++; | |||||
| 1544 | } | |||||
| 1545 | ||||||
| 1546 | th is.queryTo picInfo = function( a_Context, a_this ) | |||||
| 1547 | { | |||||
| 1548 | if ( a_this.iC urTopic >= a_this.aQ ueryTopics .length ) | |||||
| 1549 | return ; | |||||
| 1550 | ||||||
| 1551 | a_th is.topicRe ader.nQuer yId = a_th is.aQueryT opics[a_th is.iCurTop ic].nTopic Id; | |||||
| 1552 | a_Co ntext.push ( a_this.t opicReader .queryTopi cInfo, a_t his.topicR eader, | |||||
| 1553 | a_ this.proce ssTopicInf o, a_this, | |||||
| 1554 | a_ this.incCu rTopic, a_ this, | |||||
| 1555 | a_ this.query TopicInfo, a_this ); | |||||
| 1556 | } | |||||
| 1557 | ||||||
| 1558 | th is.queryTo picInfos = function( a_Context , a_this ) | |||||
| 1559 | { | |||||
| 1560 | if ( !a_this.b Inited ) | |||||
| 1561 | { | |||||
| 1562 | a_this .bSucc = f alse; | |||||
| 1563 | return ; | |||||
| 1564 | } | |||||
| 1565 | a_th is.bSucc = true; | |||||
| 1566 | ||||||
| 1567 | a_th is.topicRe ader.strTo picTablePa th = a_thi s.strTopic TablePath; | |||||
| 1568 | a_th is.iCurTop ic = 0; //this is an iterato r of a "fo r" loop | |||||
| 1569 | a_th is.topicRe ader.lastI ndex = -1; | |||||
| 1570 | a_Co ntext.push ( a_this.t opicReader .prepareMa p , a_this .topicRead er, | |||||
| 1571 | a_ this.query TopicInfo, a_this ); | |||||
| 1572 | } | |||||
| 1573 | } | |||||
| 1574 | ||||||
| 1575 | // Languag eService.j s--------- ---------- -------- | |||||
| 1576 | ||||||
| 1577 | function L anguageSer vice() | |||||
| 1578 | { | |||||
| 1579 | th is.getNorm alizedOrg = function ( a_strOrg , a_Result ) | |||||
| 1580 | { | |||||
| 1581 | var strUpper = a_strOrg. toUpperCas e(); | |||||
| 1582 | var strLower = a_strOrg. toLowerCas e(); | |||||
| 1583 | ||||||
| 1584 | if ( utf8Compa re(strUppe r, strLowe r) == 0 || utf8Compa re(strUppe r, a_strOr g) != 0 ) | |||||
| 1585 | { | |||||
| 1586 | a_Resu lt.strNorm alizedOrg = strLower ; | |||||
| 1587 | a_Resu lt.bUpperC ase = fals e; | |||||
| 1588 | } | |||||
| 1589 | else | |||||
| 1590 | { | |||||
| 1591 | a_Resu lt.strNorm alizedOrg = strUpper ; | |||||
| 1592 | a_Resu lt.bUpperC ase = true ; | |||||
| 1593 | } | |||||
| 1594 | } | |||||
| 1595 | th is.stemWit h = functi on( a_strW ord, a_str Suffix ) | |||||
| 1596 | { | |||||
| 1597 | var s = a_strS uffix.spli t( "," ); | |||||
| 1598 | var strSuffix = s[0]; | |||||
| 1599 | var bRemoveOnl y = ( s[1] == '1' ); | |||||
| 1600 | ||||||
| 1601 | var ss = a_str Word.match ( "^..+" + strSuffix + "$" ); | |||||
| 1602 | if ( ss == nul l ) | |||||
| 1603 | return null; | |||||
| 1604 | ||||||
| 1605 | var nLenRest = a_strWord .length - strSuffix. length; | |||||
| 1606 | var bAddE = fa lse; | |||||
| 1607 | if ( !bRemoveO nly ) | |||||
| 1608 | { | |||||
| 1609 | if ( ! this.isVow el( a_strW ord.charAt ( nLenRest - 1 ) ) ) | |||||
| 1610 | { | |||||
| 1611 | if ( a_s trWord.cha rAt( nLenR est - 1 ) == a_strWo rd.charAt( nLenRest - 2 ) ) | |||||
| 1612 | nLenRest-- ; | |||||
| 1613 | else | |||||
| 1614 | bAddE = tr ue; | |||||
| 1615 | } | |||||
| 1616 | } | |||||
| 1617 | ||||||
| 1618 | var strStem = a_strWord. substr( 0, nLenRest ); | |||||
| 1619 | ||||||
| 1620 | if ( strStem.l ength < 2 || (( strS tem.length == 2) && !bAddE ) ) | |||||
| 1621 | return null; | |||||
| 1622 | ||||||
| 1623 | //if ( strStem .length <= 2 ) | |||||
| 1624 | //retu rn null; | |||||
| 1625 | ||||||
| 1626 | retu rn strStem ; | |||||
| 1627 | } | |||||
| 1628 | th is.helStem = functio n( a_Resul t ) | |||||
| 1629 | { | |||||
| 1630 | var strWord = a_Result.s trNormaliz edOrg.toLo werCase(); | |||||
| 1631 | ||||||
| 1632 | var nSuffixNum = g_Runes HelSuffixe s.length; | |||||
| 1633 | var nStemFound = 0; | |||||
| 1634 | var strStem = null; | |||||
| 1635 | for ( var i = 0; i < nSu ffixNum; i ++ ) | |||||
| 1636 | { | |||||
| 1637 | strSte m = this.s temWith( s trWord, g_ RunesHelSu ffixes[i] ); | |||||
| 1638 | if ( s trStem != null ) | |||||
| 1639 | { | |||||
| 1640 | nStemFou nd = i + 1 ; | |||||
| 1641 | break; | |||||
| 1642 | } | |||||
| 1643 | } | |||||
| 1644 | if ( strStem = = null ) | |||||
| 1645 | strSte m = strWor d; | |||||
| 1646 | ||||||
| 1647 | a_Re sult.strHe lStem = st rStem; | |||||
| 1648 | a_Re sult.nHelW ordShape = a_Result. bUpperCase ? nStemFo und * 2 + 1 : nStemF ound * 2; | |||||
| 1649 | } | |||||
| 1650 | th is.isVowel = functio n( a_ch ) | |||||
| 1651 | { | |||||
| 1652 | retu rn g_Runes Vowels.ind exOf( a_ch ) >= 0; | |||||
| 1653 | } | |||||
| 1654 | th is.isWordB reak = fun ction( a_c h ) | |||||
| 1655 | { | |||||
| 1656 | retu rn ( !this .isQuote( a_ch ) && g_RunesWor dBreaks.in dexOf( a_c h ) >= 0 ) ; | |||||
| 1657 | } | |||||
| 1658 | th is.isWhite Space = fu nction( a_ ch ) | |||||
| 1659 | { | |||||
| 1660 | retu rn ( g_Run esWhiteSpa ces.indexO f( a_ch ) >= 0 ); | |||||
| 1661 | } | |||||
| 1662 | th is.isSpeci alBreak = function( a_ch ) | |||||
| 1663 | { | |||||
| 1664 | retu rn ( g_Run esSpecialB reaks.inde xOf( a_ch ) >= 0 ); | |||||
| 1665 | } | |||||
| 1666 | th is.isCJKCo dePoint = function( a_ch ) | |||||
| 1667 | { | |||||
| 1668 | //fr om http:// en.wikiped ia.org/wik i/Plane_%2 8Unicode%2 9 | |||||
| 1669 | if ( (typeof(a _ch) == "u ndefined" ) || (a_ch == "" ) ) | |||||
| 1670 | return false ; | |||||
| 1671 | var val = a_ch .charCodeA t(0) ; | |||||
| 1672 | ||||||
| 1673 | retu rn ( ((0x 2E80 <= va l) && ( v al <= 0x9F FF)) //Eas t Asian sc ripts and symbols | |||||
| 1674 | || ((0x F900 <= va l) && ( v al <= 0xFA FF)) //CJ K Compatib ility Ideo graphs | |||||
| 1675 | || ((0x FE30 <= va l) && ( v al <= 0xFE 4F)) //CJK Com patibility Forms | |||||
| 1676 | || ((0x FF00 <= va l) && ( v al <= 0xFF EF)) ); // Halfwidth and Fullwi dth Forms (FF00–FF EF) | |||||
| 1677 | } | |||||
| 1678 | th is.isQuote = functio n( a_ch ) | |||||
| 1679 | { | |||||
| 1680 | retu rn ( a_ch == g_Runes Quote ); | |||||
| 1681 | } | |||||
| 1682 | th is.isAND = function( a_strOp ) | |||||
| 1683 | { retu rn ( a_str Op == "and " ); } | |||||
| 1684 | th is.isOR = function( a_strOp ) | |||||
| 1685 | { retu rn ( a_str Op == "or" ); } | |||||
| 1686 | th is.isNOT = function( a_strOp ) | |||||
| 1687 | { retu rn ( a_str Op == "not " ); } | |||||
| 1688 | th is.isOpera tor = func tion( strO p ) | |||||
| 1689 | { if ( strOp == "and" || | |||||
| 1690 | strOp == "or" | | | |||||
| 1691 | strOp == "not" ) | |||||
| 1692 | return true; | |||||
| 1693 | } | |||||
| 1694 | } | |||||
| 1695 | ||||||
| 1696 | // Runes.j s--------- ---------- ---------- ----- | |||||
| 1697 | ||||||
| 1698 | var ES NT_AND = 1; | |||||
| 1699 | var ES NT_OR = 2; | |||||
| 1700 | var ES NT_NOT = 3; | |||||
| 1701 | var ES NT_DEFAULT = 4; | |||||
| 1702 | var ES NT_PHRASE = 5; | |||||
| 1703 | ||||||
| 1704 | function R unesContex t( a_strSr c ) | |||||
| 1705 | { | |||||
| 1706 | th is.strSrc = a_strSrc ; | |||||
| 1707 | th is.nCur = 0; | |||||
| 1708 | th is.bFailed = false; | |||||
| 1709 | th is.bNot = false; | |||||
| 1710 | th is.nWordIn dex = 0; | |||||
| 1711 | ||||||
| 1712 | th is.getCurC har = func tion() | |||||
| 1713 | { | |||||
| 1714 | retu rn this.st rSrc.charA t( this.nC ur ); | |||||
| 1715 | } | |||||
| 1716 | th is.getChar = functio n( i ) | |||||
| 1717 | { | |||||
| 1718 | retu rn this.st rSrc.charA t( i ); | |||||
| 1719 | } | |||||
| 1720 | th is.reachEn d = functi on() | |||||
| 1721 | { | |||||
| 1722 | retu rn this.nC ur >= this .strSrc.le ngth; | |||||
| 1723 | } | |||||
| 1724 | } | |||||
| 1725 | ||||||
| 1726 | function D olWord( a_ strWord, a _nPosition ) | |||||
| 1727 | { | |||||
| 1728 | th is.strWord = a_strW ord; | |||||
| 1729 | th is.nPositi on = a_nPos ition; | |||||
| 1730 | } | |||||
| 1731 | ||||||
| 1732 | function S olNode(){} | |||||
| 1733 | ||||||
| 1734 | function R unesServic e() | |||||
| 1735 | { | |||||
| 1736 | th is.langSev = new Lan guageServi ce(); | |||||
| 1737 | ||||||
| 1738 | th is.isOpera tor = func tion( a_st r, a_nFrom ) | |||||
| 1739 | { | |||||
| 1740 | var strOp = th is.getWord ( a_str, a _nFrom ).t oLowerCase (); | |||||
| 1741 | ||||||
| 1742 | if ( this.lang Sev.isOper ator( strO p ) ) | |||||
| 1743 | return true; | |||||
| 1744 | ||||||
| 1745 | retu rn false; | |||||
| 1746 | } | |||||
| 1747 | ||||||
| 1748 | th is.getLeng thOfWordBr eak = func tion( a_st r, a_nFrom ) | |||||
| 1749 | { | |||||
| 1750 | var i = a_nFro m, nLen = a_str.leng th; | |||||
| 1751 | whil e ( i < nL en && this .langSev.i sWordBreak ( a_str.ch arAt( i ) ) ) | |||||
| 1752 | i++; | |||||
| 1753 | retu rn i - a_n From; | |||||
| 1754 | } | |||||
| 1755 | ||||||
| 1756 | th is.getLeng thOfCJKWor dBreak = f unction( a _str, a_nF rom ) | |||||
| 1757 | { | |||||
| 1758 | var i = a_nFro m, nLen = a_str.leng th; | |||||
| 1759 | whil e ( i < nL en && (thi s.langSev. isWordBrea k( a_str.c harAt( i ) ) || this .langSev.i sCJKCodePo int( a_str .charAt( i ) ))) | |||||
| 1760 | i++; | |||||
| 1761 | retu rn i - a_n From; | |||||
| 1762 | } | |||||
| 1763 | ||||||
| 1764 | th is.getLeng thOfWord = function( a_str, a_ nFrom ) | |||||
| 1765 | { | |||||
| 1766 | var i = a_nFro m, nLen = a_str.leng th; | |||||
| 1767 | whil e ( i < nL en && | |||||
| 1768 | !this.la ngSev.isWo rdBreak( a _str.charA t( i ) ) & & | |||||
| 1769 | !this.la ngSev.isQu ote( a_str .charAt( i ) ) ) | |||||
| 1770 | ++i; | |||||
| 1771 | retu rn i - a_n From; | |||||
| 1772 | } | |||||
| 1773 | ||||||
| 1774 | th is.getNonC JKWord = f unction( a _str, a_nF rom ) | |||||
| 1775 | { | |||||
| 1776 | var i = a_nFro m, nLen = a_str.leng th; | |||||
| 1777 | whil e ( i < nL en && | |||||
| 1778 | !this.la ngSev.isWo rdBreak( a _str.charA t( i ) ) & & | |||||
| 1779 | !this.la ngSev.isCJ KCodePoint ( a_str.ch arAt( i ) ) && | |||||
| 1780 | !this.la ngSev.isQu ote( a_str .charAt( i ) ) ) | |||||
| 1781 | ++i; | |||||
| 1782 | var nLen = i - a_nFrom; | |||||
| 1783 | retu rn a_str.s ubstr( a_n From, nLen ); | |||||
| 1784 | } | |||||
| 1785 | ||||||
| 1786 | th is.getWord = functio n( a_str, a_nFrom ) | |||||
| 1787 | { | |||||
| 1788 | var nLen = thi s.getLengt hOfWord( a _str, a_nF rom ); | |||||
| 1789 | retu rn a_str.s ubstr( a_n From, nLen ); | |||||
| 1790 | } | |||||
| 1791 | ||||||
| 1792 | th is.getTerm = functio n( a_Conte xt, a_Rslt ) | |||||
| 1793 | { | |||||
| 1794 | if ( this.lang Sev.isQuot e( a_Conte xt.getCurC har() ) ) | |||||
| 1795 | { | |||||
| 1796 | a_Cont ext.nCur++ ; | |||||
| 1797 | ||||||
| 1798 | var nL en = this. getLengthO fPhrase( a _Context.s trSrc, a_C ontext.nCu r ); | |||||
| 1799 | if ( n Len <= 0 ) | |||||
| 1800 | return f alse; | |||||
| 1801 | ||||||
| 1802 | if(gbE nableAndSe arch && gC hangedQuer y.length > 0 ) | |||||
| 1803 | { | |||||
| 1804 | a_Contex t.strSrc = gChangedQ uery; | |||||
| 1805 | } | |||||
| 1806 | ||||||
| 1807 | a_Rslt .eType = E SNT_PHRASE ; | |||||
| 1808 | a_Rslt .strTerm = a_Context .strSrc.su bstr( a_Co ntext.nCur , nLen ); | |||||
| 1809 | a_Cont ext.nCur + = nLen + 1 ; | |||||
| 1810 | } | |||||
| 1811 | else | |||||
| 1812 | { | |||||
| 1813 | var nL en = this. getLengthO fDefault( a_Context. strSrc, a_ Context.nC ur ); | |||||
| 1814 | if ( n Len <= 0 ) | |||||
| 1815 | return f alse; | |||||
| 1816 | ||||||
| 1817 | if(gbE nableAndSe arch && gC hangedQuer y.length > 0 ) | |||||
| 1818 | { | |||||
| 1819 | a_Contex t.strSrc = gChangedQ uery; | |||||
| 1820 | } | |||||
| 1821 | ||||||
| 1822 | a_Rslt .eType = E SNT_DEFAUL T; | |||||
| 1823 | a_Rslt .strTerm = a_Context .strSrc.su bstr( a_Co ntext.nCur , nLen ); | |||||
| 1824 | a_Cont ext.nCur + = nLen; | |||||
| 1825 | } | |||||
| 1826 | ||||||
| 1827 | retu rn true; | |||||
| 1828 | } | |||||
| 1829 | ||||||
| 1830 | th is.getOper ator = fun ction( a_C ontext, a_ Rslt ) | |||||
| 1831 | { | |||||
| 1832 | if ( a_Context .reachEnd( ) ) | |||||
| 1833 | return false; | |||||
| 1834 | ||||||
| 1835 | var strOp = th is.getWord ( a_Contex t.strSrc, a_Context. nCur ).toL owerCase() ; | |||||
| 1836 | ||||||
| 1837 | if ( this.lang Sev.isAND( strOp ) ) | |||||
| 1838 | { | |||||
| 1839 | a_Rslt .eType = E SNT_AND; | |||||
| 1840 | a_Cont ext.nCur + = strOp.le ngth; | |||||
| 1841 | } | |||||
| 1842 | else if ( this .langSev.i sOR( strOp ) ) | |||||
| 1843 | { | |||||
| 1844 | a_Rslt .eType = E SNT_OR; | |||||
| 1845 | a_Cont ext.nCur + = strOp.le ngth; | |||||
| 1846 | } | |||||
| 1847 | else if ( this .langSev.i sNOT( strO p ) ) | |||||
| 1848 | { | |||||
| 1849 | a_Rslt .eType = E SNT_NOT; | |||||
| 1850 | a_Cont ext.nCur + = strOp.le ngth; | |||||
| 1851 | } | |||||
| 1852 | else | |||||
| 1853 | { | |||||
| 1854 | a_Rslt .eType = E SNT_OR; | |||||
| 1855 | } | |||||
| 1856 | ||||||
| 1857 | retu rn true; | |||||
| 1858 | } | |||||
| 1859 | ||||||
| 1860 | th is.getLeng thOfPhrase = functio n( a_str, a_nFrom ) | |||||
| 1861 | { | |||||
| 1862 | var i = a_nFro m, nLen = a_str.leng th; | |||||
| 1863 | whil e ( i < nL en ) | |||||
| 1864 | { | |||||
| 1865 | if ( t his.langSe v.isQuote( a_str.cha rAt( i ) ) ) | |||||
| 1866 | { | |||||
| 1867 | if(gbEna bleAndSear ch) | |||||
| 1868 | { | |||||
| 1869 | var nWordB reakLen = 0; | |||||
| 1870 | nWordBreak Len = this .getLength OfWordBrea k( a_str, i+1 ); | |||||
| 1871 | ||||||
| 1872 | var str = a_str.subs tring(i+nW ordBreakLe n, nLen); | |||||
| 1873 | ||||||
| 1874 | str = trim (str); | |||||
| 1875 | ||||||
| 1876 | if(str != "\"" && st r.length > 0) | |||||
| 1877 | gC hangedQuer y = a_str. substring( 0, i+1) + " AND " + str; | |||||
| 1878 | ||||||
| 1879 | } | |||||
| 1880 | ||||||
| 1881 | return i - a_nFrom ; | |||||
| 1882 | } | |||||
| 1883 | ||||||
| 1884 | ++i; | |||||
| 1885 | } | |||||
| 1886 | retu rn -1; | |||||
| 1887 | } | |||||
| 1888 | ||||||
| 1889 | th is.getLeng thOfDefaul t = functi on( a_str, a_nFrom ) | |||||
| 1890 | { | |||||
| 1891 | var i = a_nFro m, nLen = a_str.leng th; | |||||
| 1892 | whil e ( i < nL en && | |||||
| 1893 | !this.is Operator( a_str, i ) && | |||||
| 1894 | !this.la ngSev.isQu ote( a_str .charAt( i ) ) ) | |||||
| 1895 | { | |||||
| 1896 | i += t his.getLen gthOfWord( a_str, i ); | |||||
| 1897 | ||||||
| 1898 | if(gbE nableAndSe arch) | |||||
| 1899 | { | |||||
| 1900 | var nWor dBreakLen = 0; | |||||
| 1901 | nWordBre akLen = th is.getLeng thOfWordBr eak( a_str , i ); | |||||
| 1902 | ||||||
| 1903 | var str = a_str.su bstring(i+ nWordBreak Len, nLen) ; | |||||
| 1904 | ||||||
| 1905 | str = tr im(str); | |||||
| 1906 | ||||||
| 1907 | if(str.l ength>0) | |||||
| 1908 | gChangedQu ery = a_st r.substrin g(0, i) + " AND " + str; | |||||
| 1909 | ||||||
| 1910 | i+=1; | |||||
| 1911 | break; | |||||
| 1912 | } | |||||
| 1913 | else | |||||
| 1914 | i += thi s.getLengt hOfWordBre ak( a_str, i ); | |||||
| 1915 | ||||||
| 1916 | ||||||
| 1917 | } | |||||
| 1918 | retu rn i - a_n From; | |||||
| 1919 | } | |||||
| 1920 | ||||||
| 1921 | th is.parseOp erator = f unction( a _Context, a_Result, a_bNotAllo wed ) | |||||
| 1922 | { | |||||
| 1923 | a_Co ntext.nCur += this.g etLengthOf WordBreak( a_Context .strSrc, a _Context.n Cur ); | |||||
| 1924 | ||||||
| 1925 | var rslt = new Object; | |||||
| 1926 | if ( !this.get Operator( a_Context, rslt ) ) | |||||
| 1927 | return false; | |||||
| 1928 | ||||||
| 1929 | if ( rslt.eTyp e == ESNT_ NOT ) | |||||
| 1930 | { | |||||
| 1931 | if (a_ bNotAllowe d) | |||||
| 1932 | { | |||||
| 1933 | if ( a_Conte xt.bNOT ) | |||||
| 1934 | { | |||||
| 1935 | rslt .eType = E SNT_OR; | |||||
| 1936 | } | |||||
| 1937 | el se | |||||
| 1938 | { | |||||
| 1939 | a_Co ntext.bNOT = true; | |||||
| 1940 | } | |||||
| 1941 | } | |||||
| 1942 | else | |||||
| 1943 | { | |||||
| 1944 | a_ Context.bF ailed = tr ue; | |||||
| 1945 | re turn false ; | |||||
| 1946 | } | |||||
| 1947 | } | |||||
| 1948 | a_Re sult.eType = rslt.eT ype; | |||||
| 1949 | a_Re sult.right = new Sol Node(); | |||||
| 1950 | if ( !this.par seTerm( a_ Context, a _Result.ri ght ) ) | |||||
| 1951 | return false; | |||||
| 1952 | ||||||
| 1953 | retu rn true; | |||||
| 1954 | } | |||||
| 1955 | ||||||
| 1956 | /* * | |||||
| 1957 | St art parsin g the sear ch query f rom a_Cont ext.nCur a nd check f or presenc e of a phr ase or nor mal term | |||||
| 1958 | Or a term pr efixed wit h NOT oper ator. In c ase a phra se or norm al term is encounter ed, check for operat ors | |||||
| 1959 | in the rest of the exp ression. | |||||
| 1960 | A term can c ontain man y words fo r e.g. | |||||
| 1961 | Se arch query : hello wo rld AND fi rst topic | |||||
| 1962 | Th is consist of two se arch terms : | |||||
| 1963 | 1) hello wor ld | |||||
| 1964 | 2) first top ic | |||||
| 1965 | An d each of these term s have two words eac h. | |||||
| 1966 | ** / | |||||
| 1967 | th is.parseTe rm = funct ion( a_Con text, a_Re sult ) | |||||
| 1968 | { | |||||
| 1969 | a_Co ntext.nCur += this.g etLengthOf WordBreak( a_Context .strSrc, a _Context.n Cur ); | |||||
| 1970 | ||||||
| 1971 | var rslt = new Object; | |||||
| 1972 | if ( !this.get Term( a_Co ntext, rsl t ) ) | |||||
| 1973 | { | |||||
| 1974 | if (( this.parse Operator( a_Context, rslt, tru e ) )&&(rs lt.eType = = ESNT_NOT )) | |||||
| 1975 | { | |||||
| 1976 | a_Resu lt.eType = rslt.eTyp e; | |||||
| 1977 | if (rs lt.right.e Type == ES NT_DEFAULT ) | |||||
| 1978 | { | |||||
| 1979 | a_Result .strTerm = rslt.righ t.strTerm; | |||||
| 1980 | return t rue ; | |||||
| 1981 | } | |||||
| 1982 | el se | |||||
| 1983 | { | |||||
| 1984 | a_Contex t.bFailed = true; | |||||
| 1985 | return f alse; | |||||
| 1986 | } | |||||
| 1987 | } | |||||
| 1988 | else | |||||
| 1989 | { | |||||
| 1990 | a_Cont ext.bFaile d = true; | |||||
| 1991 | re turn false ; | |||||
| 1992 | } | |||||
| 1993 | } | |||||
| 1994 | ||||||
| 1995 | if ( this.pars eOperator( a_Context , a_Result , false ) ) | |||||
| 1996 | { | |||||
| 1997 | a_Resu lt.left = new SolNod e(); | |||||
| 1998 | a_Resu lt.left.eT ype = rslt .eType; | |||||
| 1999 | a_Resu lt.left.st rTerm = rs lt.strTerm ; | |||||
| 2000 | } | |||||
| 2001 | else | |||||
| 2002 | { | |||||
| 2003 | a_Resu lt.eType = rslt.eTyp e; | |||||
| 2004 | a_Resu lt.strTerm = rslt.st rTerm; | |||||
| 2005 | } | |||||
| 2006 | ||||||
| 2007 | retu rn true; | |||||
| 2008 | } | |||||
| 2009 | ||||||
| 2010 | th is.extract Term = fun ction( a_C ontext, a_ Term ) | |||||
| 2011 | { | |||||
| 2012 | a_Te rm.aWords = new Arra y(); | |||||
| 2013 | var termType = a_Term.eT ype ; | |||||
| 2014 | ||||||
| 2015 | this .dolSegmen t( a_Term ); | |||||
| 2016 | if ( (termType == ESNT_NO T ) && ( a _Term.eTyp e == ESNT_ PHRASE)) | |||||
| 2017 | return false ; / /change in term type to pharse means CJK search; n ot allowed for not o perator | |||||
| 2018 | ||||||
| 2019 | if ( a_Term.aW ords.lengt h == 0 ) | |||||
| 2020 | return false; | |||||
| 2021 | ||||||
| 2022 | if(a _Term.eTyp e != ESNT_ PHRASE) | |||||
| 2023 | { | |||||
| 2024 | //if s earch type is not ph rase searc h, remove special br eak charac ters | |||||
| 2025 | var j =0; | |||||
| 2026 | for ( var i = 0; i < a_Ter m.aWords.l ength; i++ ) | |||||
| 2027 | { | |||||
| 2028 | if(!this .langSev.i sSpecialBr eak( a_Ter m.aWords[i ].strWord. charAt( 0 ) )) | |||||
| 2029 | { | |||||
| 2030 | a_Term.aWo rds[j] = a _Term.aWor ds[i]; | |||||
| 2031 | j++; | |||||
| 2032 | } | |||||
| 2033 | } | |||||
| 2034 | a_Term .aWords.le ngth = j; | |||||
| 2035 | } | |||||
| 2036 | ||||||
| 2037 | ||||||
| 2038 | for ( var i = 0; i < a_T erm.aWords .length; i ++ ) | |||||
| 2039 | { | |||||
| 2040 | a_Term .aWords[i] .nWordId = a_Term.aW ords[i].nP osition + a_Context. nWordIndex ; | |||||
| 2041 | } | |||||
| 2042 | a_Co ntext.nWor dIndex = a _Term.aWor ds[a_Term. aWords.len gth - 1].n WordId + 1 ; | |||||
| 2043 | retu rn true; | |||||
| 2044 | } | |||||
| 2045 | ||||||
| 2046 | /* * | |||||
| 2047 | Ch eck each t erm in the query and break up each term in individ ual words. | |||||
| 2048 | ** / | |||||
| 2049 | th is.parsePh raseAndDef ault = fun ction( a_C ontext, a_ Node ) | |||||
| 2050 | { | |||||
| 2051 | if ( a_Node.eT ype == ESN T_PHRASE | | a_Node.e Type == ES NT_DEFAULT || a_Node .eType == ESNT_NOT) | |||||
| 2052 | { | |||||
| 2053 | if ( ! this.extra ctTerm( a_ Context, a _Node ) && | |||||
| 2054 | a_Node. eType == E SNT_PHRASE ) | |||||
| 2055 | a_Contex t.bFailed = true; | |||||
| 2056 | } | |||||
| 2057 | else | |||||
| 2058 | { | |||||
| 2059 | this.p arsePhrase AndDefault ( a_Contex t, a_Node. left ); | |||||
| 2060 | this.p arsePhrase AndDefault ( a_Contex t, a_Node. right ); | |||||
| 2061 | } | |||||
| 2062 | } | |||||
| 2063 | ||||||
| 2064 | th is.helStem = functio n( a_strOr g, a_Resul t ) | |||||
| 2065 | { | |||||
| 2066 | this .langSev.g etNormaliz edOrg( a_s trOrg, a_R esult ); | |||||
| 2067 | this .langSev.h elStem( a_ Result ); | |||||
| 2068 | } | |||||
| 2069 | ||||||
| 2070 | /* * | |||||
| 2071 | * Check pre sence of a ny break c haracters in given t erm, start ing from " cur" posit ion. | |||||
| 2072 | * If the br eak charac ters prese nt are spe cial break /CJK, incl ude them i n a_Result . | |||||
| 2073 | * Update po sition of next word and also c haracter p osition of next non breaking | |||||
| 2074 | * character in the te rm. | |||||
| 2075 | * Change th e term typ e to phras e, if a CJ K break is encounter ed. | |||||
| 2076 | * / | |||||
| 2077 | th is.parseBr eakCharact ers = fun ction( a_T erm , a_po sitions) | |||||
| 2078 | { | |||||
| 2079 | var a_strSrc = a_Term.st rTerm; | |||||
| 2080 | var a_Result = a_Term.aW ords ; | |||||
| 2081 | var nLen = a_s trSrc.leng th; | |||||
| 2082 | var nCur = a_p ositions[" cur"]; | |||||
| 2083 | var nPosition = a_positi ons["pos"] ; | |||||
| 2084 | var bCJKTerm = false ; | |||||
| 2085 | var bCJKBreak = false ; | |||||
| 2086 | whil e ( nCur < nLen && ( this.langS ev.isWordB reak( a_st rSrc.charA t( nCur )) || this.l angSev.isC JKCodePoin t( a_strSr c.charAt( nCur ))) ) | |||||
| 2087 | { | |||||
| 2088 | ||||||
| 2089 | if ( t his.langSe v.isSpecia lBreak( a_ strSrc.cha rAt( nCur ) ) || (bC JKBreak = this.langS ev.isCJKCo dePoint( a _strSrc.ch arAt( nCur ))) ) | |||||
| 2090 | { | |||||
| 2091 | //it's a special w ord/CJK br eak, inclu de it in s earch | |||||
| 2092 | a_Result [a_Result. length] = new DolWor d( a_strSr c.charAt( nCur ), nP osition ); | |||||
| 2093 | nPositio n++; | |||||
| 2094 | ||||||
| 2095 | if (!bCJ KTerm && b CJKBreak) //set the term as CJ K term | |||||
| 2096 | bCJKTerm = true ; | |||||
| 2097 | } | |||||
| 2098 | nCur++ ; | |||||
| 2099 | } | |||||
| 2100 | a_po sitions["c ur"] = nCu r ; | |||||
| 2101 | a_po sitions["p os"] = nPo sition ; | |||||
| 2102 | ||||||
| 2103 | if ( bCJKTerm) | |||||
| 2104 | a_Term .eType = E SNT_PHRASE ; | |||||
| 2105 | } | |||||
| 2106 | ||||||
| 2107 | /* * | |||||
| 2108 | Br eak the cu rrent term in words. | |||||
| 2109 | If the term contains C JK charact ers, treat each one of them | |||||
| 2110 | as a seperat e word. | |||||
| 2111 | If any of th e words is a CJK cha racter, tr eat this t erm as a p hrase term . | |||||
| 2112 | ** / | |||||
| 2113 | th is.dolSegm ent = func tion( a_Te rm ) | |||||
| 2114 | { | |||||
| 2115 | var a_strSrc = a_Term.st rTerm; | |||||
| 2116 | var a_Result = a_Term.aW ords ; | |||||
| 2117 | var nLen = a_s trSrc.leng th; | |||||
| 2118 | var strWord = ""; | |||||
| 2119 | var positions = new Arra y(); | |||||
| 2120 | posi tions["cur "] = 0 ; | |||||
| 2121 | posi tions["pos "] = 1 ; | |||||
| 2122 | ||||||
| 2123 | this .parseBrea kCharacter s( a_Term, positions ); | |||||
| 2124 | ||||||
| 2125 | whil e ( positi ons["cur"] < nLen ) | |||||
| 2126 | { | |||||
| 2127 | strWor d = this.g etNonCJKWo rd( a_strS rc, positi ons["cur"] ); | |||||
| 2128 | a_Resu lt[a_Resul t.length] = new DolW ord( strWo rd, positi ons["pos"] ); | |||||
| 2129 | ||||||
| 2130 | positi ons["cur"] += strWor d.length; | |||||
| 2131 | positi ons["pos"] ++ ; | |||||
| 2132 | ||||||
| 2133 | //chec k if we ca n find som e special break/CJK characters in betwee n this and next word | |||||
| 2134 | this.p arseBreakC haracters( a_Term, p ositions ); | |||||
| 2135 | } | |||||
| 2136 | } | |||||
| 2137 | ||||||
| 2138 | th is.solPars e = functi on( a_strS rc, a_Resu lt ) | |||||
| 2139 | { | |||||
| 2140 | var context = new RunesC ontext( a_ strSrc ); | |||||
| 2141 | this .parseTerm ( context, a_Result ); | |||||
| 2142 | ||||||
| 2143 | if ( context.b Failed ) | |||||
| 2144 | return false; | |||||
| 2145 | ||||||
| 2146 | this .parsePhra seAndDefau lt( contex t, a_Resul t ); | |||||
| 2147 | if ( context.b Failed ) | |||||
| 2148 | return false; | |||||
| 2149 | ||||||
| 2150 | retu rn true; | |||||
| 2151 | } | |||||
| 2152 | } | |||||
| 2153 | ||||||
| 2154 | // HuginIn put.js---- ---------- ---------- -------- | |||||
| 2155 | ||||||
| 2156 | function _ helStemNod e( a_Runes , a_Node ) | |||||
| 2157 | { | |||||
| 2158 | wi th ( a_Nod e ) | |||||
| 2159 | { | |||||
| 2160 | if ( eType == ESNT_PHRAS E || eType == ESNT_D EFAULT || eType == E SNT_NOT) | |||||
| 2161 | { | |||||
| 2162 | for ( var i = 0; i < aWord s.length; i++ ) | |||||
| 2163 | { | |||||
| 2164 | a_Runes. helStem( a Words[i].s trWord, aW ords[i] ) | |||||
| 2165 | } | |||||
| 2166 | } | |||||
| 2167 | else | |||||
| 2168 | { | |||||
| 2169 | _helSt emNode( a_ Runes, lef t ); | |||||
| 2170 | _helSt emNode( a_ Runes, rig ht ); | |||||
| 2171 | } | |||||
| 2172 | } | |||||
| 2173 | } | |||||
| 2174 | ||||||
| 2175 | function p arseQueryE xpression( a_strQuer y ) | |||||
| 2176 | { | |||||
| 2177 | va r runes = new RunesS ervice(); | |||||
| 2178 | va r expressi on = new S olNode(); | |||||
| 2179 | if ( !runes. solParse( a_strQuery , expressi on ) ) | |||||
| 2180 | retu rn null; | |||||
| 2181 | ||||||
| 2182 | _h elStemNode ( runes, e xpression ) | |||||
| 2183 | ||||||
| 2184 | re turn expre ssion; | |||||
| 2185 | } | |||||
| 2186 | ||||||
| 2187 | ||||||
| 2188 | // Ranking Calculator .js------- ---------- -------- | |||||
| 2189 | ||||||
| 2190 | var EW MT_NotMatc h = 0; | |||||
| 2191 | var EW MT_Synonym Match = 1; | |||||
| 2192 | var EW MT_WordMat ch = 2; | |||||
| 2193 | var EW MT_ShapeMa tch = 3; | |||||
| 2194 | ||||||
| 2195 | var WEIGHT _OF_SHAPE_ MATCH = 0.5; | |||||
| 2196 | var WEIGHT _OF_SINGLE _WORD_SCOR E = 0.5; | |||||
| 2197 | var HUGIN_ KEYWORD_FL AG = 0x0040; | |||||
| 2198 | var HUGIN_ TITLE_FLAG = 0x0080; | |||||
| 2199 | var WORDSH APE_SYNONY M = -2; | |||||
| 2200 | ||||||
| 2201 | function _ rank_ULaw( a_fX ) | |||||
| 2202 | { | |||||
| 2203 | if ( a_fX < 0.0 ) | |||||
| 2204 | retu rn 0.0; | |||||
| 2205 | ||||||
| 2206 | re turn 1.0 - 1.0 / ( a _fX + 1.0 ); | |||||
| 2207 | } | |||||
| 2208 | ||||||
| 2209 | function _ rank_Weake n( a_fWeig ht, a_fPer cent ) | |||||
| 2210 | { | |||||
| 2211 | va r fPercent = ( a_fPe rcent < 0. 0 ) ? 0.0 : | |||||
| 2212 | ( a_f Percent > 1.0 ) ? 1. 0 : a_fPer cent; | |||||
| 2213 | ||||||
| 2214 | re turn 1 - f Percent + a_fWeight * fPercent ; | |||||
| 2215 | } | |||||
| 2216 | ||||||
| 2217 | function _ isKeyWord( a_uEmphas is ) | |||||
| 2218 | { | |||||
| 2219 | re turn ( a_u Emphasis & HUGIN_KEY WORD_FLAG ) != 0; | |||||
| 2220 | } | |||||
| 2221 | ||||||
| 2222 | function _ isTitle( a _uEmphasis ) | |||||
| 2223 | { | |||||
| 2224 | re turn ( a_u Emphasis & HUGIN_TIT LE_FLAG ) != 0; | |||||
| 2225 | } | |||||
| 2226 | ||||||
| 2227 | function _ isUpperCas eShape( a_ nWordShape ) | |||||
| 2228 | { | |||||
| 2229 | re turn a_nWo rdShape % 2 != 0; | |||||
| 2230 | } | |||||
| 2231 | ||||||
| 2232 | function _ emphasisTo Score( a_u Emphasis ) | |||||
| 2233 | { | |||||
| 2234 | va r nScore = 0; | |||||
| 2235 | ||||||
| 2236 | // H1 = 64, H 2 = 32, H3 = 16, H4 = 8, H5 = 4, H6 = 2 | |||||
| 2237 | fo r ( var i = 5, nInc = 2; i >= 0; i--, nI nc *= 2 ) | |||||
| 2238 | nSco re += nInc * ( ( a_u Emphasis > > i ) & 1 ); | |||||
| 2239 | ||||||
| 2240 | re turn nScor e; | |||||
| 2241 | } | |||||
| 2242 | ||||||
| 2243 | function _ getWordMat chType( a_ Word, a_Ti le, a_nPos ition, a_n Offset ) | |||||
| 2244 | { | |||||
| 2245 | va r eRslt = EWMT_NotMa tch; | |||||
| 2246 | ||||||
| 2247 | // The term must be co nsecutive. | |||||
| 2248 | if ( a_nPosi tion - a_n Offset != a_Word.nWo rdId ) | |||||
| 2249 | retu rn eRslt; | |||||
| 2250 | ||||||
| 2251 | fo r ( var i = 0; i < a _Tile.aWor ds.length; i++ ) | |||||
| 2252 | { | |||||
| 2253 | var eCur = EWM T_NotMatch ; | |||||
| 2254 | if ( a_Tile.aW ords[i].nW ordId == a _Word.nWor dId ) | |||||
| 2255 | { | |||||
| 2256 | if ( a _Tile.aWor ds[i].nWor dForm == W ORDSHAPE_S YNONYM ) | |||||
| 2257 | eCur = E WMT_Synony mMatch; | |||||
| 2258 | else | |||||
| 2259 | { | |||||
| 2260 | if ( _is UpperCaseS hape( a_Wo rd.nWordSh ape ) ) | |||||
| 2261 | { | |||||
| 2262 | if ( a_Wor d.nWordSha pe == a_Ti le.aWords[ i].nWordFo rm ) | |||||
| 2263 | eC ur = EWMT_ ShapeMatch ; | |||||
| 2264 | else | |||||
| 2265 | eC ur = EWMT_ NotMatch; | |||||
| 2266 | } | |||||
| 2267 | else | |||||
| 2268 | { | |||||
| 2269 | if ( a_Wor d.nWordSha pe == a_Ti le.aWords[ i].nWordFo rm || | |||||
| 2270 | a _Word.nWor dShape == a_Tile.aWo rds[i].nWo rdForm - 1 ) | |||||
| 2271 | eC ur = EWMT_ ShapeMatch ; | |||||
| 2272 | else | |||||
| 2273 | eC ur = EWMT_ WordMatch; | |||||
| 2274 | } | |||||
| 2275 | } | |||||
| 2276 | } | |||||
| 2277 | if ( eRslt < e Cur ) | |||||
| 2278 | eRslt = eCur; | |||||
| 2279 | } | |||||
| 2280 | re turn eRslt ; | |||||
| 2281 | } | |||||
| 2282 | ||||||
| 2283 | function _ getTermMat chType( a_ aTiles, a_ nTileFrom, a_aWords, a_nFrom, a_nLen ) | |||||
| 2284 | { | |||||
| 2285 | va r eRslt = EWMT_Shape Match; | |||||
| 2286 | ||||||
| 2287 | if ( a_nFrom < 0 || a_ nLen <= 0 || a_aWord s.length < a_nFrom + a_nLen ) | |||||
| 2288 | retu rn EWMT_No tMatch; | |||||
| 2289 | ||||||
| 2290 | va r nOffset = a_nTileF rom ; | |||||
| 2291 | ||||||
| 2292 | va r j = a_nT ileFrom; | |||||
| 2293 | fo r ( var i = a_nFrom; i < a_nFr om + a_nLe n; i++ ) | |||||
| 2294 | { | |||||
| 2295 | nOff set = nOff set - a_aW ords[i].nW ordId | |||||
| 2296 | j = nOffset + a_aWords[i ].nWordId; //se ek j to th e tile tha t should b e matched | |||||
| 2297 | ||||||
| 2298 | if ( !a_aTiles [j] ) | |||||
| 2299 | return EWMT_NotM atch; | |||||
| 2300 | ||||||
| 2301 | var eCur = _ge tWordMatch Type( a_aW ords[i], a _aTiles[j] , j, nOffs et ); | |||||
| 2302 | if ( eCur < eR slt ) | |||||
| 2303 | eRslt = eCur; | |||||
| 2304 | if ( eRslt == EWMT_NotMa tch ) | |||||
| 2305 | return eRslt; | |||||
| 2306 | nOffset = nOffset + a_aWords [i].strWor d.length + a_aWords[ i].nWordId ; | |||||
| 2307 | } | |||||
| 2308 | re turn eRslt ; | |||||
| 2309 | } | |||||
| 2310 | ||||||
| 2311 | function _ matchTypeT oScore( a_ eMatchType ) | |||||
| 2312 | { | |||||
| 2313 | sw itch( a_eM atchType ) | |||||
| 2314 | { | |||||
| 2315 | ca se EWMT_No tMatch: re turn 0; | |||||
| 2316 | ca se EWMT_Sy nonymMatch : return 1; | |||||
| 2317 | ca se EWMT_Wo rdMatch: return 2; | |||||
| 2318 | ca se EWMT_Sh apeMatch: return 4; | |||||
| 2319 | de fault: retu rn 0; | |||||
| 2320 | } | |||||
| 2321 | } | |||||
| 2322 | ||||||
| 2323 | function _ computeSin gleWordSco re( a_Topi cImage, a_ nWordId ) | |||||
| 2324 | { | |||||
| 2325 | if ( !a_Topi cImage.aWo rds[a_nWor dId] ) | |||||
| 2326 | retu rn 0.0; | |||||
| 2327 | ||||||
| 2328 | va r emphasis = a_Topic Image.aWor ds[a_nWord Id].uEmpha sis ; | |||||
| 2329 | if (emphasis != 0 ) | |||||
| 2330 | emphasis = _emphas isToScore( emphasis ) ; | |||||
| 2331 | ||||||
| 2332 | em phasis += a_TopicIma ge.aWords[ a_nWordId] .uFreq; | |||||
| 2333 | ||||||
| 2334 | va r fWeightS core = _ra nk_Weaken( _rank_ULa w( emphasi s ), WEIGH T_OF_SINGL E_WORD_SCO RE ); | |||||
| 2335 | ||||||
| 2336 | if ( _isTitl e( a_Topic Image.aWor ds[a_nWord Id].uEmpha sis ) ) // Words i n title ar e importan t than key words and the rest. | |||||
| 2337 | { | |||||
| 2338 | retu rn fWeight Score / 3. 0 + 2.0 / 3.0; | |||||
| 2339 | } | |||||
| 2340 | if ( _isKeyW ord( a_Top icImage.aW ords[a_nWo rdId].uEmp hasis ) ) // Key w ords are a lways more important than non- keywords. | |||||
| 2341 | { | |||||
| 2342 | retu rn fWeight Score / 3. 0 + 1.0 / 3.0; | |||||
| 2343 | } | |||||
| 2344 | el se | |||||
| 2345 | { | |||||
| 2346 | retu rn fWeight Score / 3. 0; | |||||
| 2347 | } | |||||
| 2348 | } | |||||
| 2349 | ||||||
| 2350 | function _ computeTer mWeight( a _TopicImag e, a_Term ) | |||||
| 2351 | { | |||||
| 2352 | va r nTermLen = a_Term. aWords.len gth; // e mpty term means igno red or all stop word s | |||||
| 2353 | if ( nTermLe n == 0 ) | |||||
| 2354 | retu rn -1.0; | |||||
| 2355 | ||||||
| 2356 | va r fTermSco re = 0.0; // posit ion indepe ndent scor e | |||||
| 2357 | fo r ( i = 0; i < nTerm Len; i++ ) | |||||
| 2358 | fTer mScore += _computeSi ngleWordSc ore( a_Top icImage, a _Term.aWor ds[i].nWor dId ); | |||||
| 2359 | if ( a_Term. eType == E SNT_PHRASE ) | |||||
| 2360 | { | |||||
| 2361 | //ch eck if its a phrase | |||||
| 2362 | var bPhrase = false ; | |||||
| 2363 | var iPosition = 0; | |||||
| 2364 | for ( var strP osition in a_TopicIm age.aTiles ) | |||||
| 2365 | { | |||||
| 2366 | iPosit ion = pars eInt( strP osition ); | |||||
| 2367 | bPhras e = _getPh raseMatch( a_TopicIm age.aTiles , iPositio n, a_Term. aWords, 0 ); | |||||
| 2368 | if ( b Phrase ) | |||||
| 2369 | break ; | |||||
| 2370 | } | |||||
| 2371 | ||||||
| 2372 | if ( bPhrase) | |||||
| 2373 | return fTermScor e; | |||||
| 2374 | else | |||||
| 2375 | return 0.0 ; | |||||
| 2376 | } | |||||
| 2377 | el se | |||||
| 2378 | { | |||||
| 2379 | retu rn fTermSc ore; | |||||
| 2380 | } | |||||
| 2381 | } | |||||
| 2382 | ||||||
| 2383 | function _ getPhraseM atch(a_aTi les, iPosi tion, a_aW ords, a_nC urIdx ) | |||||
| 2384 | { | |||||
| 2385 | va r nOffset = iPositio n ; | |||||
| 2386 | if (a_nCurId x >= a_aWo rds.length ) | |||||
| 2387 | retu rn false ; | |||||
| 2388 | if (iPositio n >= a_aTi les.length ) | |||||
| 2389 | retu rn false ; | |||||
| 2390 | va r nCurWord Id = a_aWo rds[a_nCur Idx].nWord Id ; | |||||
| 2391 | if (!a_aTiles [iPosition ]) | |||||
| 2392 | retu rn false ; | |||||
| 2393 | ||||||
| 2394 | va r i ; | |||||
| 2395 | fo r ( i = 0 ; i < a_aT iles[iPosi tion].aWor ds.length ; i++) | |||||
| 2396 | { | |||||
| 2397 | var wordAtPos = a_aTiles [iPosition ].aWords[i ].nWordId ; | |||||
| 2398 | if (wordAtPo s == nCurW ordId) | |||||
| 2399 | { | |||||
| 2400 | if ( a_nCurIdx == (a_aWor ds.length -1 )) | |||||
| 2401 | { | |||||
| 2402 | //last word matc hes, then return tru e | |||||
| 2403 | return true ; | |||||
| 2404 | } | |||||
| 2405 | else | |||||
| 2406 | { | |||||
| 2407 | var wo rdLen = a_ aWords[a_n CurIdx].st rWord.leng th ; | |||||
| 2408 | return _getPhras eMatch(a_a Tiles , iP osition + wordLen , a_aWords , a_nCurIdx +1); | |||||
| 2409 | } | |||||
| 2410 | } | |||||
| 2411 | } | |||||
| 2412 | retu rn false ; | |||||
| 2413 | } | |||||
| 2414 | ||||||
| 2415 | function _ removeNega tiveWeight ( a_fWeigh t, a_eOpTy pe ) | |||||
| 2416 | { | |||||
| 2417 | if ( a_fWeig ht >= 0.0 ) | |||||
| 2418 | retu rn a_fWeig ht; | |||||
| 2419 | ||||||
| 2420 | sw itch ( a_e OpType ) | |||||
| 2421 | { | |||||
| 2422 | ca se ESNT_OR : return 0.0; | |||||
| 2423 | ca se ESNT_AN D: return 1.0; | |||||
| 2424 | ca se ESNT_NO T: return 0.0; | |||||
| 2425 | } | |||||
| 2426 | re turn 0.0; | |||||
| 2427 | } | |||||
| 2428 | ||||||
| 2429 | function _ getWeightO fNode( a_T opicImage, a_Node ) | |||||
| 2430 | { | |||||
| 2431 | if ( a_Node == null ) | |||||
| 2432 | retu rn 0.0; | |||||
| 2433 | ||||||
| 2434 | if ( a_Node. eType == E SNT_DEFAUL T || a_Nod e.eType == ESNT_PHRA SE || a_No de.eType = = ESNT_NOT ) | |||||
| 2435 | { | |||||
| 2436 | retu rn _comput eTermWeigh t( a_Topic Image, a_N ode ); | |||||
| 2437 | } | |||||
| 2438 | el se | |||||
| 2439 | { | |||||
| 2440 | // R ight has o nly 1/2 we ight of le ft | |||||
| 2441 | var fWeightRig ht = _getW eightOfNod e( a_Topic Image, a_N ode.right ) / 2.0; | |||||
| 2442 | var fWeightLef t = _getWe ightOfNode ( a_TopicI mage, a_No de.left ); | |||||
| 2443 | ||||||
| 2444 | // T o both neg ativeWeigh t return n egative | |||||
| 2445 | if ( fWeightRi ght < 0.0 && fWeight Left < 0.0 ) | |||||
| 2446 | return -1.0; | |||||
| 2447 | ||||||
| 2448 | // C onvert Neg ativeWeigh t to 1.0 o r 0.0 acco rding to o perator ty pe | |||||
| 2449 | fWei ghtRight = _removeNe gativeWeig ht( fWeigh tRight, a_ Node.eType ); | |||||
| 2450 | fWei ghtLeft = _removeNeg ativeWeigh t( fWeight Left, a_No de.eType ) ; | |||||
| 2451 | ||||||
| 2452 | // B oolean ope ration | |||||
| 2453 | swit ch ( a_Nod e.eType ) | |||||
| 2454 | { | |||||
| 2455 | case ESNT_OR: | |||||
| 2456 | return ( fWeight Left + fWe ightRight ) / 2.0; | |||||
| 2457 | case ESNT_AND: | |||||
| 2458 | return ( fWeight Left * fWe ightRight ); | |||||
| 2459 | case ESNT_NOT: | |||||
| 2460 | fWeigh tRight = ( fWeightRi ght == 0.0 ) ? 1.0 : 0.0; | |||||
| 2461 | return fWeightLe ft * fWeig htRight; | |||||
| 2462 | } | |||||
| 2463 | ||||||
| 2464 | // U ncoverd ca ses (inexi stent). | |||||
| 2465 | retu rn 0.0; | |||||
| 2466 | } | |||||
| 2467 | } | |||||
| 2468 | ||||||
| 2469 | function c alculateRa nking( a_T opicImage, a_Express ion ) | |||||
| 2470 | { | |||||
| 2471 | re turn _getW eightOfNod e( a_Topic Image, a_E xpression ); | |||||
| 2472 | } | |||||
| 2473 | ||||||
| 2474 | // HuginHu nter.js--- ---------- ---------- -------- | |||||
| 2475 | ||||||
| 2476 | function a rrayRemove At( a_ary, a_nIndex ) | |||||
| 2477 | { | |||||
| 2478 | va r nLen = a _ary.lengt h; | |||||
| 2479 | fo r ( var i = a_nIndex ; i < nLen - 1; i++ ) | |||||
| 2480 | a_ar y[i] = a_a ry[i + 1]; | |||||
| 2481 | a_ ary.length --; | |||||
| 2482 | } | |||||
| 2483 | ||||||
| 2484 | function H uginQueryR esult() | |||||
| 2485 | { | |||||
| 2486 | th is.aTopics = new Arr ay(); | |||||
| 2487 | } | |||||
| 2488 | ||||||
| 2489 | function H uginImageW ord() | |||||
| 2490 | { | |||||
| 2491 | th is.uEmphas is = 0; | |||||
| 2492 | th is.uFreq = 0; | |||||
| 2493 | ||||||
| 2494 | }; | |||||
| 2495 | ||||||
| 2496 | function H uginImageT ileWord( a _nWordId, a_nWordFor m ) | |||||
| 2497 | { | |||||
| 2498 | th is.nWordId = a_nWord Id; | |||||
| 2499 | th is.nWordFo rm = a_nWo rdForm; | |||||
| 2500 | } | |||||
| 2501 | ||||||
| 2502 | function H uginImageT ile() | |||||
| 2503 | { | |||||
| 2504 | th is.aWords = new Arra y(); | |||||
| 2505 | } | |||||
| 2506 | ||||||
| 2507 | function H uginTopicI mage( a_nT opicId ) | |||||
| 2508 | { | |||||
| 2509 | th is.aWords = new Arra y(); | |||||
| 2510 | th is.aTiles = new Arra y();; | |||||
| 2511 | } | |||||
| 2512 | ||||||
| 2513 | function H uginHunter () | |||||
| 2514 | { | |||||
| 2515 | th is.aOdbPat hes = null ; //in | |||||
| 2516 | th is.strOdbP ath = null ; //in | |||||
| 2517 | ||||||
| 2518 | th is.strQuer y = null; //in | |||||
| 2519 | th is.queryRe sult = nul l; //ou t | |||||
| 2520 | ||||||
| 2521 | th is.bInited = false; | |||||
| 2522 | th is.bSucc = true; | |||||
| 2523 | ||||||
| 2524 | th is.aDataba ses = null ; | |||||
| 2525 | ||||||
| 2526 | th is.iCurPro j = null; | |||||
| 2527 | ||||||
| 2528 | th is.queryEx pression = null; | |||||
| 2529 | th is.queryWo rd = null; | |||||
| 2530 | th is.curTerm Node = nul l; | |||||
| 2531 | ||||||
| 2532 | th is.aRecord Table = nu ll; | |||||
| 2533 | th is.aSuspen dTopics = null; | |||||
| 2534 | th is.aTopics = null; | |||||
| 2535 | th is.iCurTop ic = null; | |||||
| 2536 | ||||||
| 2537 | th is.aTopicI mages = nu ll; | |||||
| 2538 | th is.aNodeSt ack = null ; | |||||
| 2539 | th is.iCurTer mNodeWord = null; | |||||
| 2540 | ||||||
| 2541 | th is.aPossib leOrgs = n ull; | |||||
| 2542 | th is.aRanked Topics = n ull; | |||||
| 2543 | ||||||
| 2544 | th is.nWordLo aded = 0; | |||||
| 2545 | th is.nWordNu m = 0; | |||||
| 2546 | th is.nState = 0; | |||||
| 2547 | th is.nProgre ss = 0; | |||||
| 2548 | ||||||
| 2549 | th is.prepare Query = fu nction() | |||||
| 2550 | { | |||||
| 2551 | this .queryResu lt = null; | |||||
| 2552 | this .bSucc = t rue; | |||||
| 2553 | ||||||
| 2554 | this .iCurProj = 0; | |||||
| 2555 | this .queryExpr ession = n ull; | |||||
| 2556 | this .queryWord = null; | |||||
| 2557 | this .curTermNo de = null; | |||||
| 2558 | ||||||
| 2559 | this .aRecordTa ble = null ; | |||||
| 2560 | this .aSuspendT opics = nu ll; | |||||
| 2561 | this .aTopics = null; | |||||
| 2562 | this .iCurTopic = 0; | |||||
| 2563 | ||||||
| 2564 | this .aTopicIma ges = null ; | |||||
| 2565 | this .aNodeStac k = null; | |||||
| 2566 | this .iCurTermN odeWord = 0; | |||||
| 2567 | ||||||
| 2568 | this .aPossible Orgs = nul l; | |||||
| 2569 | this .aRankedTo pics = nul l; | |||||
| 2570 | ||||||
| 2571 | this .nWordLoad ed = 0; | |||||
| 2572 | this .nWordNum = 0; | |||||
| 2573 | this .nState = 0; | |||||
| 2574 | this .nProgress = 0; | |||||
| 2575 | ||||||
| 2576 | for ( var i in this.aDat abases ) | |||||
| 2577 | this.a Databases[ i].prepare Query(); | |||||
| 2578 | } | |||||
| 2579 | ||||||
| 2580 | th is.updateP rogress = function() | |||||
| 2581 | { | |||||
| 2582 | var fProgress = 100 * th is.iCurPro j / this.a Databases. length; | |||||
| 2583 | var fBase = 10 0 / this.a Databases. length; | |||||
| 2584 | ||||||
| 2585 | if ( this.nSta te == 1 ) | |||||
| 2586 | this.n Progress = Math.roun d( fProgre ss + ( thi s.nWordLoa ded / this .nWordNum ) * ( fBas e / 3 ) ); | |||||
| 2587 | else if ( this .nState == 2 ) | |||||
| 2588 | this.n Progress = Math.roun d( fProgre ss + fBase / 3 + | |||||
| 2589 | ( this.iC urTopic / this.aTopi cs.length ) * ( fBas e * 2 / 3 ) ); | |||||
| 2590 | } | |||||
| 2591 | ||||||
| 2592 | th is.incCurP rojForInit = functio n( a_Conte xt, a_this ) | |||||
| 2593 | { | |||||
| 2594 | a_th is.iCurPro j++; | |||||
| 2595 | if ( a_this.iC urProj < a _this.aDat abases.len gth ) | |||||
| 2596 | { | |||||
| 2597 | a_Cont ext.push( a_this.aDa tabases[a_ this.iCurP roj].init, a_this.aD atabases[a _this.iCur Proj], | |||||
| 2598 | a_th is.incCurP rojForInit , a_this ) ; | |||||
| 2599 | } | |||||
| 2600 | } | |||||
| 2601 | ||||||
| 2602 | th is.incCurP rojForEval uate = fun ction( a_C ontext, a_ this ) | |||||
| 2603 | { | |||||
| 2604 | a_th is.iCurPro j++; | |||||
| 2605 | if ( a_this.iC urProj < a _this.aDat abases.len gth ) | |||||
| 2606 | { | |||||
| 2607 | a_this .aRankedTo pics[a_thi s.iCurProj ] = new Ar ray(); | |||||
| 2608 | a_Cont ext.push( a_this.get Records, a _this, | |||||
| 2609 | a_th is.evaluat eTopics, a _this, | |||||
| 2610 | a_th is.getTopi cInfo, a_t his, | |||||
| 2611 | a_th is.incCurP rojForEval uate, a_th is ); | |||||
| 2612 | } | |||||
| 2613 | } | |||||
| 2614 | ||||||
| 2615 | th is.incCurT ermNodeWor d = functi on( a_Cont ext, a_thi s ) | |||||
| 2616 | { | |||||
| 2617 | a_th is.nState = 1; | |||||
| 2618 | ||||||
| 2619 | a_th is.iCurTer mNodeWord+ +; | |||||
| 2620 | a_th is.nWordLo aded++; | |||||
| 2621 | a_th is.updateP rogress(); | |||||
| 2622 | } | |||||
| 2623 | ||||||
| 2624 | th is.incCurT opic = fun ction( a_C ontext, a_ this ) | |||||
| 2625 | { | |||||
| 2626 | a_th is.nState = 2; | |||||
| 2627 | ||||||
| 2628 | a_th is.iCurTop ic++; | |||||
| 2629 | a_th is.updateP rogress(); | |||||
| 2630 | } | |||||
| 2631 | ||||||
| 2632 | th is.checkIn itSucc = f unction( a _Context, a_this ) | |||||
| 2633 | { | |||||
| 2634 | var bAllFailed = true; | |||||
| 2635 | var bNotAllDat abaseInite d = false; | |||||
| 2636 | a_th is.bInited = false; | |||||
| 2637 | for ( var i = 0; i < a_t his.aDatab ases.lengt h; i++ ) | |||||
| 2638 | { | |||||
| 2639 | if ( ! a_this.aDa tabases[i] .bSucc || !a_this.aD atabases[i ].bInited ) | |||||
| 2640 | bNotAllD atabaseIni ted = true ; | |||||
| 2641 | else | |||||
| 2642 | bAllFail ed = false ; | |||||
| 2643 | } | |||||
| 2644 | if ( bAllFaile d ) | |||||
| 2645 | { | |||||
| 2646 | a_Cont ext.strMsg = gsInitD atabaseFai led; | |||||
| 2647 | g_CurS tate = ECS _FATALERRO R; | |||||
| 2648 | update ResultView (); | |||||
| 2649 | return ; | |||||
| 2650 | } | |||||
| 2651 | if ( bNotAllDa tabaseInit ed ) | |||||
| 2652 | { | |||||
| 2653 | a_Cont ext.strMsg = gsInitD atabaseFai led; | |||||
| 2654 | } | |||||
| 2655 | a_Co ntext.strM sg = ""; | |||||
| 2656 | g_Cu rState = E CS_FTSREAD Y; | |||||
| 2657 | a_th is.bInited = true; | |||||
| 2658 | } | |||||
| 2659 | ||||||
| 2660 | th is.getWord ImageToAdd = functio n( a_nWord Id, a_aWor ds ) | |||||
| 2661 | { | |||||
| 2662 | retu rn a_aWord s[a_nWordI d] ? a_aWo rds[a_nWor dId] : ( a _aWords[a_ nWordId] = new Hugin ImageWord( ) ); | |||||
| 2663 | } | |||||
| 2664 | ||||||
| 2665 | th is.getTile ImageToAdd = functio n( a_nPosi tion, a_aT iles ) | |||||
| 2666 | { | |||||
| 2667 | retu rn a_aTile s[a_nPosit ion] ? a_a Tiles[a_nP osition] : ( a_aTile s[a_nPosit ion] = new HuginImag eTile() ); | |||||
| 2668 | } | |||||
| 2669 | ||||||
| 2670 | th is.addReco rdToRecord Table = fu nction( a_ nWordId, a _strRecord ) | |||||
| 2671 | { | |||||
| 2672 | if ( a_strReco rd == "" ) | |||||
| 2673 | return ; | |||||
| 2674 | ||||||
| 2675 | if(t ypeof(this .aRecordTa ble[a_nWor dId]) == " undefined" ) | |||||
| 2676 | this.a RecordTabl e[a_nWordI d] = new A rray(); | |||||
| 2677 | ||||||
| 2678 | var aTopics = a_strRecor d.split( " |" ); | |||||
| 2679 | for ( var iTop ic = 0; iT opic < aTo pics.lengt h; iTopic+ + ) | |||||
| 2680 | { | |||||
| 2681 | var to picHead = aTopics[iT opic].matc h( "^(\\d+ ),(.*)$" ) ; | |||||
| 2682 | if ( t opicHead = = null ) | |||||
| 2683 | continue ; | |||||
| 2684 | this.a RecordTabl e[a_nWordI d][topicHe ad[1]] = t opicHead[2 ]; | |||||
| 2685 | this.a SuspendTop ics[topicH ead[1]] = true; | |||||
| 2686 | } | |||||
| 2687 | } | |||||
| 2688 | ||||||
| 2689 | th is.process RecordResu lt = funct ion( a_Con text, a_th is ) | |||||
| 2690 | { | |||||
| 2691 | if ( !a_this.a Databases[ a_this.iCu rProj].bSu cc ) // Go on sea rching for other wor ds while o ne not fou nd | |||||
| 2692 | return ; | |||||
| 2693 | ||||||
| 2694 | a_th is.wordRec ord = a_th is.aDataba ses[a_this .iCurProj] .recordRes ult; | |||||
| 2695 | a_th is.addReco rdToRecord Table( a_t his.queryW ord.nWordI d, a_this. wordRecord .strRecord ); | |||||
| 2696 | } | |||||
| 2697 | ||||||
| 2698 | th is.getReco rdOfTermWo rd = funct ion( a_Con text, a_th is ) | |||||
| 2699 | { | |||||
| 2700 | if ( a_this.iC urTermNode Word >= a_ this.curTe rmNode.aWo rds.length ) | |||||
| 2701 | return ; | |||||
| 2702 | ||||||
| 2703 | a_th is.queryWo rd = a_thi s.curTermN ode.aWords [a_this.iC urTermNode Word]; | |||||
| 2704 | a_th is.aDataba ses[a_this .iCurProj] .queryWord = a_this. queryWord; | |||||
| 2705 | a_th is.aDataba ses[a_this .iCurProj] .eType = a _this.curT ermNode.eT ype ; | |||||
| 2706 | a_th is.aDataba ses[a_this .iCurProj] .bNeedStop Word = a_t his.bNeedS topWord; | |||||
| 2707 | a_Co ntext.push ( a_this.a Databases[ a_this.iCu rProj].que ryRecord, a_this.aDa tabases[a_ this.iCurP roj], | |||||
| 2708 | a_ this.proce ssRecordRe sult, a_th is, | |||||
| 2709 | a_ this.incCu rTermNodeW ord, a_thi s, | |||||
| 2710 | a_ this.getRe cordOfTerm Word, a_th is ); | |||||
| 2711 | } | |||||
| 2712 | ||||||
| 2713 | th is.getReco rdOfTermNo de = funct ion( a_Con text, a_th is ) | |||||
| 2714 | { | |||||
| 2715 | a_th is.aPossib leOrgs = n ew Array() ; | |||||
| 2716 | a_th is.bNeedSt opWord = ( a_this.cu rTermNode. eType == E SNT_PHRASE ); | |||||
| 2717 | a_th is.iCurTer mNodeWord = 0; //Init the iterator of a "for loop" | |||||
| 2718 | a_Co ntext.push ( a_this.g etRecordOf TermWord, a_this); | |||||
| 2719 | } | |||||
| 2720 | ||||||
| 2721 | th is.getReco rdOfNode = function( a_Context , a_this ) | |||||
| 2722 | { | |||||
| 2723 | if ( a_this.aN odeStack.l ength == 0 ) | |||||
| 2724 | return ; | |||||
| 2725 | ||||||
| 2726 | var curNode = a_this.aNo deStack[a_ this.aNode Stack.leng th - 1]; | |||||
| 2727 | a_th is.aNodeSt ack.length --; | |||||
| 2728 | ||||||
| 2729 | if ( curNode ! = null ) | |||||
| 2730 | { | |||||
| 2731 | if ( c urNode.eTy pe == ESNT _PHRASE || curNode.e Type == ES NT_DEFAULT || curNod e.eType == ESNT_NOT) | |||||
| 2732 | { | |||||
| 2733 | a_this.c urTermNode = curNode ; | |||||
| 2734 | a_Contex t.push( a_ this.getRe cordOfTerm Node, a_th is ); | |||||
| 2735 | } | |||||
| 2736 | else | |||||
| 2737 | { | |||||
| 2738 | a_this.a NodeStack[ a_this.aNo deStack.le ngth] = cu rNode.righ t; | |||||
| 2739 | a_this.a NodeStack[ a_this.aNo deStack.le ngth] = cu rNode.left ; | |||||
| 2740 | ||||||
| 2741 | a_Contex t.push( a_ this.getRe cordOfNode , a_this, | |||||
| 2742 | a_this .getRecord OfNode, a_ this ); | |||||
| 2743 | } | |||||
| 2744 | } | |||||
| 2745 | } | |||||
| 2746 | ||||||
| 2747 | th is.addToTo picImage = function( a_Image, a_nWordId, a_Record ) | |||||
| 2748 | { | |||||
| 2749 | var wordImage = this.get WordImageT oAdd( a_nW ordId, a_I mage.aWord s ); | |||||
| 2750 | ||||||
| 2751 | word Image.uEmp hasis |= a _Record.uE mphasis; | |||||
| 2752 | word Image.uFre q = a_Reco rd.aPositi ons.length ; | |||||
| 2753 | for ( var strP osition in a_Record. aPositions ) | |||||
| 2754 | { | |||||
| 2755 | var ti leImage = this.getTi leImageToA dd( a_Reco rd.aPositi ons[strPos ition], | |||||
| 2756 | a_Image. aTiles ); | |||||
| 2757 | tileIm age.aWords [tileImage .aWords.le ngth] = ne w HuginIma geTileWord ( a_nWordI d, 0 /*nWo rdShape*/ ); | |||||
| 2758 | } | |||||
| 2759 | } | |||||
| 2760 | ||||||
| 2761 | th is.unpackT opicRecord = functio n( a_strRe cord ) | |||||
| 2762 | { | |||||
| 2763 | var aShapes = a_strRecor d.split( " :" ); | |||||
| 2764 | if ( aShapes.l ength == 0 ) | |||||
| 2765 | return null; | |||||
| 2766 | ||||||
| 2767 | var record = n ew Object( ); | |||||
| 2768 | reco rd.uEmphas is = parse Int( aShap es[0] ); | |||||
| 2769 | reco rd.aPositi ons = aSha pes[1].spl it( "," ); | |||||
| 2770 | if ( record.aP ositions.l ength < 1 ) | |||||
| 2771 | return null; | |||||
| 2772 | retu rn record; | |||||
| 2773 | } | |||||
| 2774 | ||||||
| 2775 | th is.makeTop icImage = function( a_nTopicId ) | |||||
| 2776 | { | |||||
| 2777 | var topicImage = new Hug inTopicIma ge(); | |||||
| 2778 | for ( var strW ordId in t his.aRecor dTable ) | |||||
| 2779 | { | |||||
| 2780 | if ( ! this.aReco rdTable[st rWordId][a _nTopicId] ) | |||||
| 2781 | continue ; | |||||
| 2782 | ||||||
| 2783 | var re cord = thi s.unpackTo picRecord( this.aRec ordTable[s trWordId][ a_nTopicId ] ) | |||||
| 2784 | this.a ddToTopicI mage( topi cImage, pa rseInt( st rWordId ), record ); | |||||
| 2785 | } | |||||
| 2786 | retu rn topicIm age; | |||||
| 2787 | } | |||||
| 2788 | ||||||
| 2789 | th is.calcula teRanking = function ( a_TopicI mage ) | |||||
| 2790 | { | |||||
| 2791 | retu rn calcula teRanking( a_TopicIm age, this. queryExpre ssion ); | |||||
| 2792 | } | |||||
| 2793 | ||||||
| 2794 | th is.calcula teWordNum = function ( a_Node ) | |||||
| 2795 | { | |||||
| 2796 | if ( a_Node.eT ype == ESN T_PHRASE | | a_Node.e Type == ES NT_DEFAULT || a_Node .eType == ESNT_NOT) | |||||
| 2797 | { | |||||
| 2798 | this.n WordNum += a_Node.aW ords.lengt h; | |||||
| 2799 | } | |||||
| 2800 | else | |||||
| 2801 | { | |||||
| 2802 | this.c alculateWo rdNum( a_N ode.right ); | |||||
| 2803 | this.c alculateWo rdNum( a_N ode.left ) ; | |||||
| 2804 | } | |||||
| 2805 | } | |||||
| 2806 | ||||||
| 2807 | th is.getReco rds = func tion( a_Co ntext, a_t his ) | |||||
| 2808 | { | |||||
| 2809 | a_th is.aNodeSt ack = new Array(); | |||||
| 2810 | a_th is.aNodeSt ack[a_this .aNodeStac k.length] = a_this.q ueryExpres sion; | |||||
| 2811 | a_th is.aRecord Table = ne w Array(); | |||||
| 2812 | a_th is.aSuspen dTopics = new Array( ); | |||||
| 2813 | ||||||
| 2814 | a_th is.nWordLo aded = 0; | |||||
| 2815 | a_th is.calcula teWordNum( a_this.qu eryExpress ion ); | |||||
| 2816 | ||||||
| 2817 | a_Co ntext.push ( a_this.g etRecordOf Node, a_th is ); | |||||
| 2818 | } | |||||
| 2819 | ||||||
| 2820 | th is.evaluat eTopic = f unction( a _Context, a_this ) | |||||
| 2821 | { | |||||
| 2822 | if ( a_this.iC urTopic >= a_this.aT opics.leng th ) | |||||
| 2823 | return ; | |||||
| 2824 | ||||||
| 2825 | var rankedTopi c = new Ob ject(); | |||||
| 2826 | rank edTopic.fR anking = a _this.calc ulateRanki ng( a_this .makeTopic Image( a_t his.aTopic s[a_this.i CurTopic] ) ); | |||||
| 2827 | if ( rankedTop ic.fRankin g > 0 ) | |||||
| 2828 | { | |||||
| 2829 | ranked Topic.nTop icId = par seInt( a_t his.aTopic s[a_this.i CurTopic] ); | |||||
| 2830 | a_this .aRankedTo pics[a_thi s.iCurProj ][a_this.a RankedTopi cs[a_this. iCurProj]. length] = rankedTopi c; | |||||
| 2831 | } | |||||
| 2832 | a_Co ntext.push ( a_this.i ncCurTopic , a_this, | |||||
| 2833 | a_ this.evalu ateTopic, a_this ); | |||||
| 2834 | } | |||||
| 2835 | ||||||
| 2836 | th is.evaluat eTopics = function( a_Context, a_this ) | |||||
| 2837 | { | |||||
| 2838 | a_th is.aTopics = new Arr ay(); | |||||
| 2839 | for ( var iTop ic in a_th is.aSuspen dTopics ) | |||||
| 2840 | a_this .aTopics[a _this.aTop ics.length ] = iTopic ; | |||||
| 2841 | ||||||
| 2842 | a_th is.iCurTop ic = 0; | |||||
| 2843 | a_Co ntext.push ( a_this.e valuateTop ic, a_this ); | |||||
| 2844 | } | |||||
| 2845 | ||||||
| 2846 | th is.createT opicImages = functio n( a_Conte xt, a_this ) | |||||
| 2847 | { | |||||
| 2848 | a_th is.aTopicI mages = ne w Array(); | |||||
| 2849 | a_th is.aPossib leOrgs = n ew Array() ; | |||||
| 2850 | ||||||
| 2851 | a_th is.aNodeSt ack = new Array(); | |||||
| 2852 | a_th is.aNodeSt ack[a_this .aNodeStac k.length] = a_this.q ueryExpres sion; | |||||
| 2853 | ||||||
| 2854 | a_Co ntext.push ( a_this.a ddNodeToTo picImages, a_this ); | |||||
| 2855 | } | |||||
| 2856 | ||||||
| 2857 | th is.calcula teRankings = functio n( a_Conte xt, a_this ) | |||||
| 2858 | { | |||||
| 2859 | a_th is.aRanked Topics = n ew Array() ; | |||||
| 2860 | for ( var strT opicId in a_this.aTo picImages ) | |||||
| 2861 | { | |||||
| 2862 | var ra nkedTopic = new Obje ct(); | |||||
| 2863 | ranked Topic.fRan king = cal culateRank ing( a_thi s.aTopicIm ages[strTo picId], a_ this.query Expression ); | |||||
| 2864 | if ( r ankedTopic .fRanking <= 0 ) | |||||
| 2865 | continue ; | |||||
| 2866 | ranked Topic.nTop icId = par seInt( str TopicId ); | |||||
| 2867 | docume nt.writeln ( "<br>" + rankedTop ic.nTopicI d + "<br>" ); | |||||
| 2868 | a_this .aRankedTo pics[a_thi s.aRankedT opics.leng th] = rank edTopic; | |||||
| 2869 | } | |||||
| 2870 | } | |||||
| 2871 | ||||||
| 2872 | th is.compRan kedTopics = function ( a_itemA, a_itemB ) | |||||
| 2873 | { | |||||
| 2874 | if ( a_itemA.f Ranking > a_itemB.fR anking ) | |||||
| 2875 | return true; | |||||
| 2876 | else if ( a_it emA.fRanki ng == a_it emB.fRanki ng ) | |||||
| 2877 | { | |||||
| 2878 | var k = compare( a_itemA.s trTitle, a _itemB.str Title ); | |||||
| 2879 | if ( k < 0 ) | |||||
| 2880 | return t rue; | |||||
| 2881 | } | |||||
| 2882 | retu rn false; | |||||
| 2883 | } | |||||
| 2884 | ||||||
| 2885 | th is.swapRan kedTopics = function ( a_aTopic s, a_nIdx, a_itemNew ) | |||||
| 2886 | { | |||||
| 2887 | a_aT opics[a_nI dx] = a_it emNew; | |||||
| 2888 | } | |||||
| 2889 | ||||||
| 2890 | th is.quickSo rtRankedTo pics = fun ction( a_n Low, a_nHi gh ) | |||||
| 2891 | { | |||||
| 2892 | quic kSort( thi s.queryRes ult.aTopic s, | |||||
| 2893 | 0, th is.queryRe sult.aTopi cs.length - 1, | |||||
| 2894 | this. compRanked Topics, | |||||
| 2895 | this. swapRanked Topics ); | |||||
| 2896 | } | |||||
| 2897 | ||||||
| 2898 | th is.compPos sibleOrgs = function ( a_itemA, a_itemB ) | |||||
| 2899 | { | |||||
| 2900 | if ( utf8Compa re(a_itemA , a_itemB) <= 0 ) | |||||
| 2901 | return true; | |||||
| 2902 | retu rn false; | |||||
| 2903 | } | |||||
| 2904 | ||||||
| 2905 | th is.swapPos sibleOrgs = function ( a_aOrgs, a_nIdx, a _itemNew ) | |||||
| 2906 | { | |||||
| 2907 | a_aO rgs[a_nIdx ] = a_item New; | |||||
| 2908 | } | |||||
| 2909 | ||||||
| 2910 | th is.getTopi cInfo = fu nction( a_ Context, a _this ) | |||||
| 2911 | { // t he databas e will fil l the quer y result i n the same mapRanked Topics | |||||
| 2912 | a_th is.aDataba ses[a_this .iCurProj] .aQueryTop ics = a_th is.aRanked Topics[a_t his.iCurPr oj]; | |||||
| 2913 | a_Co ntext.push ( a_this.a Databases[ a_this.iCu rProj].que ryTopicInf os, a_this .aDatabase s[a_this.i CurProj] ) ; | |||||
| 2914 | } | |||||
| 2915 | ||||||
| 2916 | th is.evaluat eExpressio n = functi on( a_Cont ext, a_thi s ) | |||||
| 2917 | { | |||||
| 2918 | // In case of AIR, the AND search variable is set thr ough other route | |||||
| 2919 | if (!gbAIRSSL ) | |||||
| 2920 | { | |||||
| 2921 | //To set the gbEna bleAndSear ch variabl e which en ables the AND search | |||||
| 2922 | SetVaria blesFromNa meValuePai rString(gb ExtraInfoI nSearchQue ry,false); | |||||
| 2923 | } | |||||
| 2924 | ||||||
| 2925 | gC hangedQuer y=''; | |||||
| 2926 | a_th is.queryEx pression = parseQuer yExpressio n( a_this. strQuery ) ; | |||||
| 2927 | if ( a_this.qu eryExpress ion == nul l ) | |||||
| 2928 | { | |||||
| 2929 | a_Cont ext.strMsg = gsInval idExpressi on_1 ; | |||||
| 2930 | a_this .bSucc = f alse; | |||||
| 2931 | return ; | |||||
| 2932 | } | |||||
| 2933 | ||||||
| 2934 | a_th is.aRanked Topics = n ew Array() ; | |||||
| 2935 | a_th is.iCurPro j = -1; | |||||
| 2936 | a_Co ntext.push ( a_this.i ncCurProjF orEvaluate , a_this ) ; | |||||
| 2937 | } | |||||
| 2938 | ||||||
| 2939 | th is.makeRes ult = func tion( a_Co ntext, a_t his ) | |||||
| 2940 | { | |||||
| 2941 | a_th is.queryRe sult.aTopi cs = new A rray(); | |||||
| 2942 | if ( !a_this.b Succ ) | |||||
| 2943 | return ; | |||||
| 2944 | var nLen = 0; | |||||
| 2945 | for ( var i = 0; i < a_t his.aRanke dTopics.le ngth; i++ ) | |||||
| 2946 | { | |||||
| 2947 | for ( var j = 0; j < a_thi s.aRankedT opics[i].l ength; j++ ) | |||||
| 2948 | { | |||||
| 2949 | nLen = a _this.quer yResult.aT opics.leng th; | |||||
| 2950 | a_this.q ueryResult .aTopics[n Len] = a_t his.aRanke dTopics[i] [j]; | |||||
| 2951 | strTopic Url = a_th is.queryRe sult.aTopi cs[nLen].s trUrl; | |||||
| 2952 | if(!(_is AbsPath(st rTopicUrl) || _isRem oteUrl(str TopicUrl)) ) | |||||
| 2953 | { | |||||
| 2954 | if(gbAIRSS L) | |||||
| 2955 | { | |||||
| 2956 | a_ this.query Result.aTo pics[nLen] .strProjDi r = a_this .aProjPath es[i].strP rojDir; | |||||
| 2957 | } | |||||
| 2958 | a_th is.queryRe sult.aTopi cs[nLen].s trUrl = a_ this.aProj Pathes[i]. strProjDir | |||||
| 2959 | + a_th is.queryRe sult.aTopi cs[nLen].s trUrl; | |||||
| 2960 | } | |||||
| 2961 | a_this.q ueryResult .aTopics[n Len].fRank ing = a_th is.aRanked Topics[i][ j].fRankin g; | |||||
| 2962 | } | |||||
| 2963 | } | |||||
| 2964 | a_th is.quickSo rtRankedTo pics( 0, a _this.quer yResult.aT opics.leng th - 1 ); | |||||
| 2965 | for ( var i = 0; i < a_t his.queryR esult.aTop ics.length ; i++ ) | |||||
| 2966 | { | |||||
| 2967 | a_this .queryResu lt.aTopics [i].nIndex = i + 1; | |||||
| 2968 | } | |||||
| 2969 | } | |||||
| 2970 | ||||||
| 2971 | // interface | |||||
| 2972 | th is.init = function( a_Context, a_this ) | |||||
| 2973 | { | |||||
| 2974 | a_th is.bInited = false; | |||||
| 2975 | ||||||
| 2976 | a_th is.aDataba ses = new Array(); | |||||
| 2977 | for ( var i in a_this.aP rojPathes ) | |||||
| 2978 | { | |||||
| 2979 | var nL en = a_thi s.aDatabas es.length; | |||||
| 2980 | a_this .aDatabase s[nLen] = new HuginD atabase(); | |||||
| 2981 | a_this .aDatabase s[nLen].st rOdbPath = a_this.aP rojPathes[ i].strOdbP ath; | |||||
| 2982 | } | |||||
| 2983 | if ( a_this.aD atabases.l ength == 0 ) | |||||
| 2984 | return ; | |||||
| 2985 | ||||||
| 2986 | // f or the rob oengine se rver we do n't need d atabase in its | |||||
| 2987 | if( gbAIRSSL | | mrIsOnEn gine()==fa lse ) | |||||
| 2988 | { | |||||
| 2989 | a_this .iCurProj = 0; | |||||
| 2990 | a_Cont ext.push( a_this.aDa tabases[a_ this.iCurP roj].init, a_this.aD atabases[a _this.iCur Proj], | |||||
| 2991 | a_ this.incCu rProjForIn it, a_this , | |||||
| 2992 | a_ this.check InitSucc, a_this ); | |||||
| 2993 | }; | |||||
| 2994 | } | |||||
| 2995 | ||||||
| 2996 | th is.query = function( a_Context , a_this ) | |||||
| 2997 | { | |||||
| 2998 | if ( !a_this.b Inited ) | |||||
| 2999 | { | |||||
| 3000 | a_this .bSucc = f alse; | |||||
| 3001 | return ; | |||||
| 3002 | } | |||||
| 3003 | ||||||
| 3004 | a_th is.prepare Query(); | |||||
| 3005 | g_Cu rState = E CS_SEARCHI NG; | |||||
| 3006 | upda teResultVi ew(); | |||||
| 3007 | ||||||
| 3008 | a_th is.queryRe sult = new HuginQuer yResult(); | |||||
| 3009 | a_Co ntext.push ( a_this.e valuateExp ression, a _this, | |||||
| 3010 | a_ this.makeR esult, a_t his ); | |||||
| 3011 | } | |||||
| 3012 | } | |||||
| 3013 | ||||||
| 3014 | //Display/ ////////// ////////// ////////// ////////// ////////// ////////// //////// | |||||
| 3015 | ||||||
| 3016 | function g etEventX( e ) | |||||
| 3017 | { | |||||
| 3018 | if ( gbIE5 ) | |||||
| 3019 | retu rn event.x ; | |||||
| 3020 | if ( gbNav7 ||gbAIR) | |||||
| 3021 | retu rn e.pageX ; | |||||
| 3022 | re turn 0; | |||||
| 3023 | } | |||||
| 3024 | ||||||
| 3025 | function g etEventY( e ) | |||||
| 3026 | { | |||||
| 3027 | if ( gbIE5 ) | |||||
| 3028 | retu rn event.y ; | |||||
| 3029 | if ( gbNav7 ||gbAIR) | |||||
| 3030 | retu rn e.pageY ; | |||||
| 3031 | re turn 0; | |||||
| 3032 | } | |||||
| 3033 | ||||||
| 3034 | function s etInnerHTM L( a_Node, a_strText ) | |||||
| 3035 | { | |||||
| 3036 | a_ Node.inner HTML = a_s trText; | |||||
| 3037 | } | |||||
| 3038 | ||||||
| 3039 | function c ompByTitle Descend( a _itemA, a_ itemB ) | |||||
| 3040 | { | |||||
| 3041 | va r k = comp are( getIn nerText( a _itemA.cel ls[0] ), g etInnerTex t( a_itemB .cells[0] ) ); | |||||
| 3042 | if ( k > 0 ) | |||||
| 3043 | retu rn true; | |||||
| 3044 | el se if ( k == 0 ) | |||||
| 3045 | retu rn compByR ank( a_ite mA, a_item B ); | |||||
| 3046 | el se | |||||
| 3047 | retu rn false; | |||||
| 3048 | } | |||||
| 3049 | ||||||
| 3050 | function c ompByTitle Ascend( a_ itemA, a_i temB ) | |||||
| 3051 | { | |||||
| 3052 | va r k = comp are( getIn nerText( a _itemA.cel ls[0] ), g etInnerTex t( a_itemB .cells[0] ) ); | |||||
| 3053 | if ( k < 0 ) | |||||
| 3054 | retu rn true; | |||||
| 3055 | el se if ( k == 0 ) | |||||
| 3056 | retu rn compByR ank( a_ite mA, a_item B ); | |||||
| 3057 | el se | |||||
| 3058 | retu rn false; | |||||
| 3059 | ||||||
| 3060 | re turn getIn nerText( a _itemA.cel ls[0] ) <= getInnerT ext( a_ite mB.cells[0 ] ); | |||||
| 3061 | } | |||||
| 3062 | ||||||
| 3063 | function c ompByRank( a_itemA, a_itemB ) | |||||
| 3064 | { | |||||
| 3065 | re turn parse Int( getIn nerText( a _itemA.cel ls[2] ) ) <= parseIn t( getInne rText( a_i temB.cells [2] ) ); | |||||
| 3066 | } | |||||
| 3067 | ||||||
| 3068 | function s wapTableNo de( a_aIte ms, a_nIdx , a_itemB ) | |||||
| 3069 | { | |||||
| 3070 | a_ aItems[a_n Idx].swapN ode( a_ite mB ); | |||||
| 3071 | } | |||||
| 3072 | ||||||
| 3073 | function g etPartitio n( a_aRows , i, j, a_ funcComp, a_funcSwap ) | |||||
| 3074 | { | |||||
| 3075 | va r pivot = a_aRows[i] ; | |||||
| 3076 | wh ile( i < j ) | |||||
| 3077 | { | |||||
| 3078 | whil e( i < j & & a_funcCo mp( pivot, a_aRows[j ] ) ) | |||||
| 3079 | j--; | |||||
| 3080 | if( i < j ) | |||||
| 3081 | a_func Swap( a_aR ows, i++, a_aRows[j] ); | |||||
| 3082 | whil e( i < j & & a_funcCo mp( a_aRow s[i], pivo t ) ) | |||||
| 3083 | i++; | |||||
| 3084 | if( i < j ) | |||||
| 3085 | a_func Swap( a_aR ows, j--, a_aRows[i] ); | |||||
| 3086 | } | |||||
| 3087 | a_ funcSwap( a_aRows, i , pivot ); | |||||
| 3088 | re turn i; | |||||
| 3089 | } | |||||
| 3090 | ||||||
| 3091 | function q uickSort( a_aRows, a _nLow, a_n High, a_fu ncComp, a_ funcSwap ) | |||||
| 3092 | { | |||||
| 3093 | if ( a_nLow < a_nHigh ) | |||||
| 3094 | { | |||||
| 3095 | var nPivotpos = getParti tion( a_aR ows, a_nLo w, a_nHigh , a_funcCo mp, a_func Swap ); | |||||
| 3096 | quic kSort( a_a Rows, a_nL ow, nPivot pos - 1, a _funcComp, a_funcSwa p ); | |||||
| 3097 | quic kSort( a_a Rows, nPiv otpos + 1, a_nHigh, a_funcComp , a_funcSw ap ); | |||||
| 3098 | } | |||||
| 3099 | } | |||||
| 3100 | ||||||
| 3101 | function u pdateHeade r() | |||||
| 3102 | { | |||||
| 3103 | va r tdTitle = getEleme nt( "OdinF tsTitle" ) ; | |||||
| 3104 | va r tdRank = getElemen t( "OdinFt sRank" ); | |||||
| 3105 | if ( tdTitle == null | | tdRank = = null ) | |||||
| 3106 | retu rn; | |||||
| 3107 | sw itch( g_nS ortType ) | |||||
| 3108 | { | |||||
| 3109 | case 0: setInn erHTML( td Title, gsT itle ); | |||||
| 3110 | setInner HTML( tdRa nk, gsRank + ' ' + g sAscendFla g ); | |||||
| 3111 | break; | |||||
| 3112 | case 1: setInn erHTML( td Title, gsT itle + ' ' + gsAscen dFlag ); | |||||
| 3113 | setInner HTML( tdRa nk, gsRank ); | |||||
| 3114 | break; | |||||
| 3115 | case 2: setInn erHTML( td Title, gsT itle + ' ' + gsDesce ndFlag ); | |||||
| 3116 | setInner HTML( tdRa nk, gsRank ); | |||||
| 3117 | break; | |||||
| 3118 | } | |||||
| 3119 | } | |||||
| 3120 | ||||||
| 3121 | function q uickSortRe sult() | |||||
| 3122 | { | |||||
| 3123 | va r tbl = ge tElement( "OdinFtsRs lt" ); | |||||
| 3124 | if ( tbl == null ) | |||||
| 3125 | retu rn; | |||||
| 3126 | ||||||
| 3127 | va r tdRank = getElemen t( "OdinFt sRank" ); | |||||
| 3128 | if ( tdRank == null ) | |||||
| 3129 | return ; | |||||
| 3130 | ||||||
| 3131 | va r comp = g _nSortType == 0 ? co mpByRank | |||||
| 3132 | : g_nS ortType == 1 ? compB yTitleAsce nd | |||||
| 3133 | : comp ByTitleDes cend; | |||||
| 3134 | qu ickSort( t bl.rows, 0 , tbl.rows .length - 1, comp, s wapTableNo de ); | |||||
| 3135 | up dateHeader (); | |||||
| 3136 | } | |||||
| 3137 | ||||||
| 3138 | function g etStylePro pertyValue (elementTa g,stylePro p) | |||||
| 3139 | { | |||||
| 3140 | var y= null; | |||||
| 3141 | if (elementT ag.current Style) | |||||
| 3142 | y = elementTag .currentSt yle[styleP rop]; | |||||
| 3143 | el se if (win dow.getCom putedStyle ) | |||||
| 3144 | y = document.d efaultView .getComput edStyle(el ementTag,n ull).getPr opertyValu e(stylePro p); | |||||
| 3145 | re turn y; | |||||
| 3146 | } | |||||
| 3147 | ||||||
| 3148 | function u iMouseDown ( e ) | |||||
| 3149 | { | |||||
| 3150 | va r myEvent = gbNav7 | | gbAIR ? e : event; | |||||
| 3151 | va r clickedE lement = g bNav7 || g bAIR ? myE vent.targe t : myEven t.srcEleme nt; | |||||
| 3152 | if ( clicked Element.id == 'DragS ep' ) | |||||
| 3153 | { | |||||
| 3154 | var tdRank = g etElement( "OdinFtsR ank" ); | |||||
| 3155 | if ( tdRank == null ) | |||||
| 3156 | return ; | |||||
| 3157 | ||||||
| 3158 | var elementWid th = tdRan k.style.wi dth; | |||||
| 3159 | if(e lementWidt h==null || elementWi dth.length ==0) | |||||
| 3160 | { | |||||
| 3161 | elem entWidth = getStyleP ropertyVal ue(tdRank, "width"); | |||||
| 3162 | } | |||||
| 3163 | if(e lementWidt h != null && element Width.leng th>0) | |||||
| 3164 | { | |||||
| 3165 | //in case of every t hing fail try the of fsetwidth as well | |||||
| 3166 | if(tdRank. offsetWidt h) | |||||
| 3167 | elemen tWidth = ' ' +tdRank. offsetWidt h+'px'; | |||||
| 3168 | } | |||||
| 3169 | ||||||
| 3170 | if(e lementWidt h != null && element Width.leng th>0) | |||||
| 3171 | { | |||||
| 3172 | var matchR esult = el ementWidth .match( "^ (.+)px$" ) ; | |||||
| 3173 | if(matchRe sult!=null ) | |||||
| 3174 | { | |||||
| 3175 | g_nIni tWidth = p arseInt( e lementWidt h.match( " ^(.+)px$" )[1] ); | |||||
| 3176 | if ( g _nInitWidt h.toString () != "NaN " ) | |||||
| 3177 | { | |||||
| 3178 | g_ nX0 = getE ventX( e ) ; | |||||
| 3179 | g_ bDraging = true; | |||||
| 3180 | } | |||||
| 3181 | } | |||||
| 3182 | } | |||||
| 3183 | } | |||||
| 3184 | el se if ( cl ickedEleme nt.id == ' OdinFtsTit le' ) | |||||
| 3185 | { | |||||
| 3186 | g_nS ortType = g_nSortTyp e != 1 ? 1 : 2; | |||||
| 3187 | quic kSortResul t(); | |||||
| 3188 | } | |||||
| 3189 | el se if ( cl ickedEleme nt.id == ' OdinFtsRan k' ) | |||||
| 3190 | { | |||||
| 3191 | g_nS ortType = 0; | |||||
| 3192 | quic kSortResul t(); | |||||
| 3193 | } | |||||
| 3194 | } | |||||
| 3195 | ||||||
| 3196 | function u iMouseMove ( e ) | |||||
| 3197 | { | |||||
| 3198 | va r tdRank = getElemen t( "OdinFt sRank" ); | |||||
| 3199 | if ( tdRank == null ) | |||||
| 3200 | retu rn; | |||||
| 3201 | if ( g_bDrag ing == tru e ) | |||||
| 3202 | { | |||||
| 3203 | var d = getEve ntX( e ) - g_nX0; | |||||
| 3204 | if ( g_nInitWi dth - d > g_nRankWid thMin ) | |||||
| 3205 | tdRank .style.wid th = g_nIn itWidth - d; | |||||
| 3206 | } | |||||
| 3207 | } | |||||
| 3208 | ||||||
| 3209 | function u iMouseUp( e ) | |||||
| 3210 | { | |||||
| 3211 | g_ bDraging = false; | |||||
| 3212 | } | |||||
| 3213 | ||||||
| 3214 | function u iClick( e ) | |||||
| 3215 | { | |||||
| 3216 | va r myEvent = gbNav7 ? e : event ; | |||||
| 3217 | va r clickedE lement = g bNav7 ? my Event.targ et : myEve nt.srcElem ent; | |||||
| 3218 | if ( clicked Element.cl assName == "fr_tc" & & clickedE lement.tag Name == "A " ) | |||||
| 3219 | { | |||||
| 3220 | var lnkAct = g etElement( "ActiveLi nk" ); | |||||
| 3221 | if ( lnkAct != null ) | |||||
| 3222 | { | |||||
| 3223 | lnkAct .id = ""; | |||||
| 3224 | lnkAct .className = "fr_tc" ; | |||||
| 3225 | } | |||||
| 3226 | ||||||
| 3227 | clic kedElement .id = "Act iveLink"; | |||||
| 3228 | clic kedElement .className = "fr_act "; | |||||
| 3229 | } | |||||
| 3230 | el se if (gbA IR && clic kedElement .className == "sl_pa ge" && cli ckedElemen t.tagName == "LI" ) | |||||
| 3231 | { | |||||
| 3232 | var id = clickedEl ement.id; | |||||
| 3233 | if(id!=n ull && id. length>0) | |||||
| 3234 | { | |||||
| 3235 | var pageNu m =parseIn t(clickedE lement.id) ; | |||||
| 3236 | onClickPag e(pageNum) ; | |||||
| 3237 | } | |||||
| 3238 | } | |||||
| 3239 | } | |||||
| 3240 | ||||||
| 3241 | if ( gbNav 7 || gbAIR ||gbSafar i) | |||||
| 3242 | { | |||||
| 3243 | No de.prototy pe.swapNod e = functi on( a_Node ) | |||||
| 3244 | { | |||||
| 3245 | var nextSiblin g = this.n extSibling ; | |||||
| 3246 | var parentNode = this.pa rentNode; | |||||
| 3247 | a_No de.parentN ode.insert Before( th is, a_Node ); | |||||
| 3248 | pare ntNode.ins ertBefore( a_Node, n extSibling ); | |||||
| 3249 | } | |||||
| 3250 | ||||||
| 3251 | do cument.cap tureEvents ( Event.MO USEMOVE | Event.MOUS EDOWN | Ev ent.MOUSEU P | Event. CLICK ); | |||||
| 3252 | } | |||||
| 3253 | ||||||
| 3254 | ////////// ////////// ////////// ////////// ////////// ////////// ////////// ///// | |||||
| 3255 | function o nGetProjIn fo(oMsg) | |||||
| 3256 | { | |||||
| 3257 | if(oMs g && oMsg. oParam) | |||||
| 3258 | { | |||||
| 3259 | gb Ready = tr ue; | |||||
| 3260 | var oProj = oM sg.oParam; | |||||
| 3261 | var aProj = oP roj.aProj; | |||||
| 3262 | gbXM L = oProj. bXML; | |||||
| 3263 | if( aProj && a Proj.lengt h > 0 ) | |||||
| 3264 | { | |||||
| 3265 | contex t = new Hu ginContext (); | |||||
| 3266 | goOdin Hunter = n ew HuginHu nter(); | |||||
| 3267 | goOdin Hunter.aPr ojPathes = new Array (); | |||||
| 3268 | var proj Indx = 0; | |||||
| 3269 | for (v ar i=0; i< aProj.leng th; i++ ) | |||||
| 3270 | { | |||||
| 3271 | if(t ypeof(aPro j[i].sFts) != 'undef ined' && a Proj[i].sF ts != null ){ | |||||
| 3272 | goOd inHunter.a ProjPathes [projIndx] = new Obj ect(); | |||||
| 3273 | goOd inHunter.a ProjPathes [projIndx] .strProjDi r = aProj[ i].sPPath; | |||||
| 3274 | goOd inHunter.a ProjPathes [projIndx] .strOdbPat h = aProj[ i].sPPath + aProj[i] .sDPath + aProj[i].s Fts; | |||||
| 3275 | projIndx++ ; | |||||
| 3276 | } | |||||
| 3277 | } | |||||
| 3278 | ||||||
| 3279 | contex t.reset(); | |||||
| 3280 | contex t.push( go OdinHunter .init, goO dinHunter, | |||||
| 3281 | regist Listener, this, | |||||
| 3282 | Search PendingReq uest, this ); | |||||
| 3283 | contex t.resume() ; | |||||
| 3284 | } | |||||
| 3285 | } | |||||
| 3286 | } | |||||
| 3287 | ||||||
| 3288 | function l oadFts() | |||||
| 3289 | { | |||||
| 3290 | if ( !gbReady ) | |||||
| 3291 | { | |||||
| 3292 | var oResMsg = new whMess age( WH_MS G_GETPROJI NFO, null, null ); | |||||
| 3293 | requ est(oResMs g, onGetPr ojInfo); | |||||
| 3294 | } | |||||
| 3295 | } | |||||
| 3296 | ||||||
| 3297 | var gbAIRM ergeArray; | |||||
| 3298 | function o nGetMergeP rojInfo(me rgeProjInf o, strProj Dir) | |||||
| 3299 | { | |||||
| 3300 | goOdin Hunter = n ew HuginHu nter(); | |||||
| 3301 | go OdinHunter .aProjPath es = new A rray(); | |||||
| 3302 | go OdinHunter .aProjPath es[0] = ne w Object() ; | |||||
| 3303 | go OdinHunter .aProjPath es[0].strP rojDir = s trProjDir ; | |||||
| 3304 | go OdinHunter .aProjPath es[0].strO dbPath = g oOdinHunte r.aProjPat hes[0].str ProjDir + "whxdata/w hfts.xml"; | |||||
| 3305 | ||||||
| 3306 | if (mergeProj Info!=null ) | |||||
| 3307 | { | |||||
| 3308 | var index=0; | |||||
| 3309 | whil e(index<me rgeProjInf o.length) | |||||
| 3310 | { | |||||
| 3311 | goOdin Hunter.aPr ojPathes[i ndex+1] = new Object (); | |||||
| 3312 | goOdin Hunter.aPr ojPathes[i ndex+1].st rProjDir = mergeProj Info[index ]; | |||||
| 3313 | goOdin Hunter.aPr ojPathes[i ndex+1].st rOdbPath = mergeProj Info[index ] + "whxda ta/whfts.x ml"; | |||||
| 3314 | index+ +; | |||||
| 3315 | } | |||||
| 3316 | ||||||
| 3317 | } | |||||
| 3318 | ||||||
| 3319 | co ntext = ne w HuginCon text(); | |||||
| 3320 | co ntext.rese t(); | |||||
| 3321 | ||||||
| 3322 | go OdinHunter .strQuery = GetSearc hTextFromU RL(); | |||||
| 3323 | co ntext.push ( goOdinHu nter.init, goOdinHun ter, | |||||
| 3324 | Query, this ); | |||||
| 3325 | ||||||
| 3326 | co ntext.resu me(); | |||||
| 3327 | } | |||||
| 3328 | ||||||
| 3329 | function l oadFts_con text(strPr ojDir , st rFtsFile) | |||||
| 3330 | { | |||||
| 3331 | tr y | |||||
| 3332 | { | |||||
| 3333 | if(g bAIR) | |||||
| 3334 | onGetM ergeProjIn fo(gbAIRMe rgeArray, strProjDir ); | |||||
| 3335 | else if(gbAIRS SL) | |||||
| 3336 | { | |||||
| 3337 | if(isChrom eLocal()){ | |||||
| 3338 | this.p arent.post Message("g etMergePro jInfo" + g MsgSeparat or + " ", "*"); | |||||
| 3339 | } | |||||
| 3340 | else{ | |||||
| 3341 | if (this.pare nt.gbAIRme rgeProject Array != n ull) | |||||
| 3342 | onGe tMergeProj Info(this. parent.gbA IRmergePro jectArray, strProjDi r); | |||||
| 3343 | } | |||||
| 3344 | } | |||||
| 3345 | }c atch(e){} | |||||
| 3346 | } | |||||
| 3347 | ||||||
| 3348 | function i sValidType (obj) | |||||
| 3349 | { | |||||
| 3350 | re turn ( (ty peof(obj)! ='undefine d')&&(obj! =null) ); | |||||
| 3351 | } | |||||
| 3352 | ||||||
| 3353 | function Q uery() | |||||
| 3354 | { | |||||
| 3355 | if(gbA IRSSL) | |||||
| 3356 | { | |||||
| 3357 | if (goOdinHun ter.bInite d == false ) | |||||
| 3358 | { | |||||
| 3359 | setTimeo ut(functio n() { Quer y(); }, 10 ); | |||||
| 3360 | return; | |||||
| 3361 | } | |||||
| 3362 | } | |||||
| 3363 | gb AIRSearchS tring = g oOdinHunte r.strQuery ; | |||||
| 3364 | g_ CurPage = 1; | |||||
| 3365 | if (isValidT ype(contex t) && isVa lidType(co ntext.aTas ks)) | |||||
| 3366 | { | |||||
| 3367 | whil e(context. aTasks.len gth>0) | |||||
| 3368 | { | |||||
| 3369 | contex t.resume() ; | |||||
| 3370 | } | |||||
| 3371 | } | |||||
| 3372 | co ntext = ne w HuginCon text(); | |||||
| 3373 | co ntext.rese t(); | |||||
| 3374 | co ntext.push ( goOdinHu nter.query , goOdinHu nter, | |||||
| 3375 | proces sHunterRes ult, null ); | |||||
| 3376 | co ntext.resu me(); | |||||
| 3377 | } | |||||
| 3378 | ||||||
| 3379 | function c hangeResul tView( a_s trHTML ) | |||||
| 3380 | { | |||||
| 3381 | va r resultDi v = getEle ment( gsRe sultDivID ); | |||||
| 3382 | if (resultDiv ) | |||||
| 3383 | { | |||||
| 3384 | var resultDiv Parent = g etParentNo de( result Div ); | |||||
| 3385 | if ( !resultDiv Parent ) | |||||
| 3386 | return ; | |||||
| 3387 | resu ltDiv.inne rHTML = a_ strHTML; | |||||
| 3388 | } | |||||
| 3389 | el se documen t.body.inn erHTML = a _strHTML; | |||||
| 3390 | } | |||||
| 3391 | ||||||
| 3392 | function d isplayMsg( a_strMsg ) | |||||
| 3393 | { | |||||
| 3394 | if (!gbAIRSSL ) | |||||
| 3395 | { | |||||
| 3396 | //se t num of r esults | |||||
| 3397 | var oMsg = new whMessage (WH_MSG_SE TNUMRSLT, 0, null); | |||||
| 3398 | noti fy(oMsg); | |||||
| 3399 | } | |||||
| 3400 | ch angeResult View( "<P CLASS='msg '>" + a_st rMsg + "</ P>" ); | |||||
| 3401 | } | |||||
| 3402 | ||||||
| 3403 | function w riteTableH ead() | |||||
| 3404 | { | |||||
| 3405 | if (!gsHideRa nkColumn) | |||||
| 3406 | { | |||||
| 3407 | if(g bAIRSSL) | |||||
| 3408 | { | |||||
| 3409 | return "<TABLE CE LLSPACING= 0 CEllPADD ING=0 STYL E='table-l ayout:fixe d; width:1 00%'>" + | |||||
| 3410 | "< THEAD>" + | |||||
| 3411 | "<TR STYLE='fo nt-weight: bold'>" + | |||||
| 3412 | "<TD I D='OdinFts Title' CL ASS='fr_tt ' STYLE='c ursor:poin ter'>"+gsT itle+"</TD >" + | |||||
| 3413 | "<TD I D='DragSep ' CLAS S='fr_ts' STYLE='cur sor:w-resi ze; width: 4px'>  ;</TD>" + | |||||
| 3414 | "<TD I D='OdinFts Rank' CL ASS='fr_tt ' STYLE='c ursor:poin ter; width :60px'>"+g sRank+"^</ TD>" + | |||||
| 3415 | "</T R>" + | |||||
| 3416 | "< /THEAD>" + | |||||
| 3417 | "< TBODY ID=' OdinFtsRsl t'>"; | |||||
| 3418 | } | |||||
| 3419 | else | |||||
| 3420 | { | |||||
| 3421 | return "<TABLE CE LLSPACING= 0 CEllPADD ING=0 STYL E='table-l ayout:fixe d; width:1 10%'>" + | |||||
| 3422 | "< THEAD>" + | |||||
| 3423 | "<TR STYLE='fo nt-weight: bold'>" + | |||||
| 3424 | "<TD I D='OdinFts Title' CL ASS='fr_tt ' STYLE='c ursor:poin ter'>"+gsT itle+"</TD >" + | |||||
| 3425 | "<TD I D='DragSep ' CLAS S='fr_ts' STYLE='cur sor:w-resi ze; width: 4px'>  ;</TD>" + | |||||
| 3426 | "<TD I D='OdinFts Rank' CL ASS='fr_tt ' STYLE='c ursor:poin ter'>"+gsR ank+"^</TD >" + | |||||
| 3427 | "</T R>" + | |||||
| 3428 | "< /THEAD>" + | |||||
| 3429 | "< TBODY ID=' OdinFtsRsl t'>"; | |||||
| 3430 | } | |||||
| 3431 | } | |||||
| 3432 | el se | |||||
| 3433 | retu rn "<TABLE CELLSPACI NG=0 CEllP ADDING=0 S TYLE='tabl e-layout:f ixed; widt h:110%'>" + | |||||
| 3434 | "<TBODY ID='OdinFt sRslt'>"; | |||||
| 3435 | } | |||||
| 3436 | ||||||
| 3437 | function w riteResult ( a_strUrl , a_strHig hlight, a_ strTitle, a_strFont, a_nIndex, a_sSummar y ) | |||||
| 3438 | { | |||||
| 3439 | va r strOutpu t = ""; | |||||
| 3440 | if (a_sSummar y.length > 0) | |||||
| 3441 | { | |||||
| 3442 | strO utput = "< TR>" + | |||||
| 3443 | "<TD CLA SS='fr_tc' ><A CLASS= 'fr_tc'" + | |||||
| 3444 | " HREF=' " + a_strU rl + "'" + ">" + _te xtToHtml_n onbsp(a_st rTitle) + "</A><div> " + _textT oHtml_nonb sp(a_sSumm ary) + "</ div><br></ TD>"; | |||||
| 3445 | if(! gsHideRank Column) | |||||
| 3446 | { | |||||
| 3447 | strOutpu t += "<TD CLASS='fr_ tc'> </TD>" + | |||||
| 3448 | "<TD CLA SS='fr_tc' STYLE='te xt-align:c enter'>" + a_nIndex + "</TD>"; | |||||
| 3449 | } | |||||
| 3450 | strO utput += " </TR>"; | |||||
| 3451 | } | |||||
| 3452 | el se | |||||
| 3453 | { | |||||
| 3454 | strO utput = "< TR>" + | |||||
| 3455 | "<TD CLA SS='fr_tc' ><A CLASS= 'fr_tc' ST YLE='font- weight:nor mal;'" + | |||||
| 3456 | " HREF=' " + a_strU rl + "'" + ">" + _te xtToHtml_n onbsp(a_st rTitle) + "</A></TD> "; | |||||
| 3457 | if(! gsHideRank Column) | |||||
| 3458 | { | |||||
| 3459 | strOutpu t += "<TD CLASS='fr_ tc'> </TD>" + | |||||
| 3460 | "<TD CLA SS='fr_tc' STYLE='te xt-align:c enter'>" + a_nIndex + "</TD>"; | |||||
| 3461 | } | |||||
| 3462 | strO utput += " </TR>"; | |||||
| 3463 | } | |||||
| 3464 | ||||||
| 3465 | re turn strOu tput; | |||||
| 3466 | } | |||||
| 3467 | ||||||
| 3468 | function w riteTableT ail() | |||||
| 3469 | { | |||||
| 3470 | re turn "</T BODY>" + | |||||
| 3471 | "</TAB LE>"; | |||||
| 3472 | } | |||||
| 3473 | ||||||
| 3474 | function H andleAIRSe archFuncti on() | |||||
| 3475 | { | |||||
| 3476 | if (gAIRSearc hObject != undefined && gAIRSe archObject .displayFu nction != undefined) | |||||
| 3477 | { | |||||
| 3478 | gAIR SearchObje ct.display Function() ; | |||||
| 3479 | retu rn; | |||||
| 3480 | } | |||||
| 3481 | } | |||||
| 3482 | ||||||
| 3483 | function d isplayTopi cs( a_Quer yResult) | |||||
| 3484 | { | |||||
| 3485 | Ha ndleAIRSea rchFunctio n(); | |||||
| 3486 | va r sHTML = ""; | |||||
| 3487 | va r sLine = ""; | |||||
| 3488 | va r szSearch Strings= g bAIRSearch String; | |||||
| 3489 | va r sHighlig ht = "CLRF =" + gsHLC olorFront + | |||||
| 3490 | ",CLRB=" + gsHLColo rBackgroun d + ",HL=" ; | |||||
| 3491 | ||||||
| 3492 | va r nMaxResu lt = 10 ; | |||||
| 3493 | if (g_nMaxRes ult > 0) | |||||
| 3494 | nMaxResu lt = g_nMa xResult; | |||||
| 3495 | if (gbAIRSSL) | |||||
| 3496 | nMax Result = 2 5; | |||||
| 3497 | ||||||
| 3498 | va r i = 0; | |||||
| 3499 | if (g_CurPag e < 1) | |||||
| 3500 | g_CurPag e = 1 ; | |||||
| 3501 | ||||||
| 3502 | if ( a_Query Result != null ) | |||||
| 3503 | { | |||||
| 3504 | if(! gbAIRSSL) | |||||
| 3505 | { | |||||
| 3506 | //set num of res ults | |||||
| 3507 | var oM sg = new w hMessage(W H_MSG_SETN UMRSLT, a_ QueryResul t.aTopics. length, nu ll); | |||||
| 3508 | notify (oMsg); | |||||
| 3509 | } | |||||
| 3510 | ||||||
| 3511 | if (gbShowTo talNumberO fSearchRes ults && a_ QueryResul t.aTopics. length > 0 ) | |||||
| 3512 | { | |||||
| 3513 | var strT emp = gsTo talNumberO fSearchRes ults.repla ce(/%1/i, a_QueryRes ult.aTopic s.length); | |||||
| 3514 | sHTML = "<p class= 'msg'>" + strTemp + "</p>"; | |||||
| 3515 | sHTML += "<hr width =150% />"; | |||||
| 3516 | } | |||||
| 3517 | ||||||
| 3518 | ||||||
| 3519 | sHTM L += write TableHead( ); | |||||
| 3520 | if ( gbHighLig ht ) | |||||
| 3521 | { | |||||
| 3522 | var st rAddForHig hlight; | |||||
| 3523 | strAdd ForHighlig ht = "?" ; | |||||
| 3524 | if(gbA IRSSL) | |||||
| 3525 | { | |||||
| 3526 | strAddFo rHighlight += "searc hhighlight TextString RoboHelp=\ ""; | |||||
| 3527 | //in cas e of AIR, we need to add synon yms as wel l | |||||
| 3528 | if(gbAIR SynonymStr ing!=null && gbAIRSy nonymStrin g.length>0 ) | |||||
| 3529 | szSe archString s+= gbAIRS ynonymStri ng; | |||||
| 3530 | } | |||||
| 3531 | sHighl ight = str AddForHigh light + es cape( szSe archString s ) + "\"" ; | |||||
| 3532 | } | |||||
| 3533 | else | |||||
| 3534 | sHighl ight = ""; | |||||
| 3535 | ||||||
| 3536 | for( i = (g_Cu rPage-1)*n MaxResult; (i < a_Qu eryResult. aTopics.le ngth)&&(i< (g_CurPage *nMaxResul t)); i++ ) | |||||
| 3537 | { | |||||
| 3538 | var sz TopicURL = a_QueryRe sult.aTopi cs[i].strU rl; | |||||
| 3539 | var bA ddHighLigh t=false; | |||||
| 3540 | if(gbA IRSSL) | |||||
| 3541 | { | |||||
| 3542 | if(!_isR emoteUrl(s zTopicURL) ) | |||||
| 3543 | { | |||||
| 3544 | bAddHighLi ght = true ; | |||||
| 3545 | } | |||||
| 3546 | else if( isValidTyp e(a_QueryR esult.aTop ics[i].str ProjDir)) | |||||
| 3547 | { | |||||
| 3548 | //check if the lengt h is great er than | |||||
| 3549 | if(a_Query Result.aTo pics[i].st rProjDir.l ength>0) | |||||
| 3550 | { | |||||
| 3551 | bA ddHighLigh t = true; | |||||
| 3552 | } | |||||
| 3553 | } | |||||
| 3554 | } | |||||
| 3555 | ||||||
| 3556 | if(bAd dHighLight ) | |||||
| 3557 | { | |||||
| 3558 | //if it is AIR, we need to a dd the hig hlight opt ion now | |||||
| 3559 | szTopicU RL += sHig hlight; | |||||
| 3560 | } | |||||
| 3561 | sLine += writeRe sult( szTo picURL, | |||||
| 3562 | sHig hlight, | |||||
| 3563 | a_Qu eryResult. aTopics[i] .strTitle, | |||||
| 3564 | getF ontStyle(g oFont), | |||||
| 3565 | a_Qu eryResult. aTopics[i] .nIndex, | |||||
| 3566 | a_Qu eryResult. aTopics[i] .strSummar y ); | |||||
| 3567 | if( i & 0xF == 0 ) | |||||
| 3568 | { | |||||
| 3569 | sHTML += sLine; | |||||
| 3570 | sLine = ""; | |||||
| 3571 | } | |||||
| 3572 | } | |||||
| 3573 | if( sLine.leng th > 0 ) | |||||
| 3574 | sHTML += sLine; | |||||
| 3575 | ||||||
| 3576 | sHTM L += write TableTail( ); | |||||
| 3577 | ||||||
| 3578 | var nNumPages = Math.cei l(a_QueryR esult.aTop ics.length / nMaxRes ult ); | |||||
| 3579 | var sPageHTML = "" ; | |||||
| 3580 | var j ; | |||||
| 3581 | if ( nNumPages > 1) | |||||
| 3582 | { | |||||
| 3583 | sHTML += "<div>< ul style=\ "list-styl e:none; ma rgin:0; pa dding:0\" >" ; | |||||
| 3584 | if (g_ CurPage > 1) | |||||
| 3585 | sPageHTM L += "<li class='sl_ page' id=' "+(g_CurPa ge-1).toSt ring()+"' onMouseOve r=\"this.c lassName=' sl_pageC'\ " onMouseO ut=\"this. className= 'sl_page'\ " onclick= \"onClickP age(" + (g _CurPage-1 ).toString () + ")\"> <<</ li>" ; | |||||
| 3586 | var sC lass = "sl _page" ; | |||||
| 3587 | for (j =g_CurPage ;j<=nNumPa ges && j<= (g_CurPage +g_nMaxPag es) ;j++) | |||||
| 3588 | { | |||||
| 3589 | if (j == g_CurPage ) | |||||
| 3590 | sClass = " sl_pageC" ; | |||||
| 3591 | else | |||||
| 3592 | sClass = " sl_page" ; | |||||
| 3593 | sPageHTM L += "<li class='" + sClass + " ' id='"+j. toString() +"' onMous eOver=\"th is.classNa me='sl_pag eC'\" onMo useOut=\"t his.classN ame='" + s Class + "' \" onclick =\"onClick Page(" + j + ")\">" + j.toStri ng() + "</ li>" ; | |||||
| 3594 | } | |||||
| 3595 | ||||||
| 3596 | if(g_C urPage != nNumPages) | |||||
| 3597 | sPageHTM L += "<li class='sl_ page' id=' "+(g_CurPa ge+1).toSt ring()+"' onMouseOve r=\"this.c lassName=' sl_pageC'\ " onMouseO ut=\"this. className= 'sl_page'\ " onclick= \"onClickP age(" + (g _CurPage+1 ).toString () + ")\"> >></ li>" ; | |||||
| 3598 | sHTML += sPageHT ML ; | |||||
| 3599 | sHTML += "</ul>< /div>" ; | |||||
| 3600 | } | |||||
| 3601 | } | |||||
| 3602 | ||||||
| 3603 | if ( a_QueryR esult.aTop ics.length == 0 ) | |||||
| 3604 | sHTM L = "<P CL ASS='msg'> " + gsNoTo pics + "</ P>" | |||||
| 3605 | el se | |||||
| 3606 | sHTM L= "<dl>" + sHTML + "</dl>"; | |||||
| 3607 | ||||||
| 3608 | ch angeResult View( sHTM L ); | |||||
| 3609 | if (gbAIR) | |||||
| 3610 | { | |||||
| 3611 | quic kSortResul t(); | |||||
| 3612 | if(g bAIRSearch ResultDisp layDoneFn! =null) | |||||
| 3613 | { | |||||
| 3614 | gbAIRS earchResul tDoneSteps ++; | |||||
| 3615 | if(gbA IRSearchRe sultDoneSt eps>0) | |||||
| 3616 | { | |||||
| 3617 | gbAIRSea rchResultD one = true ; | |||||
| 3618 | gbAIRSea rchResultD oneSteps = 0; | |||||
| 3619 | gbAIRSea rchResultD isplayDone Fn(); | |||||
| 3620 | } | |||||
| 3621 | } | |||||
| 3622 | } | |||||
| 3623 | el se setT imeout( "q uickSortRe sult();", 1 ); | |||||
| 3624 | } | |||||
| 3625 | ||||||
| 3626 | function d ummySearch ResultFn() | |||||
| 3627 | { | |||||
| 3628 | // don no | |||||
| 3629 | } | |||||
| 3630 | ||||||
| 3631 | function o nClickPage ( a_nPageN umber ) | |||||
| 3632 | { | |||||
| 3633 | g_CurP age = a_nP ageNumber ; | |||||
| 3634 | g_CurS tate = ECS _FOUND ; | |||||
| 3635 | update ResultView (); | |||||
| 3636 | } | |||||
| 3637 | ||||||
| 3638 | function d isplaySear chProgress Bar( a_nPr ogress ) | |||||
| 3639 | { | |||||
| 3640 | va r pb = get Element( ' SearchProg ressBar' ) ; | |||||
| 3641 | va r pt = get Element( ' SearchProg ress' ); | |||||
| 3642 | if ( !pb || ! pt ) | |||||
| 3643 | { | |||||
| 3644 | var sHTML = "< P ID='Sear chProgress ' CLASS='p b_tt'>" + gsSearchin g + " " + a_nProgres s + "%</P> \n" + | |||||
| 3645 | "<DIV CLAS S='pb_out' >\n" + | |||||
| 3646 | "<P ID='Se archProgre ssBar' CLA SS='pb_in' STYLE='wi dth:" + a_ nProgress + "%'></P> \n" + | |||||
| 3647 | "</DIV>\n" + | |||||
| 3648 | "<CENTER>< P CLASS='p b_cancel' ONMOUSEDOW N='context .stop()'>" +gsCancel+ "</P></CEN TER>\n"; | |||||
| 3649 | chan geResultVi ew( sHTML ); | |||||
| 3650 | } | |||||
| 3651 | el se | |||||
| 3652 | { | |||||
| 3653 | setI nnerHTML( pt, gsSear ching + " " + a_nPro gress + "% " ); | |||||
| 3654 | pb.s tyle.width = a_nProg ress + "%" ; | |||||
| 3655 | } | |||||
| 3656 | } | |||||
| 3657 | ||||||
| 3658 | function u pdateResul tView() | |||||
| 3659 | { | |||||
| 3660 | if ( g_CurSt ate == ECS _SEARCHING ) | |||||
| 3661 | disp laySearchP rogressBar ( goOdinHu nter.nProg ress ); | |||||
| 3662 | ||||||
| 3663 | el se if ( g_ CurState = = ECS_FOUN D ) | |||||
| 3664 | disp layTopics( goOdinHun ter.queryR esult ); | |||||
| 3665 | ||||||
| 3666 | el se if ( g_ CurState = = ECS_SEAR CHFAILED ) | |||||
| 3667 | disp layMsg( co ntext.strM sg ); | |||||
| 3668 | ||||||
| 3669 | el se if ( g_ CurState = = ECS_FATA LERROR ) | |||||
| 3670 | disp layMsg( co ntext.strM sg ); | |||||
| 3671 | ||||||
| 3672 | el se if ( g_ CurState = = ECS_CANC ELED ) | |||||
| 3673 | disp layMsg( gs Canceled ) ; | |||||
| 3674 | ||||||
| 3675 | if (g_CurStat e == ECS_S EARCHFAILE D || | |||||
| 3676 | g_CurSta te == ECS_ FATALERROR || | |||||
| 3677 | g_CurSta te == ECS_ CANCELED | |||||
| 3678 | ) | |||||
| 3679 | { | |||||
| 3680 | HandleAI RSearchFun ction(); | |||||
| 3681 | } | |||||
| 3682 | } | |||||
| 3683 | ||||||
| 3684 | function p rocessHunt erResult( a_Context ) | |||||
| 3685 | { | |||||
| 3686 | if ( a_Conte xt ) | |||||
| 3687 | { | |||||
| 3688 | upda teResultVi ew(); | |||||
| 3689 | if(g bAIR) | |||||
| 3690 | proces sHunterRes ult(); | |||||
| 3691 | else setTimeou t( "proces sHunterRes ult();", 1 ); | |||||
| 3692 | retu rn; | |||||
| 3693 | } | |||||
| 3694 | ||||||
| 3695 | if ( goOdinH unter == n ull ) | |||||
| 3696 | retu rn; | |||||
| 3697 | ||||||
| 3698 | if ( !goOdin Hunter.bSu cc ) | |||||
| 3699 | { | |||||
| 3700 | g_Cu rState = E CS_SEARCHF AILED; | |||||
| 3701 | upda teResultVi ew(); | |||||
| 3702 | retu rn; | |||||
| 3703 | } | |||||
| 3704 | ||||||
| 3705 | g_ CurState = ECS_FOUND ; | |||||
| 3706 | up dateResult View(); | |||||
| 3707 | } | |||||
| 3708 | ||||||
| 3709 | function s tringToBoo lean(strin g){ | |||||
| 3710 | sw itch(strin g.toLowerC ase()){ | |||||
| 3711 | case "true": c ase "yes": case "1": return tr ue; | |||||
| 3712 | case "false": case "no": case "0": case null : return f alse; | |||||
| 3713 | defa ult: retur n Boolean( string); | |||||
| 3714 | } | |||||
| 3715 | } | |||||
| 3716 | ||||||
| 3717 | function S etVariable sFromNameV aluePairSt ring(strNa meValuePai r,bDecodeV alue) //we need to decode in case of BB URL pa rameters | |||||
| 3718 | { | |||||
| 3719 | var nv Pairs = st rNameValue Pair.split ('&'); | |||||
| 3720 | ||||||
| 3721 | for (i = 0; i < nvPairs.le ngth; i++) { | |||||
| 3722 | va r nvPair = nvPairs[i ].split("= "); | |||||
| 3723 | va r name = n vPair[0]; | |||||
| 3724 | va r value = nvPair[1]; | |||||
| 3725 | ||||||
| 3726 | if(b DecodeValu e) | |||||
| 3727 | { | |||||
| 3728 | value = decodeUR IComponent (value); | |||||
| 3729 | } | |||||
| 3730 | ||||||
| 3731 | ||||||
| 3732 | if ( window[nam e] != unde fined) | |||||
| 3733 | { | |||||
| 3734 | if( ty peof windo w[name] == 'number') | |||||
| 3735 | { | |||||
| 3736 | window[n ame] = str ingToBoole an(value); | |||||
| 3737 | } | |||||
| 3738 | if( type of window[ name] == ' boolean') | |||||
| 3739 | { | |||||
| 3740 | window[n ame] = str ingToBoole an(value); | |||||
| 3741 | } | |||||
| 3742 | else | |||||
| 3743 | window[n ame] = val ue; | |||||
| 3744 | } | |||||
| 3745 | } | |||||
| 3746 | } | |||||
| 3747 | ||||||
| 3748 | function G etSearchTe xtFromURL( ) | |||||
| 3749 | { | |||||
| 3750 | var st rLocation = document .location. href; | |||||
| 3751 | ||||||
| 3752 | st rLocation = decodeUR I(strLocat ion); | |||||
| 3753 | ||||||
| 3754 | va r searchSt ring = str Location.s ubstring(s trLocation .indexOf(' ?') + 1 ); | |||||
| 3755 | ||||||
| 3756 | SetVar iablesFrom NameValueP airString( searchStri ng,true); | |||||
| 3757 | ||||||
| 3758 | return gsSearchQ uery; | |||||
| 3759 | ||||||
| 3760 | } | |||||
| 3761 | ||||||
| 3762 | function s etSearchDi splayFunct ion(funcNa me) | |||||
| 3763 | { | |||||
| 3764 | gA IRSearchOb ject = new Object(); | |||||
| 3765 | gA IRSearchOb ject.displ ayFunction = funcNam e; | |||||
| 3766 | } | |||||
| 3767 | ||||||
| 3768 | if ( gbAIR SSL || !wi ndow.gbTes ting ) | |||||
| 3769 | { | |||||
| 3770 | if ( window. gbWhUtil & & window.g bWhLang && window.gb WhVer && | |||||
| 3771 | (wi ndow.gbAIR SSL || | |||||
| 3772 | ( | |||||
| 3773 | window. gbWhProxy && | |||||
| 3774 | window. gbWhMsg | |||||
| 3775 | ) | |||||
| 3776 | ) | |||||
| 3777 | ) | |||||
| 3778 | { | |||||
| 3779 | goFo nt=new whF ont("Verda na","8pt", "#000000", "normal"," normal","n one"); | |||||
| 3780 | goEr rFont=new whFont("Ve rdana","8p t","#00000 0","normal ","bold"," none"); | |||||
| 3781 | goHo verFont=ne w whFont(" Verdana"," 8pt","#007 f00","norm al","norma l","underl ine"); | |||||
| 3782 | if(! gbAIR) | |||||
| 3783 | window .onload=wi ndow_OnLoa d; | |||||
| 3784 | wind ow.onbefor eunload=wi ndow_BUnlo ad; | |||||
| 3785 | wind ow.onunloa d=window_U nload; | |||||
| 3786 | if(! gbAIRSSL) | |||||
| 3787 | { | |||||
| 3788 | regist erListener 2(WH_MSG_P ROJECTREAD Y); | |||||
| 3789 | regist erListener 2(WH_MSG_S ETMAXRSLT) ; | |||||
| 3790 | } | |||||
| 3791 | gbWh FHost=true ; | |||||
| 3792 | } | |||||
| 3793 | el se | |||||
| 3794 | { | |||||
| 3795 | docu ment.locat ion.reload (); | |||||
| 3796 | } | |||||
| 3797 | } | |||||
| 3798 | ||||||
| 3799 | function u tf8Compare (strText1, strText2) | |||||
| 3800 | { | |||||
| 3801 | va r strt1=st rText1; | |||||
| 3802 | va r strt2=st rText2; | |||||
| 3803 | ||||||
| 3804 | tr y { | |||||
| 3805 | strt 1=strText1 .toLowerCa se(); | |||||
| 3806 | } | |||||
| 3807 | ca tch(er) { | |||||
| 3808 | } | |||||
| 3809 | ||||||
| 3810 | tr y { | |||||
| 3811 | strt 2=strText2 .toLowerCa se(); | |||||
| 3812 | } | |||||
| 3813 | ca tch(er) { | |||||
| 3814 | } | |||||
| 3815 | ||||||
| 3816 | if (strt1<str t2) return -1; | |||||
| 3817 | if (strt1>str t2) return 1; | |||||
| 3818 | re turn 0; | |||||
| 3819 | } | |||||
| 3820 | ||||||
| 3821 | ||||||
| 3822 | function l trim(str) { | |||||
| 3823 | fo r(var k = 0; k < str .length && isWhitesp ace(str.ch arAt(k)); k++); | |||||
| 3824 | re turn str.s ubstring(k , str.leng th); | |||||
| 3825 | } | |||||
| 3826 | function r trim(str) { | |||||
| 3827 | fo r(var j=st r.length-1 ; j>=0 && isWhitespa ce(str.cha rAt(j)) ; j--) ; | |||||
| 3828 | re turn str.s ubstring(0 ,j+1); | |||||
| 3829 | } | |||||
| 3830 | function t rim(str) { | |||||
| 3831 | re turn ltrim (rtrim(str )); | |||||
| 3832 | } | |||||
| 3833 | function i sWhitespac e(charToCh eck) { | |||||
| 3834 | va r whitespa ceChars = " \t\n\r\f "; | |||||
| 3835 | re turn (whit espaceChar s.indexOf( charToChec k) != -1); | |||||
| 3836 | } | |||||
| 3837 | ||||||
| 3838 | ||||||
| 3839 | document.o nmousedown = uiMouse Down; | |||||
| 3840 | document.o nmousemove = uiMouse Move; | |||||
| 3841 | document.o nmouseup = uiMouseUp ; | |||||
| 3842 | document.o nclick = u iClick; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.