-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathui.js
182 lines (176 loc) · 5.77 KB
/
ui.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//------------------------------------------------------------------------------------------------------------------------------------------
/**
* For all html links (a) with class 'reference', if clicked, trigger another link as per the data-reference tag
*/
$( "a.reference" ).click(function() {
var reference=this.getAttribute('data-reference')
if (reference != null){
console.log('Triggered ' + reference)
$(reference).trigger('click');
}
});
/**
* For all html links (a) without a class or id, open the url as specified in the 'href' attribute
*/
// $( "a.weblink" ).click(function() {
$( "a:not([class])a:not([id]), a.uri" ).click(function() {
url = this.getAttribute('href')
if (url != null){
openURL(url)
}
});
/**
* For all html links (a) with class 'powershell' invoke the powershell command encased in comment strings <!--POWERSHELLCODE-->
*/
$( "a.powershell" ).click(function() {
var command_string = ''
var test = this.innerHTML.match(/<!--[\s\S]*-->/)
if (test != null){
var regex = /<!--|-->/gi;
command_string = test[0].replace(regex,'')
}else {
command_string = heredoc(function () {/*
'You must specify powershell commands for this link by encasing these in comment strings'
'e.g.'
'<a href="#" class="powershell">'
'<!--'
'Hello World!'
'-->'
'</a>'
&pause
*/});
alert(command_string)
return
}
var pause=this.getAttribute('data-pause')
if (pause != 1){
pause = 0
}
var interactive=this.getAttribute('data-interactive')
if (interactive != 0){
interactive = 1
}
$(this).toggleClass('clicked');
powershell(command_string, interactive, pause);
$(this).toggleClass('clicked');
});
//------------------------------------------------------------------------------------------------------------------------------------------
/**
* For all html links (a) with class 'shell' invoke the shell as encased in comment strings <!--SHELL-->
*/
$( "a.shell" ).click(function() {
command_string = ''
var test = this.innerHTML.match(/<!--[\s\S]*-->/)
if (test != null){
var regex = /<!--|-->/gi;
command_string = test[0].replace(regex,'')
}
var cmd_keep_open=$(this).data('cmdKeepOpen')
var cmd_new_window=$(this).data('cmdNewWindow')
var program_window_style=$(this).data('windowStyle')
var wait_for_exit=$(this).data('wait')
cmd_keep_open = (cmd_keep_open == 1) ? '/k':'/c'
cmd_new_window = (cmd_new_window == 1) ? 'start \"\"':''
// Specify WScript.Shell .Run parameters
// Read more: .Run - VBScript - SS64.com
// https://ss64.com/vb/run.html
program_window_style = (program_window_style != null) ? program_window_style:1
wait_for_exit = (wait_for_exit == 1) ? true:false
shell('cmd.exe', command_string, cmd_keep_open, cmd_new_window, program_window_style, wait_for_exit)
});
//------------------------------------------------------------------------------------------------------------------------------------------
/**
* For all html links (a) with class 'cmd' invoke the cmd command encased in comment strings <!--CMDCODE-->
*/
$( "a.cmd" ).click(function() {
command_string = ''
if (test != null){
var regex = /<!--|-->/gi;
command_string = test[0].replace(regex,'')
}else {
command_string = heredoc(function () {/*
'You must specify cmd commands for this link by encasing these in comment strings'
'e.g.'
'<a href="#" class="cmd">'
'<!--'
'Hello World!'
'-->'
'</a>'
&pause
*/});
alert(command_string)
return
}
cmd(command_string, 0);
});
//------------------------------------------------------------------------------------------------------------------------------------------
/**
* html link (a) with id 'powershell_hello' triggers a test powershell command
*/
$("#powershell_hello").click(function(e) {
e.preventDefault();
var command_string = heredoc(function () {/*
'Hello from Powershell!'
*/});
powershell(command_string, 0);
});
/**
* For html links with class 'menu-toggle', if clicked, toggle the left navigation menu
*/
$("a.menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
/**
* For the html link with id 'about', if clicked, show the 'about' message
*/
$("a[id='about']").click(function(e) {
console.log("clicked 'About' link")
var test = this.innerHTML.match(/<!--[\s\S]*-->/)
if (test != null){
var regex = /<!--|-->/gi;
about_string = test[0].replace(regex,'')
alert(about_string)
}
});
/**
* For the html link with id 'home', if clicked, hide all divs with class 'section', show the div with id 'start'
*/
$( "a[id='home'], a[id='topnav-home']" ).click(function() {
$(".section, section").hide();
$("div#start").show();
});
/**
* For html links with class 'section_link', if clicked, hide the div with id 'start', show the div we just clicked
*/
$( ".section_link" ).click(function() {
$("div#start").hide();
$(".section, section").hide();
$("section#".concat(this.id)).show();
});
/**
* For html links with class 'flash', if clicked, flash the dom object as specified by the 'data-selector' html tag
*/
$( "a.flash" ).click(function() {
var selector = this.getAttribute('data-selector')
var duration = this.getAttribute('data-duration')
if (duration == null){
duration = 100
}
if (selector != null){
flash(selector, duration);
}
});
/**
* For the html link with id 'console', if clicked, show the hta console
*/
$("a[id='console']").click(function(e) {
htaConsole.toggle()
});
/**
* For the html link with id 'runas', if clicked, relaunch the HTA as admin
*/
$("a[id='elevate']").click(function(e) {
run_as_admin()
});
//------------------------------------------------------------------------------------------------------------------------------------------