2018-07-15 12:46:29 +02:00
|
|
|
<template>
|
|
|
|
<span class="content">
|
2018-07-19 19:44:24 +02:00
|
|
|
<span class="text"><ParsedMessage
|
|
|
|
:network="network"
|
2019-02-25 06:38:13 +01:00
|
|
|
:text="cleanText"
|
|
|
|
/></span>
|
2018-07-15 12:46:29 +02:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ParsedMessage from "../ParsedMessage.vue";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "MessageTypeMOTD",
|
|
|
|
components: {
|
|
|
|
ParsedMessage,
|
|
|
|
},
|
|
|
|
props: {
|
2018-07-19 19:44:24 +02:00
|
|
|
network: Object,
|
2018-07-15 12:46:29 +02:00
|
|
|
message: Object,
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
cleanText() {
|
|
|
|
let lines = this.message.text.split("\n");
|
|
|
|
|
|
|
|
// If all non-empty lines of the MOTD start with a hyphen (which is common
|
|
|
|
// across MOTDs), remove all the leading hyphens.
|
|
|
|
if (lines.every((line) => line === "" || line[0] === "-")) {
|
|
|
|
lines = lines.map((line) => line.substr(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove empty lines around the MOTD (but not within it)
|
2018-07-16 21:05:55 +02:00
|
|
|
return lines
|
2018-07-17 15:38:17 +02:00
|
|
|
.map((line) => line.replace(/\s*$/,""))
|
2018-07-16 21:05:55 +02:00
|
|
|
.join("\n")
|
|
|
|
.replace(/^[\r\n]+|[\r\n]+$/g, "");
|
2018-07-15 12:46:29 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|