mirror of https://github.com/bra1n/townsquare.git
added custom image opt in
This commit is contained in:
parent
4d33e7dda9
commit
ec64584da5
|
@ -73,7 +73,7 @@
|
||||||
Background image
|
Background image
|
||||||
<em><font-awesome-icon icon="image"/></em>
|
<em><font-awesome-icon icon="image"/></em>
|
||||||
</li>
|
</li>
|
||||||
<li @click="toggleMute">
|
<li @click="toggleMuted">
|
||||||
Mute Sounds
|
Mute Sounds
|
||||||
<em
|
<em
|
||||||
><font-awesome-icon
|
><font-awesome-icon
|
||||||
|
@ -89,17 +89,16 @@
|
||||||
<li class="headline" v-else>
|
<li class="headline" v-else>
|
||||||
Live Session
|
Live Session
|
||||||
</li>
|
</li>
|
||||||
<li @click="hostSession" v-if="!session.sessionId">
|
<template v-if="!session.sessionId">
|
||||||
Host (Storyteller)<em>[H]</em>
|
<li @click="hostSession">Host (Storyteller)<em>[H]</em></li>
|
||||||
</li>
|
<li @click="joinSession">Join (Player)<em>[J]</em></li>
|
||||||
<li @click="joinSession" v-if="!session.sessionId">
|
</template>
|
||||||
Join (Player)<em>[J]</em>
|
<template v-else>
|
||||||
</li>
|
<li v-if="session.ping">
|
||||||
<li v-if="session.sessionId && session.ping">
|
|
||||||
Delay to {{ session.isSpectator ? "host" : "players" }}
|
Delay to {{ session.isSpectator ? "host" : "players" }}
|
||||||
<em>{{ session.ping }}ms</em>
|
<em>{{ session.ping }}ms</em>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="session.sessionId" @click="copySessionUrl">
|
<li @click="copySessionUrl">
|
||||||
Copy player link
|
Copy player link
|
||||||
<em><font-awesome-icon icon="copy"/></em>
|
<em><font-awesome-icon icon="copy"/></em>
|
||||||
</li>
|
</li>
|
||||||
|
@ -107,17 +106,28 @@
|
||||||
Send Characters
|
Send Characters
|
||||||
<em><font-awesome-icon icon="theater-masks"/></em>
|
<em><font-awesome-icon icon="theater-masks"/></em>
|
||||||
</li>
|
</li>
|
||||||
|
<li v-if="session.isSpectator" @click="imageOptIn">
|
||||||
|
Show Custom Images
|
||||||
|
<em
|
||||||
|
><font-awesome-icon
|
||||||
|
:icon="[
|
||||||
|
'fas',
|
||||||
|
grimoire.isImageOptIn ? 'check-square' : 'square'
|
||||||
|
]"
|
||||||
|
/></em>
|
||||||
|
</li>
|
||||||
<li
|
<li
|
||||||
v-if="session.voteHistory.length"
|
v-if="session.voteHistory.length"
|
||||||
@click="toggleModal('voteHistory')"
|
@click="toggleModal('voteHistory')"
|
||||||
>
|
>
|
||||||
Nomination history<em>[V]</em>
|
Nomination history<em>[V]</em>
|
||||||
</li>
|
</li>
|
||||||
<li @click="leaveSession" v-if="session.sessionId">
|
<li @click="leaveSession">
|
||||||
Leave Session
|
Leave Session
|
||||||
<em>{{ session.sessionId }}</em>
|
<em>{{ session.sessionId }}</em>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template v-if="tab === 'players' && !session.isSpectator">
|
<template v-if="tab === 'players' && !session.isSpectator">
|
||||||
<!-- Users -->
|
<!-- Users -->
|
||||||
|
@ -218,9 +228,6 @@ export default {
|
||||||
this.$store.commit("setBackground", background);
|
this.$store.commit("setBackground", background);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleMute() {
|
|
||||||
this.$store.commit("setIsMuted", !this.grimoire.isMuted);
|
|
||||||
},
|
|
||||||
hostSession() {
|
hostSession() {
|
||||||
if (this.session.sessionId) return;
|
if (this.session.sessionId) return;
|
||||||
const sessionId = prompt(
|
const sessionId = prompt(
|
||||||
|
@ -253,6 +260,13 @@ export default {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
imageOptIn() {
|
||||||
|
const popup =
|
||||||
|
"Are you sure you want to allow custom images? A malicious storyteller might get access to your IP address this way.";
|
||||||
|
if (this.grimoire.isImageOptIn || confirm(popup)) {
|
||||||
|
this.toggleImageOptIn();
|
||||||
|
}
|
||||||
|
},
|
||||||
joinSession() {
|
joinSession() {
|
||||||
if (this.session.sessionId) return this.leaveSession();
|
if (this.session.sessionId) return this.leaveSession();
|
||||||
const sessionId = prompt(
|
const sessionId = prompt(
|
||||||
|
@ -299,6 +313,8 @@ export default {
|
||||||
...mapMutations([
|
...mapMutations([
|
||||||
"toggleGrimoire",
|
"toggleGrimoire",
|
||||||
"toggleMenu",
|
"toggleMenu",
|
||||||
|
"toggleImageOptIn",
|
||||||
|
"toggleMuted",
|
||||||
"toggleNight",
|
"toggleNight",
|
||||||
"toggleNightOrder",
|
"toggleNightOrder",
|
||||||
"setZoom",
|
"setZoom",
|
||||||
|
|
|
@ -10,12 +10,14 @@ import fabledJSON from "../fabled.json";
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
|
// global data maps
|
||||||
const editionJSONbyId = new Map(
|
const editionJSONbyId = new Map(
|
||||||
editionJSON.map(edition => [edition.id, edition])
|
editionJSON.map(edition => [edition.id, edition])
|
||||||
);
|
);
|
||||||
const rolesJSONbyId = new Map(rolesJSON.map(role => [role.id, role]));
|
const rolesJSONbyId = new Map(rolesJSON.map(role => [role.id, role]));
|
||||||
const fabled = new Map(fabledJSON.map(role => [role.id, role]));
|
const fabled = new Map(fabledJSON.map(role => [role.id, role]));
|
||||||
|
|
||||||
|
// helper functions
|
||||||
const getRolesByEdition = (edition = editionJSON[0]) => {
|
const getRolesByEdition = (edition = editionJSON[0]) => {
|
||||||
return new Map(
|
return new Map(
|
||||||
rolesJSON
|
rolesJSON
|
||||||
|
@ -38,6 +40,18 @@ const getTravelersNotInEdition = (edition = editionJSON[0]) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const set = key => ({ grimoire }, val) => {
|
||||||
|
grimoire[key] = val;
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggle = key => ({ grimoire }, val) => {
|
||||||
|
if (val === true || val === false) {
|
||||||
|
grimoire[key] = val;
|
||||||
|
} else {
|
||||||
|
grimoire[key] = !grimoire[key];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// base definition for custom roles
|
// base definition for custom roles
|
||||||
const imageBase =
|
const imageBase =
|
||||||
"https://raw.githubusercontent.com/bra1n/townsquare/main/src/assets/icons/";
|
"https://raw.githubusercontent.com/bra1n/townsquare/main/src/assets/icons/";
|
||||||
|
@ -67,6 +81,7 @@ export default new Vuex.Store({
|
||||||
isPublic: true,
|
isPublic: true,
|
||||||
isMenuOpen: false,
|
isMenuOpen: false,
|
||||||
isMuted: false,
|
isMuted: false,
|
||||||
|
isImageOptIn: false,
|
||||||
zoom: 0,
|
zoom: 0,
|
||||||
background: ""
|
background: ""
|
||||||
},
|
},
|
||||||
|
@ -119,38 +134,14 @@ export default new Vuex.Store({
|
||||||
rolesJSONbyId: () => rolesJSONbyId
|
rolesJSONbyId: () => rolesJSONbyId
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
toggleMenu({ grimoire }) {
|
setZoom: set("zoom"),
|
||||||
grimoire.isMenuOpen = !grimoire.isMenuOpen;
|
setBackground: set("background"),
|
||||||
},
|
toggleMuted: toggle("isMuted"),
|
||||||
toggleGrimoire({ grimoire }, isPublic) {
|
toggleMenu: toggle("isMenuOpen"),
|
||||||
if (isPublic === true || isPublic === false) {
|
toggleNightOrder: toggle("isNightOrder"),
|
||||||
grimoire.isPublic = isPublic;
|
toggleNight: toggle("isNight"),
|
||||||
} else {
|
toggleGrimoire: toggle("isPublic"),
|
||||||
grimoire.isPublic = !grimoire.isPublic;
|
toggleImageOptIn: toggle("isImageOptIn"),
|
||||||
}
|
|
||||||
document.title = `Blood on the Clocktower ${
|
|
||||||
grimoire.isPublic ? "Town Square" : "Grimoire"
|
|
||||||
}`;
|
|
||||||
},
|
|
||||||
toggleNight({ grimoire }, isNight) {
|
|
||||||
if (isNight === true || isNight === false) {
|
|
||||||
grimoire.isNight = isNight;
|
|
||||||
} else {
|
|
||||||
grimoire.isNight = !grimoire.isNight;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleNightOrder({ grimoire }) {
|
|
||||||
grimoire.isNightOrder = !grimoire.isNightOrder;
|
|
||||||
},
|
|
||||||
setZoom({ grimoire }, zoom) {
|
|
||||||
grimoire.zoom = zoom;
|
|
||||||
},
|
|
||||||
setBackground({ grimoire }, background) {
|
|
||||||
grimoire.background = background;
|
|
||||||
},
|
|
||||||
setIsMuted({ grimoire }, isMuted) {
|
|
||||||
grimoire.isMuted = isMuted;
|
|
||||||
},
|
|
||||||
toggleModal({ modals }, name) {
|
toggleModal({ modals }, name) {
|
||||||
if (name) {
|
if (name) {
|
||||||
modals[name] = !modals[name];
|
modals[name] = !modals[name];
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
// helper functions
|
|
||||||
const set = key => (state, val) => {
|
|
||||||
state[key] = val;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a vote request.
|
* Handle a vote request.
|
||||||
* If the vote is from a seat that is already locked, ignore it.
|
* If the vote is from a seat that is already locked, ignore it.
|
||||||
|
@ -37,6 +32,11 @@ const getters = {};
|
||||||
|
|
||||||
const actions = {};
|
const actions = {};
|
||||||
|
|
||||||
|
// mutations helper functions
|
||||||
|
const set = key => (state, val) => {
|
||||||
|
state[key] = val;
|
||||||
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setPlayerId: set("playerId"),
|
setPlayerId: set("playerId"),
|
||||||
setSpectator: set("isSpectator"),
|
setSpectator: set("isSpectator"),
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
module.exports = store => {
|
module.exports = store => {
|
||||||
|
const updatePagetitle = isPublic =>
|
||||||
|
(document.title = `Blood on the Clocktower ${
|
||||||
|
isPublic ? "Town Square" : "Grimoire"
|
||||||
|
}`);
|
||||||
|
|
||||||
// initialize data
|
// initialize data
|
||||||
if (localStorage.getItem("background")) {
|
if (localStorage.getItem("background")) {
|
||||||
store.commit("setBackground", localStorage.background);
|
store.commit("setBackground", localStorage.background);
|
||||||
}
|
}
|
||||||
if (localStorage.getItem("muted")) {
|
if (localStorage.getItem("muted")) {
|
||||||
store.commit("setIsMuted", true);
|
store.commit("toggleMuted", true);
|
||||||
|
}
|
||||||
|
if (localStorage.getItem("imageOptIn")) {
|
||||||
|
store.commit("toggleImageOptIn", true);
|
||||||
}
|
}
|
||||||
if (localStorage.getItem("zoom")) {
|
if (localStorage.getItem("zoom")) {
|
||||||
store.commit("setZoom", parseFloat(localStorage.getItem("zoom")));
|
store.commit("setZoom", parseFloat(localStorage.getItem("zoom")));
|
||||||
}
|
}
|
||||||
if (localStorage.isPublic !== undefined) {
|
if (localStorage.getItem("isGrimoire")) {
|
||||||
store.commit("toggleGrimoire", JSON.parse(localStorage.isPublic));
|
store.commit("toggleGrimoire", false);
|
||||||
|
updatePagetitle(false);
|
||||||
}
|
}
|
||||||
if (localStorage.roles !== undefined) {
|
if (localStorage.roles !== undefined) {
|
||||||
store.commit("setCustomRoles", JSON.parse(localStorage.roles));
|
store.commit("setCustomRoles", JSON.parse(localStorage.roles));
|
||||||
|
@ -61,10 +70,12 @@ module.exports = store => {
|
||||||
store.subscribe(({ type, payload }, state) => {
|
store.subscribe(({ type, payload }, state) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "toggleGrimoire":
|
case "toggleGrimoire":
|
||||||
localStorage.setItem(
|
if (!state.grimoire.isPublic) {
|
||||||
"isPublic",
|
localStorage.setItem("isGrimoire", 1);
|
||||||
JSON.stringify(state.grimoire.isPublic)
|
} else {
|
||||||
);
|
localStorage.removeItem("isGrimoire");
|
||||||
|
}
|
||||||
|
updatePagetitle(state.grimoire.isPublic);
|
||||||
break;
|
break;
|
||||||
case "setBackground":
|
case "setBackground":
|
||||||
if (payload) {
|
if (payload) {
|
||||||
|
@ -73,13 +84,20 @@ module.exports = store => {
|
||||||
localStorage.removeItem("background");
|
localStorage.removeItem("background");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setIsMuted":
|
case "toggleMuted":
|
||||||
if (payload) {
|
if (state.grimoire.isMuted) {
|
||||||
localStorage.setItem("muted", 1);
|
localStorage.setItem("muted", 1);
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem("muted");
|
localStorage.removeItem("muted");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "toggleImageOptIn":
|
||||||
|
if (state.grimoire.isImageOptIn) {
|
||||||
|
localStorage.setItem("imageOptIn", 1);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem("imageOptIn");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "setZoom":
|
case "setZoom":
|
||||||
if (payload !== 0) {
|
if (payload !== 0) {
|
||||||
localStorage.setItem("zoom", payload);
|
localStorage.setItem("zoom", payload);
|
||||||
|
|
Loading…
Reference in New Issue