this should solve any JScript errors by adding exception handling or drop to the simplest and ugliest solution if exception handling is not available
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3342 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ea890d3e2e
commit
d97cc95c6c
2 changed files with 76 additions and 12 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
\cfg{xhtml-contents-depth-0}{5}
|
||||
|
||||
\cfg{xhtml-head-end}{<link rel="stylesheet" href="style.css" type='text/css' /><script language="JScript" src="chmlink.js"></script>}
|
||||
\cfg{xhtml-head-end}{<link rel="stylesheet" href="style.css" type='text/css' /><script language="JavaScript" type="text/javascript" src="chmlink.js"></script>}
|
||||
|
||||
\cfg{xhtml-rlink-prefix}{#" onclick="parser('}
|
||||
|
||||
|
|
|
@ -1,18 +1,56 @@
|
|||
function FolderExists(fn)
|
||||
{
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
return fso.FolderExists(fn);
|
||||
alert("testing for folder " + fn);
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
try
|
||||
{
|
||||
var objShell = new ActiveXObject("Shell.Application");
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
return fso.FolderExists(fn);
|
||||
}
|
||||
catch(e) { }
|
||||
/*@end @*/
|
||||
alert("exception or old version");
|
||||
return false;
|
||||
}
|
||||
|
||||
function FileExists(fn)
|
||||
{
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
return fso.FileExists(fn);
|
||||
alert("testing for file " + fn);
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
try
|
||||
{
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
return fso.FileExists(fn);
|
||||
}
|
||||
catch(e) { }
|
||||
/*@end @*/
|
||||
alert("exception or old version");
|
||||
return true;
|
||||
}
|
||||
|
||||
function TryShellExec(fn)
|
||||
{
|
||||
alert("trying to shell execute " + fn);
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
try
|
||||
{
|
||||
var objShell = new ActiveXObject("Shell.Application");
|
||||
objShell.ShellExecute(fn, "", "", "open", 1);
|
||||
return true;
|
||||
}
|
||||
catch(e) { }
|
||||
/*@end @*/
|
||||
alert("exception or old version");
|
||||
return false;
|
||||
}
|
||||
|
||||
function parser(fn)
|
||||
{
|
||||
var X, Y, sl, a, ra, link;
|
||||
var X, Y, sl, a, ra, re;
|
||||
ra = /:/;
|
||||
a = location.href.search(ra);
|
||||
if (a == 2)
|
||||
|
@ -21,32 +59,58 @@ function parser(fn)
|
|||
X = 7;
|
||||
sl = "\\";
|
||||
Y = location.href.lastIndexOf(sl) + 1;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
try
|
||||
{
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
if (fn.substring(0, 3) == "../")
|
||||
{
|
||||
fn = fn.substring(3);
|
||||
}
|
||||
}
|
||||
@else @*/
|
||||
if (fn.substring(0, 3) == "../")
|
||||
{
|
||||
fn = fn.substring(3);
|
||||
}
|
||||
/*@end @*/
|
||||
lfn = location.href.substring(X, Y) + fn;
|
||||
re = /%20/g;
|
||||
lfn = lfn.replace(re, " ");
|
||||
re = /\//g;
|
||||
lfn = lfn.replace(re, "\\");
|
||||
var objShell = new ActiveXObject("Shell.Application");
|
||||
|
||||
alert("trying to open " + lfn);
|
||||
|
||||
if (FolderExists(lfn))
|
||||
{
|
||||
alert("folder exists, execing");
|
||||
var objShell = new ActiveXObject("Shell.Application");
|
||||
objShell.Open(lfn);
|
||||
}
|
||||
else if (FileExists(lfn))
|
||||
{
|
||||
alert("file exists, execing");
|
||||
execed = false;
|
||||
htmlre = /\.html?$/;
|
||||
txtre = /\.txt$/;
|
||||
if (!("ShellExecute" in objShell) || lfn.match(htmlre) || lfn.match(txtre))
|
||||
if (!lfn.match(htmlre) && !lfn.match(txtre))
|
||||
{
|
||||
execed = TryShellExec(lfn);
|
||||
}
|
||||
if (!execed)
|
||||
{
|
||||
re = /\\/g;
|
||||
lfn = lfn.replace(re, "/");
|
||||
re = /\ /g;
|
||||
lfn = lfn.replace(re, "%20");
|
||||
alert("using normal method " + lfn);
|
||||
location.href = 'file:///' + lfn;
|
||||
}
|
||||
else
|
||||
{
|
||||
objShell.ShellExecute(lfn, "", "", "open", 1);
|
||||
}
|
||||
}
|
||||
else if (fn.substring(0, 3) == "../")
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue