📄 whfhost.js
字号:
}
if ((strSyn == "")||(strSyn == " "))
return ;
if(!gbAIRSSL)
{
var oResMsg = new whMessage( WH_MSG_SETSYNSTR, a_this, 1, strSyn );
SendMessage( oResMsg );
}
else
{
gbAIRSynonymString = strSyn;
}
}
this.doQueryWordRecord = function( a_Context, a_this )
{
if ( !theXmlReader.bSucc )
{
a_Context.strMsg = gsLoadXmlFailed;
a_Context.bError = true;
return;
}
if ( !a_this.bSucc )
return;
// By Lein 4:59 PM 7/15/2004
a_this.recordResult = new HuginPackageReaderResult();
var strRecord = theXmlReader.getWordRec(a_this.strQueryWord,a_this.bPhraseSearch);
if ( strRecord == null )
return;
a_this.recordResult.bStopWord = false;
a_this.recordResult.strNefStem = a_this.strQueryWord;
a_this.recordResult.strRecord = strRecord;
if (strRecord == "" )
{
a_this.bSucc = false;
return;
}
a_this.bSucc = true;
theXmlReader.strFilePath = a_this.strSynonymPath;
a_Context.push( a_this.loadFromFile, a_this,
a_this.setSynonymForHighlighting, a_this );
}
this.query = function( a_Context, a_this )
{
a_this.bSucc = true;
theXmlReader.strFilePath = a_this.strPackagePath;
a_Context.push( a_this.loadFromFile, a_this,
a_this.doQueryWordRecord, a_this );
}
}
function HuginPackageIndexReader()
{
this.queryWord = null; //in
this.strPackageIndexPath = null; //in
this.packageInfo = null; //out
this.bSucc = true;
this.strCurQuery = null;
this.strPackageInfo = null;
this.prepareQuery = function()
{
this.packageInfo = null; //out
this.bSucc = true;
this.strCurQuery = null;
this.strPackageInfo = null;
}
this.getPackagePath = function( a_strSuffix )
{
var sf = splitPathName( this.strPackageIndexPath );
return sf.strDir + "package_" + a_strSuffix + sf.strExt;
}
this.getTopicTablePath = function( a_strSuffix )
{
var sf = splitPathName( this.strPackageIndexPath );
return sf.strDir + "topictable_" + a_strSuffix + sf.strExt;
}
this.parsePackageInfo = function( a_Context, a_this )
{
if ( !theXmlReader.bSucc ||
!theXmlReader.checkRoot( "cki" ) )
{
a_this.bSucc = false;
return;
}
var nPackageIndex = theXmlReader.getPackageIndex(a_this.strCurQuery);
if ( nPackageIndex == null || nPackageIndex < 0 )
{
a_this.packageInfo = null;
a_this.bSucc = false;
return;
}
a_this.packageInfo = a_this.getPackagePath( nPackageIndex );
this.bSucc = true;
return ;
}
this.parseTopicInfo = function( a_Context, a_this )
{
if ( !theXmlReader.bSucc ||
!theXmlReader.checkRoot( "cki" ) )
{
a_this.bSucc = false;
return;
}
var nPackageIndex = theXmlReader.getPackageIndex(a_this.strCurQuery);
if ( nPackageIndex == null || nPackageIndex < 0 )
{
a_this.packageInfo = null;
a_this.bSucc = false;
return;
}
a_this.packageInfo = a_this.getTopicTablePath( nPackageIndex );
this.bSucc = true;
return ;
}
this.loadFromFile = function( a_Context, a_this, a_funcCallback )
{
theXmlReader.loadFromFile( a_funcCallback , false);
}
this.queryPackageInfo = function( a_Context, a_this )
{
a_this.bSucc = true;
theXmlReader.strFilePath = a_this.strPackageIndexPath;
a_Context.push( a_this.loadFromFile, a_this,
a_this.parsePackageInfo, a_this );
}
this.queryTopicInfo = function( a_Context, a_this )
{
a_this.bSucc = true;
theXmlReader.strFilePath = a_this.strPackageIndexPath;
a_Context.push( a_this.loadFromFile, a_this,
a_this.parseTopicInfo, a_this );
}
}
function HuginTopicTableReader()
{
this.nQueryId = null; //in
this.strTopicTablePath = null; //in
this.lastIndex = -1;
this.topicInfo = null; //out
this.bSucc = true;
this.strTopicInfo = null;
this.strTopicContext = null;
this.topicMap = null ;
this.curTopicIndex = null ;
this.prepareQuery = function()
{
this.bSucc = true;
this.strTopicInfo = null;
}
this.loadFromFile = function( a_Context, a_this, a_funcCallback )
{
theXmlReader.loadFromFile( a_funcCallback );
}
this.processReaderResult = function( a_Context, a_this )
{
if ( !theXmlReader.bSucc ||
!theXmlReader.checkRoot( "ck" ) )
{
a_this.bSucc = false;
a_this.bInited = false;
return;
}
var queryId = a_this.nQueryId ;
if (a_this.curTopicIndex > 0 )
queryId = queryId - a_this.topicMap[a_this.curTopicIndex -1 ] ;
var topicInfo = theXmlReader.getTopicRec(queryId);
a_this.strTopicInfo = topicInfo.rd;
a_this.strTopicContext = topicInfo.ct;
}
this.parseTopicInfo = function( a_Context, a_this )
{
if ( !a_this.bSucc )
return;
a_this.topicInfo = new Object();
var v = a_this.strTopicInfo.split( "|" );
if ( v.length < 2 || v[0] == "" || v[1] == "" )
{
a_this.bSucc == false;
return;
}
a_this.topicInfo.strUrl = v[0];
a_this.topicInfo.strTitle = v[1];
}
this.queryTopicInfo = function( a_Context, a_this )
{
for (var i = 0 ; i < a_this.topicMap.length ; i++)
{
if (a_this.nQueryId < a_this.topicMap[i] )
break ;
}
if (i >= a_this.topicMap.length)
{
a_this.bSucc == false;
return;
}
a_this.curTopicIndex = i ;
var topictablefilename = "topictable_" + i + ".xml" ;
if(i != a_this.lastIndex)
{
a_this.lastIndex = i;
theXmlReader.strFilePath = getAbsPath( a_this.strTopicTablePath, topictablefilename );
a_Context.push( a_this.loadFromFile, a_this,
a_this.processReaderResult, a_this,
a_this.parseTopicInfo, a_this );
}
else
{
a_Context.push( a_this.processReaderResult, a_this,
a_this.parseTopicInfo, a_this );
}
}
this.makeIndexMap = function( a_Context, a_this )
{
a_this.topicMap = new Array() ;
var prev = 0 ;
for (var i = 0; i < theXmlReader.getNumOfNodes() ; i++)
{
a_this.topicMap[i] = theXmlReader.getNumOfTopics(i) + prev;
prev = a_this.topicMap[i] ;
}
}
this.prepareMap = function( a_Context, a_this )
{
a_this.bSucc = true;
theXmlReader.strFilePath = a_this.strTopicTablePath;
a_Context.push( a_this.loadFromFile, a_this,
a_this.makeIndexMap, a_this);
}
}
// HuginDatabase.js-----------------------------
function HuginDatabase()
{
this.strOdbPath = ""; //in
this.queryWord = null; //in
this.bNeedStopWord = false; //in
this.recordResult = null; //out
this.eType = null ; //in
this.aQueryTopics = null; //in out
this.bSucc = false;
this.bInited = false;
this.strTopicTablePath = null;
this.strPackageIndexPath = null;
this.strSynonymPath = null ;
this.packageInfo = null;
this.iCurTopic = null;
this.packageIndexReader = new HuginPackageIndexReader();
this.packageReader = new HuginPackageReader();
this.topicReader = new HuginTopicTableReader();
this.prepareQuery = function()
{
this.recordResult = null;
this.bSucc = true;
this.packageInfo = null;
this.iCurTopic = 0;
this.packageIndexReader.prepareQuery();
this.packageReader.prepareQuery();
this.topicReader.prepareQuery();
this.eType = ESNT_DEFAULT ;
}
this.getIndexUrl = function( a_strIndexType )
{
var strRelPath = theXmlReader.getAttr( "index", "type", a_strIndexType, "url" );
if ( strRelPath == "" )
return "";
return getAbsPath( this.strOdbPath, strRelPath );
}
this.readOdbInfo = function( a_Context, a_this )
{
if ( !theXmlReader.bSucc ||
!theXmlReader.checkRoot( "odb" ) )
{
a_this.bSucc = false;
a_this.bInited = false;
return;
}
a_this.strTopicTablePath = a_this.getIndexUrl( "TopicIndex" );
a_this.strPackageIndexPath = a_this.getIndexUrl( "PackageIndex" );
a_this.strSynonymPath = a_this.getIndexUrl( "Synonym" );
if ( a_this.strTopicTablePath == "" || a_this.strPackageIndexPath == "" || a_this.strSynonymPath == "")
{
a_this.bSucc = false;
a_this.bInited = false;
return;
}
else
{
a_this.bSucc = true;
a_this.bInited = true;
}
}
this.loadFromFile = function( a_Context, a_this, a_funcCallback )
{
theXmlReader.loadFromFile( a_funcCallback );
}
this.queryRecordInPackage = function( a_Context, a_this )
{
if ( !a_this.packageIndexReader.bSucc )
return;
a_this.packageInfo = a_this.packageIndexReader.packageInfo;
a_this.packageReader.strPackagePath = a_this.packageInfo;
a_this.packageReader.strSynonymPath = a_this.strSynonymPath ;
a_this.packageReader.bPhraseSearch = (a_this.eType == ESNT_PHRASE);
if (gsSubstrSrch)
a_this.packageReader.strQueryWord = a_this.queryWord.strNormalizedOrg;
else
a_this.packageReader.strQueryWord = a_this.queryWord.strHelStem; //use stem in case substring search is off
a_Context.push( a_this.packageReader.query, a_this.packageReader );
}
this.makeResult = function( a_Context, a_this )
{
if ( !a_this.packageIndexReader.bSucc ||
!a_this.packageReader.bSucc )
{
a_this.bSucc = false;
}
a_this.recordResult = a_this.packageReader.recordResult;
if (a_this.eType == ESNT_NOT)
{
if ((typeof(a_this.recordResult)=='undefined')||(a_this.recordResult==null))
{
a_this.bSucc = true ;
a_this.recordResult = a_this.makeDummyResultRec(a_this.queryWord.strNormalizedOrg,a_this.queryWord.strHelStem) ;
}
theXmlReader.strFilePath = a_this.strTopicTablePath;
a_Context.push( a_this.loadFromFile, a_this,
a_this.makeNotResult, a_this );
}
}
this.makeDummyResultRec = function(strOrg, strStem)
{
var recordResult = new Object();
recordResult.strRecord = "" ;
recordResult.strNefStem = strStem ;
recordResult.bStopWord = false ;
return recordResult ;
}
this.makeNotResult = function( a_Context, a_this )
{
var topicRecs = a_this.recordResult.strRecord.split( "|" );
var bIncludeAll = (a_this.recordResult.strRecord == "" );
var arrTopicIds = new Array();
var j ;
for(j=0;j<topicRecs.length;j++)
{
var pos = topicRecs[j].indexOf(",");
if(pos != -1)
arrTopicIds[arrTopicIds.length] = topicRecs[j].substring(0,pos);
}
var bCheck = false ;
if(arrTopicIds.length > 0)
bCheck = true ;
var curIndex = 0 ;
var sDummyTopicRec = ",192:0,0,10" ;
var i = 0;
var numTopics = 0 ;
for (var k =0 ; k < theXmlReader.getNumOfNodes() ; k++)
{
numTopics += theXmlReader.getNumOfTopics(k);
}
a_this.recordResult.strRecord = '' ;
while(i < numTopics)
{
var bIncludeTopic = true ;
if (bCheck && (curIndex < arrTopicIds.length)&&(arrTopicIds[curIndex]==i) && (!bIncludeAll))
{
curIndex++ ;
bIncludeTopic = false ;
}
if(bIncludeTopic)
{
a_this.bSucc = true ;
var topicRec = i + sDummyTopicRec ;
if (a_this.recordResult.strRecord == '')
a_this.recordResult.strRecord = topicRec ;
else
a_this.recordResult.strRecord += "|" + topicRec ;
}
i++ ;
}
}
this.init = function( a_Context, a_this )
{
theXmlReader.strFilePath = a_this.strOdbPath;
a_Context.push( a_this.loadFromFile, a_this,
a_this.readOdbInfo, a_this );
}
this.queryRecord = function( a_Context, a_this )
{
if ( !a_this.bInited )
{
a_this.bSucc = false;
return;
}
a_this.bSucc = true;
a_this.packageIndexReader.strPackageIndexPath = a_this.strPackageIndexPath;
if (gsSubstrSrch)
a_this.packageIndexReader.strCurQuery = a_this.queryWord.strNormalizedOrg;
else
a_this.packageIndexReader.strCurQuery = a_this.queryWord.strHelStem; //use stem in case substring search is off
a_Context.push( a_this.packageIndexReader.queryPackageInfo, a_this.packageIndexReader,
a_this.queryRecordInPackage, a_this,
a_this.makeResult, a_this )
}
this.processTopicInfo = function( a_Context, a_this )
{
if ( !a_this.topicReader.bSucc )
{
a_this.bSucc = false;
return;
}
a_this.aQueryTopics[a_this.iCurTopic].strUrl = a_this.topicReader.topicInfo.strUrl;
a_this.aQueryTopics[a_this.iCurTopic].strTitle = a_this.topicReader.topicInfo.strTitle;
a_this.aQueryTopics[a_this.iCurTopic].strSummary = a_this.topicReader.strTopicContext;
}
this.incCurTopic = function( a_Context, a_this )
{
a_this.iCurTopic++;
}
this.queryTopicInfo = function( a_Context, a_this )
{
if ( a_this.iCurTopic >= a_this.aQueryTopics.length )
return;
a_this.topicReader.nQueryId = a_this.aQueryTopics[a_this.iCurTopic].nTopicId;
a_Context.push( a_this.topicReader.queryTopicInfo, a_this.topicReader,
a_this.processTopicInfo, a_this,
a_this.incCurTopic, a_this,
a_this.queryTopicInfo, a_this );
}
this.queryTopicInfos = function( a_Context, a_this )
{
if ( !a_this.bInited )
{
a_this.bSucc = false;
return;
}
a_this.bSucc = true;
a_this.topicReader.strTopicTablePath = a_this.strTopicTablePath;
a_this.iCurTopic = 0; //this is an iterator of a "for" loop
a_this.topicReader.lastIndex = -1;
a_Context.push( a_this.topicReader.prepareMap , a_this.topicReader,
a_this.queryTopicInfo, a_this );
}
}
// LanguageService.js---------------------------
function LanguageService()
{
this.getNormalizedOrg = function( a_strOrg, a_Result )
{
var strUpper = a_strOrg.toUpperCase();
var strLower = a_strOrg.toLowerCase();
if ( utf8Compare(strUpper, strLower) == 0 || utf8Compare(strUpper, a_strOrg) != 0 )
{
a_Result.strNormalizedOrg = strLower;
a_Result.bUpperCase = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -