aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-02-04 01:43:37 +0300
committerRblSb <msrblsb@gmail.com>2021-02-04 01:43:37 +0300
commit2bb127e1cd582d9151ef1b70c3496bc79776a95a (patch)
tree918bacef6e9e59754948fc7103570853fbb6c419 /res
parentec90923038d902d7c0fa5220afd5b79650e17d47 (diff)
Improve changeOrder permission
closes #21
Diffstat (limited to 'res')
-rw-r--r--res/client.js40
-rw-r--r--res/css/des.css8
2 files changed, 43 insertions, 5 deletions
diff --git a/res/client.js b/res/client.js
index 94af960..6f01550 100644
--- a/res/client.js
+++ b/res/client.js
@@ -68,6 +68,18 @@ ClientTools.getByName = function(clients,name,def) {
}
return def;
};
+ClientTools.hasPermission = function(client,permission,permissions) {
+ if((client.group & 4) != 0) {
+ return permissions.admin.indexOf(permission) != -1;
+ }
+ if((client.group & 2) != 0) {
+ return permissions.leader.indexOf(permission) != -1;
+ }
+ if((client.group & 1) != 0) {
+ return permissions.user.indexOf(permission) != -1;
+ }
+ return permissions.guest.indexOf(permission) != -1;
+};
var EReg = function(r,opt) {
this.r = new RegExp(r,opt.split("u").join(""));
};
@@ -1259,7 +1271,7 @@ client_Main.prototype = {
var data = JSON.parse(e.data);
if(this.config != null && this.config.isVerbose) {
var t = data.type;
- haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 347, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]});
+ haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 348, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]});
}
client_JsApi.fireOnceEvent(data);
switch(data.type) {
@@ -1333,10 +1345,11 @@ client_Main.prototype = {
case "Logout":
this.updateClients(data.logout.clients);
this.personal = new Client(data.logout.clientName,0);
+ this.onUserGroupChanged();
+ this.showGuestLoginPanel();
this.settings.name = "";
this.settings.hash = "";
client_Settings.write(this.settings);
- this.showGuestLoginPanel();
break;
case "Message":
this.addMessage(data.message.clientName,data.message.text);
@@ -1421,7 +1434,11 @@ client_Main.prototype = {
break;
case "UpdateClients":
this.updateClients(data.updateClients.clients);
+ var oldGroup = this.personal.group;
this.personal = ClientTools.getByName(this.clients,this.personal.name,this.personal);
+ if(this.personal.group != oldGroup) {
+ this.onUserGroupChanged();
+ }
break;
case "UpdatePlaylist":
this.player.setItems(data.updatePlaylist.videoList);
@@ -1469,6 +1486,21 @@ client_Main.prototype = {
this.addMessage(message.name,message.text,message.time);
}
this.player.setItems(connected.videoList,connected.itemPos);
+ this.onUserGroupChanged();
+ }
+ ,onUserGroupChanged: function() {
+ var button = window.document.querySelector("#queue_next");
+ if(ClientTools.hasPermission(this.personal,"changeOrder",this.config.permissions)) {
+ button.disabled = false;
+ } else {
+ button.disabled = true;
+ }
+ var adminMenu = window.document.querySelector("#adminMenu");
+ if((this.personal.group & 4) != 0) {
+ adminMenu.style.display = "block";
+ } else {
+ adminMenu.style.display = "none";
+ }
}
,guestLogin: function(name) {
if(name.length == 0) {
@@ -1550,6 +1582,7 @@ client_Main.prototype = {
return;
}
this.personal = newPersonal;
+ this.onUserGroupChanged();
this.hideGuestLoginPanel();
}
,showGuestLoginPanel: function() {
@@ -1563,9 +1596,6 @@ client_Main.prototype = {
window.document.querySelector("#guestpassword").style.display = "none";
window.document.querySelector("#chatbox").style.display = "flex";
window.document.querySelector("#exitBtn").textContent = Lang.get("exit");
- if((this.personal.group & 4) != 0) {
- window.document.querySelector("#adminMenu").style.display = "block";
- }
}
,showGuestPasswordPanel: function() {
window.document.querySelector("#guestlogin").style.display = "none";
diff --git a/res/css/des.css b/res/css/des.css
index aa423bd..8788bdd 100644
--- a/res/css/des.css
+++ b/res/css/des.css
@@ -132,6 +132,14 @@ button:focus ion-icon {
color: var(--foreground);
}
+button[disabled],
+button[disabled]:hover {
+ background-color: var(--background-chat);
+ color: var(--midground);
+ opacity: 0.5;
+ cursor: default;
+}
+
button > * {
line-height: 1;
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage