Skip to content

Commit 6a081c9

Browse files
Add language dropdown
1 parent 0b52f4c commit 6a081c9

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

index.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en-US" class="w-full h-full">
2+
<html lang="en-US" class="size-full">
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -78,13 +78,24 @@
7878
<meta name="theme-color" content="#ffffff">
7979
</head>
8080

81-
<body class="flex flex-col w-full h-full text-black bg-white dark:bg-black dark:text-white" style="opacity: 0 !important;">
81+
<body class="flex flex-col text-black bg-white size-full dark:bg-black dark:text-white" style="opacity: 0 !important;">
8282
<header class="flex items-center p-1 space-x-1 judge0-showNavigation">
8383
<a href="https://judge0.com" target="_blank" rel="noopener" tabindex="-1" class="w-8 h-8 rounded-md judge0-showLogo">
8484
<img src="./images/icon_var2_rounded_512.png">
8585
</a>
86-
<input id="judge0-compiler-options" class="h-8 px-3 py-2 text-sm bg-transparent border rounded-md dark:border-zinc-800 max-md:hidden focus-visible:outline-none focus-visible:ring-2 placeholder:text-sm judge0-showCompilerOptions" placeholder="Compiler options" type="text">
87-
<input id="judge0-command-line-arguments" class="h-8 px-3 py-2 text-sm bg-transparent border rounded-md dark:border-zinc-800 max-md:hidden focus-visible:outline-none focus-visible:ring-2 placeholder:text-sm judge0-showCommandLineArguments" placeholder="Command line arguments" type="text">
86+
<div class="max-md:hidden judge0-showSelectLanguage judge0-dropdown">
87+
<button class="flex items-center justify-between h-8 px-2 text-sm text-left bg-transparent border rounded-md judge0-dropdown-btn dark:border-zinc-800 focus-visible:outline-none focus-visible:ring-2">
88+
<span class="overflow-hidden text-nowrap"></span>
89+
<i class="pl-2 text-xs fa-solid fa-chevron-down"></i>
90+
</button>
91+
<div class="absolute hidden mt-1 overflow-y-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:rounded-md [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-md [&::-webkit-scrollbar-thumb]:bg-zinc-200 dark:[&::-webkit-scrollbar-track]:bg-transparent dark:[&::-webkit-scrollbar-thumb]:bg-zinc-700 text-sm bg-white border rounded-md shadow-md judge0-dropdown-menu max-h-1/2 dark:border-zinc-800 dark:bg-black z-50">
92+
<ul class="py-2">
93+
<li class="hidden px-4 py-1 mx-2 rounded-md cursor-pointer judge0-dropdown-option hover:bg-zinc-100 dark:hover:bg-zinc-800"></li>
94+
</ul>
95+
</div>
96+
</div>
97+
<input id="judge0-compiler-options" class="h-8 px-2 text-sm bg-transparent border rounded-md dark:border-zinc-800 max-md:hidden focus-visible:outline-none focus-visible:ring-2 placeholder:text-sm judge0-showCompilerOptions" placeholder="Compiler options" type="text">
98+
<input id="judge0-command-line-arguments" class="h-8 px-2 text-sm bg-transparent border rounded-md dark:border-zinc-800 max-md:hidden focus-visible:outline-none focus-visible:ring-2 placeholder:text-sm judge0-showCommandLineArguments" placeholder="Command line arguments" type="text">
8899
<button id="judge0-run-btn" class="inline-flex items-center justify-center h-8 gap-2 px-4 text-sm font-semibold transition bg-blue-800 rounded-md focus-visible:outline-none focus-visible:ring-2 hover:bg-blue-900 dark:hover:bg-blue-700 text-blue-50 whitespace-nowrap judge0-showRunButton">
89100
<i class="fa-solid fa-play"></i>
90101
Run

js/site.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
"use strict";
2+
23
document.addEventListener("DOMContentLoaded", function () {
34
document.getElementById("judge0-year").innerText = new Date().getFullYear();
45
});
6+
7+
document.body.addEventListener("click", function (event) {
8+
const dropdown = event.target.closest(".judge0-dropdown");
9+
const dropdownBtn = event.target.closest(".judge0-dropdown-btn");
10+
11+
if (event.target && dropdownBtn && dropdownBtn.contains(event.target)) {
12+
dropdown.querySelector(".judge0-dropdown-menu").classList.toggle("hidden");
13+
} else if (event.target && event.target.classList.contains("judge0-dropdown-option")) {
14+
const span = dropdown.querySelector("span");
15+
span.innerText = event.target.innerText;
16+
dropdown.querySelector(".judge0-dropdown-menu").classList.toggle("hidden");
17+
} else {
18+
document.querySelectorAll(".judge0-dropdown-menu").forEach(function (dropdownMenu) {
19+
if (!dropdownMenu.contains(event.target)) {
20+
dropdownMenu.classList.add("hidden");
21+
}
22+
});
23+
}
24+
});

0 commit comments

Comments
 (0)