minor changs here and there, and tried to make aunser work, not working in chrome working in rest!

This commit is contained in:
RezHackXYZ 2025-05-07 21:09:14 +05:30
parent a7fa6d620e
commit 1278b1d975
11 changed files with 1370 additions and 148 deletions

View file

@ -0,0 +1,51 @@
<script>
import { newNames, RandomNamesState } from "./main.svelte";
let names =
RandomNamesState.NotSelectedYet.join("\n") +
"\n" +
RandomNamesState.Selected.join("\n") +
"\n" +
RandomNamesState.Absent.join("\n");
let namesArray = [];
</script>
<div id="root">
<div id="root">
<h1>Edit Names</h1>
<p></p>
<textarea
bind:value={names}
id="box"
onchange={() => {
let namesArray = names.split("\n");
newNames(namesArray);
}}
></textarea>
</div>
</div>
<style>
#root {
display: flex;
flex-direction: column;
gap: 5px;
margin: 10px;
justify-content: center;
background-color: #303030;
padding: 10px;
margin: 20px;
border-radius: 10px;
}
#box {
width: 100%;
height: 500px;
background-color: #121212;
color: white;
border-radius: 10px;
resize: vertical;
font-size: 20px;
}
</style>

View file

@ -7,40 +7,6 @@
</script>
<div id="root">
<div
id="NotSelectedYet"
on:dragover|preventDefault
role="list"
aria-label="drag name to this list!"
on:drop={(event) => {
event.preventDefault();
if (DragTempName !== "na") {
RandomNamesState.NotSelectedYet.push(DragTempName);
DragTempName = "na";
}
}}
>
<h1>Not Selected Yet</h1>
<div class="wrap">
{#each RandomNamesState.NotSelectedYet as name, i}
<span
class="NotSelectedYet"
draggable="true"
role="listitem"
aria-label="drag name to different list!"
on:dragstart={() => {
setTimeout(() => {
RandomNamesState.NotSelectedYet.splice(i, 1);
DragTempName = name;
}, 100);
}}
>
{name}
</span>
{/each}
</div>
</div>
<hr />
<div
id="Selected"
on:dragover|preventDefault
@ -75,6 +41,40 @@
</div>
</div>
<hr />
<div
id="NotSelectedYet"
on:dragover|preventDefault
role="list"
aria-label="drag name to this list!"
on:drop={(event) => {
event.preventDefault();
if (DragTempName !== "na") {
RandomNamesState.NotSelectedYet.push(DragTempName);
DragTempName = "na";
}
}}
>
<h1>Not Selected Yet</h1>
<div class="wrap">
{#each RandomNamesState.NotSelectedYet as name, i}
<span
class="NotSelectedYet"
draggable="true"
role="listitem"
aria-label="drag name to different list!"
on:dragstart={() => {
setTimeout(() => {
RandomNamesState.NotSelectedYet.splice(i, 1);
DragTempName = name;
}, 100);
}}
>
{name}
</span>
{/each}
</div>
</div>
<hr />
<div
id="Absent"
on:dragover|preventDefault

View file

@ -1,49 +1,13 @@
<script module>
import Selector from "./selector.svelte";
import TopDisplay from "./TopDisplay.svelte";
function EditList() {
console.log("Edit list of names");
}
import EditNameOfStudents from "./EditNameOfStudents.svelte";
export let RandomNamesState = $state({
NotSelectedYet: [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"Diana",
"Eve",
"Frank",
"Grace",
"Hank",
],
Selected: [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"Diana",
"Eve",
"Frank",
"Grace",
"Hank",
],
Absent: [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"Diana",
"Eve",
"Frank",
"Grace",
"Hank",
],
selectedStudent: "none :(",
NotSelectedYet: [],
Selected: [],
Absent: [],
selectedStudent: "None yet!",
});
export function SelectStudent() {
@ -53,14 +17,41 @@
);
RandomNamesState.selectedStudent =
RandomNamesState.NotSelectedYet[randomIndex];
RandomNamesState.Selected.push(
RandomNamesState.NotSelectedYet[randomIndex]
);
RandomNamesState.Selected = [
RandomNamesState.NotSelectedYet[randomIndex],
...RandomNamesState.Selected,
];
RandomNamesState.NotSelectedYet.splice(randomIndex, 1);
} else {
alert("All students have been selected.");
}
}
let TabOpen = $state({
v: false,
});
export function newNames(Names) {
localStorage.setItem("Names", JSON.stringify(Names));
RandomNamesState.NotSelectedYet = Names;
RandomNamesState.Selected = [];
RandomNamesState.Absent = [];
RandomNamesState.selectedStudent = "None yet!";
}
let TempelateNames = ["John", "Jane", "Alice", "Bob"];
let TempNames = localStorage.getItem("Names") || "";
if (TempNames != "") {
RandomNamesState.NotSelectedYet = JSON.parse(TempNames);
RandomNamesState.Selected = [];
RandomNamesState.Absent = [];
RandomNamesState.selectedStudent = "None yet!";
} else {
newNames($state.snapshot(TempelateNames));
}
</script>
<div id="wrap">
@ -81,9 +72,11 @@
</span></button
></a
>
<h1>Random Name</h1>
<h1>Random student selector</h1>
<div>
<button aria-label="Back to main menu" onclick={() => EditList()}
<button
aria-label="Back to main menu"
onclick={() => (TabOpen.v = true)}
><span class="front"
><svg
xmlns="http://www.w3.org/2000/svg"
@ -100,11 +93,24 @@
</div>
</div>
<div id="root">
<div id="listWrap"><TopDisplay /></div>
<Selector />
<div id="listWrap"><TopDisplay /></div>
</div>
</div>
{#if TabOpen.v !== false}
<div id="UperLayer">
<div id="wrapClose">
<EditNameOfStudents />
<button
class="close"
onclick={() => (TabOpen.v = false)}
aria-label="close">CLOSE</button
>
</div>
</div>
{/if}
<style>
#wrap {
height: 100%;
@ -182,4 +188,32 @@
flex-direction: column;
justify-content: center;
}
#UperLayer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
backdrop-filter: blur(5px);
background-color: rgba(0, 0, 0, 0.5);
z-index: 1;
display: flex;
justify-content: center;
align-items: center;
}
#wrapClose {
display: flex;
flex-direction: column;
}
.close {
background-color: #2b2b2b;
color: #888;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
align-self: center;
}
</style>

View file

@ -3,54 +3,86 @@
</script>
<div id="root">
<p>The Selected Student is</p>
<p>The latest selected student is:</p>
<h1>{RandomNamesState.selectedStudent}</h1>
<p>(The Selected Student's name will be auto moved to the Selected list)</p>
<button
aria-label="Back to main menu"
onclick={() => {
SelectStudent();
}}
><span class="front"
><svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="#FFFFFF"
><path
d="M0-240v-63q0-43 44-70t116-27q13 0 25 .5t23 2.5q-14 21-21 44t-7 48v65H0Zm240 0v-65q0-32 17.5-58.5T307-410q32-20 76.5-30t96.5-10q53 0 97.5 10t76.5 30q32 20 49 46.5t17 58.5v65H240Zm540 0v-65q0-26-6.5-49T754-397q11-2 22.5-2.5t23.5-.5q72 0 116 26.5t44 70.5v63H780Zm-455-80h311q-10-20-55.5-35T480-370q-55 0-100.5 15T325-320ZM160-440q-33 0-56.5-23.5T80-520q0-34 23.5-57t56.5-23q34 0 57 23t23 57q0 33-23 56.5T160-440Zm640 0q-33 0-56.5-23.5T720-520q0-34 23.5-57t56.5-23q34 0 57 23t23 57q0 33-23 56.5T800-440Zm-320-40q-50 0-85-35t-35-85q0-51 35-85.5t85-34.5q51 0 85.5 34.5T600-600q0 50-34.5 85T480-480Zm0-80q17 0 28.5-11.5T520-600q0-17-11.5-28.5T480-640q-17 0-28.5 11.5T440-600q0 17 11.5 28.5T480-560Zm1 240Zm-1-280Z"
/></svg
>
{#if RandomNamesState.selectedStudent !== "none :("}
<span>Select Another Student</span>
{:else}
<span>Select one now :D</span>{/if}
<svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="#FFFFFF"
><path
d="M0-240v-63q0-43 44-70t116-27q13 0 25 .5t23 2.5q-14 21-21 44t-7 48v65H0Zm240 0v-65q0-32 17.5-58.5T307-410q32-20 76.5-30t96.5-10q53 0 97.5 10t76.5 30q32 20 49 46.5t17 58.5v65H240Zm540 0v-65q0-26-6.5-49T754-397q11-2 22.5-2.5t23.5-.5q72 0 116 26.5t44 70.5v63H780Zm-455-80h311q-10-20-55.5-35T480-370q-55 0-100.5 15T325-320ZM160-440q-33 0-56.5-23.5T80-520q0-34 23.5-57t56.5-23q34 0 57 23t23 57q0 33-23 56.5T160-440Zm640 0q-33 0-56.5-23.5T720-520q0-34 23.5-57t56.5-23q34 0 57 23t23 57q0 33-23 56.5T800-440Zm-320-40q-50 0-85-35t-35-85q0-51 35-85.5t85-34.5q51 0 85.5 34.5T600-600q0 50-34.5 85T480-480Zm0-80q17 0 28.5-11.5T520-600q0-17-11.5-28.5T480-640q-17 0-28.5 11.5T440-600q0 17 11.5 28.5T480-560Zm1 240Zm-1-280Z"
/></svg
>
</span></button
>
<div id="options">
<button
aria-label="Back to main menu"
id="selectStudent"
onclick={() => {
SelectStudent();
}}
><span class="front">
<span>Select a random student</span>
</span></button
>
<div>
{#if RandomNamesState.Selected.length > 0}
<button
aria-label="Back to main menu"
onclick={() => {
if (
confirm(
"Are you sure you want to reset all the Selected names? This action cannot be undone."
)
) {
RandomNamesState.NotSelectedYet = [
...RandomNamesState.NotSelectedYet,
...RandomNamesState.Selected,
];
RandomNamesState.Selected = [];
RandomNamesState.selectedStudent = "None yet!";
}
}}
><span class="front">
<span>Reset selected</span>
</span></button
>{/if}
{#if RandomNamesState.Absent.length > 0}
<button
aria-label="Back to main menu"
onclick={() => {
if (
confirm(
"Are you sure you want to reset all the names? this will also move all the students to the 'Not Selected Yet' list. This action cannot be undone."
)
) {
RandomNamesState.NotSelectedYet = [
...RandomNamesState.NotSelectedYet,
...RandomNamesState.Absent,
];
RandomNamesState.Absent = [];
RandomNamesState.selectedStudent = "None yet!";
}
}}
><span class="front">
<span>Reset absentees</span>
</span></button
>{/if}
</div>
</div>
</div>
<style>
#root {
background-color: #222;
border-radius: 30px 30px 0 0;
border-radius: 30px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding-top: 20px;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 0px;
margin: 20px;
}
#options {
display: flex;
justify-content: space-between;
width: 100%;
}
button {
@ -62,7 +94,7 @@
cursor: pointer;
outline-offset: 4px;
width: fit-content;
margin-bottom: 40px;
margin-bottom: 20px;
}
button:hover .front {
transform: translateY(-7px);
@ -96,4 +128,8 @@
color: #aaa;
margin: 0;
}
#selectStudent > .front {
background-color: #0e71e2;
}
</style>