Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion admin/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ <h1>Questions</h1>
</div>
<button class="space" id="launch-speed-mode">Launch Speed Mode</button>
</div>
<button class="space" id="create-button">Create</button>
<div class="input-group row space">
<button id="create-button">Create</button>
<button id="create-and-exit-button">Create and Exit</button>
</div>
</div>
<!-- Controls -->
<div id="controls-container" class="pill">
Expand Down
6 changes: 1 addition & 5 deletions admin/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@
flex-direction: column;
}

.input-group.row {
flex-direction: row;
gap: 0.25em;
}

.input-group:not(.row),
.input-group:has(#ai),
.input-group:has([data-question-number]) {
Expand Down Expand Up @@ -187,6 +182,7 @@

#stem.active {
background: var(--accent-color, dodgerblue);
color: var(--accent-text-color, white);
}

#stem.active i.bi-diagram-3 {
Expand Down
19 changes: 13 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,19 @@ <h6 data-question-title hidden></h6>
<i class="bi bi-three-dots"></i>
</button>
</div>
<div id="set-type-selector" data-button-select>
<button aria-selected="true" data-value="brackets">&lcub; Brackets &rcub;</button>
<button aria-selected="false" data-value="vector">&lt; Vector &gt;</button>
<button aria-selected="false" data-value="array">&lbrack; Array &rbrack;</button>
<button aria-selected="false" data-value="coordinate">&lpar; Coordinate &rpar;</button>
<button aria-selected="false" data-value="product">&lang; Product &rang;</button>
<div class="row">
<div id="set-type-selector" data-button-select>
<button aria-selected="true" data-value="brackets">&lcub; Brackets &rcub;</button>
<button aria-selected="false" data-value="vector">&lt; Vector &gt;</button>
<button aria-selected="false" data-value="array">&lbrack; Array &rbrack;</button>
<button aria-selected="false" data-value="coordinate">&lpar; Coordinate &rpar;</button>
<button aria-selected="false" data-value="product">&lang; Product &rang;</button>
</div>
<div class="button-grid" style="width: fit-content; margin-left: auto;">
<button data-insert-symbol="40" data-target-input="set-input"></button>
<button data-insert-symbol="41" data-target-input="set-input"></button>
<button data-insert-symbol="42" data-target-input="set-input"></button>
</div>
</div>
<div class="button-grid">
<input type="text" autocomplete="off" id="set-input" data-set-input="1" />
Expand Down
16 changes: 13 additions & 3 deletions src/checker/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,9 @@ try {
// Save
document.querySelectorAll("#save-button").forEach(w => w.addEventListener("click", save));
document.querySelectorAll("#create-button").forEach(w => w.addEventListener("click", createSegment));
document.querySelectorAll("#create-and-exit-button").forEach(w => w.addEventListener("click", () => {
createSegment(null, true);
}));

async function save(event, hideResult) {
if (!active) return;
Expand Down Expand Up @@ -2882,14 +2885,15 @@ try {
const top = (window.screen.height / 2) - (height / 2);
const windowFeatures = `width=${width},height=${height},resizable=no,scrollbars=no,status=yes,left=${left},top=${top}`;
const newWindow = window.open(url, '_blank', windowFeatures);
ui.modeless(`<i class="bi bi-window-stack"></i>`, "Speed Mode Started", "Waiting for window to close...", true);
let uploadSuccessful = false;
let endingQuestionId = startingQuestionId || null;
let endingQuestion = startingQuestion || null;
window.addEventListener('message', (event) => {
if (event.origin !== (window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''))) return;
if (event.data && (String(event.data) === 'uploadSuccess')) {
uploadSuccessful = true;
init();
// init();
} else if (event.data && String(event.data).includes(';+;')) {
[endingQuestionId, endingQuestion] = event.data.split(';+;');
} else if (event.data === 'exitToCourse') {
Expand Down Expand Up @@ -3782,7 +3786,7 @@ try {
ui.reloadUnsavedInputs();
}

function createSegment() {
function createSegment(event = null, exitToCourse = false) {
if (!active) return;
const course = document.getElementById("course-period-input");
const number = document.getElementById("segment-number-input");
Expand All @@ -3802,6 +3806,7 @@ try {
return name.focus();
}
document.querySelector("#create-button").disabled = true;
document.querySelector("#create-and-exit-button").disabled = true;
const question_ids = JSON.stringify(Array.from(document.querySelectorAll('.question')).filter(q => (q.querySelectorAll('input')[1].value.length > 0) && (q.querySelectorAll('input')[1].value != ' ')).map(q => {
return {
name: q.querySelectorAll('input')[1].value,
Expand Down Expand Up @@ -3847,7 +3852,11 @@ try {
.then((r) => {
ui.setUnsavedChanges(false);
ui.toast(loadedSegmentEditor ? "Segment updated successfully." : "Segment created successfully.", 3000, "success", "bi bi-check-circle-fill");
editSegment(null, loadedSegmentEditor ? loadedSegment.id : (r.id || null));
if (exitToCourse) {
window.location.href = '/admin/';
} else {
editSegment(null, loadedSegmentEditor ? loadedSegment.id : (r.id || null));
}
})
.catch((e) => {
console.error(e);
Expand Down Expand Up @@ -3888,6 +3897,7 @@ try {
document.getElementById("question-list").innerHTML = '';
JSON.parse(loadedSegment.question_ids).filter((item, index, self) => index === self.findIndex((t) => (t.id === item.id))).forEach(q => addExistingQuestion(q.id));
document.getElementById("create-button").innerText = "Save";
document.getElementById("create-and-exit-button").innerText = "Save and Exit";
document.querySelector('[data-delete-segment]')?.addEventListener('click', deleteSegmentConfirm);
document.querySelector('[edit-segment-questions]')?.addEventListener('click', () => {
if (ui.unsavedChanges) return ui.toast("You have unsaved changes. Please save or discard them before editing questions.", 3000, "error", "bi bi-exclamation-triangle-fill");
Expand Down
8 changes: 1 addition & 7 deletions src/checker/checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Element from "/src/modules/element.js";
import extendedSchedule from "/src/periods/extendedSchedule.json";
import * as themes from "/src/themes/themes.js";

import { autocomplete, uniqueSymbols } from "/src/symbols/symbols.js";
import { autocomplete, uniqueSymbols, insertFromIndex } from "/src/symbols/symbols.js";
import { unixToString, unixToTimeString } from "/src/modules/time.js";
import { getExtendedPeriodRange } from "/src/periods/periods";
import { convertLatexToAsciiMath, convertLatexToMarkup, renderMathInElement } from "mathlive";
Expand Down Expand Up @@ -880,12 +880,6 @@ try {

resetInputs();

if (question.nonscored) {
document.querySelector('.column:has(#answer-mode-selector)').setAttribute('hidden', '');
} else {
document.querySelector('.column:has(#answer-mode-selector)').removeAttribute('hidden');
}

const feed = document.getElementById('question-history-feed');
var latestResponses = history.filter(r => (String(r.segment) === String(segments.value)) && (String(r.question_id) === String(question.id))).sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));
feed.innerHTML = "";
Expand Down
5 changes: 5 additions & 0 deletions src/design.css
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ div.ML__keyboard {
width: -webkit-fill-available;
}

.input-group.row {
flex-direction: row;
gap: 0.25em;
}

[square] {
width: 2.25em !important;
min-width: 36px;
Expand Down
2 changes: 1 addition & 1 deletion src/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ body:has(.island.visible) #checker {
width: fit-content;
overflow: hidden;
align-self: center;
position: sticky;
position: fixed;
bottom: 25px;
}

Expand Down
24 changes: 22 additions & 2 deletions src/modules/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ dialog > button[data-suggestions] {
}

div.modeless {
position: absolute;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 999;

display: flex;
flex-direction: column;
align-items: center;
padding: 1.5rem;
border-radius: 1rem;
box-shadow: 0 0 2rem rgba(0, 0, 0, 0.2);
pointer-events: none;
background: var(--background-color);
}

div.modeless > h2 {
Expand Down Expand Up @@ -1099,6 +1099,26 @@ body:has(.topbar) #checker.horizontal .column:last-child {
transition: border-right-width 0.25s ease-in-out;
}

[data-modal-page="store"] .themes-grid .theme-item.suggest-theme {
border: 2px dashed var(--accent-color) !important;
background: transparent !important;
cursor: pointer;
transition: background-color 0.25s ease-in-out;
}

[data-modal-page="store"] .themes-grid .theme-item.suggest-theme:hover {
background: var(--surface-color) !important;
transition: background-color 0.25s ease-in-out;
}

[data-modal-page="store"] .themes-grid .theme-item.suggest-theme i {
position: relative !important;
margin: auto;
padding: 0;
top: 0;
left: 0;
}

[data-modal-page="store"] .themes-grid .theme-item i:not(.hd) {
position: absolute;
bottom: 10px;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export function view(path = "") {
target.dispatchEvent(event);
}

export function modeless(icon, message, description = null) {
export function modeless(icon, message, description = null, stayOpen = false) {
document.querySelector("div.modeless")?.remove();
const element = document.createElement("div");
const keyframes = [{ opacity: 0 }, { opacity: 1 }];
Expand All @@ -448,7 +448,7 @@ export function modeless(icon, message, description = null) {
duration: 100,
fill: "forwards",
});
setTimeout(() => {
if (!stayOpen) setTimeout(() => {
element.animate(keyframes, {
duration: 100,
direction: "reverse",
Expand Down
7 changes: 6 additions & 1 deletion src/symbols/symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@
"mu": "μ",
"lambda": "λ",
"gamma": "γ",
"kappa": "κ"
"kappa": "κ",
"omega": "ω",
"omegacap": "Ω",
"ihat": "î",
"jhat": "ĵ",
"khat": "k̂"
}
10 changes: 10 additions & 0 deletions src/themes/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,20 @@ export async function renderStore() {
const freeThemesGridText = document.createElement("b");
freeThemesGridText.innerText = 'Free Themes';
store.appendChild(freeThemesGridText);
const freeThemesGridSuggestTheme = document.createElement("div");
freeThemesGridSuggestTheme.classList = 'theme-item suggest-theme';
freeThemesGridSuggestTheme.innerHTML = `<i class="bi bi-plus-lg"></i>`;
freeThemesGridSuggestTheme.onclick = ui.suggestionsModal;
freeThemesGrid.appendChild(freeThemesGridSuggestTheme);
store.appendChild(freeThemesGrid);
const premiumThemesGridText = document.createElement("b");
premiumThemesGridText.innerText = 'Premium Themes';
store.appendChild(premiumThemesGridText);
const premiumThemesGridSuggestTheme = document.createElement("div");
premiumThemesGridSuggestTheme.classList = 'theme-item suggest-theme';
premiumThemesGridSuggestTheme.innerHTML = `<i class="bi bi-plus-lg"></i>`;
premiumThemesGridSuggestTheme.onclick = ui.suggestionsModal;
premiumThemesGrid.appendChild(premiumThemesGridSuggestTheme);
store.appendChild(premiumThemesGrid);
const costInfo = document.createElement("ul");
costInfo.classList = 'cost-info';
Expand Down