Replaced split ID's with DOM Dataset in channel settings page.

This commit is contained in:
rainbow napkin 2025-09-08 07:31:43 -04:00
parent e539b9d75d
commit 92659929b9
4 changed files with 14 additions and 15 deletions

View file

@ -20,8 +20,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. %>
<% Object.keys(channel.permissions.toObject()).forEach((key)=>{ %> <% Object.keys(channel.permissions.toObject()).forEach((key)=>{ %>
<% if(key != "channelOverrides"){ %> <% if(key != "channelOverrides"){ %>
<span class="admin-list-field-container"> <span class="admin-list-field-container">
<label id="admin-perm-list-label-<%- key %>" class="admin-list-label admin-perm-list" for="admin-perm-list-rank-select-<%- key %>"><%- key %>: </label> <label class="admin-list-label admin-perm-list" for="admin-perm-list-rank-select-<%- key %>"><%- key %>: </label>
<select id="admin-perm-list-rank-select-<%- key %>" name="admin-perm-list-rank-select-<%- key %>" class="channel-perm-select admin-list-select admin-perm-list-rank-select"> <select data-key="<%- key %>" name="admin-perm-list-rank-select-<%- key %>" class="channel-perm-select admin-list-select admin-perm-list-rank-select">
<%rankEnum.slice().reverse().forEach((rank)=>{ %> <%rankEnum.slice().reverse().forEach((rank)=>{ %>
<option <%if(channel.permissions.toObject()[key] == rank){%> selected <%}%> value="<%- rank %>"><%- rank %></option> <option <%if(channel.permissions.toObject()[key] == rank){%> selected <%}%> value="<%- rank %>"><%- rank %></option>
<% }); %> <% }); %>

View file

@ -22,10 +22,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. %>
<label class="admin-list-label"><%- key %>:</label> <label class="admin-list-label"><%- key %>:</label>
<% switch(typeof channel.settings[key]){ <% switch(typeof channel.settings[key]){
case "string": %> case "string": %>
<input id=<%- `channel-preference-${key}` %> class="channel-preference-list-item" value="<%- channel.settings[key] %>"> <input data-key="<%- key %>" class="channel-preference-list-item" value="<%- channel.settings[key] %>">
<% break; <% break;
default: %> default: %>
<input id=<%- `channel-preference-${key}` %> class="channel-preference-list-item" type="checkbox" <% if(channel.settings[key]){ %> checked <% } %>> <input data-key="<%- key %>" class="channel-preference-list-item" type="checkbox" <% if(channel.settings[key]){ %> checked <% } %>>
<% break; <% break;
} %> } %>
</span> </span>

View file

@ -284,7 +284,6 @@ class emotePanel extends panelObj{
//Create trash icon //Create trash icon
const trashIcon = document.createElement('i'); const trashIcon = document.createElement('i');
trashIcon.classList.add('emote-list-trash-icon', 'bi-trash-fill'); trashIcon.classList.add('emote-list-trash-icon', 'bi-trash-fill');
trashIcon.id = `emote-list-trash-icon-${emote.name}`;
//add deletePersonalEmote event listener //add deletePersonalEmote event listener
trashIcon.addEventListener('click', ()=>{this.deletePersonalEmote(emote.name)}); trashIcon.addEventListener('click', ()=>{this.deletePersonalEmote(emote.name)});

View file

@ -163,7 +163,7 @@ class rankList{
} }
async submitUpdate(event){ async submitUpdate(event){
const user = event.target.id.replace("channel-rank-select-",""); const user = event.target.dataset.user;
const rank = event.target.value; const rank = event.target.value;
await this.submitUserRank(user, rank); await this.submitUserRank(user, rank);
@ -203,7 +203,7 @@ class rankList{
}else{ }else{
//Create rank select //Create rank select
var rankContent = document.createElement('select'); var rankContent = document.createElement('select');
rankContent.id = `channel-rank-select-${user.user}` rankContent.dataset.user = user.user;
rankContent.classList.add("channel-rank-select") rankContent.classList.add("channel-rank-select")
rankContent.addEventListener("change", this.submitUpdate.bind(this)); rankContent.addEventListener("change", this.submitUpdate.bind(this));
@ -273,7 +273,7 @@ class banList{
async unban(event){ async unban(event){
//Rip user outta the target id //Rip user outta the target id
const user = event.target.id.replace("admin-user-list-unban-icon-",""); const user = event.target.dataset.name;
//Tell the server to unban them and get the list returned //Tell the server to unban them and get the list returned
const list = await utils.ajax.chanUnban(this.channel, user); const list = await utils.ajax.chanUnban(this.channel, user);
@ -297,7 +297,7 @@ class banList{
//Create unban icon node //Create unban icon node
const unbanIcon = document.createElement('i'); const unbanIcon = document.createElement('i');
unbanIcon.classList.add("bi-emoji-smile-fill","admin-user-list-icon","admin-user-list-unban-icon"); unbanIcon.classList.add("bi-emoji-smile-fill","admin-user-list-icon","admin-user-list-unban-icon");
unbanIcon.id = `admin-user-list-unban-icon-${ban.user.user}`; unbanIcon.dataset.name = ban.user.user;
unbanIcon.title = `Unban ${ban.user.user}`; unbanIcon.title = `Unban ${ban.user.user}`;
unbanIcon.addEventListener("click", this.unban.bind(this)); unbanIcon.addEventListener("click", this.unban.bind(this));
@ -334,7 +334,7 @@ class prefrenceList{
async submitUpdate(event){ async submitUpdate(event){
//Get key from event target //Get key from event target
const key = event.target.id.replace("channel-preference-",""); const key = event.target.dataset.key;
//Pull value from event target //Pull value from event target
let value = event.target.value; let value = event.target.value;
@ -378,7 +378,7 @@ class permList{
} }
async submitUpdate(event){ async submitUpdate(event){
const key = event.target.id.replace("admin-perm-list-rank-select-",""); const key = event.target.dataset.key;
const value = event.target.value; const value = event.target.value;
const permMap = new Map([ const permMap = new Map([
[key, value] [key, value]
@ -429,7 +429,7 @@ class tokeCommandList{
} }
async deleteToke(event){ async deleteToke(event){
const name = event.target.id.replace("toke-command-delete-",""); const name = event.target.dataset.name;
const tokeList = await utils.ajax.deleteChanToke(this.channel, name); const tokeList = await utils.ajax.deleteChanToke(this.channel, name);
@ -462,7 +462,7 @@ class tokeCommandList{
//Create toke command delete icon //Create toke command delete icon
const tokeDelete = document.createElement('i'); const tokeDelete = document.createElement('i');
tokeDelete.classList.add('toke-command-list', 'bi-trash-fill', 'toke-command-delete'); tokeDelete.classList.add('toke-command-list', 'bi-trash-fill', 'toke-command-delete');
tokeDelete.id = `toke-command-delete-${toke}`; tokeDelete.dataset.name = toke;
tokeDelete.addEventListener('click', this.deleteToke.bind(this)); tokeDelete.addEventListener('click', this.deleteToke.bind(this));
//append span contents to tokeSpan //append span contents to tokeSpan
@ -495,7 +495,7 @@ class emoteList{
async deleteEmote(event){ async deleteEmote(event){
//Strip name from element id //Strip name from element id
const name = event.target.id.replace('emote-list-delete-',''); const name = event.target.dataset.name;
//Delete emote and pull list //Delete emote and pull list
const list = await utils.ajax.deleteChanEmote(this.channel, name); const list = await utils.ajax.deleteChanEmote(this.channel, name);
@ -572,7 +572,7 @@ class emoteList{
const deleteIcon = document.createElement('i'); const deleteIcon = document.createElement('i');
//Set delete icon id and class //Set delete icon id and class
deleteIcon.classList.add('bi-trash-fill', 'emote-list-delete'); deleteIcon.classList.add('bi-trash-fill', 'emote-list-delete');
deleteIcon.id = `emote-list-delete-${emote.name}`; deleteIcon.dataset.name = emote.name;
//Add delete icon event listener //Add delete icon event listener
deleteIcon.addEventListener('click',this.deleteEmote.bind(this)); deleteIcon.addEventListener('click',this.deleteEmote.bind(this));