-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample.html
94 lines (89 loc) · 3.16 KB
/
example.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Cmd example</title>
<link rel="stylesheet" type="text/css" href="dist/css/cmd.min.css">
<style type="text/css">
body {
background-color: #444;
}
#cmd1, #cmd2 {
width: 600px;
height: 200px;
margin: 10px;
}
</style>
</head>
<body>
<div id="cmd1"></div>
<div id="cmd2"></div>
<button>Invert</button>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="dist/js/cmd.min.js"></script>
<script type="text/javascript">
var interface1 = new Cmd({
selector: '#cmd1',
dark_css: 'dist/cmd_dark.min.css',
light_css: 'dist/cmd_light.min.css',
history_id: 'interface1'
});
var interface2 = new Cmd({
selector: '#cmd2',
dark_css: 'dist/cmd_dark.min.css',
light_css: 'dist/cmd_light.min.css',
history_id: 'interface2',
tabcomplete_url: 'tabcomplete.json',
remote_cmd_list_url: 'commands.json',
external_processor: function(input, cmd) {
if (input === 'test') {
setTimeout(function() {
cmd.handleResponse({
cmd_out: 'Success!'
});
}, 1000);
return true;
} else if (input === 'foo') {
return 'String style return.';
} else if (input === 'text') {
return 'This is normal text. This is <em>italic</em> text. This is <em>bold</em> text.';
} else if (input === 'bar') {
return {
cmd_out: 'Object style return.'
};
} else if (input === 'long') {
return 'This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. This is a really long output. '
} else if (input === 'autofill') {
return '<span data-type="autofill" data-autofill="here is some text">click me</span>';
} else if (input === 'password') {
return {
cmd_out: 'Type in a password. Type "reset" to return to normal',
show_pass: true
};
} else if (input === 'password-async') {
setTimeout(function() {
cmd.handleResponse({
cmd_out: 'Type in a password. Type "reset" to return to normal.',
show_pass: true
});
}, 100);
return true;
} else if (input === 'reset') {
return {
cmd_out: 'Back to normal',
show_pass: false,
hide_output: true
};
}
}
});
// Customise the prompt string (PS1)
interface1.setPrompt('? ');
// Run an arbitrary command string
$('button').on('click', function () {
interface1.handleInput('invert');
interface2.handleInput('invert');
});
</script>
</body>
</html>