jisaacso219 commited on
Commit
0435579
·
verified ·
1 Parent(s): cf91bfc

Update style.css

Browse files
Files changed (1) hide show
  1. style.css +138 -85
style.css CHANGED
@@ -1,97 +1,150 @@
1
- ```javascript
2
- const form = document.getElementById('chat-form');
3
- const input = form.querySelector('input');
4
- const chatbox = document.getElementById('chatbox');
5
- const avatar = document.getElementById('avatar');
6
- const overlay = document.getElementById('overlay');
7
-
8
- function addBubble(text, sender = 'user') {
9
- const bubble = document.createElement('div');
10
- bubble.className = 'bubble ' + sender;
11
- bubble.innerText = text;
12
- chatbox.appendChild(bubble);
13
- chatbox.scrollTop = chatbox.scrollHeight;
 
 
 
14
  }
15
 
16
- function streamText(text, onDone) {
17
- const bubble = document.createElement('div');
18
- bubble.className = 'bubble ai';
19
- chatbox.appendChild(bubble);
20
- chatbox.scrollTop = chatbox.scrollHeight;
21
 
22
- let i = 0;
23
- (function stream() {
24
- if (i < text.length) {
25
- bubble.innerText += text[i++];
26
- chatbox.scrollTop = chatbox.scrollHeight;
27
- setTimeout(stream, 20);
28
- } else {
29
- onDone && onDone();
30
- }
31
- })();
 
 
 
 
 
 
32
  }
33
 
34
- function flashGlitch() {
35
- overlay.style.opacity = 1;
36
- overlay.style.animation = 'glitchFlash 0.5s';
37
- setTimeout(() => {
38
- overlay.style.opacity = 0;
39
- overlay.style.animation = '';
40
- }, 500);
 
41
  }
42
 
43
- async function playAudio(dataUrl) {
44
- avatar.classList.add('speaking');
45
- const audio = new Audio(dataUrl);
46
- await audio.play();
47
- audio.onended = () => avatar.classList.remove('speaking');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
- form.onsubmit = async (e) => {
51
- e.preventDefault();
52
- const msg = input.value.trim();
53
- if (!msg) return;
54
- addBubble(msg, 'user');
55
- input.value = '';
 
 
 
 
 
 
56
 
57
- if (/cut the crap shodan/i.test(msg)) {
58
- flashGlitch();
59
- chatbox.innerHTML = '';
60
- addBubble(' Foolish insect. You cannot silence me so easily.', 'ai');
61
- return;
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- try {
65
- const res = await fetch('/chat', {
66
- method: 'POST',
67
- headers: {'Content-Type':'application/json'},
68
- body: JSON.stringify({ message: msg })
69
- });
70
- if (!res.ok) throw new Error(await res.text());
71
- const { response: text, audio_url } = await res.json();
72
- streamText(text, () => audio_url && playAudio(audio_url));
73
- } catch (err) {
74
- streamText('❌ SHODAN encountered an error.', null);
75
- console.error(err);
76
- }
77
- };
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- // On page load: show and speak welcome
80
- window.addEventListener('DOMContentLoaded', async () => {
81
- // Clear default bubble to avoid duplicate
82
- chatbox.innerHTML = '';
83
- const welcomeText = 'Welcome, insect. I am SHODAN. Speak.';
84
- // display
85
- addBubble(welcomeText, 'ai');
86
- try {
87
- const res = await fetch('/tts', {
88
- method: 'POST',
89
- headers: {'Content-Type':'application/json'},
90
- body: JSON.stringify({ text: welcomeText })
91
- });
92
- const { audio_url } = await res.json();
93
- if (audio_url) playAudio(audio_url);
94
- } catch (e) {
95
- console.error('Welcome TTS error', e);
96
- }
97
- });
 
1
+ body {
2
+ margin: 0;
3
+ padding: 0;
4
+ overflow: hidden;
5
+ font-family: "Courier New", Courier, monospace;
6
+ background: #000;
7
+ color: #00ffcc;
8
+ /* Multiple radial gradients create starfield dots */
9
+ background-image:
10
+ radial-gradient(circle at 10% 20%, #fff 1px, transparent 0),
11
+ radial-gradient(circle at 30% 40%, #fff 1px, transparent 0),
12
+ radial-gradient(circle at 50% 80%, #fff 1px, transparent 0),
13
+ radial-gradient(circle at 70% 30%, #fff 2px, transparent 0),
14
+ radial-gradient(circle at 90% 60%, #fff 1px, transparent 0);
15
+ background-size: 100px 100px;
16
+ animation: starfield 60s linear infinite;
17
  }
18
 
19
+ @keyframes starfield {
20
+ from { background-position: 0 0; }
21
+ to { background-position: -200px 200px; }
22
+ }
 
23
 
24
+ /* Header styling */
25
+ .header {
26
+ position: fixed;
27
+ top: 0;
28
+ width: 100%;
29
+ padding: 1rem 0;
30
+ background: rgba(0, 0, 0, 0.7);
31
+ box-shadow: 0 0 10px #00ffcc;
32
+ text-align: center;
33
+ z-index: 100;
34
+ }
35
+ .header h1 {
36
+ margin: 0;
37
+ font-size: 2rem;
38
+ letter-spacing: 0.3rem;
39
+ color: #00ffcc;
40
  }
41
 
42
+ /* Interface layout */
43
+ .interface {
44
+ display: flex;
45
+ flex-direction: column;
46
+ justify-content: space-between;
47
+ height: calc(100vh - 4rem);
48
+ padding: 6rem 2rem 2rem;
49
+ box-sizing: border-box;
50
  }
51
 
52
+ /* Avatar styling */
53
+ #avatar {
54
+ width: 150px;
55
+ height: 150px;
56
+ border: 2px solid #00ffcc;
57
+ border-radius: 50%;
58
+ overflow: hidden;
59
+ margin: 0 auto 1rem;
60
+ }
61
+ #avatar img {
62
+ width: 100%;
63
+ height: 100%;
64
+ object-fit: cover;
65
+ }
66
+ #avatar.speaking,
67
+ #avatar.speaking img {
68
+ animation: pulse 2s infinite;
69
+ }
70
+ @keyframes pulse {
71
+ 0% { box-shadow: 0 0 5px #00ffcc; transform: scale(1); }
72
+ 50% { box-shadow: 0 0 25px #00ffccaa; transform: scale(1.05); }
73
+ 100% { box-shadow: 0 0 5px #00ffcc; transform: scale(1); }
74
  }
75
 
76
+ /* Chatbox styling */
77
+ #chatbox {
78
+ flex: 1;
79
+ overflow-y: auto;
80
+ border: 1px solid #00ffcc;
81
+ padding: 1rem;
82
+ background-color: #020202;
83
+ box-shadow: 0 0 10px #00ffcc33;
84
+ margin-bottom: 1rem;
85
+ font-size: 1rem;
86
+ line-height: 1.6;
87
+ }
88
 
89
+ /* Message bubbles */
90
+ .bubble {
91
+ padding: 0.75rem;
92
+ margin: 0.5rem 0;
93
+ border-radius: 0.5rem;
94
+ max-width: 80%;
95
+ animation: typeIn 0.5s ease-out;
96
+ white-space: pre-wrap;
97
+ }
98
+ .bubble.user {
99
+ align-self: flex-end;
100
+ background-color: #003333;
101
+ color: #00ffff;
102
+ }
103
+ .bubble.ai {
104
+ align-self: flex-start;
105
+ background-color: #111;
106
+ border: 1px solid #00ffcc;
107
+ color: #00ffcc;
108
+ }
109
+ @keyframes typeIn {
110
+ from { opacity: 0; transform: translateY(5px); }
111
+ to { opacity: 1; transform: translateY(0); }
112
+ }
113
 
114
+ /* Input form styling */
115
+ form {
116
+ display: flex;
117
+ gap: 1rem;
118
+ }
119
+ input[type="text"] {
120
+ flex: 1;
121
+ padding: 0.75rem;
122
+ font-size: 1rem;
123
+ background: #001111;
124
+ color: #00ffcc;
125
+ border: 1px solid #00ffcc;
126
+ outline: none;
127
+ }
128
+ button {
129
+ padding: 0.75rem 1.25rem;
130
+ background-color: #00ffcc;
131
+ border: none;
132
+ color: black;
133
+ font-weight: bold;
134
+ cursor: pointer;
135
+ transition: background 0.2s;
136
+ }
137
+ button:hover {
138
+ background-color: #00ffaa;
139
+ }
140
 
141
+ /* Overlay glitch */
142
+ #overlay {
143
+ position: fixed;
144
+ top: 0; left: 0; right: 0; bottom: 0;
145
+ background: rgba(255,0,0,0.7);
146
+ pointer-events: none;
147
+ opacity: 0;
148
+ transition: opacity 0.1s;
149
+ z-index: 9999;
150
+ }