forked from jcubic/jquery.terminal-www
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiple-interpreters-demo.html
More file actions
114 lines (112 loc) · 4.71 KB
/
Copy pathmultiple-interpreters-demo.html
File metadata and controls
114 lines (112 loc) · 4.71 KB
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
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>JSON-RPC Demo for JQuery Terminal Emulator</title>
<meta name="author" content="Jakub Jankiewicz - jcubic@onet.pl"/>
<meta name="Description" content="Demonstration for JQuery Terminal Emulator using call automaticly JSON-RPC service (in php) with authentication."/>
<link rel="shortcut icon" href="favicon.ico"/>
<script src="https://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="https://unpkg.com/jquery.terminal/js/jquery.mousewheel-min.js"></script>
<script src="https://unpkg.com/jquery.terminal/js/jquery.terminal.min.js"></script>
<link href="https://unpkg.com/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/js-polyfills/keyboard.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<script>
jQuery(function($) {
var id = 1;
$('body').terminal(function(command, term) {
if (command == 'help') {
term.echo("available commands are mysql, js, test");
} else if (command == 'test'){
term.push(function(command, term) {
if (command == 'help') {
term.echo('if you type ping it will display pong');
} else if (command == 'ping') {
term.echo('pong');
} else {
term.echo('unknown command ' + command);
}
}, {
prompt: 'test> ',
name: 'test'
});
} else if (command == "js") {
term.push(function(command, term) {
var result = window.eval(command);
if (result != undefined) {
term.echo(String(result));
}
}, {
name: 'js',
prompt: 'js> '
});
} else if (command == 'mysql') {
term.push(function(command, term) {
term.pause();
$.jrpc("mysql-rpc-demo.php",
"query",
[command],
function(data) {
term.resume();
if (data.error) {
if (data.error.error && data.error.error.message) {
term.error(data.error.error.message);
} else if (data.error.message) {
term.error(data.error.message);
}
} else {
if (typeof data.result == 'boolean') {
term.echo(data.result ? 'success' : 'fail');
} else {
var len = data.result.length;
for(var i=0;i<len; ++i) {
term.echo(data.result[i].join(' | '));
}
}
}
},
function(xhr, status, error) {
term.error('[AJAX] ' + status +
' - Server reponse is: \n' +
xhr.responseText);
term.resume();
});
}, {
greetings: "This is example of using mysql from terminal\n\
you are allowed to execute: select, insert, update and delete from/to table:\n\
table test(integer_value integer, varchar_value varchar(255))",
prompt: "mysql> "});
} else {
term.echo("unknow command " + command);
}
}, {
greetings: "multiple terminals demo use help to see available commands",
completion: ['mysql', 'js', 'test', 'help']
});
});
</script>
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwik.jcubic.pl/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '3']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
<noscript>
<!-- Matomo Image Tracker-->
<img src="https://piwik.jcubic.pl/matomo.php?idsite=3&rec=1" style="border:0" alt="" />
<!-- End Matomo -->
</noscript>
</body>
</html>