@php
use App\Models\Url;
$urls = Url::first();
@endphp
{{-- ✅ REPLACED: Monaco -> Ace --}}
@php
use App\Helpers\StudentHelper;
$logoPath = StudentHelper::collegeLogo();
$ctitle = StudentHelper::collegeCtitle();
$ptitle = StudentHelper::collegePtitle();
$logoExists = $logoPath && file_exists(storage_path('app/public/' . $logoPath));
@endphp
@yield('ctitle', $ptitle)
\n`, -1);
cssEditor.setValue(`/* Your CSS code here */`, -1);
jsEditor.setValue(`// Your JavaScript code here`, -1);
}
}
/* Ping Test (unchanged) */
function testPing() {
const start = performance.now();
fetch("https://www.gstatic.com/generate_204", { mode: "no-cors" })
.then(() => updatePingUI(Math.round(performance.now() - start)))
.catch(() => updatePingUI(1000));
}
function updatePingUI(ping) {
const wifiIcon = document.getElementById("wifi-icon");
const pingCount = document.getElementById("ping-count");
if (ping >= 999) {
wifiIcon.classList.remove("text-green-500");
wifiIcon.classList.add("text-red-500");
pingCount.innerText = "999+";
} else {
wifiIcon.classList.remove("text-red-500");
wifiIcon.classList.add("text-green-500");
pingCount.innerText = ping + "ms";
}
}
setInterval(testPing, 2000);
/* Block context menu on whole page except our custom menu (updated for Ace) */
document.addEventListener('contextmenu', function(e) {
if (e.target.closest('#custom-editor-context-menu')) return;
const editors = [htmlEditor, cssEditor, jsEditor];
const isInEditor = editors.some(ed => ed && ed.container && ed.container.contains(e.target));
if (isInEditor) {
e.preventDefault();
e.stopPropagation();
}
}, true);
/* ==================== NEW FEATURES (unchanged behavior, updated allow-list to Ace) ==================== */
// 1. Disable text selection on the entire page
document.addEventListener('selectstart', function(e) {
e.preventDefault();
return false;
});
// Also disable selection via CSS (updated: allow inside Ace)
document.head.insertAdjacentHTML('beforeend', `
`);
// 2. Modified automatic back navigation - DON'T trigger if popups are open
let lastBlurTime = Date.now();
let isSubmitting = false;
function arePopupsOpen() { return popupWindows.length > 0; }
window.addEventListener('blur', function() {
lastBlurTime = Date.now();
setTimeout(function() {
if (Date.now() - lastBlurTime >= 1000 &&
!isSubmitting &&
!hasSubmittedBack &&
!arePopupsOpen()) {
autoSubmitBack();
}
}, 1000);
});
window.addEventListener('focus', function() {
lastBlurTime = Date.now();
});
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
lastBlurTime = Date.now();
setTimeout(function() {
if (document.hidden &&
!isSubmitting &&
!hasSubmittedBack &&
!arePopupsOpen()) {
autoSubmitBack();
}
}, 1000);
}
});
function autoSubmitBack() {
if (hasSubmittedBack) return;
hasSubmittedBack = true;
isSubmitting = true;
const backForm = document.createElement('form');
backForm.method = 'POST';
backForm.action = "{{ route('student.course.allocatedquestions') }}";
backForm.style.display = 'none';
const csrfInput = document.createElement('input');
csrfInput.type = 'hidden';
csrfInput.name = '_token';
csrfInput.value = "{{ csrf_token() }}";
backForm.appendChild(csrfInput);
const courseInput = document.createElement('input');
courseInput.type = 'hidden';
courseInput.name = 'coursename';
courseInput.value = "{{ $course_id }}";
backForm.appendChild(courseInput);
const moduleInput = document.createElement('input');
moduleInput.type = 'hidden';
moduleInput.name = 'module';
moduleInput.value = "{{ $module_id }}";
backForm.appendChild(moduleInput);
const topicInput = document.createElement('input');
topicInput.type = 'hidden';
topicInput.name = 'topic';
topicInput.value = "{{ $topic_id }}";
backForm.appendChild(topicInput);
document.body.appendChild(backForm);
backForm.submit();
}
// Block Ctrl+A globally
document.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && e.keyCode === 65) {
e.preventDefault();
e.stopPropagation();
return false;
}
}, true);
// Prevent any programmatic selection (updated for Ace)
document.addEventListener('selectionchange', function() {
const selection = window.getSelection();
if (selection && !selection.isCollapsed) {
const editors = [htmlEditor, cssEditor, jsEditor];
const isInEditor = editors.some(ed => ed && ed.container && (selection.anchorNode && ed.container.contains(selection.anchorNode)));
if (!isInEditor) selection.removeAllRanges();
}
});
// Prevent drag selection
document.addEventListener('mousedown', function(e) {
if (e.shiftKey || e.ctrlKey) {
const editors = [htmlEditor, cssEditor, jsEditor];
const isInEditor = editors.some(ed => ed && ed.container && ed.container.contains(e.target));
if (!isInEditor) e.preventDefault();
}
}, true);
// Prevent text selection via double click
document.addEventListener('dblclick', function(e) {
const editors = [htmlEditor, cssEditor, jsEditor];
const isInEditor = editors.some(ed => ed && ed.container && ed.container.contains(e.target));
if (!isInEditor) e.preventDefault();
}, true);
// Monitor for popup opening from submit button (unchanged)
const originalSubmitCode = window.submitCode;
window.submitCode = function() {
const data = {
uname: "{{ $uname }}",
cname: "{{ $cname }}",
dept: "{{ $dept }}",
batch: "{{ $batch }}",
course_id: "{{ $course_id }}",
module_id: "{{ $module_id ?? '' }}",
topic_id: "{{ $topic_id }}",
student_id: "{{ $student_id }}",
question_id: "{{ $qid }}",
current_url: window.location.href,
return_route: "{{ route('student.course.compiler.html') }}",
csrf_token: "{{ csrf_token() }}",
coding_id: "{{ $qid }}",
fullscreen: "true"
};
const screenWidth = 1000;
const screenHeight = 700;
const popup = window.open('', 'submitWindow', `width=${screenWidth},height=${screenHeight},left=100,top=50,resizable=yes,scrollbars=yes`);
if (!popup) {
alert("Popup blocked! Please allow popups for this site.");
return;
}
popupWindows.push(popup);
const evaluationUploadUrl = @json($urls?->studentweb);
const form = popup.document.createElement('form');
form.method = 'POST';
if (evaluationUploadUrl) {
form.action = evaluationUploadUrl;
} else {
alert('Evaluation upload URL not configured. Contact admin.');
return;
}
form.target = '_self';
for (const key in data) {
const input = popup.document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = data[key];
form.appendChild(input);
}
popup.document.body.appendChild(form);
form.submit();
const checkPopup = setInterval(() => {
if (popup.closed) {
clearInterval(checkPopup);
const index = popupWindows.indexOf(popup);
if (index > -1) popupWindows.splice(index, 1);
}
}, 1000);
};