Default expressions for groups

This commit is contained in:
SillyLossy
2023-04-17 00:20:35 +03:00
parent 339f212981
commit 3af6bcafa7

View File

@ -247,16 +247,27 @@ async function setExpression(character, expression, force) {
const imgUrl = `/characters/${character}/${filename}`; const imgUrl = `/characters/${character}/${filename}`;
img.attr('src', imgUrl); img.attr('src', imgUrl);
img.removeClass('default'); img.removeClass('default');
img.off('error');
img.on('error', function() {
$(this).attr('src', '');
if (force && extension_settings.expressions.showDefault) {
setDefault();
}
});
} else { } else {
if (extension_settings.expressions.showDefault) { if (extension_settings.expressions.showDefault) {
//console.log('no character images, trying default expressions'); //console.log('no character images, trying default expressions');
setDefault();
}
}
function setDefault() {
const defImgUrl = `/img/default-expressions/${filename}`; const defImgUrl = `/img/default-expressions/${filename}`;
//console.log(defImgUrl); //console.log(defImgUrl);
img.attr('src', defImgUrl); img.attr('src', defImgUrl);
img.addClass('default'); img.addClass('default');
} }
} }
}
function onClickExpressionImage() { function onClickExpressionImage() {
// online mode doesn't need force set // online mode doesn't need force set
@ -276,9 +287,6 @@ function onClickExpressionImage() {
function addExpressionImage() { function addExpressionImage() {
const html = `<div class="expression-holder"><img class="expression"></div>`; const html = `<div class="expression-holder"><img class="expression"></div>`;
$('body').append(html); $('body').append(html);
$('img.expression').on('error', function () {
$(this).attr('src', '');
});
} }
function addSettings() { function addSettings() {
const html = ` const html = `