mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
Added styles support, fixed messages with no author, removed JQuery dep
This commit is contained in:
@@ -6,6 +6,13 @@ Vue.component('message', {
|
||||
computed: {
|
||||
textEscaped() {
|
||||
let s = this.template ? this.template : this.templates[this.templateId];
|
||||
|
||||
//This hack is required to preserve backwards compatability
|
||||
if (this.templateId == CONFIG.defaultTemplateId
|
||||
&& this.args.length == 1) {
|
||||
s = this.templates[CONFIG.defaultAltTemplateId] //Swap out default template :/
|
||||
}
|
||||
|
||||
s = s.replace(/{(\d+)}/g, (match, number) => {
|
||||
const argEscaped = this.args[number] != undefined ? this.escape(this.args[number]) : match
|
||||
if (number == 0 && this.color) {
|
||||
@@ -19,10 +26,16 @@ Vue.component('message', {
|
||||
},
|
||||
methods: {
|
||||
colorizeOld(str) {
|
||||
return `<strong style="color: rgb(${this.color[0]}, ${this.color[1]}, ${this.color[2]})">${str}</strong>`
|
||||
return `<span style="color: rgb(${this.color[0]}, ${this.color[1]}, ${this.color[2]})">${str}</span>`
|
||||
},
|
||||
colorize(str) {
|
||||
const s = "<span>" + (str.replace(/\^([0-9]+)/g, (str, color) => `</span><span class="color-${color}">`)) + "</span>";
|
||||
const s = "<span>" + (str.replace(/\^([0-9]+)([busr])|\^([0-9]+)|\^([busr])/g,
|
||||
(match, color1, style1, color2, style2) => {
|
||||
const color = (color1 || color2) ? `color-${color1 || color2} ` : '';
|
||||
const style = (style1 || style2) ? `style-${style1 || style2} ` : '';
|
||||
return `</span><span class="${color}${style}">`;
|
||||
}
|
||||
)) + "</span>";
|
||||
return s.replace(/<span[^>]*><\/span[^>]*>/g, '');
|
||||
},
|
||||
escape(unsafe) {
|
||||
|
||||
Reference in New Issue
Block a user