From 6c012626bbb2ed02465deb3d8ec90857050017cb Mon Sep 17 00:00:00 2001 From: Sad Date: Sat, 11 Sep 2021 14:33:36 +0800 Subject: [PATCH] Storage the checkbox state. #3 1.2.0 --- README.md | 4 ++++ index.js | 36 +++++++++++++++++++++++++++++++----- module.json | 2 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c26050f..47b4a02 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ Specify the identity of the speaker, no longer based on the selected token ## Changelog +### v1.2.0 + +Storage the checkbox state. + ### v1.1.5 Get the style by js. diff --git a/index.js b/index.js index 38e494c..0aad915 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,27 @@ var color; var height; var bgcolor; -var width; +var width = "80%";; + +Hooks.once('init', () => { + //Not used anymore but kept for compatibility with migration + game.settings.register("speak-as", "checked", { + name: "checked", + scope: "client", + default: true, + type: Boolean, + config: false + }); + +}); + +Hooks.once('ready', () => { + const btn = document.querySelector('#speakerSwitch'); + btn.addEventListener('click', (event) => { + let checked = document.getElementById("speakerSwitch").checked; + game.settings.set("speak-as", "checked", checked) + }); +}); Hooks.on("renderSidebarTab", (dialog, $element, targets) => { /** * 自己的登入名字 @@ -14,7 +34,7 @@ Hooks.on("renderSidebarTab", (dialog, $element, targets) => { $(".roll-type-select").css("color") ? color = $(".roll-type-select").css("color") : null; $(".roll-type-select").css("height") ? height = $(".roll-type-select").css("height") : null; $(".roll-type-select").css("background") ? bgcolor = $(".roll-type-select").css("background") : null; - $(".roll-type-select").css("width") ? width = $(".roll-type-select").css("width") : null; + check(); var x = document.querySelectorAll("#namelist"); if (width) x[0].style.setProperty("width", width, "important") @@ -33,7 +53,7 @@ function updateSpeakerList() { let selectedCharacter = myactors.find(actor => actor.id === myUser.character?.id); let addText = `
- +