Added function for rules, and moved thumbnail/data somewhat around for better readability

This commit is contained in:
Kasper Rynning-Tønnesen
2018-09-27 22:03:23 +02:00
parent 5a84a4bc70
commit 0b3e7177b1
12 changed files with 599 additions and 208 deletions

View File

@@ -8,7 +8,7 @@ var Admin = {
Admin.logged_in = msg;
if(!msg) return;
w_p = false;
M.Modal.init(document.getElementById("channel_info"));
if(Admin.logged_in) {
Helper.css("#thumbnail_form", "display", "inline-block");
Helper.css("#description_form", "display", "inline-block");
@@ -179,15 +179,34 @@ var Admin = {
Helper.addClass(".change_user_pass", "hide");
//Crypt.remove_userpass(chan.toLowerCase());
}
var updated = false;
if(conf_array.thumbnail != undefined && conf_array.thumbnail != "") {
document.getElementById("thumbnail_image").innerHTML = "<img id='thumbnail_image_channel' src='" + conf_array.thumbnail + "' alt='thumbnail' />";
document.getElementById("thumbnail_input").value = conf_array.thumbnail;
updated = true;
}
if(conf_array.description != undefined && conf_array.description != "") {
document.getElementById("description_area").innerHTML = conf_array.description;
document.getElementById("description_input").value = conf_array.description;
updated = true;
}
if(conf_array.rules != undefined && conf_array.rules != "") {
var existingRules = document.querySelector(".rules-container");
if(existingRules) existingRules.remove();
var rules = conf_array.rules.split("\n");
var elementToAdd = "<li class='rules-container'><div class='row'><div class='col s10 offset-s1'><h4 class='center-align'>Rules</h4>";
for(var i = 0; i < rules.length; i++) {
elementToAdd += "<p class='initial-line-height'>" + rules[i] + "</p>";
}
elementToAdd += "</div></div>";
document.querySelector(".channel_info_container").insertAdjacentHTML("afterend", elementToAdd);
document.getElementById("rules_input").value = conf_array.rules;
updated = true;
}
if(updated) M.updateTextFields();
},
submitAdmin: function(form, userpass_changed) {

View File

@@ -21,6 +21,21 @@ function removeAllListeners() {
socket.removeEventListener(id);
}
function sendDescription() {
emit("suggest_description", {channel: chan, description: document.getElementById("description_input").value});
document.getElementById("description_input").value = "";
}
function sendThumbnail() {
emit("suggest_thumbnail", {channel: chan, thumbnail: document.getElementById("thumbnail_input").value});
document.getElementById("thumbnail_input").value = "";
}
function sendRules() {
emit("suggest_rules", {channel: chan, rules: document.getElementById("rules_input").value});
document.getElementById("rules_input").value = "";
}
function resizeFunction() {
if(chan && !Helper.mobilecheck()){
if(document.querySelector("#wrapper") == null) return;
@@ -1072,6 +1087,12 @@ function toast(msg, _class) {
case "other_list_pass":
msg = "The other list has a pass, can't import the songs..";
break;
case "suggested_rules":
msg = "Your rules have been suggested";
break;
case "rules_denied":
msg = "Your rules will be denied";
break;
case "nolist":
msg = "There is no list with that name";
break;

View File

@@ -433,6 +433,11 @@ function addDynamicListeners() {
}
});
addListener("click", ".info_change_button", function(event) {
this.preventDefault();
M.Modal.getInstance(document.querySelector("#channel_info")).open();
});
addListener("click", "#hide-playlist", function(event) {
this.preventDefault();
fullVideo(!hiddenPlaylist);
@@ -506,16 +511,34 @@ function addDynamicListeners() {
}
});
addListener("submit", "#thumbnail_form", function(event){
addListener("click", ".description_input_send", function(event) {
this.preventDefault();
emit("suggest_thumbnail", {channel: chan, thumbnail: document.getElementById("chan_thumbnail").value});
document.getElementById("chan_thumbnail").value = "";
sendDescription();
});
addListener("submit", "#description_form", function(event){
addListener("click", ".rules_input_send", function(event) {
this.preventDefault();
emit("suggest_description", {channel: chan, description: document.getElementById("chan_description").value});
document.getElementById("chan_description").value = "";
sendRules();
});
addListener("click", ".thumbnail_input_send", function(event) {
this.preventDefault();
sendThumbnail();
});
addListener("submit", "#thumbnail_input_form", function(event){
this.preventDefault();
sendThumbnail();
});
addListener("submit", "#description_input_form", function(event){
this.preventDefault();
sendDescription();
});
addListener("submit", "#rules_input_form", function(event){
this.preventDefault();
sendRules();
});
addListener("click", "#playpause-overlay", function(){
@@ -1639,8 +1662,9 @@ function addDynamicListeners() {
document.querySelector("#text-chat-input") != document.activeElement &&
document.querySelector("#password") != document.activeElement &&
document.querySelector("#user-pass-input") != document.activeElement &&
document.querySelector("#chan_thumbnail") != document.activeElement &&
document.querySelector("#chan_description") != document.activeElement &&
document.querySelector("#thumbnail_input") != document.activeElement &&
document.querySelector("#rules_input") != document.activeElement &&
document.querySelector("#description_input") != document.activeElement &&
document.querySelector("#contact-form-from") != document.activeElement &&
document.querySelector("#contact-form-message") != document.activeElement &&
document.querySelector("#remote_channel") != document.activeElement &&