File size: 6,965 Bytes
10470f9 |
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive Terminal and Chat Bot</title>
<!-- jQuery Terminal CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css">
<!-- Chart.js for Visualizations -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- jQuery -->
<script src="https://cdn.jsdelivr.net/npm/jquery"></script>
<!-- jQuery Terminal JS -->
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js"></script>
<style>
body {
margin: 0;
background-color: #000;
color: #0f0;
font-family: monospace;
}
.container {
display: flex;
height: 100vh;
}
#terminal {
flex: 1;
border-right: 2px solid #0f0;
padding: 10px;
}
#chat {
flex: 1;
display: flex;
flex-direction: column;
padding: 10px;
color: #0f0;
}
#chat-messages {
flex: 1;
overflow-y: auto;
margin-bottom: 10px;
padding: 10px;
border: 1px solid #0f0;
background: #111;
}
#chat-input {
display: flex;
}
#chat-input input {
flex: 1;
padding: 5px;
background: #111;
color: #0f0;
border: 1px solid #0f0;
outline: none;
}
#chat-input button {
padding: 5px 10px;
background: #0f0;
color: #000;
border: none;
cursor: pointer;
}
canvas {
display: block;
margin: 10px auto;
}
</style>
</head>
<body>
<div class="container">
<!-- Terminal -->
<div id="terminal"></div>
<!-- Chat System -->
<div id="chat">
<div id="chat-messages"></div>
<div id="chat-input">
<input type="text" id="chat-text" placeholder="Type your message here...">
<button id="send-chat">Send</button>
</div>
</div>
</div>
<canvas id="chart" width="400" height="200"></canvas>
<script>
$(function () {
// Initialize the Terminal
const terminal = $('#terminal').terminal({
echo: function (...args) {
this.echo(args.join(' '));
},
optimize: function (type = 'matrix') {
if (type === 'matrix') {
this.echo('[[;cyan;]Performing Matrix Optimization...\\n]');
this.pause();
setTimeout(() => {
this.echo('Optimization complete: [[;yellow;]98% efficiency achieved]');
drawChart();
this.resume();
}, 2000);
} else {
this.error('Unsupported optimization type');
}
},
status: function () {
this.echo('[[;green;]Fetching statuses...\\n]');
this.echo('BrowserStack: [[;yellow;]Live - 100% uptime]');
this.echo('Coveralls: [[;yellow;]Coverage: 95%]');
},
js: function (code) {
try {
const result = eval(code);
this.echo('Result: ' + result);
} catch (e) {
this.error('Error: ' + e.message);
}
},
help: function () {
this.echo(`
Available commands:
- echo <text> : Echoes the input text
- optimize <type> : Performs optimization (type: matrix)
- status : Fetches statuses of services
- js <code> : Executes JavaScript code
- help : Shows this help message
`);
}
}, {
greetings: '[[;yellow;]Welcome to the Futuristic Interactive Terminal Bot!]',
name: 'interactive_terminal',
prompt: '>> '
});
// Chart.js Visualization
function drawChart() {
const ctx = document.getElementById('chart').getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: ['Start', 'Step 1', 'Step 2', 'Step 3', 'Complete'],
datasets: [{
label: 'Matrix Optimization Efficiency',
data: [10, 40, 70, 85, 98],
borderColor: 'cyan',
borderWidth: 2,
pointBackgroundColor: 'yellow',
fill: false
}]
},
options: {
scales: {
y: { beginAtZero: true }
}
}
});
}
// Chat Functionality
const chatMessages = $('#chat-messages');
const chatInput = $('#chat-text');
$('#send-chat').on('click', function () {
const message = chatInput.val().trim();
if (message) {
appendMessage('You', message);
handleChatBotResponse(message);
chatInput.val('');
}
});
chatInput.on('keypress', function (e) {
if (e.which === 13) {
$('#send-chat').click();
}
});
function appendMessage(sender, message) {
chatMessages.append(`<div><strong>${sender}:</strong> ${message}</div>`);
chatMessages.scrollTop(chatMessages[0].scrollHeight);
}
function handleChatBotResponse(message) {
// Basic chat bot responses
let response = "I'm not sure how to respond to that.";
if (message.toLowerCase().includes('hello')) {
response = "Hi there! How can I help you?";
} else if (message.toLowerCase().includes('status')) {
response = "All systems operational!";
} else if (message.toLowerCase().includes('optimize')) {
response = "Try running `optimize matrix` in the terminal for optimization!";
}
appendMessage('Bot', response);
}
});
</script>
</body>
</html> |