DSDUDEd commited on
Commit
9b1c89f
·
verified ·
1 Parent(s): f91a993

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +23 -21
script.js CHANGED
@@ -15,6 +15,13 @@ document.addEventListener("DOMContentLoaded", () => {
15
  const appsContainer = document.getElementById("ai-apps-container");
16
  const modal = document.getElementById("settings-modal");
17
 
 
 
 
 
 
 
 
18
  // Create Comments container
19
  const commentsContainer = document.createElement("div");
20
  commentsContainer.id = "comments-container";
@@ -23,6 +30,7 @@ document.addEventListener("DOMContentLoaded", () => {
23
  commentsContainer.style.maxHeight = "200px";
24
  commentsContainer.style.overflowY = "auto";
25
  chatSection.appendChild(commentsContainer);
 
26
 
27
  // ------------------
28
  // Helper Functions
@@ -84,11 +92,11 @@ document.addEventListener("DOMContentLoaded", () => {
84
  chatSection.style.display = "block";
85
  aiAppsSection.style.display = "block";
86
 
87
- // Load existing comments
88
  loadComments();
89
 
90
- // Fullscreen
91
- document.documentElement.requestFullscreen?.();
 
92
  return true;
93
  } else {
94
  localStorage.removeItem("jwtToken");
@@ -123,14 +131,14 @@ document.addEventListener("DOMContentLoaded", () => {
123
  else {
124
  token = data.token;
125
  localStorage.setItem("jwtToken", token);
126
- alert("✅ " + data.message);
127
  loginForm.style.display = "none";
128
  chatSection.style.display = "block";
129
  aiAppsSection.style.display = "block";
130
 
131
  loadAIApps();
132
  loadComments();
133
- document.documentElement.requestFullscreen?.();
 
134
  }
135
  } catch (err) {
136
  alert("❌ Login failed: Could not reach server");
@@ -253,7 +261,7 @@ document.addEventListener("DOMContentLoaded", () => {
253
  async function loadComments() {
254
  if (!token) return;
255
  try {
256
- const res = await fetch("/api/comments/1", { headers: authHeaders() }); // example app_id=1
257
  const data = await res.json();
258
  commentsContainer.innerHTML = "";
259
  if (data && data.length > 0) {
@@ -267,8 +275,8 @@ document.addEventListener("DOMContentLoaded", () => {
267
  }
268
  }
269
 
270
- // Add new comment
271
- commentsContainer.addEventListener("keydown", async (e) => {
272
  if (e.key === "Enter") {
273
  const content = e.target.value.trim();
274
  if (!content) return;
@@ -304,7 +312,7 @@ document.addEventListener("DOMContentLoaded", () => {
304
  });
305
 
306
  // ------------------
307
- // Full HuggingFace UI Removal (header, footer, toolbar, tabs)
308
  // ------------------
309
  function hideHuggingFaceUI() {
310
  const header = document.querySelector("header") || document.querySelector(".css-1c1wz1k");
@@ -312,20 +320,14 @@ document.addEventListener("DOMContentLoaded", () => {
312
  const toolbar = document.querySelector('[data-testid="space-header"]');
313
  const tabStrip = document.querySelector('[data-testid="space-tabs"]');
314
 
315
- let hidden = false;
 
 
 
316
 
317
- if (header) { header.style.display = "none"; hidden = true; }
318
- if (footer) { footer.style.display = "none"; hidden = true; }
319
- if (toolbar) { toolbar.style.display = "none"; hidden = true; }
320
- if (tabStrip) { tabStrip.style.display = "none"; hidden = true; }
321
-
322
- // HF dynamically re-renders → keep checking
323
- if (!hidden) {
324
- setTimeout(hideHuggingFaceUI, 300);
325
- }
326
  }
327
 
328
- // Start hiding loop
329
  hideHuggingFaceUI();
330
  });
331
-
 
15
  const appsContainer = document.getElementById("ai-apps-container");
16
  const modal = document.getElementById("settings-modal");
17
 
18
+ // Comments input
19
+ const commentInput = document.createElement("input");
20
+ commentInput.id = "comment-input";
21
+ commentInput.placeholder = "Type comment and press Enter";
22
+ commentInput.style.width = "100%";
23
+ commentInput.style.marginTop = "5px";
24
+
25
  // Create Comments container
26
  const commentsContainer = document.createElement("div");
27
  commentsContainer.id = "comments-container";
 
30
  commentsContainer.style.maxHeight = "200px";
31
  commentsContainer.style.overflowY = "auto";
32
  chatSection.appendChild(commentsContainer);
33
+ chatSection.appendChild(commentInput);
34
 
35
  // ------------------
36
  // Helper Functions
 
92
  chatSection.style.display = "block";
93
  aiAppsSection.style.display = "block";
94
 
 
95
  loadComments();
96
 
97
+ // Request fullscreen safely
98
+ setTimeout(() => document.documentElement.requestFullscreen?.(), 500);
99
+
100
  return true;
101
  } else {
102
  localStorage.removeItem("jwtToken");
 
131
  else {
132
  token = data.token;
133
  localStorage.setItem("jwtToken", token);
 
134
  loginForm.style.display = "none";
135
  chatSection.style.display = "block";
136
  aiAppsSection.style.display = "block";
137
 
138
  loadAIApps();
139
  loadComments();
140
+
141
+ setTimeout(() => document.documentElement.requestFullscreen?.(), 500);
142
  }
143
  } catch (err) {
144
  alert("❌ Login failed: Could not reach server");
 
261
  async function loadComments() {
262
  if (!token) return;
263
  try {
264
+ const res = await fetch("/api/comments/1", { headers: authHeaders() });
265
  const data = await res.json();
266
  commentsContainer.innerHTML = "";
267
  if (data && data.length > 0) {
 
275
  }
276
  }
277
 
278
+ // Add new comment from input
279
+ commentInput.addEventListener("keydown", async (e) => {
280
  if (e.key === "Enter") {
281
  const content = e.target.value.trim();
282
  if (!content) return;
 
312
  });
313
 
314
  // ------------------
315
+ // Full HuggingFace UI Removal
316
  // ------------------
317
  function hideHuggingFaceUI() {
318
  const header = document.querySelector("header") || document.querySelector(".css-1c1wz1k");
 
320
  const toolbar = document.querySelector('[data-testid="space-header"]');
321
  const tabStrip = document.querySelector('[data-testid="space-tabs"]');
322
 
323
+ if (header) header.style.display = "none";
324
+ if (footer) footer.style.display = "none";
325
+ if (toolbar) toolbar.style.display = "none";
326
+ if (tabStrip) tabStrip.style.display = "none";
327
 
328
+ // Recheck in case HF re-renders
329
+ setTimeout(hideHuggingFaceUI, 500);
 
 
 
 
 
 
 
330
  }
331
 
 
332
  hideHuggingFaceUI();
333
  });