Skip to content

Commit

Permalink
Signal quickselect
Browse files Browse the repository at this point in the history
  • Loading branch information
Antifantwerp-Pigeon committed Sep 5, 2024
1 parent 2816dca commit cc8b498
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/layouts/settings.pug
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
mixin select(label, options)
- const id = label.toLowerCase();
label(for=id)
h4=label
select(id=id name=id)
h5=label
select(id=id name=id class="class")
each option in options
option=option

mixin settings()
section#send-signal
form
h3 Send signal
+select("Location", ["Front", "Middle", "Back", "Custom"])
+select("Type", ["Wait", "Need water", "Need medical intervention", "Police intervention", "Police brutality", "Custom"])
+select("Urgency", ["Incoming", "When possible", "Urgent", "Life-threatening", "Custom" ])
h4 Quick select
+select("Urgency", ["Incoming", "When possible", "Urgent", "Life-threatening" ])
+select("Type", ["wait", "need water", "need medical intervention", "police intervention", "police brutality"])
+select("Location", ["everywhere", "at the front", "at the middle", "at the back"])

label(for="signal") Signal to send:
input(type="text" name="signal" id="signal")
input(type="submit" value="Send signal")

section#settings
Expand Down
11 changes: 10 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let pb: PocketBase;

let addingSlogan = false;
let oldSlogansListInner = "";
const signalQuickSelectors = $("#send-signal select");

async function changeCurrentSlogan(e) {
const selectedRadio = $(e.target)
Expand Down Expand Up @@ -78,6 +79,10 @@ function sendSignal(e) {
}


function signalQuickSelect() {
const [urgency, type, location] = signalQuickSelectors.map((i, elem) => $(elem).val());
$("#signal").val(`${urgency}: ${type} ${location}`)
}

function settingsInit() : PocketBase {
pb = init();
Expand All @@ -86,6 +91,9 @@ function settingsInit() : PocketBase {
const addSlogan = $("#add-slogan")
const editSlogans = $("#edit-slogans")

// Load default values into #signal value
signalQuickSelect();

$("#slogan-changer").on("change", function() {
// Save old slogan state
if (oldSlogansListInner == "") {
Expand All @@ -94,6 +102,7 @@ function settingsInit() : PocketBase {
activateSloganChanger();
})
$("#send-signal").on("submit", sendSignal);
signalQuickSelectors.on("input", signalQuickSelect);

addSlogan.on("click", (e) => {
if (!addingSlogan) {
Expand Down Expand Up @@ -137,8 +146,8 @@ function settingsInit() : PocketBase {
newLi.append(form);
li.replaceWith(newLi);
})

})

})

return pb;
Expand Down

0 comments on commit cc8b498

Please sign in to comment.