forked from jcubic/jquery.terminal-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtilda-demo.html
126 lines (118 loc) · 3.84 KB
/
tilda-demo.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
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Quake like teminal - JQuery Terminal Emulator Demo</title>
<meta name="Description" content="This is demonstration of JQuery Terminal Emulator Plugin. To run terminal type tilda on you keyboard."/>
<script src="https://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="/js/jquery.mousewheel-min.js"></script>
<script src="/js/jquery.terminal.min.js"></script>
<script src="https://rawgit.com/cvan/keyboardevent-key-polyfill/master/index.js"></script>
<link href="/css/jquery.terminal.min.css" rel="stylesheet"/>
<!--[if IE]>
<style>
body {
margin: 0;
padding: 0;
}
.tilda {
position: absolute;
}
</style>
<script>
jQuery(document).ready(function($) {
$(window).scroll(function() {
$('.tilda').each(function() {
$(this).css({top: $('body').prop('scrollTop')});
});
});
});
</script>
<![endif]-->
<script>
keyboardeventKeyPolyfill.polyfill();
String.prototype.strip = function(char) {
return this.replace(new RegExp("^" + char + "*"), '').
replace(new RegExp(char + "*$"), '');
}
$.extend_if_has = function(desc, source, array) {
for (var i=array.length;i--;) {
if (typeof source[array[i]] != 'undefined') {
desc[array[i]] = source[array[i]];
}
}
return desc;
};
(function($) {
$.fn.tilda = function(eval, options) {
if ($('body').data('tilda')) {
return $('body').data('tilda').terminal;
}
this.addClass('tilda');
options = options || {};
eval = eval || function(command, term) {
term.echo("you don't set eval for tilda");
};
var settings = {
prompt: 'tilda> ',
name: 'tilda',
height: 100,
enabled: false,
greetings: 'Quake like console',
keypress: function(e) {
if (e.which == 96) {
return false;
}
}
};
if (options) {
$.extend(settings, options);
}
this.append('<div class="td"></div>');
var self = this;
self.terminal = this.find('.td').terminal(eval, settings);
var focus = false;
$(document.documentElement).keypress(function(e) {
if (e.which == 96) {
self.slideToggle('fast');
self.terminal.focus(focus = !focus);
self.terminal.attr({
scrollTop: self.terminal.attr("scrollHeight")
});
}
});
$('body').data('tilda', this);
this.hide();
return self;
};
})(jQuery);
//--------------------------------------------------------------------------
jQuery(document).ready(function($) {
$('#tilda').tilda(function(command, terminal) {
terminal.echo('you type command "' + command + '"');
});
});
</script>
</head>
<body>
<div id="tilda"></div>
<h1>This is demo of JQuery Terminal Emulator, type tilda to open terminal</h1>
<!-- Piwik -->
<script type="text/javascript">
if (location.host == 'terminal.jcubic.pl') {
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.jcubic.pl/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
}
</script>
<noscript><p><img src="https://piwik.jcubic.pl/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>