mirror of https://github.com/calzoneman/sync.git
Migrate old MOTDs and don't replace \n with <br> after
This commit is contained in:
parent
21756d7cb2
commit
654573af68
|
@ -163,10 +163,7 @@ Channel.prototype.loadState = function () {
|
|||
var errorLoad = function (msg) {
|
||||
if (self.modules.customization) {
|
||||
self.modules.customization.load({
|
||||
motd: {
|
||||
motd: msg,
|
||||
html: msg
|
||||
}
|
||||
motd: msg
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,7 @@ function CustomizationModule(channel) {
|
|||
ChannelModule.apply(this, arguments);
|
||||
this.css = "";
|
||||
this.js = "";
|
||||
this.motd = {
|
||||
motd: "",
|
||||
html: ""
|
||||
};
|
||||
this.motd = "";
|
||||
}
|
||||
|
||||
CustomizationModule.prototype = Object.create(ChannelModule.prototype);
|
||||
|
@ -35,12 +32,15 @@ CustomizationModule.prototype.load = function (data) {
|
|||
}
|
||||
|
||||
if ("motd" in data) {
|
||||
this.motd = {
|
||||
motd: data.motd.motd || ""
|
||||
};
|
||||
|
||||
this.motd.motd = XSS.sanitizeHTML(this.motd.motd);
|
||||
this.motd.html = this.motd.motd.replace(/\n/g, "<br>");
|
||||
if (typeof data.motd === "object" && data.motd.motd) {
|
||||
// Old style MOTD, convert to new
|
||||
this.motd = XSS.sanitizeHTML(data.motd.motd).replace(
|
||||
/\n/g, "<br>\n");
|
||||
} else if (typeof data.motd === "string") {
|
||||
// The MOTD is filtered before it is saved, however it is also
|
||||
// re-filtered on load in case the filtering rules change
|
||||
this.motd = XSS.sanitizeHTML(data.motd);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -51,12 +51,7 @@ CustomizationModule.prototype.save = function (data) {
|
|||
};
|
||||
|
||||
CustomizationModule.prototype.setMotd = function (motd) {
|
||||
motd = XSS.sanitizeHTML(motd);
|
||||
var html = motd.replace(/\n/g, "<br>");
|
||||
this.motd = {
|
||||
motd: motd,
|
||||
html: html
|
||||
};
|
||||
this.motd = XSS.sanitizeHTML(motd);
|
||||
this.sendMotd(this.channel.users);
|
||||
};
|
||||
|
||||
|
|
|
@ -175,11 +175,10 @@ Callbacks = {
|
|||
}
|
||||
},
|
||||
|
||||
setMotd: function(data) {
|
||||
CHANNEL.motd = data.html;
|
||||
CHANNEL.motd_text = data.motd;
|
||||
$("#motd").html(CHANNEL.motd);
|
||||
$("#cs-motdtext").val(CHANNEL.motd_text);
|
||||
setMotd: function(motd) {
|
||||
CHANNEL.motd = motd;
|
||||
$("#motd").html(motd);
|
||||
$("#cs-motdtext").val(motd);
|
||||
if (data.motd != "") {
|
||||
$("#motdwrap").show();
|
||||
$("#motd").show();
|
||||
|
|
|
@ -19,7 +19,6 @@ var CHANNEL = {
|
|||
css: "",
|
||||
js: "",
|
||||
motd: "",
|
||||
motd_text: "",
|
||||
name: false,
|
||||
usercount: 0,
|
||||
emotes: []
|
||||
|
|
|
@ -882,7 +882,7 @@ function handleModPermissions() {
|
|||
})();
|
||||
$("#cs-csstext").val(CHANNEL.css);
|
||||
$("#cs-jstext").val(CHANNEL.js);
|
||||
$("#cs-motdtext").val(CHANNEL.motd_text);
|
||||
$("#cs-motdtext").val(CHANNEL.motd);
|
||||
setParentVisible("a[href='#cs-motdeditor']", hasPermission("motdedit"));
|
||||
setParentVisible("a[href='#cs-permedit']", CLIENT.rank >= 3);
|
||||
setParentVisible("a[href='#cs-banlist']", hasPermission("ban"));
|
||||
|
|
Loading…
Reference in New Issue