diff options
| author | RblSb <msrblsb@gmail.com> | 2022-03-15 06:51:53 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2022-03-15 06:51:53 +0300 |
| commit | 79f3c34d24d6ae6aba17dd643726e20754140d80 (patch) | |
| tree | d6b1d23bcfbdc023fc757f25b1b3fa085fd5e790 /res/client.js | |
| parent | 692e4690abc2083d151c011a2df2976ecf6886cc (diff) | |
Update locked playlist restrictions
And add "toggleItemType" permission. Closes #36
Diffstat (limited to 'res/client.js')
| -rw-r--r-- | res/client.js | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/res/client.js b/res/client.js index 2f73059..d15aea4 100644 --- a/res/client.js +++ b/res/client.js @@ -1,4 +1,3 @@ -// Generated by Haxe 4.2.2 (function ($hx_exports, $global) { "use strict"; $hx_exports["client"] = $hx_exports["client"] || {}; $hx_exports["client"]["JsApi"] = $hx_exports["client"]["JsApi"] || {}; @@ -29,7 +28,22 @@ Client.fromData = function(data) { return new Client(data.name,data.group); }; Client.prototype = { - setGroupFlag: function(type,flag) { + hasPermission: function(permission,permissions) { + if((this.group & 1) != 0) { + return permissions.banned.indexOf(permission) != -1; + } + if((this.group & 8) != 0) { + return permissions.admin.indexOf(permission) != -1; + } + if((this.group & 4) != 0) { + return permissions.leader.indexOf(permission) != -1; + } + if((this.group & 2) != 0) { + return permissions.user.indexOf(permission) != -1; + } + return permissions.guest.indexOf(permission) != -1; + } + ,setGroupFlag: function(type,flag) { if(flag) { this.group |= 1 << type._hx_index; } else { @@ -70,21 +84,6 @@ ClientTools.getByName = function(clients,name,def) { } return def; }; -ClientTools.hasPermission = function(client,permission,permissions) { - if((client.group & 1) != 0) { - return permissions.banned.indexOf(permission) != -1; - } - if((client.group & 8) != 0) { - return permissions.admin.indexOf(permission) != -1; - } - if((client.group & 4) != 0) { - return permissions.leader.indexOf(permission) != -1; - } - if((client.group & 2) != 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("")); }; @@ -639,9 +638,15 @@ client_Buttons.init = function(main) { main.send({ type : "ShufflePlaylist"}); }; window.document.querySelector("#lockplaylist").onclick = function(e) { - if((main.personal.group & 8) != 0) { - main.send({ type : "TogglePlaylistLock"}); + if(!main.hasPermission("lockPlaylist")) { + return; + } + if(main.isPlaylistOpen) { + if(!window.confirm(Lang.get("lockPlaylistConfirm"))) { + return; + } } + main.send({ type : "TogglePlaylistLock"}); }; var showMediaUrl = window.document.querySelector("#showmediaurl"); showMediaUrl.onclick = function(e) { @@ -1127,6 +1132,7 @@ var client_Main = function() { this.filters = []; this.pageTitle = window.document.title; this.clients = []; + this.isPlaylistOpen = true; this.globalIp = ""; this.forceSyncNextTick = false; this.isSyncActive = true; @@ -1294,6 +1300,9 @@ client_Main.prototype = { }; window.document.querySelector("#customembed-content").onkeydown = window.document.querySelector("#customembed-title").onkeydown; } + ,hasPermission: function(permission) { + return this.personal.hasPermission(permission,this.config.permissions); + } ,handleUrlMasks: function(links) { var _g = 0; while(_g < links.length) { @@ -1463,7 +1472,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 : 380, 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 : 384, 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) { @@ -1697,7 +1706,7 @@ client_Main.prototype = { } ,onUserGroupChanged: function() { var button = window.document.querySelector("#queue_next"); - if(ClientTools.hasPermission(this.personal,"changeOrder",this.config.permissions)) { + if(this.personal.hasPermission("changeOrder",this.config.permissions)) { button.disabled = false; } else { button.disabled = true; @@ -2036,6 +2045,7 @@ client_Main.prototype = { } } ,setPlaylistLock: function(isOpen) { + this.isPlaylistOpen = isOpen; var lockPlaylist = window.document.querySelector("#lockplaylist"); var icon = lockPlaylist.firstElementChild; if(isOpen) { @@ -2059,9 +2069,6 @@ client_Main.prototype = { this.settings.synchThreshold = s; client_Settings.write(this.settings); } - ,hasPermission: function(group,permission) { - return Reflect.field(this.config.permissions,$hxEnums[group.__enum__].__constructs__[group._hx_index]._hx_name.toLowerCase()).indexOf(permission) != -1; - } ,toggleLeader: function() { this.setLeaderButton((this.personal.group & 4) == 0); this.send({ type : "SetLeader", setLeader : { clientName : (this.personal.group & 4) != 0 ? "" : this.personal.name}}); @@ -2132,7 +2139,7 @@ client_Player.prototype = { } ,toggleItemType: function(pos) { this.videoList.toggleItemType(pos); - this.setItemElementType(this.videoItemsEl.children[pos],this.videoList.items[this.videoList.pos].isTemp); + this.setItemElementType(this.videoItemsEl.children[pos],this.videoList.items[pos].isTemp); } ,setPlayer: function(newPlayer) { if(this.player != newPlayer) { @@ -2226,7 +2233,7 @@ client_Player.prototype = { } this.main.send({ type : "Play", play : { time : this.getTime()}}); if(this.main.hasLeaderOnPauseRequest() && this.videoList.items.length > 0) { - if(this.main.hasPermission((this.main.personal.group & 8) != 0 ? ClientGroup.Admin : ClientGroup.User,"requestLeader")) { + if(this.main.hasPermission("requestLeader")) { this.main.toggleLeader(); } } |
