sh1k4ku commited on
Commit
9d8645a
Β·
verified Β·
1 Parent(s): b89117c

Remove live preview panel from assignment3.html, keep only the force-save button

Browse files
Files changed (1) hide show
  1. assignment3.html +6 -32
assignment3.html CHANGED
@@ -223,22 +223,13 @@ InventoryService PaymentGateway</pre>
223
  </div><!-- /.layout -->
224
  </div>
225
 
226
- <!-- ============ live preview panel ============ -->
227
- <div id="previewPanel" style="display:none;position:fixed;left:0;right:0;bottom:52px;max-height:45vh;overflow:auto;background:#181825;border-top:1px solid var(--border);padding:12px 28px;z-index:9">
228
- <div style="display:flex;align-items:center;gap:10px;margin-bottom:6px">
229
- <b style="font-size:12px;color:var(--muted)">Live preview β€” exactly what Copy/Export will send (updates as you type)</b>
230
- <button class="ghost" id="previewCloseBtn" style="margin-left:auto;padding:2px 10px;font-size:11px">Close</button>
231
- </div>
232
- <pre id="previewJson" style="margin:0;font-size:11px;white-space:pre-wrap"></pre>
233
- </div>
234
-
235
  <!-- ============ sticky export bar ============ -->
236
  <div class="exportbar">
237
  <div class="sid">Student ID <input class="txt" id="studentId" placeholder="z1234567" style="width:130px"></div>
238
  <div class="spacer"></div>
239
  <span class="toast" id="toast"></span>
240
  <button class="ghost" id="clearBtn">Clear saved</button>
241
- <button class="ghost" id="previewBtn">πŸ” Force save &amp; preview</button>
242
  <button class="ghost" id="copyBtn">Copy JSON</button>
243
  <button id="exportBtn">– Export JSON</button>
244
  </div>
@@ -511,32 +502,18 @@ document.getElementById("exportBtn").onclick = () => {
511
  const sid = document.getElementById("studentId").value.trim() || "submission";
512
  a.href = URL.createObjectURL(blob); a.download = `assignment3_${sid}.json`;
513
  a.click(); URL.revokeObjectURL(a.href); toast("Exported βœ“");
514
- if (__previewOpen) renderPreview();
515
  };
516
  document.getElementById("copyBtn").onclick = async () => {
517
  try { await navigator.clipboard.writeText(JSON.stringify(buildJSON(), null, 2)); toast("Copied βœ“"); }
518
  catch(_){ toast("Copy failed"); }
519
- if (__previewOpen) renderPreview();
520
  };
521
 
522
- // ============ live preview / force-save ============
523
- // If you're ever unsure whether Copy/Export reflects your latest edit, use
524
- // this: it immediately (no debounce) writes the session and shows exactly
525
- // the JSON buildJSON() currently computes -- the same data Copy/Export send.
526
- let __previewOpen = false;
527
- function renderPreview(){
528
- document.getElementById("previewJson").textContent = JSON.stringify(buildJSON(), null, 2);
529
- }
530
  document.getElementById("previewBtn").onclick = () => {
531
  flushSession();
532
- renderPreview();
533
- __previewOpen = true;
534
- document.getElementById("previewPanel").style.display = "block";
535
- toast("Saved & previewed βœ“");
536
- };
537
- document.getElementById("previewCloseBtn").onclick = () => {
538
- __previewOpen = false;
539
- document.getElementById("previewPanel").style.display = "none";
540
  };
541
 
542
  // ============ local session (auto-save / restore) ============
@@ -557,10 +534,7 @@ function flushSession(){
557
  }
558
  function saveSession(){
559
  clearTimeout(__saveTimer);
560
- __saveTimer = setTimeout(() => {
561
- flushSession();
562
- if (__previewOpen) renderPreview();
563
- }, 250);
564
  }
565
  function restoreRadio(name, val){
566
  if (!val) return;
 
223
  </div><!-- /.layout -->
224
  </div>
225
 
 
 
 
 
 
 
 
 
 
226
  <!-- ============ sticky export bar ============ -->
227
  <div class="exportbar">
228
  <div class="sid">Student ID <input class="txt" id="studentId" placeholder="z1234567" style="width:130px"></div>
229
  <div class="spacer"></div>
230
  <span class="toast" id="toast"></span>
231
  <button class="ghost" id="clearBtn">Clear saved</button>
232
+ <button class="ghost" id="previewBtn">πŸ’Ύ Force save</button>
233
  <button class="ghost" id="copyBtn">Copy JSON</button>
234
  <button id="exportBtn">– Export JSON</button>
235
  </div>
 
502
  const sid = document.getElementById("studentId").value.trim() || "submission";
503
  a.href = URL.createObjectURL(blob); a.download = `assignment3_${sid}.json`;
504
  a.click(); URL.revokeObjectURL(a.href); toast("Exported βœ“");
 
505
  };
506
  document.getElementById("copyBtn").onclick = async () => {
507
  try { await navigator.clipboard.writeText(JSON.stringify(buildJSON(), null, 2)); toast("Copied βœ“"); }
508
  catch(_){ toast("Copy failed"); }
 
509
  };
510
 
511
+ // ============ force-save ============
512
+ // If you're ever unsure whether Copy/Export reflects your latest edit, click
513
+ // this: it writes the session immediately instead of waiting for the debounce.
 
 
 
 
 
514
  document.getElementById("previewBtn").onclick = () => {
515
  flushSession();
516
+ toast("Saved βœ“");
 
 
 
 
 
 
 
517
  };
518
 
519
  // ============ local session (auto-save / restore) ============
 
534
  }
535
  function saveSession(){
536
  clearTimeout(__saveTimer);
537
+ __saveTimer = setTimeout(flushSession, 250);
 
 
 
538
  }
539
  function restoreRadio(name, val){
540
  if (!val) return;