From f7cd0932b5c831109a5336010912c28b5455e991 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Tue, 23 Apr 2024 16:41:53 +0200 Subject: [PATCH] fire input event when file is read, fix deprecated func and improved display --- ccp/js/inputwidgetcontroller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ccp/js/inputwidgetcontroller.js b/ccp/js/inputwidgetcontroller.js index 5fc732e..f0b7f89 100644 --- a/ccp/js/inputwidgetcontroller.js +++ b/ccp/js/inputwidgetcontroller.js @@ -524,7 +524,10 @@ class CCPFileInputWidgetController extends CCPBaseInputWidgetController { encoded += '='.repeat(4 - (encoded.length % 4)); } this.value[index] = encoded - this.querySelector("small[name=preview]").textContent = encoded.substr(0, 5) + "..." + encoded.substr(encoded.length - 5) + this.querySelector("small[name=preview]").textContent = + encoded.length > 15 ? encoded.substring(0, 5) + "..." + encoded.substring(encoded.length - 5) : encoded + const newev = new Event("input", { bubbles : true}) + this.dispatchEvent(newev) }) reader.readAsDataURL(file) }