mirror of
https://github.com/darkwire/darkwire.io.git
synced 2025-07-25 13:26:26 +00:00
Add ability to pass in class names to message log function
This commit is contained in:
parent
16f58684a0
commit
8bd05cf7a0
@ -23,6 +23,7 @@ export default class Chat {
|
|||||||
// Log a message
|
// Log a message
|
||||||
log(message, options) {
|
log(message, options) {
|
||||||
let html = options && options.html === true || false;
|
let html = options && options.html === true || false;
|
||||||
|
let classNames = options && options.classNames ? options.classNames : '';
|
||||||
let $el;
|
let $el;
|
||||||
|
|
||||||
let matchedUsernames = this.checkIfUsername(message.split(' '));
|
let matchedUsernames = this.checkIfUsername(message.split(' '));
|
||||||
@ -40,15 +41,15 @@ export default class Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options && options.error) {
|
if (options && options.error) {
|
||||||
$el = $('<li class="log-error">').addClass('log').html('ERROR: ' + message);
|
$el = $('<li class="log-error">').addClass(`log ${classNames}`).html('ERROR: ' + message);
|
||||||
} else if (options && options.warning) {
|
} else if (options && options.warning) {
|
||||||
$el = $('<li class="log-warning">').addClass('log').html('WARNING: ' + message);
|
$el = $('<li class="log-warning">').addClass(`log ${classNames}`).html('WARNING: ' + message);
|
||||||
} else if (options && options.notice) {
|
} else if (options && options.notice) {
|
||||||
$el = $('<li class="log-info">').addClass('log').html('NOTICE: ' + message);
|
$el = $('<li class="log-info">').addClass(`log ${classNames}`).html('NOTICE: ' + message);
|
||||||
} else if (options && options.info) {
|
} else if (options && options.info) {
|
||||||
$el = $('<li class="log-info">').addClass('log').html(message);
|
$el = $('<li class="log-info">').addClass(`log ${classNames}`).html(message);
|
||||||
} else {
|
} else {
|
||||||
$el = $('<li>').addClass('log').html(message);
|
$el = $('<li>').addClass(`log ${classNames}`).html(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addMessageElement($el, options);
|
this.addMessageElement($el, options);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user