reformat a bit (less spaces)

This commit is contained in:
whosit 2025-03-20 16:42:55 +03:00
parent dc663be1c9
commit 457cb45eb2

View File

@ -14,29 +14,31 @@ function show_vote_welcome()
-- by making them click the button, we can know their name
if mem.vote_active then
digiline_send("vote",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 7,
real_coordinates = true,
},
{command = "addtextarea", name = "", default = mem.message_welcome_vote, X = 1.8, Y = 1.4, W = 7, H = 2.6},
{command = "addbutton", name = "start", label = "Begin voting", X = 3.1, Y = 4.6, W = 4.3, H = 1.7},
}
digiline_send(
"vote",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 7,
real_coordinates = true,
},
{command = "addtextarea", name = "", default = mem.message_welcome_vote, X = 1.8, Y = 1.4, W = 7, H = 2.6},
{command = "addbutton", name = "start", label = "Begin voting", X = 3.1, Y = 4.6, W = 4.3, H = 1.7},
}
)
else
digiline_send("vote",
{
{command = "clear"},
{command = "set",
width = 6,
height = 2,
real_coordinates = true,
},
{command = "addlabel", label = "Voting is stopped!", X = 0.5, Y = 1.0},
}
digiline_send(
"vote",
{
{command = "clear"},
{command = "set",
width = 6,
height = 2,
real_coordinates = true,
},
{command = "addlabel", label = "Voting is stopped!", X = 0.5, Y = 1.0},
}
)
end
end
@ -45,19 +47,20 @@ end
function show_vote_error(voter, offender)
-- show this when owner of the ballot and clicker do not match
local msg = string.format("%s has tried to cast a vote instead of %s!\nThey also saw %s's votes, they're naughty!", offender, voter, voter)
digiline_send("vote",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 11,
real_coordinates = true,
},
{command = "addlabel", label = "ERROR!", X = 4.7, Y = 2.4},
{command = "addtextarea", name = "", label = "", default = msg, X = 1.3, Y = 3.2, W = 7.9, H = 4.1},
{command = "addbutton", name = "start", label = "Start", X = 3.8, Y = 9.6, W = 3, H = 0.8},
{command = "addlabel", label = "Try again:", X = 1.4, Y = 10}
}
digiline_send(
"vote",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 11,
real_coordinates = true,
},
{command = "addlabel", label = "ERROR!", X = 4.7, Y = 2.4},
{command = "addtextarea", name = "", label = "", default = msg, X = 1.3, Y = 3.2, W = 7.9, H = 4.1},
{command = "addbutton", name = "start", label = "Start", X = 3.8, Y = 9.6, W = 3, H = 0.8},
{command = "addlabel", label = "Try again:", X = 1.4, Y = 10}
}
)
end
@ -67,34 +70,35 @@ function show_admin_welcome()
local toggle_submit_label = mem.submit_active and "Stop submissions" or "Allow submissions"
local toggle_vote_label = mem.vote_active and "Disable voting" or "Enable voting"
digiline_send("admin",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 11,
real_coordinates = true,
locked = true,
},
{command = "addlabel", label = "Admin only!", X = 4.4, Y = 1.3},
{command = "addlabel",
label = "Submissions: " .. (mem.submit_active and "accepting" or "stopped"),
X = 0.6, Y = 2.0},
{command = "addlabel",
label = "Voting: " .. (mem.vote_active and "active" or "stopped"),
X = 0.6, Y = 2.3},
{command = "addbutton", name = "edit_entries", label = "Edit entries", X = 3.7, Y = 2.3, W = 3, H = 0.8},
{command = "addbutton", name = "view_results", label = "View results", X = 3.7, Y = 3.7, W = 3, H = 0.8},
{command = "addbutton", name = "toggle_submit",
label = toggle_submit_label,
X = 3.7, Y = 5.1, W = 3, H = 0.8},
{command = "addbutton", name = "toggle_vote",
label = toggle_vote_label,
X = 3.7, Y = 6.5, W = 3, H = 0.8},
{command = "addbutton", name = "edit_messages", label = "Edit messages", X = 3.7, Y = 7.9, W = 3, H = 0.8},
{command = "addbutton", name = "danger_zone", label = "Danger zone", X = 3.7, Y = 9.3, W = 3, H = 0.8},
digiline_send(
"admin",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 11,
real_coordinates = true,
locked = true,
},
{command = "addlabel", label = "Admin only!", X = 4.4, Y = 1.3},
{command = "addlabel",
label = "Submissions: " .. (mem.submit_active and "accepting" or "stopped"),
X = 0.6, Y = 2.0},
{command = "addlabel",
label = "Voting: " .. (mem.vote_active and "active" or "stopped"),
X = 0.6, Y = 2.3},
{command = "addbutton", name = "edit_entries", label = "Edit entries", X = 3.7, Y = 2.3, W = 3, H = 0.8},
{command = "addbutton", name = "view_results", label = "View results", X = 3.7, Y = 3.7, W = 3, H = 0.8},
{command = "addbutton", name = "toggle_submit",
label = toggle_submit_label,
X = 3.7, Y = 5.1, W = 3, H = 0.8},
{command = "addbutton", name = "toggle_vote",
label = toggle_vote_label,
X = 3.7, Y = 6.5, W = 3, H = 0.8},
{command = "addbutton", name = "edit_messages", label = "Edit messages", X = 3.7, Y = 7.9, W = 3, H = 0.8},
{command = "addbutton", name = "danger_zone", label = "Danger zone", X = 3.7, Y = 9.3, W = 3, H = 0.8},
}
}
)
end
@ -107,28 +111,29 @@ function show_admin_edit()
end
local entry = mem.entries[mem.admin_entries_idx] or {}
digiline_send("admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addtextlist", name = "entries", listelements = list_entries, transparent = false, selected_id = mem.admin_entries_idx, X = 0.5, Y = 0.5, W = 11.0, H = 6.0},
{command = "addtextarea", name = "", label = "Coordinates:", default = entry.coords or "<NONE>", X = 0.5, Y = 7.0, W = 11.0, H = 0.5},
{command = "addtextarea", name = "", label = "Description:", default = entry.description or "<NONE>", X = 0.5, Y = 8, W = 11.0, H = 2.0},
digiline_send(
"admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addtextlist", name = "entries", listelements = list_entries, transparent = false, selected_id = mem.admin_entries_idx, X = 0.5, Y = 0.5, W = 11.0, H = 6.0},
{command = "addtextarea", name = "", label = "Coordinates:", default = entry.coords or "<NONE>", X = 0.5, Y = 7.0, W = 11.0, H = 0.5},
{command = "addtextarea", name = "", label = "Description:", default = entry.description or "<NONE>", X = 0.5, Y = 8, W = 11.0, H = 2.0},
{command = "addbutton", name = "edit_accept", label = "Accept/Decline", X = 12.2, Y = 4.3, W = 3, H = 0.8},
{command = "addfield", name = "new_entry_submitter", label = "New entry submitter", default = "", X = 1.2, Y = 10.4, W = 2.5, H = 0.8},
{command = "addfield", name = "new_entry_title", label = "New entry title", default = "", X = 4.0, Y = 10.4, W = 8.5, H = 0.8},
{command = "addbutton", name = "add_entry", label = "Add entry", X = 13.0, Y = 10.4, W = 1.7, H = 0.8},
{command = "addbutton", name = "delete_entry", label = "Delete", X = 12.7, Y = 8, W = 1.5, H = 0.8},
{command = "add", element = "field_close_on_enter", name = "new_entry", close_on_enter = false},
{command = "addbutton", name = "edit_accept", label = "Accept/Decline", X = 12.2, Y = 4.3, W = 3, H = 0.8},
{command = "addfield", name = "new_entry_submitter", label = "New entry submitter", default = "", X = 1.2, Y = 10.4, W = 2.5, H = 0.8},
{command = "addfield", name = "new_entry_title", label = "New entry title", default = "", X = 4.0, Y = 10.4, W = 8.5, H = 0.8},
{command = "addbutton", name = "add_entry", label = "Add entry", X = 13.0, Y = 10.4, W = 1.7, H = 0.8},
{command = "addbutton", name = "delete_entry", label = "Delete", X = 12.7, Y = 8, W = 1.5, H = 0.8},
{command = "add", element = "field_close_on_enter", name = "new_entry", close_on_enter = false},
{command = "addbutton", name = "edit_back", label = "Back", X = 12.7, Y = 0.3, W = 1.7, H = 0.8},
}
{command = "addbutton", name = "edit_back", label = "Back", X = 12.7, Y = 0.3, W = 1.7, H = 0.8},
}
)
end
@ -189,65 +194,68 @@ function show_admin_results()
table.insert(entry_list, string.format("%03d||%03d|%03d|%03d|%03d -- %s", sum, s[1], s[2], s[3], s[4], name))
end
digiline_send("admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addlabel", label = sorted_by_str, X = 0.9, Y = 0.6},
{command = "addbutton", name = "results_update", label = "Update", X = 8.7, Y = 0.3, W = 3, H = 1},
{command = "addbutton", name = "results_back", label = "Back", X = 12.7, Y = 0.3, W = 3, H = 1},
{command = "addtextlist", name = "", listelements = entry_list, transparent = false, selected_id = 1, X = 0.3, Y = 1.5, W = 12.3, H = 9.2},
{command = "addlabel", label = "Sort by:", X = 13.5, Y = 2.6},
{command = "addbutton", name = "sort_sum", label = "Sum", X = 12.7, Y = 3.1, W = 3, H = 1},
{command = "addbutton", name = "sort_1", label = categories[1], X = 12.7, Y = 4.2, W = 3, H = 1},
{command = "addbutton", name = "sort_2", label = categories[2], X = 12.7, Y = 5.3, W = 3, H = 1},
{command = "addbutton", name = "sort_3", label = categories[3], X = 12.7, Y = 6.4, W = 3, H = 1},
{command = "addbutton", name = "sort_4", label = categories[4], X = 12.7, Y = 7.5, W = 3, H = 1},
}
digiline_send(
"admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addlabel", label = sorted_by_str, X = 0.9, Y = 0.6},
{command = "addbutton", name = "results_update", label = "Update", X = 8.7, Y = 0.3, W = 3, H = 1},
{command = "addbutton", name = "results_back", label = "Back", X = 12.7, Y = 0.3, W = 3, H = 1},
{command = "addtextlist", name = "", listelements = entry_list, transparent = false, selected_id = 1, X = 0.3, Y = 1.5, W = 12.3, H = 9.2},
{command = "addlabel", label = "Sort by:", X = 13.5, Y = 2.6},
{command = "addbutton", name = "sort_sum", label = "Sum", X = 12.7, Y = 3.1, W = 3, H = 1},
{command = "addbutton", name = "sort_1", label = categories[1], X = 12.7, Y = 4.2, W = 3, H = 1},
{command = "addbutton", name = "sort_2", label = categories[2], X = 12.7, Y = 5.3, W = 3, H = 1},
{command = "addbutton", name = "sort_3", label = categories[3], X = 12.7, Y = 6.4, W = 3, H = 1},
{command = "addbutton", name = "sort_4", label = categories[4], X = 12.7, Y = 7.5, W = 3, H = 1},
}
)
end
function show_admin_danger()
digiline_send("admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addbutton", name = "danger_back", label = "Back", X = 12.7, Y = 0.3, W = 3, H = 1},
{command = "addbutton", name = "danger_vote_reset", label = "RESET VOTES", X = 1.7, Y = 0.3, W = 3, H = 1},
{command = "addbutton", name = "danger_memory_reset", label = "WIPE ALL MEMORY", X = 1.7, Y = 2.3, W = 3, H = 1},
}
digiline_send(
"admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addbutton", name = "danger_back", label = "Back", X = 12.7, Y = 0.3, W = 3, H = 1},
{command = "addbutton", name = "danger_vote_reset", label = "RESET VOTES", X = 1.7, Y = 0.3, W = 3, H = 1},
{command = "addbutton", name = "danger_memory_reset", label = "WIPE ALL MEMORY", X = 1.7, Y = 2.3, W = 3, H = 1},
}
)
end
function show_admin_messages()
digiline_send("admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addlabel", label = "Enter information about vote", X = 1, Y = 0.9},
{command = "addbutton", name = "messages_back", label = "Back", X = 12.7, Y = 0.3, W = 3, H = 1},
{command = "addtextarea", name = "message_welcome_vote", label = "Voting welcome", default = mem.message_welcome_vote, X = 0.5, Y = 1.5, W = 15.0, H = 2.5},
{command = "addtextarea", name = "message_welcome_submission", label = "Submission welcome", default = mem.message_welcome_submission, X = 0.5, Y = 4.5, W = 15.0, H = 2.5},
{command = "addtextarea", name = "message_submission_instructions", label = "Submission instructions", default = mem.message_submission_instructions, X = 0.5, Y = 7.5, W = 15.0, H = 2.5},
{command = "addbutton", name = "messages_ok", label = "OK", X = 12.6, Y = 10.7, W = 3, H = 0.8},
}
digiline_send(
"admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addlabel", label = "Enter information about vote", X = 1, Y = 0.9},
{command = "addbutton", name = "messages_back", label = "Back", X = 12.7, Y = 0.3, W = 3, H = 1},
{command = "addtextarea", name = "message_welcome_vote", label = "Voting welcome", default = mem.message_welcome_vote, X = 0.5, Y = 1.5, W = 15.0, H = 2.5},
{command = "addtextarea", name = "message_welcome_submission", label = "Submission welcome", default = mem.message_welcome_submission, X = 0.5, Y = 4.5, W = 15.0, H = 2.5},
{command = "addtextarea", name = "message_submission_instructions", label = "Submission instructions", default = mem.message_submission_instructions, X = 0.5, Y = 7.5, W = 15.0, H = 2.5},
{command = "addbutton", name = "messages_ok", label = "OK", X = 12.6, Y = 10.7, W = 3, H = 0.8},
}
)
end
@ -322,29 +330,31 @@ end
function show_submit_welcome()
if mem.submit_active then
digiline_send("submit",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 7,
real_coordinates = true,
},
{command = "addtextarea", name = "", default = mem.message_welcome_submission, X = 1.8, Y = 1.4, W = 7, H = 2.6},
{command = "addbutton", name = "start_submission", label = "Enter submission", X = 3.1, Y = 4.6, W = 4.3, H = 1.7},
}
digiline_send(
"submit",
{
{command = "clear"},
{command = "set",
width = 10.5,
height = 7,
real_coordinates = true,
},
{command = "addtextarea", name = "", default = mem.message_welcome_submission, X = 1.8, Y = 1.4, W = 7, H = 2.6},
{command = "addbutton", name = "start_submission", label = "Enter submission", X = 3.1, Y = 4.6, W = 4.3, H = 1.7},
}
)
else
digiline_send("submit",
{
{command = "clear"},
{command = "set",
width = 6,
height = 2,
real_coordinates = true,
},
{command = "addlabel", label = "Currently not accepting new submissions, sorry!", X = 0.5, Y = 1.0},
}
digiline_send(
"submit",
{
{command = "clear"},
{command = "set",
width = 6,
height = 2,
real_coordinates = true,
},
{command = "addlabel", label = "Currently not accepting new submissions, sorry!", X = 0.5, Y = 1.0},
}
)
end
end
@ -353,24 +363,25 @@ end
function show_submit(username)
local submission = mem.entries_by_user[username] or {}
digiline_send("submit",
{
{command = "clear"},
{command = "set",
width = 18,
height = 12,
real_coordinates = true,
},
{command = "add", element = "box", X = 0.6, Y = 10.5, W = 17.0, H = 1.2, color = "#00FF00"},
{command = "addtextarea", name = "", label = "", default = "Please fill the fields and press 'submit'", X = 0.7, Y = 10.55, W = 13.5, H = 1.05},
{command = "addlabel", label = string.format("Welcome %s!", username), X = 0.9, Y = 0.7},
{command = "addtextarea", name = "", label = "", default = mem.message_submission_instructions, X = 0.9, Y = 1.8, W = 16.3, H = 2},
{command = "addfield", name = "submission_title", label = "Name of submission:", default = submission.title or "", X = 0.7, Y = 3.5, W = 10, H = 0.8},
{command = "addfield", name = "submission_coords", label = "Coordinates:", default = submission.coords or "", X = 0.7, Y = 5.0, W = 5, H = 0.8},
{command = "addtextarea", name = "submission_description", label = "Additional information (closest city, directions how to find it, etc.):", default = submission.description or "", X = 0.7, Y = 6.8, W = 16.8, H = 3.5},
{command = "addbutton", name = "submission_submit", label = mem.entries_by_user[username] and "Update" or "Submit", X = 14.5, Y = 10.7, W = 3, H = 0.8},
{command = "addbutton", name = "submission_back", label = "Back", X = 14.5, Y = 0.7, W = 3, H = 0.8},
}
digiline_send(
"submit",
{
{command = "clear"},
{command = "set",
width = 18,
height = 12,
real_coordinates = true,
},
{command = "add", element = "box", X = 0.6, Y = 10.5, W = 17.0, H = 1.2, color = "#00FF00"},
{command = "addtextarea", name = "", label = "", default = "Please fill the fields and press 'submit'", X = 0.7, Y = 10.55, W = 13.5, H = 1.05},
{command = "addlabel", label = string.format("Welcome %s!", username), X = 0.9, Y = 0.7},
{command = "addtextarea", name = "", label = "", default = mem.message_submission_instructions, X = 0.9, Y = 1.8, W = 16.3, H = 2},
{command = "addfield", name = "submission_title", label = "Name of submission:", default = submission.title or "", X = 0.7, Y = 3.5, W = 10, H = 0.8},
{command = "addfield", name = "submission_coords", label = "Coordinates:", default = submission.coords or "", X = 0.7, Y = 5.0, W = 5, H = 0.8},
{command = "addtextarea", name = "submission_description", label = "Additional information (closest city, directions how to find it, etc.):", default = submission.description or "", X = 0.7, Y = 6.8, W = 16.8, H = 3.5},
{command = "addbutton", name = "submission_submit", label = mem.entries_by_user[username] and "Update" or "Submit", X = 14.5, Y = 10.7, W = 3, H = 0.8},
{command = "addbutton", name = "submission_back", label = "Back", X = 14.5, Y = 0.7, W = 3, H = 0.8},
}
)
end
@ -458,14 +469,15 @@ elseif event.type == "digiline" then
elseif event.msg.submission_submit then
local user = event.msg.clicker
local function show_error(color, msg)
digiline_send("submit",
{
{command = "modify", index = 1, color = color},
{command = "modify", index = 2, default = msg},
{command = "modify", index = 5, default = event.msg.submission_title},
{command = "modify", index = 6, default = event.msg.submission_coords},
{command = "modify", index = 7, default = event.msg.submission_description},
}
digiline_send(
"submit",
{
{command = "modify", index = 1, color = color},
{command = "modify", index = 2, default = msg},
{command = "modify", index = 5, default = event.msg.submission_title},
{command = "modify", index = 6, default = event.msg.submission_coords},
{command = "modify", index = 7, default = event.msg.submission_description},
}
)
end
if not (event.msg.clicker == mem.submitter_name) then