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">
|
<input type="text" pattern="(([01][0-9])|([2][0-3])):[0-5][0-9]:[0-5][0-9]" id="time_limit">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="repeatable">Megismételhető:</label>
|
<label for="repeatable">Megismételhető:</label>
|
||||||
|
@ -22,6 +22,8 @@ function create_game(string $name, string $owner, string $description = "", arra
|
|||||||
"game_file_present" => false,
|
"game_file_present" => false,
|
||||||
"properties" => $properties,
|
"properties" => $properties,
|
||||||
"groups" => [],
|
"groups" => [],
|
||||||
|
"public" => false,
|
||||||
|
"public_id" => uniqid("p"),
|
||||||
];
|
];
|
||||||
$game_data = $gamedb->insert($game_data);
|
$game_data = $gamedb->insert($game_data);
|
||||||
|
|
||||||
|
@ -220,6 +220,8 @@ switch ($action) {
|
|||||||
$game_data["contributors"] = array_intersect($contributors, get_all_nicknames());
|
$game_data["contributors"] = array_intersect($contributors, get_all_nicknames());
|
||||||
$game_data["properties"]["time_limit"] = $properties["time_limit"];
|
$game_data["properties"]["time_limit"] = $properties["time_limit"];
|
||||||
$game_data["properties"]["repeatable"] = $properties["repeatable"];
|
$game_data["properties"]["repeatable"] = $properties["repeatable"];
|
||||||
|
|
||||||
|
$game_data["public"] = $data["public"];
|
||||||
update_game($game_data);
|
update_game($game_data);
|
||||||
|
|
||||||
// update game file if supplied
|
// 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;
|
var EDITED_GAME = null;
|
||||||
|
|
||||||
function create_edit_game(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_limitedChk = document.getElementById("time_limited");
|
||||||
let time_limitF = document.getElementById("time_limit");
|
let time_limitF = document.getElementById("time_limit");
|
||||||
let repeatableChk = document.getElementById("repeatable");
|
let repeatableChk = document.getElementById("repeatable");
|
||||||
|
let publicChk = document.getElementById("public");
|
||||||
|
let publicUrlF = document.getElementById("public_url");
|
||||||
|
|
||||||
if (!updating) { // creating a new game
|
if (!updating) { // creating a new game
|
||||||
nameF.value = "";
|
nameF.value = "";
|
||||||
@ -62,6 +68,8 @@ function create_edit_game(game = null) {
|
|||||||
groupF.value = "";
|
groupF.value = "";
|
||||||
time_limitedChk.checked = false;
|
time_limitedChk.checked = false;
|
||||||
repeatableChk.checked = true;
|
repeatableChk.checked = true;
|
||||||
|
publicChk.checked = false;
|
||||||
|
publicUrlF.value = "";
|
||||||
|
|
||||||
// hide additional controls
|
// hide additional controls
|
||||||
hide("additional_controls");
|
hide("additional_controls");
|
||||||
@ -74,6 +82,13 @@ function create_edit_game(game = null) {
|
|||||||
contributorsF.value = game["contributors"].join(", ");
|
contributorsF.value = game["contributors"].join(", ");
|
||||||
groupF.value = game["groups"].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 props = game["properties"];
|
||||||
let time_limit = Math.max(Number(props["time_limit"]), 0);
|
let time_limit = Math.max(Number(props["time_limit"]), 0);
|
||||||
time_limitF.value = seconds_to_time(time_limit);
|
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"],
|
owner: updating ? ownerF.value.trim() : USERDATA["nickname"],
|
||||||
contributors: contributorsF.value.trim(),
|
contributors: contributorsF.value.trim(),
|
||||||
groups: groupF.value.trim(),
|
groups: groupF.value.trim(),
|
||||||
|
public: publicChk.checked,
|
||||||
properties: {
|
properties: {
|
||||||
time_limit: updating ? (time_limitedChk.checked ? time_to_seconds(time_limitF.value) : 0) : 0,
|
time_limit: updating ? (time_limitedChk.checked ? time_to_seconds(time_limitF.value) : 0) : 0,
|
||||||
repeatable: updating ? repeatableChk.checked : false
|
repeatable: updating ? repeatableChk.checked : false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user