Lashtw commited on
Commit
046f2a2
·
verified ·
1 Parent(s): 6ca9732

Upload 9 files

Browse files
Files changed (1) hide show
  1. src/views/InstructorView.js +21 -0
src/views/InstructorView.js CHANGED
@@ -110,6 +110,9 @@ export async function renderInstructorView() {
110
  <div id="room-info" class="hidden flex items-center space-x-2 bg-black/30 px-3 py-1 rounded-lg border border-gray-700">
111
  <span class="text-xs text-gray-500 uppercase">Room</span>
112
  <span id="display-room-code" class="text-xl font-mono font-bold text-cyan-400 tracking-widest"></span>
 
 
 
113
  </div>
114
  </div>
115
 
@@ -643,6 +646,24 @@ export function setupInstructorEvents() {
643
  });
644
  }
645
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
646
  // Modal Events
647
  window.closeBroadcast = () => {
648
  const modal = document.getElementById('broadcast-modal');
 
110
  <div id="room-info" class="hidden flex items-center space-x-2 bg-black/30 px-3 py-1 rounded-lg border border-gray-700">
111
  <span class="text-xs text-gray-500 uppercase">Room</span>
112
  <span id="display-room-code" class="text-xl font-mono font-bold text-cyan-400 tracking-widest"></span>
113
+ <button id="leave-room-btn" class="ml-2 bg-red-900/50 hover:bg-red-800 text-red-300 hover:text-white px-2 py-0.5 rounded text-xs border border-red-800/50 transition-colors" title="離開教室">
114
+ 🚪 離開
115
+ </button>
116
  </div>
117
  </div>
118
 
 
646
  });
647
  }
648
 
649
+ // Leave Room Logic
650
+ document.getElementById('leave-room-btn').addEventListener('click', () => {
651
+ if (confirm('確定要離開目前教室嗎?(不會刪除教室資料,僅回到選擇介面)')) {
652
+ // UI Reset
653
+ createContainer.classList.remove('hidden');
654
+ roomInfo.classList.add('hidden');
655
+ dashboardContent.classList.add('hidden');
656
+
657
+ // State Clear
658
+ sessionStorage.removeItem('vibecoding_instructor_in_room');
659
+ localStorage.removeItem('vibecoding_instructor_room');
660
+
661
+ // Reload to clear listeners/subscriptions effectively
662
+ // Or we could implement an unsubscribe, but reload is safer for quick implementation
663
+ window.location.reload();
664
+ }
665
+ });
666
+
667
  // Modal Events
668
  window.closeBroadcast = () => {
669
  const modal = document.getElementById('broadcast-modal');