public game option added
This commit is contained in:
parent
99caea6bc5
commit
2fd08094a6
@ -92,6 +92,15 @@ if (!get_autologin_state() || (($user_data["privilege"] !== PRIVILEGE_CREATOR) &
|
||||
<input type="text" pattern="(([01][0-9])|([2][0-3])):[0-5][0-9]:[0-5][0-9]" id="time_limit">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="public">Publikus:</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" id="public">
|
||||
<input type="text" id="public_url" readonly>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="repeatable">Megismételhető:</label>
|
||||
|
@ -22,6 +22,8 @@ function create_game(string $name, string $owner, string $description = "", arra
|
||||
"game_file_present" => false,
|
||||
"properties" => $properties,
|
||||
"groups" => [],
|
||||
"public" => false,
|
||||
"public_id" => uniqid("p"),
|
||||
];
|
||||
$game_data = $gamedb->insert($game_data);
|
||||
|
||||
|
@ -220,6 +220,8 @@ switch ($action) {
|
||||
$game_data["contributors"] = array_intersect($contributors, get_all_nicknames());
|
||||
$game_data["properties"]["time_limit"] = $properties["time_limit"];
|
||||
$game_data["properties"]["repeatable"] = $properties["repeatable"];
|
||||
|
||||
$game_data["public"] = $data["public"];
|
||||
update_game($game_data);
|
||||
|
||||
// update game file if supplied
|
||||
|
@ -31,6 +31,10 @@ function list_all_games() {
|
||||
});
|
||||
}
|
||||
|
||||
function get_full_hostname() {
|
||||
return window.location.origin + window.location.pathname;
|
||||
}
|
||||
|
||||
var EDITED_GAME = null;
|
||||
|
||||
function create_edit_game(game = null) {
|
||||
@ -51,6 +55,8 @@ function create_edit_game(game = null) {
|
||||
let time_limitedChk = document.getElementById("time_limited");
|
||||
let time_limitF = document.getElementById("time_limit");
|
||||
let repeatableChk = document.getElementById("repeatable");
|
||||
let publicChk = document.getElementById("public");
|
||||
let publicUrlF = document.getElementById("public_url");
|
||||
|
||||
if (!updating) { // creating a new game
|
||||
nameF.value = "";
|
||||
@ -62,6 +68,8 @@ function create_edit_game(game = null) {
|
||||
groupF.value = "";
|
||||
time_limitedChk.checked = false;
|
||||
repeatableChk.checked = true;
|
||||
publicChk.checked = false;
|
||||
publicUrlF.value = "";
|
||||
|
||||
// hide additional controls
|
||||
hide("additional_controls");
|
||||
@ -74,6 +82,13 @@ function create_edit_game(game = null) {
|
||||
contributorsF.value = game["contributors"].join(", ");
|
||||
groupF.value = game["groups"].join(", ");
|
||||
|
||||
publicChk.addEventListener("change", () => {
|
||||
publicUrlF.hidden = !publicChk.checked;
|
||||
});
|
||||
publicChk.checked = game["public"];
|
||||
publicUrlF.hidden = !publicChk.checked;
|
||||
publicUrlF.value = game["public_id"];
|
||||
|
||||
let props = game["properties"];
|
||||
let time_limit = Math.max(Number(props["time_limit"]), 0);
|
||||
time_limitF.value = seconds_to_time(time_limit);
|
||||
@ -114,6 +129,7 @@ function create_edit_game(game = null) {
|
||||
owner: updating ? ownerF.value.trim() : USERDATA["nickname"],
|
||||
contributors: contributorsF.value.trim(),
|
||||
groups: groupF.value.trim(),
|
||||
public: publicChk.checked,
|
||||
properties: {
|
||||
time_limit: updating ? (time_limitedChk.checked ? time_to_seconds(time_limitF.value) : 0) : 0,
|
||||
repeatable: updating ? repeatableChk.checked : false
|
||||
|
Loading…
x
Reference in New Issue
Block a user