0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-27 03:20:27 +01:00
discourse-custom-wizard/assets/javascripts/wizard/helpers/char-counter.js.es6

17 Zeilen
658 B
Text

import { registerUnbound } from "discourse-common/lib/helpers";
import I18n from "I18n";
2021-01-19 07:47:07 +01:00
export default registerUnbound("char-counter", function(body, maxLength) {
let bodyLength = body ? body.length : 0;
2021-01-19 07:47:07 +01:00
let length = maxLength || bodyLength;
let characterString = length == 1 ? 'wizard.character' : 'wizard.characters';
let finalString;
if(maxLength) {
finalString = `<div class="body-length">${bodyLength} / ${maxLength} ${ I18n.t(characterString)}</div>`;
} else {
finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`;
}
return new Handlebars.SafeString(finalString);
2021-01-08 07:54:51 +01:00
});