-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
uriloader.js
88 lines (74 loc) · 2.32 KB
/
uriloader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// uriloader.js
// URI scheme loader for WelsonJS framework
// Namhyeon Go <[email protected]>
// https;//github.com/gnh1201/welsonjs
var SYS = require("lib/system");
var SHELL = require("lib/shell");
var URI = require("lib/uri");
var WINLIBS = require("lib/winlibs");
function main(args) {
var uri = args[0];
var pos = uri.indexOf(":///");
if (pos < 0) {
console.log("Not vaild URI scheme");
} else {
var commands = [],
queryString = uri.substring(pos + 4),
query = URI.parseQueryString(queryString);
if (!query.application)
query.application = "";
switch (query.application) {
case "app":
commands.push([
"start",
"/d",
SYS.getCurrentScriptDirectory(),
"app.hta",
uri
]);
break;
case "mscalc":
commands.push([
"calc.exe"
]);
break;
case "msie":
WINLIBS.loadLibrary("url").call("FileProtocolHandler", [
"https://github.com/gnh1201/welsonjs"
]);
break;
case "msexcel":
commands.push([
"%PROGRAMFILES%\\Microsoft Office\\Office15\\EXCEL.EXE"
]);
break;
case "mspowerpoint":
commands.push([
"%PROGRAMFILES%\\Microsoft Office\\Office15\\POWERPNT.EXE"
]);
break;
case "msword":
commands.push([
"%PROGRAMFILES%\\Microsoft Office\\Office15\\WINWORD.EXE"
]);
break;
case "msaccess":
commands.push([
"%PROGRAMFILES%\\Microsoft Office\\Office15\\MSACCESS.EXE"
]);
break;
case "arduino":
commands.push([
"%PROGRAMFILES(X86)%\\Arduino\\arduino.exe"
]);
break;
dafault:
console.log("Unknown application");
}
if (commands.length > 0) {
SHELL.run(commands.pop());
}
}
return 0;
}
exports.main = main;