mirror of https://github.com/calzoneman/sync.git
A few UI fixes; improve tab complete algorithm
This commit is contained in:
parent
6f3b10222f
commit
6051dd3939
30
lib/user.js
30
lib/user.js
|
@ -83,6 +83,10 @@ function User(socket) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (self.global_rank >= 255) {
|
||||||
|
self.initAdminCallbacks();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +411,32 @@ User.prototype.initChannelCallbacks = function () {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
User.prototype.initAdminCallbacks = function () {
|
||||||
|
var self = this;
|
||||||
|
self.socket.on("borrow-rank", function (rank) {
|
||||||
|
if (self.inChannel()) {
|
||||||
|
if (typeof rank !== "number") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rank > self.global_rank) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rank === 255 && self.global_rank > 255) {
|
||||||
|
rank = self.global_rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.rank = rank;
|
||||||
|
self.socket.emit("rank", rank);
|
||||||
|
self.channel.sendAll("setUserRank", {
|
||||||
|
name: self.name,
|
||||||
|
rank: rank
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
User.prototype.whenLoggedIn = function (fn) {
|
User.prototype.whenLoggedIn = function (fn) {
|
||||||
if (this.loggedIn) {
|
if (this.loggedIn) {
|
||||||
fn();
|
fn();
|
||||||
|
|
|
@ -20,7 +20,7 @@ html(lang="en")
|
||||||
section#mainpage
|
section#mainpage
|
||||||
.container
|
.container
|
||||||
.row
|
.row
|
||||||
#acp-logview.col-md-12(style="display: none")
|
#acp-logview.acp-panel.col-md-12(style="display: none")
|
||||||
h3 Log Viewer
|
h3 Log Viewer
|
||||||
.input-group
|
.input-group
|
||||||
div.input-group-btn
|
div.input-group-btn
|
||||||
|
@ -29,10 +29,10 @@ html(lang="en")
|
||||||
button#acp-httplog-btn.btn.btn-default HTTP log
|
button#acp-httplog-btn.btn.btn-default HTTP log
|
||||||
input#acp-chanlog-name.form-control(type="text", placeholder="Channel name")
|
input#acp-chanlog-name.form-control(type="text", placeholder="Channel name")
|
||||||
pre#acp-log
|
pre#acp-log
|
||||||
#acp-announcements.col-md-12(style="display: none")
|
#acp-announcements.acp-panel.col-md-6.col-md-offset-3(style="display: none")
|
||||||
h3 Announcements
|
h3 Announcements
|
||||||
h3 New Announcement
|
h3 New Announcement
|
||||||
div(style="max-width: 50%")
|
div
|
||||||
form.form-horizontal(action="javascript:void(0)", role="form")
|
form.form-horizontal(action="javascript:void(0)", role="form")
|
||||||
.form-group
|
.form-group
|
||||||
label.control-label.col-sm-2(for="acp-announce-title") Title
|
label.control-label.col-sm-2(for="acp-announce-title") Title
|
||||||
|
@ -45,7 +45,7 @@ html(lang="en")
|
||||||
.form-group
|
.form-group
|
||||||
.col-sm-10.col-sm-offset-2
|
.col-sm-10.col-sm-offset-2
|
||||||
button#acp-announce-submit.btn.btn-primary Announce
|
button#acp-announce-submit.btn.btn-primary Announce
|
||||||
#acp-global-bans.col-md-12(style="display: none")
|
#acp-global-bans.acp-panel.col-md-12(style="display: none")
|
||||||
h3 Global Bans
|
h3 Global Bans
|
||||||
table.table.table-striped.table-bordered
|
table.table.table-striped.table-bordered
|
||||||
thead
|
thead
|
||||||
|
@ -67,7 +67,7 @@ html(lang="en")
|
||||||
.form-group
|
.form-group
|
||||||
.col-sm-9.col-sm-offset-3
|
.col-sm-9.col-sm-offset-3
|
||||||
button#acp-gban-submit.btn.btn-danger Add ban
|
button#acp-gban-submit.btn.btn-danger Add ban
|
||||||
#acp-user-lookup.col-md-12(style="display: none")
|
#acp-user-lookup.acp-panel.col-md-12(style="display: none")
|
||||||
h3 Users
|
h3 Users
|
||||||
.input-group(style="max-width: 25%")
|
.input-group(style="max-width: 25%")
|
||||||
input#acp-ulookup-name.form-control(type="text")
|
input#acp-ulookup-name.form-control(type="text")
|
||||||
|
@ -81,7 +81,7 @@ html(lang="en")
|
||||||
th#acp-users-rank Rank
|
th#acp-users-rank Rank
|
||||||
th#acp-users-email Email
|
th#acp-users-email Email
|
||||||
th Actions
|
th Actions
|
||||||
#acp-channel-lookup.col-md-12(style="display: none")
|
#acp-channel-lookup.acp-panel.col-md-12(style="display: none")
|
||||||
h3 Channels
|
h3 Channels
|
||||||
form.form-inline(action="javascript:void(0)", role="form")
|
form.form-inline(action="javascript:void(0)", role="form")
|
||||||
.form-group
|
.form-group
|
||||||
|
@ -97,7 +97,7 @@ html(lang="en")
|
||||||
th ID
|
th ID
|
||||||
th Name
|
th Name
|
||||||
th Owner
|
th Owner
|
||||||
#acp-loaded-channels.col-md-12(style="display: none")
|
#acp-loaded-channels.acp-panel.col-md-12(style="display: none")
|
||||||
h3 Loaded Channels
|
h3 Loaded Channels
|
||||||
button#acp-lchannels-refresh.btn.btn-default Refresh
|
button#acp-lchannels-refresh.btn.btn-default Refresh
|
||||||
table.table.table-bordered.table-striped(style="margin-top: 20px")
|
table.table.table-bordered.table-striped(style="margin-top: 20px")
|
||||||
|
@ -109,12 +109,12 @@ html(lang="en")
|
||||||
th Registered
|
th Registered
|
||||||
th Public
|
th Public
|
||||||
th Force Unload
|
th Force Unload
|
||||||
#acp-eventlog.col-md-12(style="display: none")
|
#acp-eventlog.acp-panel.col-md-12(style="display: none")
|
||||||
h3 Event Log
|
h3 Event Log
|
||||||
strong Filter event types
|
strong Filter event types
|
||||||
select#acp-eventlog-filter.form-control(multiple="multiple", style="max-width: 25%")
|
select#acp-eventlog-filter.form-control(multiple="multiple", style="max-width: 25%")
|
||||||
pre#acp-eventlog-text(style="margin-top: 20px")
|
pre#acp-eventlog-text(style="margin-top: 20px")
|
||||||
#acp-stats.col-md-12(style="display: none")
|
#acp-stats.acp-panel.col-md-12(style="display: none")
|
||||||
h3 User Count
|
h3 User Count
|
||||||
canvas#stat_users(width="100%", height="400")
|
canvas#stat_users(width="100%", height="400")
|
||||||
h3 Channel Count
|
h3 Channel Count
|
||||||
|
|
|
@ -393,7 +393,7 @@ Callbacks = {
|
||||||
CLIENT.rank = r;
|
CLIENT.rank = r;
|
||||||
handlePermissionChange();
|
handlePermissionChange();
|
||||||
if(SUPERADMIN && $("#setrank").length == 0) {
|
if(SUPERADMIN && $("#setrank").length == 0) {
|
||||||
$("<a/>").attr("href", "/acp.html")
|
$("<a/>").attr("href", "/acp")
|
||||||
.attr("target", "_blank")
|
.attr("target", "_blank")
|
||||||
.text("ACP")
|
.text("ACP")
|
||||||
.appendTo($("<li/>").appendTo($(".nav")[0]));
|
.appendTo($("<li/>").appendTo($(".nav")[0]));
|
||||||
|
|
|
@ -23,13 +23,13 @@ $("#togglemotd").click(function () {
|
||||||
var hidden = $("#motd").css("display") === "none";
|
var hidden = $("#motd").css("display") === "none";
|
||||||
$("#motd").toggle();
|
$("#motd").toggle();
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
$("#togglemotd").find(".icon-plus")
|
$("#togglemotd").find(".glyphicon-plus")
|
||||||
.removeClass("icon-plus")
|
.removeClass("glyphicon-plus")
|
||||||
.addClass("icon-minus");
|
.addClass("glyphicon-minus");
|
||||||
} else {
|
} else {
|
||||||
$("#togglemotd").find(".icon-minus")
|
$("#togglemotd").find(".glyphicon-minus")
|
||||||
.removeClass("icon-minus")
|
.removeClass("glyphicon-minus")
|
||||||
.addClass("icon-plus");
|
.addClass("glyphicon-plus");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -103,6 +103,35 @@ $("#guestname").keydown(function (ev) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function chatTabComplete() {
|
||||||
|
var words = $("#chatline").val().split(" ");
|
||||||
|
var current = words[words.length - 1].toLowerCase();
|
||||||
|
var users = $("#userlist").children().map(function (_, elem) {
|
||||||
|
return elem.children[1].innerHTML;
|
||||||
|
}).filter(function (_, name) {
|
||||||
|
return name.toLowerCase().indexOf(current) === 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
// users now contains a list of names that start with current word
|
||||||
|
if (users.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var min = Math.min.apply(Math, users.map(function (_, name) {
|
||||||
|
return name.length;
|
||||||
|
}));
|
||||||
|
|
||||||
|
current = users[0].substring(0, min);
|
||||||
|
if (users.length === 1) {
|
||||||
|
if (words.length === 1) {
|
||||||
|
current += ":";
|
||||||
|
}
|
||||||
|
current += " ";
|
||||||
|
}
|
||||||
|
words[words.length - 1] = current;
|
||||||
|
$("#chatline").val(words.join(" "));
|
||||||
|
}
|
||||||
|
|
||||||
$("#chatline").keydown(function(ev) {
|
$("#chatline").keydown(function(ev) {
|
||||||
// Enter/return
|
// Enter/return
|
||||||
if(ev.keyCode == 13) {
|
if(ev.keyCode == 13) {
|
||||||
|
@ -135,31 +164,7 @@ $("#chatline").keydown(function(ev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(ev.keyCode == 9) { // Tab completion
|
else if(ev.keyCode == 9) { // Tab completion
|
||||||
var words = $("#chatline").val().split(" ");
|
chatTabComplete();
|
||||||
var current = words[words.length - 1].toLowerCase();
|
|
||||||
var users = $("#userlist").children();
|
|
||||||
var match = null;
|
|
||||||
for(var i = 0; i < users.length; i++) {
|
|
||||||
var name = users[i].children[1].innerHTML.toLowerCase();
|
|
||||||
// Last word is a unique match for a userlist name
|
|
||||||
if(name.indexOf(current) == 0 && match == null) {
|
|
||||||
match = users[i].children[1].innerHTML;
|
|
||||||
}
|
|
||||||
// Last word is NOT a unique match- a match has already
|
|
||||||
// been found. Bail because no unique completion is possible.
|
|
||||||
else if(name.indexOf(current) == 0) {
|
|
||||||
match = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(match != null) {
|
|
||||||
words[words.length - 1] = match;
|
|
||||||
if(words.length == 1)
|
|
||||||
words[0] += ": ";
|
|
||||||
else
|
|
||||||
words[words.length - 1] += " ";
|
|
||||||
$("#chatline").val(words.join(" "));
|
|
||||||
}
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ function addMenuItem(target, text) {
|
||||||
.text(text)
|
.text(text)
|
||||||
.appendTo(li)
|
.appendTo(li)
|
||||||
.click(function () {
|
.click(function () {
|
||||||
$(".col-md-12").hide();
|
$(".acp-panel").hide();
|
||||||
$(target).show();
|
$(target).show();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue