我有以下工作示例应用程序,它在终端窗口中显示键入文本:
index.php
,style.css
和typed-custom.js
)我有以下内容style.css
:
.terminal-window {
text-align: left;
width: 620px;
height: 650px;
border-radius: 10px;
margin: auto;
position: relative;
}
.terminal-window section.terminal {
color: white;
font-family: Menlo, Monaco, "Consolas", "Courier New", "Courier";
font-size: 11pt;
background: black;
padding: 10px;
box-sizing: border-box;
position: absolute;
width: 100%;
top: 30px;
bottom: 0;
overflow: auto;
}
.term-home{color: #0095ff;}
我有以下内容typed-custom.js
$(function() {
var data = [
{
action: 'type',
strings: ["typing-1:"],
output: '<span class="green"><small> This is first typing</small></span> ',
postDelay: 1000,
},
{
action: 'type',
strings: ["typing-2:"],
output: '<span class="green"><small>This is second typing</small></span> ',
postDelay: 1000
},
];
runScripts(data, 0);
});
function runScripts(data, pos) {
var prompt = $('.prompt'),
script = data[pos];
if(script.clear === true) {
$('.history').html('');
}
switch(script.action) {
case 'type':
// cleanup for next execution
prompt.removeData();
$('.typed-cursor').text('');
prompt.typed({
strings: script.strings,
typeSpeed: 10,
callback: function() {
var history = $('.history').html();
history = history ? [history] : [];
history.push('<span class="term-home">root:~$</span> ' + prompt.text());
if(script.output) {
history.push(script.output);
prompt.html('');
$('.history').html(history.join('<br>'));
}
杨魅力