Debian Codegraph @

Docs/src/chmlink.js

raw
1 function FolderExists(fn)
2 {
3 /*@cc_on @*/
4 /*@if (@_jscript_version >= 5)
5 try
6 {
7 var objShell = new ActiveXObject("Shell.Application");
8 var fso = new ActiveXObject("Scripting.FileSystemObject");
9 return fso.FolderExists(fn);
10 }
11 catch(e) { }
12 /*@end @*/
13 return false;
14 }
15
16 function FileExists(fn)
17 {
18 /*@cc_on @*/
19 /*@if (@_jscript_version >= 5)
20 try
21 {
22 var fso = new ActiveXObject("Scripting.FileSystemObject");
23 return fso.FileExists(fn);
24 }
25 catch(e) { }
26 /*@end @*/
27 return true;
28 }
29
30 function TryShellExec(fn)
31 {
32 /*@cc_on @*/
33 /*@if (@_jscript_version >= 5)
34 try
35 {
36 var objShell = new ActiveXObject("Shell.Application");
37 objShell.ShellExecute(fn, "", "", "open", 1);
38 return true;
39 }
40 catch(e) { }
41 /*@end @*/
42 return false;
43 }
44
45 function parser(fn)
46 {
47 var X, Y, sl, a, ra, re;
48 ra = /:/;
49 a = location.href.search(ra);
50 if (a == 2)
51 X = 14;
52 else
53 X = 7;
54 sl = "\\";
55 Y = location.href.lastIndexOf(sl) + 1;
56 /*@cc_on @*/
57 /*@if (@_jscript_version >= 5)
58 try
59 {
60 var fso = new ActiveXObject("Scripting.FileSystemObject");
61 }
62 catch(e)
63 {
64 if (fn.substring(0, 3) == "../")
65 {
66 fn = fn.substring(3);
67 }
68 }
69 @else @*/
70 if (fn.substring(0, 3) == "../")
71 {
72 fn = fn.substring(3);
73 }
74 /*@end @*/
75 lfn = location.href.substring(X, Y) + fn;
76 re = /%20/g;
77 lfn = lfn.replace(re, " ");
78 re = /\//g;
79 lfn = lfn.replace(re, "\\");
80
81 if (FolderExists(lfn))
82 {
83 if (!TryShellExec(lfn))
84 {
85 var objShell = new ActiveXObject("Shell.Application");
86 objShell.Open(lfn);
87 }
88 }
89 else if (FileExists(lfn))
90 {
91 execed = false;
92 htmlre = /\.html?$/;
93 txtre = /\.txt$/;
94 if (!lfn.match(htmlre) && !lfn.match(txtre))
95 {
96 execed = TryShellExec(lfn);
97 }
98 if (!execed)
99 {
100 re = /\\/g;
101 lfn = lfn.replace(re, "/");
102 re = /\ /g;
103 lfn = lfn.replace(re, "%20");
104 location.href = 'file:///' + lfn;
105 }
106 }
107 else if (fn.substring(0, 3) == "../")
108 {
109 parser(fn.substring(3));
110 }
111 else
112 {
113 alert(fn + " doesn't exist");
114 }
115 }