mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Minor formatting adjustments.
Hopefully makes code pasting easier. Added missing break to prevent unintended executions. Signed-off-by: Armored Dragon <publicmail@armoreddragon.com>
This commit is contained in:
parent
c48e9d3a69
commit
2a42bceaec
1 changed files with 16 additions and 13 deletions
|
@ -460,13 +460,8 @@ Rectangle {
|
||||||
function addMessage(username, message, date, channel, type){
|
function addMessage(username, message, date, channel, type){
|
||||||
channel = getChannel(channel)
|
channel = getChannel(channel)
|
||||||
|
|
||||||
// Linkify
|
// Format content
|
||||||
var regex = /(https?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+(?:\/[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]*)?(?=\s|$)/g;
|
message = formatContent(message);
|
||||||
message = message.replace(regex, (match) => {
|
|
||||||
return "<a onclick='Window.openUrl("+match+")' href='" + match + "'>" + match + "</a>";
|
|
||||||
});
|
|
||||||
|
|
||||||
message = sanatizeContent(message); // Make sure we don't have any nasties
|
|
||||||
|
|
||||||
if (type === "notification"){
|
if (type === "notification"){
|
||||||
channel.append({ text: message, date: date, type: "notification" });
|
channel.append({ text: message, date: date, type: "notification" });
|
||||||
|
@ -501,9 +496,16 @@ Rectangle {
|
||||||
return channels[id];
|
return channels[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanatizeContent(mess) {
|
function formatContent(mess) {
|
||||||
|
var link = /(https?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+(?:\/[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]*)?(?=\s|$)/g;
|
||||||
|
mess = mess.replace(link, () => {return "<a onclick='Window.openUrl("+match+")' href='" + match + "'>" + match + "</a>"});
|
||||||
|
|
||||||
var script_tag = /<script\b[^>]*>/gi;
|
var script_tag = /<script\b[^>]*>/gi;
|
||||||
return mess.replace(script_tag, "script");
|
mess = mess.replace(script_tag, "script");
|
||||||
|
|
||||||
|
var newline = /\n/gi;
|
||||||
|
mess = mess.replace(newline, "<br>");
|
||||||
|
return mess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Messages from script
|
// Messages from script
|
||||||
|
@ -519,12 +521,13 @@ Rectangle {
|
||||||
addMessage("SYSTEM", message.message, `[ ${time} - ${date} ]`, "domain", "notification");
|
addMessage("SYSTEM", message.message, `[ ${time} - ${date} ]`, "domain", "notification");
|
||||||
break;
|
break;
|
||||||
case "clear_messages":
|
case "clear_messages":
|
||||||
local.clear()
|
local.clear();
|
||||||
domain.clear()
|
domain.clear();
|
||||||
break;
|
break;
|
||||||
case "initial_settings":
|
case "initial_settings":
|
||||||
if (message.settings.external_window) s_external_window.checked = true
|
if (message.settings.external_window) s_external_window.checked = true;
|
||||||
if (message.settings.maximum_messages) s_maximum_messages.value = message.settings.maximum_messages
|
if (message.settings.maximum_messages) s_maximum_messages.value = message.settings.maximum_messages;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue