📄 reghelpbds3.js
字号:
}
var file2copy='', fileDest='', copyRet=0, exAll=false;
if ( arrFiles != null && arrFiles.length != 0 )
{
for ( i in arrFiles )
{
sep = fileList(arrFiles[i]).indexOf ( ',' );
file2copy = fileList(arrFiles[i]).substr ( 0, sep );
fileDest = fileList(arrFiles[i]).substr ( sep + 1 );
copyRet = updateFile ( file2copy, fileDest, exAll, versioning );
WScript.Echo ( 'Copied [' + copyRet + ']: ' + fo.GetFileName(file2copy) );
if ( copyRet == 0 && exAll == false ) { exAll = true };
if ( cleanTemp == true )
{
try
{
fo.DeleteFile ( file2copy );
}
catch ( err_tmpfiledelete )
{ }
}
}
}
a = 1; //reset action to perform reg functions
}
// ==== perform reg/rem functions ====
// remove filters
if ( a == 0 && arrFilters != null && arrFilters.length != 0 )
{
var fltName = '';
for ( i in arrFilters )
{
sep = arrFilters[i].indexOf ( ',' );
if ( sep != -1 )
{
fltName = trimit(arrFilters[i].substr(0,sep));
if ( fltName.substr ( 0,1 ) == '*' )
{ fltName = fltName.substr(1); fltNS = inamespace } else { fltNS = nsparent; };
var fltRet = rFilter ( 0, fltNS, fltName );
if ( fltRet == true )
{
WScript.Echo ( 'Removed filter [' + fltRet + ']: ' + fltName );
}
}
}
}
// remove a plugin (must occur before namespace removal)
if ( a == 0 && inamespace != ''
&& nsparent != ''
&& parentTOC != ''
&& hxt != '' && hxa != ''
&& mergetype == 'plugin' )
{
var pluginRet = rPlugin ( 0, nsparent, parentTOC, inamespace, hxt, hxa, 0 );
WScript.Echo ( 'Removed plugin [' + pluginRet + ']: ' + inamespace );
}
// register or remove a namespace
var nsRemoved = false;
if ( a < 3 && inamespace != '' && hxc != '' && fo.fileExists ( hxc ) )
{
if ( nsdescription == null ) { nsdescription = 'Help file'; }
var nsRet = rNamespace ( a, inamespace, hxc, nsdescription, 0 );
if ( a == 0 && nsRet == true ) { nsRemoved = true; }
}
if ( args(0) == 3 && getNamespacePath(nsparent) == '' )
{
nsRemoved = true;
}
// add or remove namespace registration on installed files
var hxsFull='', hxiFull='', hxBase='', rspace = nsparent;
if ( a < 3 && nsparent != ''
&& arrFiles != null && arrFiles.length != 0
&& langid != '' && nsRemoved == false )
{
var destDrive, dCheck;
if ( inamespace != '' ) { rspace = inamespace; }
for ( i in arrFiles )
{
sep = fileList(arrFiles[i]).indexOf ( ',' );
hxsFull = fileList(arrFiles[i]).substr ( sep + 1 );
if ( hxsFull != '' )
{
if ( fo.GetExtensionName(hxsFull).toLowerCase() == 'hxs' )
{
hxBase = fo.GetBaseName(hxsFull).toLowerCase();
if ( !fileList.exists ( hxBase + '.hxi' ) )
{
hxiFull = hxsFull;
}
else
{
hxiFull = hxsFull.toLowerCase().replace ( '.hxs', '.hxi' ); //
}
}
if ( fo.fileExists ( hxsFull ) && fo.fileExists ( hxiFull ) )
{
if ( a != 0 )
{
destDrive = fo.GetDrive(fo.GetDriveName(fo.GetParentFolderName(hxiFull)));
dCheck = checkDrive ( destDrive, fo.GetFile(hxiFull).size * 2 );
}
else
{ dCheck = true; }
if ( dCheck == true )
{
fileRet = rFile ( a, rspace, hxBase, langid, hxsFull, hxiFull );
WScript.Echo ( 'Registered [' + a + ']: ' + fo.GetFileName ( hxsFull ) );
}
}
}
hxsFull = ''; hxiFull = ''; hxBase = ''; fileRet = '';
}
}
// register a plugin (must occur after registration of child namespace)
if ( a == 1 && inamespace != ''
&& nsparent != ''
&& parentTOC != ''
&& hxt != '' && hxa != ''
&& mergetype == 'plugin' )
{
WScript.Echo ( hxt + ' ' + hxa );
var pluginRet = rPlugin ( 1, nsparent, parentTOC, inamespace, hxt, hxa, 0 );
WScript.Echo ( 'Registered plugin [' + pluginRet + ']: ' + inamespace );
}
// register filters
if ( a == 1 && arrFilters != null && arrFilters.length != 0 )
{
var fltName = '', fltSpec = '';
for ( i in arrFilters )
{
sep = arrFilters[i].indexOf ( ',' );
if ( sep != -1 )
{
fltName = trimit(arrFilters[i].substr(0,sep));
fltSpec = trimit(arrFilters[i].substr(sep + 1));
if ( fltName.substr ( 0,1 ) == '*' )
{ fltName = fltName.substr(1); fltNS = inamespace } else { fltNS = nsparent; };
var fltRet = rFilter ( 1, fltNS, fltName, fltSpec );
WScript.Echo ( 'Added filter [' + fltRet + ']: ' + fltName );
}
}
}
// insert merge TOC into parent TOC
if ( a == 1 && mergetype == 'merge'
&& parentTOC != ''
&& mergetoctitle != ''
&& arrFiles != null && arrFiles.length != 0
)
{
if ( fo.fileExists ( parentTOC ) )
{
//if parentTOC readonly, reset attributes so it can be rewritten
var fPT = fo.GetFile(parentTOC);
if ( fPT.attributes > 0 ) { fPT.attributes = 0; }
}
else
{
//WSHShell.Popup ( 'Parent TOC not found.', 0, mbTitle, 16 );
WScript.Echo ( 'Parent TOC not found.' );
WSHShell = null; WScript.Quit();
}
var foundTOCtitle = false;
var tocBase = fo.GetParentFolderName(parentTOC) + '\\' + fo.GetBaseName(parentTOC);
var tmpTOC = fo.CreateTextFile( tocBase + '.tmp', true );
var toc = fo.OpenTextFile ( parentTOC, 1, false );
while ( !toc.AtEndOfStream )
{
tocData = trimit(toc.readline());
if ( tocData.indexOf ( '<HelpTOCNode Title="' + mergetoctitle + '" ' ) != -1 )
{
foundTOCtitle = true;
}
if ( tocData == '</HelpTOC>' && foundTOCtitle == 0 )
{
tmpTOC.write ( '<HelpTOCNode Title="' + mergetoctitle + '" ' );
if ( mergetocurl != '' )
{
tmpTOC.write ( 'Url="' + mergetocurl + '"' );
}
tmpTOC.write ( '>\n' );
for ( i in arrFiles )
{
if ( fo.GetExtensionName(arrFiles[i]) == 'hxs' )
{
tmpTOC.writeline ( '<HelpTOCNode NodeType="TOC" Url="' + fo.GetBaseName(arrFiles[i]) + '"/>' );
}
}
tmpTOC.writeline ( '</HelpTOCNode>\n' );
}
tmpTOC.writeline ( tocData );
}
toc.close();
tmpTOC.close();
if ( foundTOCtitle == false )
{
fo.CopyFile ( tocBase + '.tmp', parentTOC );
WScript.Echo ( 'Updated main TOC [+]' );
}
fo.DeleteFile ( tocBase + '.tmp' );
}
// remove inserted TOC from parent TOC (merged TOC)
if ( a == 0 && mergetype == 'merge'
&& parentTOC != ''
&& mergetoctitle != ''
&& nsRemoved == false )
{
if ( !fo.fileExists ( parentTOC ) )
{
//WSHShell.Popup ( 'Parent TOC not found.', 0, mbTitle, 16 );
WScript.Echo ( 'Parent TOC not found.' );
WSHShell = null; WScript.Quit();
}
var foundTOCtitle = false;
var tocBase = fo.GetParentFolderName(parentTOC) + '\\' + fo.GetBaseName(parentTOC);
var tmpTOC = fo.CreateTextFile( tocBase + '.tmp', true );
var toc = fo.OpenTextFile ( parentTOC, 1, false );
while ( !toc.AtEndOfStream )
{
tocData = trimit(toc.readline());
if ( tocData.indexOf ( '<HelpTOCNode Title="' + mergetoctitle + '" ' ) != -1 )
{
foundTOCtitle = true;
while ( !toc.AtEndOfStream && tocData != '</HelpTOCNode>' )
{ tocData = trimit(toc.readline()); }
if ( tocData == '</HelpTOCNode>' )
{ tocData = trimit(toc.readline()); }
if ( tocData == '' )
{ tocData = trimit(toc.readline()); }
}
tmpTOC.writeline ( tocData );
}
toc.close();
tmpTOC.close();
if ( foundTOCtitle == true )
{
fo.CopyFile ( tocBase + '.tmp', parentTOC );
WScript.Echo ( 'Updated main TOC [-]' );
}
fo.DeleteFile ( tocBase + '.tmp' );
}
// remove installed files
if ( args(0) == 3 && installdest != sdkRoot )
{
var rmFile = '', delRet;
if ( arrFiles != null && arrFiles.length != 0 )
{
for ( i in arrFiles )
{
sep = fileList(arrFiles[i]).indexOf ( ',' );
hxsFull = fileList(arrFiles[i]).substr ( sep + 1 );
if ( hxsFull != '' && fo.fileExists ( hxsFull ) )
{
delRet = fo.DeleteFile ( hxsFull, true );
WScript.Echo ( 'Deleted file: ' + arrFiles[i] );
}
}
hxsFull = '';
}
}
return retMain;
}
/*************************************************
expands path of specified configuration file, if necessary,
and verifies existence of the file
*/
function checkConfig(f)
{
f = fo.GetAbsolutePathName(trimit(f));
if ( !fo.FileExists ( f ) )
{
if ( !fo.FileExists ( scriptPath + f ) )
{
WSHShell.Popup ( 'Configuration file not found:\n' + f, 0, mbTitle, 16 );
WScript.Echo ( 'Configuration file not found.' );
WSHShell = null; WScript.Quit();
}
else
{
f = scriptPath + f;
}
}
return f;
}
/*************************************************
returns the path of specified namespace
(for verifying namespace and locating *.hx? files)
*/
function getNamespacePath(ns)
{
var r = '';
try
{
var oRegSess = new ActiveXObject('HxDs.HxRegisterSession');
oRegSess.CreateTransaction('');
var oRegNS = oRegSess.GetRegistrationObject(0);
if ( oRegNS.IsNamespace(ns) )
{
r = oRegNS.GetCollection(ns);
}
oRegSess.CommitTransaction();
oRegNS=null;
oRegSess=null;
}
catch(err_getnamespacepath)
{
oRegNS=null;
oRegSess=null;
r = '';
}
return r;
}
/*************************************************
copies or updates files from source media
to specified position in product installation
(uses date/time stamps for comparison)
*/
function updateFile ( sf, df, q, vStr )
{
var cpRet;
var xCopy = false ;
var fsrc, fdst, dsRet, destDrive, dCheck, qVer, fxExt, sFV = '', dFV = '' ;
if ( fo.fileExists ( sf ) )
{
try
{
fsrc = fo.GetFile(sf);
if ( fo.fileExists ( df ) )
{
fdst = fo.GetFile(df);
if ( q == false )
{
if ( vStr == 'file' || vStr == 'extended' )
{
fxExt = fo.GetExtensionName ( sf ).toLowerCase();
if ( fxExt == 'hxa' || fxExt == 'hxt'
|| fxExt == 'hxk' || fxExt == 'hxc' )
{
sFV = getVersionAttrib(sf);
dFV = getVersionAttrib(df);
}
else
{
if ( fxExt.substr ( 0, 2 ) == 'hx' )
{
sFV = fo.GetFileVersion(sf);
dFV = fo.GetFileVersion(df);
}
}
}
switch ( vStr )
{
case 'date':
if ( fdst.DateLastModified < fsrc.DateLastModified )
{
xCopy = true;
} break;
case 'file':
if ( Math.abs(sFV) > Math.abs(dFV) )
{
xCopy = true;
} break;
case 'extended':
if ( q == false )
{
var sVerFull=sFV.split('.');
var dVerFull=dFV.split('.');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -