aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-02-25 07:47:29 +0300
committerRblSb <msrblsb@gmail.com>2020-02-25 07:47:29 +0300
commitd934830a64b915af0b7e8031cb5ef927534c5e86 (patch)
treee98ca9831baa6bcf749dc0b1ffdea79ec0792344
parent70b255b99ad50f1a42791b9a39f2fcfcd98f00d8 (diff)
Improve login/exit and mob view
-rw-r--r--build/server.js2
-rw-r--r--res/client.js30
-rw-r--r--res/index.html2
-rw-r--r--res/langs/en.json1
-rw-r--r--res/langs/ru.json1
-rw-r--r--src/Client.hx9
-rw-r--r--src/client/Buttons.hx11
-rw-r--r--src/client/Main.hx6
-rw-r--r--src/client/MobileView.hx21
-rw-r--r--src/server/Main.hx2
10 files changed, 56 insertions, 29 deletions
diff --git a/build/server.js b/build/server.js
index 5f13d07..d6a0c65 100644
--- a/build/server.js
+++ b/build/server.js
@@ -842,6 +842,7 @@ server_Main.prototype = {
return;
}
client.name = data.login.clientName;
+ client.setGroupFlag(ClientGroup.User,true);
this.send(client,{ type : data.type, login : { isUnknownClient : true, clientName : client.name, clients : this.clientList()}});
this.sendClientList();
break;
@@ -850,6 +851,7 @@ server_Main.prototype = {
case "Logout":
var oldName = client.name;
client.name = "Guest " + (this.clients.indexOf(client) + 1);
+ client.setGroupFlag(ClientGroup.User,false);
this.send(client,{ type : data.type, logout : { oldClientName : oldName, clientName : client.name, clients : this.clientList()}});
this.sendClientList();
break;
diff --git a/res/client.js b/res/client.js
index 95f0fd5..35e568a 100644
--- a/res/client.js
+++ b/res/client.js
@@ -456,7 +456,11 @@ client_Buttons.initNavBar = function(main) {
}
var exitBtn = window.document.querySelector("#exitBtn");
exitBtn.onclick = function(e2) {
- main.send({ type : "Logout"});
+ if((main.personal.group & 1) != 0) {
+ main.send({ type : "Logout"});
+ } else {
+ window.document.querySelector("#guestname").focus();
+ }
exitBtn.blur();
client_Buttons.hideMenus();
return;
@@ -464,12 +468,12 @@ client_Buttons.initNavBar = function(main) {
var swapLayoutBtn = window.document.querySelector("#swapLayoutBtn");
swapLayoutBtn.onclick = function(e3) {
var p = window.document.querySelector("#main");
- p.insertBefore(p.children.item(2),p.children.item(0));
- p.insertBefore(p.children.item(2),p.children.item(1));
+ p.insertBefore(p.children[2],p.children[0]);
+ p.insertBefore(p.children[2],p.children[1]);
var p1 = window.document.querySelector("#controlsrow");
- p1.insertBefore(p1.children.item(1),p1.children.item(0));
+ p1.insertBefore(p1.children[1],p1.children[0]);
var p2 = window.document.querySelector("#playlistrow");
- p2.insertBefore(p2.children.item(1),p2.children.item(0));
+ p2.insertBefore(p2.children[1],p2.children[0]);
client_Buttons.initSplit(window.document.querySelector("#main").firstElementChild == window.document.querySelector("#videowrap"));
swapLayoutBtn.blur();
client_Buttons.hideMenus();
@@ -739,7 +743,7 @@ client_Main.prototype = {
var data = JSON.parse(e.data);
var t = data.type;
var t1 = t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null);
- haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 203, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]});
+ haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 207, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]});
switch(data.type) {
case "AddVideo":
if(this.player.isListEmpty()) {
@@ -928,11 +932,13 @@ client_Main.prototype = {
,showGuestLoginPanel: function() {
window.document.querySelector("#guestlogin").style.display = "block";
window.document.querySelector("#chatline").style.display = "none";
+ window.document.querySelector("#exitBtn").textContent = Lang.get("login");
window.dispatchEvent(new Event("resize"));
}
,hideGuestLoginPanel: function() {
window.document.querySelector("#guestlogin").style.display = "none";
window.document.querySelector("#chatline").style.display = "block";
+ window.document.querySelector("#exitBtn").textContent = Lang.get("exit");
if((this.personal.group & 4) != 0) {
window.document.querySelector("#clearchatbtn").style.display = "inline-block";
}
@@ -1077,19 +1083,19 @@ client_MobileView.__name__ = true;
client_MobileView.init = function() {
var mvbtn = window.document.querySelector("#mv_btn");
mvbtn.onclick = function(e) {
- if(client_Utils.toggleFullScreen(window.document.documentElement)) {
+ var hasMobileView = client_Utils.toggleFullScreen(window.document.documentElement);
+ var vwrap = window.document.querySelector("#videowrap");
+ if(hasMobileView) {
window.document.body.classList.add("mobile-view");
mvbtn.classList.add("active");
- var vwrap = window.document.querySelector("#videowrap");
- if(vwrap.children[0] == window.document.querySelector("currenttitle")) {
+ if(vwrap.children[0].id == "currenttitle") {
vwrap.appendChild(vwrap.children[0]);
}
} else {
window.document.body.classList.remove("mobile-view");
mvbtn.classList.remove("active");
- var vwrap1 = window.document.querySelector("videowrap");
- if(vwrap1.children[0] != window.document.querySelector("currenttitle")) {
- vwrap1.insertBefore(vwrap1.children[1],vwrap1.children[0]);
+ if(vwrap.children[0].id != "currenttitle") {
+ vwrap.insertBefore(vwrap.children[1],vwrap.children[0]);
}
}
return;
diff --git a/res/index.html b/res/index.html
index 73067d8..7b51c56 100644
--- a/res/index.html
+++ b/res/index.html
@@ -33,7 +33,7 @@
<!-- <li><a href="#">${exportSettings}</a></li>
<li><a href="#">${importSettings}</a></li>
<li class="divider"></li> -->
- <li><a id="exitBtn" href="#">${exit}</a></li>
+ <li><a id="exitBtn" href="#">${login}</a></li>
</ul>
</li>
<li><a href="javascript:void(0)">${settings}</a></li>
diff --git a/res/langs/en.json b/res/langs/en.json
index bdc4cc1..3e618fb 100644
--- a/res/langs/en.json
+++ b/res/langs/en.json
@@ -17,6 +17,7 @@
"account": "Account",
"exportSettings": "Export Settings",
"importSettings": "Import Settings",
+ "login": "Login",
"exit": "Exit",
"settings": "Settings",
"channel": "Channel",
diff --git a/res/langs/ru.json b/res/langs/ru.json
index 74b05f2..5bccce1 100644
--- a/res/langs/ru.json
+++ b/res/langs/ru.json
@@ -17,6 +17,7 @@
"account": "Аккаунт",
"exportSettings": "Экспорт настроек",
"importSettings": "Импорт настроек",
+ "login": "Войти",
"exit": "Выход",
"settings": "Настройки",
"channel": "Канал",
diff --git a/src/Client.hx b/src/Client.hx
index 4604ab7..708cbaf 100644
--- a/src/Client.hx
+++ b/src/Client.hx
@@ -26,6 +26,7 @@ class Client {
#end
public var name:String;
public var group:EnumFlags<ClientGroup>;
+ public var isUser(get, set):Bool;
public var isLeader(get, set):Bool;
public var isAdmin(get, set):Bool;
@@ -43,6 +44,14 @@ class Client {
this.group = new EnumFlags(group);
}
+ inline function get_isUser():Bool {
+ return group.has(User);
+ }
+
+ inline function set_isUser(flag:Bool):Bool {
+ return setGroupFlag(User, flag);
+ }
+
inline function get_isLeader():Bool {
return group.has(Leader);
}
diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx
index 69928a5..51ba75d 100644
--- a/src/client/Buttons.hx
+++ b/src/client/Buttons.hx
@@ -172,19 +172,20 @@ class Buttons {
final exitBtn = ge("#exitBtn");
exitBtn.onclick = e -> {
- main.send({type: Logout});
+ if (main.isUser()) main.send({type: Logout});
+ else ge("#guestname").focus();
exitBtn.blur();
hideMenus();
}
final swapLayoutBtn = ge("#swapLayoutBtn");
swapLayoutBtn.onclick = e -> {
final p = ge("#main");
- p.insertBefore(p.children.item(2), p.children.item(0));
- p.insertBefore(p.children.item(2), p.children.item(1));
+ p.insertBefore(p.children[2], p.children[0]);
+ p.insertBefore(p.children[2], p.children[1]);
final p = ge("#controlsrow");
- p.insertBefore(p.children.item(1), p.children.item(0));
+ p.insertBefore(p.children[1], p.children[0]);
final p = ge("#playlistrow");
- p.insertBefore(p.children.item(1), p.children.item(0));
+ p.insertBefore(p.children[1], p.children[0]);
final swapped = ge("#main").firstElementChild == ge("#videowrap");
initSplit(swapped);
swapLayoutBtn.blur();
diff --git a/src/client/Main.hx b/src/client/Main.hx
index 70cc270..bfcc877 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -98,6 +98,10 @@ class Main {
}
}
+ public inline function isUser():Bool {
+ return personal.isUser;
+ }
+
public inline function isLeader():Bool {
return personal.isLeader;
}
@@ -366,12 +370,14 @@ class Main {
function showGuestLoginPanel():Void {
ge("#guestlogin").style.display = "block";
ge("#chatline").style.display = "none";
+ ge("#exitBtn").textContent = Lang.get("login");
Browser.window.dispatchEvent(new Event("resize"));
}
function hideGuestLoginPanel():Void {
ge("#guestlogin").style.display = "none";
ge("#chatline").style.display = "block";
+ ge("#exitBtn").textContent = Lang.get("exit");
if (isAdmin()) ge("#clearchatbtn").style.display = "inline-block";
Browser.window.dispatchEvent(new Event("resize"));
}
diff --git a/src/client/MobileView.hx b/src/client/MobileView.hx
index ad788df..52d06f9 100644
--- a/src/client/MobileView.hx
+++ b/src/client/MobileView.hx
@@ -8,20 +8,19 @@ class MobileView {
public static function init():Void {
final mvbtn = ge("#mv_btn");
mvbtn.onclick = e -> {
- final mobileView = Utils.toggleFullScreen(document.documentElement);
- if (mobileView) {
- document.body.classList.add('mobile-view');
- mvbtn.classList.add('active');
- final vwrap = ge("#videowrap");
- if (vwrap.children[0] == ge("currenttitle")) {
+ final hasMobileView = Utils.toggleFullScreen(document.documentElement);
+ final vwrap = ge("#videowrap");
+ if (hasMobileView) {
+ document.body.classList.add("mobile-view");
+ mvbtn.classList.add("active");
+ if (vwrap.children[0].id == "currenttitle") {
vwrap.appendChild(vwrap.children[0]);
}
} else {
- document.body.classList.remove('mobile-view');
- mvbtn.classList.remove('active');
- final vwrap = ge("videowrap");
- if (vwrap.children[0] != ge("currenttitle")) {
- vwrap.insertBefore(vwrap.children[1],vwrap.children[0]);
+ document.body.classList.remove("mobile-view");
+ mvbtn.classList.remove("active");
+ if (vwrap.children[0].id != "currenttitle") {
+ vwrap.insertBefore(vwrap.children[1], vwrap.children[0]);
}
}
}
diff --git a/src/server/Main.hx b/src/server/Main.hx
index 2635abb..271f6ea 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -186,6 +186,7 @@ class Main {
return;
}
client.name = data.login.clientName;
+ client.isUser = true;
send(client, {
type: data.type,
login: {
@@ -201,6 +202,7 @@ class Main {
final oldName = client.name;
final id = clients.indexOf(client) + 1;
client.name = 'Guest $id';
+ client.isUser = false;
send(client, {
type: data.type,
logout: {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage