fixed issue with remove-button not hiding on switching from private mode to online-mode, and added help function in chat2

This commit is contained in:
Kasper Rynning-Tønnesen
2017-02-12 15:50:25 +01:00
parent 86d977bb74
commit 480b3b040d
7 changed files with 84 additions and 36 deletions

View File

@@ -2,6 +2,7 @@ var Chat = {
channel_received: 0,
all_received: 0,
chat_help: ["/name <new name> to change name", "/removename to remove name"],
namechange: function(newName)
{
@@ -21,7 +22,47 @@ var Chat = {
return;
if(data.value.startsWith("/name ")){
Chat.namechange(data.value.substring(6));
}else if(data.value.startsWith("/removename")){
} else if(data.value.startsWith("/help")){
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
if($("#chatall").children().length > 100){
$("#chatall").children()[0].remove()
}
for(var x = 0; x < Chat.chat_help.length; x++){
var color = Helper.intToARGB(Helper.hashCode("System"));
if(color.length < 6) {
for(x = color.length; x < 6; x++){
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatall").append("<li title='Zöff''><span style='color:"+color_temp+";'>System</span>: </li>");
var in_text = document.createTextNode(Chat.chat_help[x]);
$("#chatall li:last")[0].appendChild(in_text);
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
}
} else {
if($("#chatchannel").children().length > 100){
$("#chatchannel").children()[0].remove()
}
for(var x = 0; x < Chat.chat_help.length; x++){
var color = Helper.intToARGB(Helper.hashCode("System"));
if(color.length < 6) {
for(x = color.length; x < 6; x++){
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>System</span>: </li>");
var in_text = document.createTextNode(Chat.chat_help[x]);
$("#chatchannel li:last")[0].appendChild(in_text);
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
}
}
} else if(data.value.startsWith("/removename")){
Chat.removename();
}
else if($(".chat-tab-li a.active").attr("href") == "#all_chat")
@@ -55,6 +96,10 @@ var Chat = {
{
$("#favicon").attr("href", "public/images/highlogo.png");
}
if($("#chatall").children().length > 100){
$("#chatall").children()[0].remove()
}
var color = Helper.intToARGB(Helper.hashCode(inp.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++){
@@ -85,6 +130,10 @@ var Chat = {
$("span.badge.new.white").html(to_display);
}
if($("#chatchannel").children().length > 100){
$("#chatchannel").children()[0].remove()
}
var color = Helper.intToARGB(Helper.hashCode(data.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++){

View File

@@ -426,12 +426,6 @@ function initfp(){
window.location.href = 'http://etys.no';
});
$("#offline-mode").tooltip({
delay: 5,
position: "bottom",
tooltip: "Enable private mode"
});
if(!Helper.mobilecheck() && Frontpage.winter) {
$(".mega").prepend('<div id="snow"></div>');
//Frontpage.start_snowfall();

View File

@@ -558,19 +558,19 @@ function change_offline(enabled, already_offline){
socket.emit("offline", enabled);
$("#offline-mode").tooltip('remove');
if(enabled){
if(list_html){
list_html = $("<div>" + list_html + "</div>");
//list_html.find(".card-content").css("display", "flex");
//list_html.find(".card-content").css("height", "100%");
//list_html.find(".list-title").css("align-self", "center");
//list_html.find(".vote-span").addClass("hide");
list_html.find(".list-remove").removeClass("hide");
list_html = list_html.html();
}
if(list_html){
list_html = $("<div>" + list_html + "</div>");
//list_html.find(".card-content").css("display", "flex");
//list_html.find(".card-content").css("height", "100%");
//list_html.find(".list-title").css("align-self", "center");
//list_html.find(".vote-span").addClass("hide");
list_html.find(".list-remove").removeClass("hide");
list_html = list_html.html();
}
//$(".card-content").css("display", "flex");
//$(".card-content").css("height", "100%");
//$(".list-title").css("align-self", "center");
$(".list-remove").removeClass("hide");
$(".list-remove").removeClass("hide");
//$(".vote-span").addClass("hide");
$("#viewers").addClass("hide");
$("#offline-mode").removeClass("waves-cyan");
@@ -591,12 +591,12 @@ function change_offline(enabled, already_offline){
if(list_html){
list_html = $("<div>" + list_html + "</div>");
//list_html.find(".card-content").css("display", "block");
//list_html.find(".card-content").css("height", "initial");
//list_html.find(".list-title").css("align-self", "center");
//list_html.find(".vote-span").removeClass("hide");
if((!hasadmin || !w_p)){
list_html.find(".list-remove").addClass("hide");
}
//list_html.find(".card-content").css("height", "initial");
//list_html.find(".list-title").css("align-self", "center");
//list_html.find(".vote-span").removeClass("hide");
if(hasadmin && w_p){
list_html.find(".list-remove").addClass("hide");
}
list_html = list_html.html();
}
//$(".card-content").css("display", "block");
@@ -604,7 +604,7 @@ function change_offline(enabled, already_offline){
//$(".list-title").css("align-self", "center");
//$(".vote-span").removeClass("hide");
$("#viewers").removeClass("hide");
if((!hasadmin || !w_p)){
if(hasadmin && w_p){
$(".list-remove").addClass("hide");
}
$("#offline-mode").addClass("waves-cyan");
@@ -1133,7 +1133,7 @@ $(document).on("click", ".import-youtube", function(e){
$(document).on("submit", "#chatForm", function(e){
e.preventDefault();
Chat.chat(document.getElementById("chatForm").input);
Chat.chat(document.getElementById("chatForm").input);
});
$(document).on("click", "#shuffle", function(e)