Skip to content

Commit

Permalink
www/js- HTMLElement.dataset attrs are always string, handle int properly
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Apr 17, 2022
1 parent da06a90 commit e3b5d9e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions www/chat/js/ui.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
//
// jshint -W003
import { create_element, dcTN } from "./util.js";
import { create_element, dcTN, decr_data, incr_data } from "./util.js";
import { el_1, el_uonline, getSettingsSelection, output } from "./ui.util.js";
import * as api from "./api/index.js";

Expand All @@ -18,26 +18,24 @@ export const volatile = {

export function refresh_permissions() {
for (const el of document.querySelectorAll("[data-requires]")) {
el.dataset.hidden |= 0;
el.dataset.hidden += 1;
incr_data(el, "hidden");
}
for (const key in volatile.me.perms) {
const has_perm = volatile.me.perms[key];
if (has_perm) {
for (const el of document.querySelectorAll(`[data-requires="${key}"]`)) {
el.dataset.hidden -= 1;
decr_data(el, "hidden");
}
}
}
}

export function refresh_members() {
for (const el of document.querySelectorAll("[data-mustbe-member]")) {
el.dataset.hidden |= 0;
el.dataset.hidden += 1;
incr_data(el, "hidden");

if (api.C.users.get(el.dataset.mustbeMember).is_member) {
el.dataset.hidden -= 1;
decr_data(el, "hidden");
}
}
}
Expand Down

0 comments on commit e3b5d9e

Please sign in to comment.