mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-02-11 08:03:02 +08:00
commit
4557a6fcd2
@ -13,15 +13,16 @@ RegisterNetEvent('_chat:messageEntered')
|
|||||||
|
|
||||||
--deprecated, use chat:addMessage
|
--deprecated, use chat:addMessage
|
||||||
AddEventHandler('chatMessage', function(author, color, text)
|
AddEventHandler('chatMessage', function(author, color, text)
|
||||||
if author == "" then
|
local args = { text }
|
||||||
author = false
|
if author ~= "" then
|
||||||
|
table.insert(args, 1, author)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
type = 'ON_MESSAGE',
|
type = 'ON_MESSAGE',
|
||||||
message = {
|
message = {
|
||||||
color = color,
|
color = color,
|
||||||
multiline = true,
|
multiline = true,
|
||||||
args = { author, text }
|
args = args
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
@ -19,7 +19,7 @@ window.APP = {
|
|||||||
window.removeEventListener('message', this.listener);
|
window.removeEventListener('message', this.listener);
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
$.post('http://chat/loaded', JSON.stringify({}));
|
post('http://chat/loaded', JSON.stringify({}));
|
||||||
this.listener = window.addEventListener('message', (event) => {
|
this.listener = window.addEventListener('message', (event) => {
|
||||||
const item = event.data || event.detail; //'detail' is for debuging via browsers
|
const item = event.data || event.detail; //'detail' is for debuging via browsers
|
||||||
if (this[item.type]) {
|
if (this[item.type]) {
|
||||||
@ -135,11 +135,10 @@ window.APP = {
|
|||||||
this.resize();
|
this.resize();
|
||||||
} else {
|
} else {
|
||||||
if(this.message !== '') {
|
if(this.message !== '') {
|
||||||
$.post('http://chat/chatResult', JSON.stringify({
|
post('http://chat/chatResult', JSON.stringify({
|
||||||
message: this.message,
|
message: this.message,
|
||||||
}));
|
}));
|
||||||
this.oldMessages.unshift(this.message);
|
this.oldMessages.unshift(this.message);
|
||||||
this.message = '';
|
|
||||||
this.oldMessagesIndex = -1;
|
this.oldMessagesIndex = -1;
|
||||||
this.hideInput();
|
this.hideInput();
|
||||||
} else {
|
} else {
|
||||||
@ -149,8 +148,9 @@ window.APP = {
|
|||||||
},
|
},
|
||||||
hideInput(canceled = false) {
|
hideInput(canceled = false) {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
$.post('http://chat/chatResult', JSON.stringify({ canceled }));
|
post('http://chat/chatResult', JSON.stringify({ canceled }));
|
||||||
}
|
}
|
||||||
|
this.message = '';
|
||||||
this.showInput = false;
|
this.showInput = false;
|
||||||
clearInterval(this.focusTimer);
|
clearInterval(this.focusTimer);
|
||||||
this.resetShowWindowTimer();
|
this.resetShowWindowTimer();
|
||||||
|
@ -6,6 +6,13 @@ Vue.component('message', {
|
|||||||
computed: {
|
computed: {
|
||||||
textEscaped() {
|
textEscaped() {
|
||||||
let s = this.template ? this.template : this.templates[this.templateId];
|
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) => {
|
s = s.replace(/{(\d+)}/g, (match, number) => {
|
||||||
const argEscaped = this.args[number] != undefined ? this.escape(this.args[number]) : match
|
const argEscaped = this.args[number] != undefined ? this.escape(this.args[number]) : match
|
||||||
if (number == 0 && this.color) {
|
if (number == 0 && this.color) {
|
||||||
@ -19,10 +26,23 @@ Vue.component('message', {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
colorizeOld(str) {
|
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) {
|
colorize(str) {
|
||||||
const s = "<span>" + (str.replace(/\^([0-9]+)/g, (str, color) => `</span><span class="color-${color}">`)) + "</span>";
|
let s = "<span>" + (str.replace(/\^([0-9]+)/g, (str, color) => `</span><span class="color-${color}">`)) + "</span>";
|
||||||
|
|
||||||
|
const styleDict = {
|
||||||
|
'*': 'font-weight: bold;',
|
||||||
|
'_': 'text-decoration: underline;',
|
||||||
|
'~': 'text-decoration: line-through;',
|
||||||
|
'=': 'text-decoration: underline line-through;',
|
||||||
|
'r': 'text-decoration: none;font-weight: normal;',
|
||||||
|
};
|
||||||
|
|
||||||
|
const styleRegex = /\^(\_|\*|\=|\~|\/|r)(.*?)(?=$|\^r|<\/em>)/;
|
||||||
|
while (s.match(styleRegex)) { //Any better solution would be appreciated :P
|
||||||
|
s = s.replace(styleRegex, (str, style, inner) => `<em style="${styleDict[style]}">${inner}</em>`)
|
||||||
|
}
|
||||||
return s.replace(/<span[^>]*><\/span[^>]*>/g, '');
|
return s.replace(/<span[^>]*><\/span[^>]*>/g, '');
|
||||||
},
|
},
|
||||||
escape(unsafe) {
|
escape(unsafe) {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
// DO NOT EDIT THIS FILE
|
// DO NOT EDIT THIS FILE
|
||||||
// Copy it to `config.js` and edit it
|
// Copy it to `config.js` and edit it
|
||||||
window.CONFIG = {
|
window.CONFIG = {
|
||||||
defaultTemplateId: 'default', //This template will be used for normal chat messages
|
defaultTemplateId: 'default', //This is the default template for 2 args1
|
||||||
|
defaultAltTemplateId: 'defaultAlt', //This one for 1 arg
|
||||||
templates: { //You can add static templates here
|
templates: { //You can add static templates here
|
||||||
'default': '<b>{0}</b>: {1}',
|
'default': '<b>{0}</b>: {1}',
|
||||||
|
'defaultAlt': '{0}',
|
||||||
'example:important': '<h1>^2{0}</h1>'
|
'example:important': '<h1>^2{0}</h1>'
|
||||||
},
|
},
|
||||||
fadeTimeout: 7000,
|
fadeTimeout: 7000,
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
em {
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
font-family: 'Lato', Helvetica, Arial, sans-serif;
|
font-family: 'Lato', Helvetica, Arial, sans-serif;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
|
@ -8,9 +8,6 @@
|
|||||||
<link href="vendor/animate.3.5.2.min.css" rel="stylesheet"></link>
|
<link href="vendor/animate.3.5.2.min.css" rel="stylesheet"></link>
|
||||||
<link href="index.css" rel="stylesheet"></link>
|
<link href="index.css" rel="stylesheet"></link>
|
||||||
|
|
||||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"></script> -->
|
|
||||||
|
|
||||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
|
||||||
<script src="vendor/vue.2.3.3.min.js" type="text/javascript"></script>
|
<script src="vendor/vue.2.3.3.min.js" type="text/javascript"></script>
|
||||||
<script src="config.default.js" type="text/javascript"></script>
|
<script src="config.default.js" type="text/javascript"></script>
|
||||||
<script src="config.js" type="text/javascript"></script>
|
<script src="config.js" type="text/javascript"></script>
|
||||||
@ -91,6 +88,13 @@
|
|||||||
|
|
||||||
<!-- Main Entry -->
|
<!-- Main Entry -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
window.post = (url, data) => {
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.open('POST', url, true);
|
||||||
|
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||||
|
request.send(data);
|
||||||
|
}
|
||||||
|
|
||||||
const instance = new Vue({
|
const instance = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
render: h => h(APP),
|
render: h => h(APP),
|
||||||
|
Loading…
Reference in New Issue
Block a user