-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
174 lines (158 loc) · 6.7 KB
/
index.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Terminal</title>
<!-- Tailwind CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/xterm/dist/xterm.min.css" rel="stylesheet">
<!-- Xterm.js -->
<script src="https://cdn.jsdelivr.net/npm/xterm/dist/xterm.min.js" defer></script>
<style>
.terminal-container {
max-width: 800px;
margin: 40px auto;
border-radius: 10px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
background-color: #1f2937;
/* Tailwind Gray 800 */
padding: 20px;
}
.terminal-input {
width: 100%;
background-color: #374151;
/* Tailwind Gray 700 */
border: none;
border-radius: 5px;
padding: 10px;
color: #d1d5db;
/* Tailwind Gray 300 */
margin-top: 10px;
transition: background-color 0.3s ease;
}
.terminal-input:focus {
outline: none;
background-color: #4b5563;
/* Tailwind Gray 600 */
}
</style>
</head>
<body class="bg-gray-900 text-white min-h-screen flex items-center justify-center">
<div class="terminal-container">
<div id="output" class="mb-4"></div>
<input id="input" type="text" class="terminal-input" placeholder="Type a command and press Enter">
</div>
<script type="module" async>
import { Loggings, LoggingsPlugin, Formatter, Colors, Timer, LoggingsColors, console_defaults } from "./dist/cdn.js";
const term = new Terminal({
cols: 80,
rows: 20,
cursorBlink: true,
theme: {
background: '#1f2937', // Tailwind Gray 800
foreground: '#f3f4f6', // Tailwind Gray 100
cursor: '#f3f4f6',
selection: '#9ca3af', // Tailwind Gray 400
black: '#000',
red: '#f87171', // Tailwind Red 400
green: '#34d399', // Tailwind Green 400
yellow: '#fbbf24', // Tailwind Yellow 400
blue: '#60a5fa', // Tailwind Blue 400
magenta: '#c084fc', // Tailwind Purple 400
cyan: '#22d3ee', // Tailwind Cyan 400
white: '#e5e7eb', // Tailwind Gray 200
}
});
term.open(document.getElementById('output'));
const input = document.getElementById("input");
Loggings.add({
identify: "LoggingsConsoleXTerm",
defaults: console_defaults,
onMessage(
options,
current_level,
args,
) {
console.log("evento")
options.level = options.console_level ? options.console_level : options.level;
if (options.console && current_level >= options.level) {
let message_csl = Formatter(options.format)[options.disable_colors ? 1 : 0];
message_csl = Timer(message_csl).format;
if (!options.disable_colors) {
if (message_csl.includes("{title}")) {
message_csl = message_csl.replace(
new RegExp("{title}", 'g'),
Colors(options.color, options.title),
);
}
if (message_csl.includes("{status}")) {
message_csl = message_csl.replace(
new RegExp("{status}", 'g'),
Colors(
options.status[current_level],
Colors("bold", current_level),
),
);
}
if (message_csl.includes("{message}")) {
message_csl = message_csl.replace(
new RegExp("{message}", 'g'),
Formatter(...args)[0],
);
}
} else {
if (message_csl.includes("{title}")) {
message_csl = message_csl.replace(
new RegExp("{title}", 'g'),
options.title,
);
}
if (message_csl.includes("{status}")) {
message_csl = message_csl.replace(
new RegExp("{status}", 'g'),
current_level,
);
}
if (message_csl.includes("{message}")) {
message_csl = message_csl.replace(
new RegExp("{message}", 'g'),
Formatter(...args)[1],
);
}
}
term.write(message_csl + "\r\n");
}
}
})
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms))
const messages = [
"[Welcome].green to the [Loggings].green-b test [environment].green!",
"[Loggings].green is an advanced logging system, offering full support for [different colors].red.",
"It allows for more detailed terminal control and is also capable of [storing logs].blue in files.",
"[Explore the features and see how Loggings can enhance your logging experience.].magenta",
"Use 'help' to view colors"
];
for await (const message of messages) {
Loggings.log(message + "\r");
await delay(1000);
}
input.addEventListener("keypress", (e) => {
if (e.key === "Enter") {
if (["help", "ajuda"].includes(input.value)) {
input.value = "";
logger.log("Colors Supported:");
for (const color in LoggingsColors) {
if (["reset", "none"].includes(color)) continue;
logger.log(`[example].${LoggingsColors[color]}${color}${LoggingsColors.reset}(-b for bold)`);
}
return;
}
const text = input.value;
input.value = "";
logger.log(text);
}
});
</script>
</body>
</html>