- Style all button and inputs on admin pages with Roboto Mono font (and sans-serif as a fallback) with 1em font size; - Remove unneeded transition effect property declaration on text hover, as the regular declaration is applied when switching from hover state to regular state. - Add NPC dedicated stylesheet in which specific NPC style has been added; - Use an icon where the picture of a NPC is not available (like when adding a new one) and provide the NPC picture as the picture instead of the edition page itself; - Move NPC's JavaScript in a dedicated file, improve its code and fix its access to DOM elements.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
function createOrUpdateNpc() {
|
|
const data = {};
|
|
data["id"] = document.querySelector("#npc_id").value;
|
|
data["name"] = document.querySelector("#npc_name").value;
|
|
|
|
const allAnswersJson = [];
|
|
data["allAnswers"] = allAnswersJson;
|
|
|
|
for (let answerTypeNode of document.querySelector(".answer_groups").children) {
|
|
const answersJson = [];
|
|
const answerTypeJson = {"answers": answersJson};
|
|
allAnswersJson.push(answerTypeJson);
|
|
|
|
answerTypeNode.querySelectorAll("input").forEach(answerNode => {
|
|
answersJson.push({"text": answerNode.value});
|
|
});
|
|
}
|
|
|
|
makeAPIRequest("admin/setNpc", {"npc": data, "lang": "FR"}, {"content": "json"}).then(() => {
|
|
alert("Opération effectuée avec succès");
|
|
});
|
|
}
|
|
|
|
async function deleteNpc() {
|
|
if (!confirm("Voulez-vous vraiment supprimer ce personnage ?")) {
|
|
return;
|
|
}
|
|
|
|
const npcId = document.querySelector("#npc_id").value;
|
|
await makeAPIRequest("admin/deleteNpc", {"npc_id": npcId, "lang": "FR"}, {"content": "json"});
|
|
alert("Opération effectuée avec succès");
|
|
document.location = "/admin";
|
|
}
|