change response-handling (code-review)

This commit is contained in:
Jakobus Schürz 2023-03-17 17:05:18 +01:00
parent 57a7a3d6d8
commit 5040bd9a1a
1 changed files with 2 additions and 3 deletions

View File

@ -13,13 +13,12 @@ var DzFactory = function () {
init: function() { init: function() {
this.on('success', function(file, serverResponse) { this.on('success', function(file, serverResponse) {
const targetTextarea = document.getElementById(textareaElementId); const targetTextarea = document.getElementById(textareaElementId);
const bbcodeString = serverResponse;
if (targetTextarea.setRangeText) { if (targetTextarea.setRangeText) {
//if setRangeText function is supported by current browser //if setRangeText function is supported by current browser
targetTextarea.setRangeText(' ' + $.trim(bbcodeString) + ' '); targetTextarea.setRangeText(' ' + $.trim(serverResponse) + ' ');
} else { } else {
targetTextarea.focus(); targetTextarea.focus();
document.execCommand('insertText', false /*no UI*/, '\n' + $.trim(bbcodeString) + '\n'); document.execCommand('insertText', false /*no UI*/, '\n' + $.trim(serverResponse) + '\n');
} }
}); });
this.on('complete', function(file) { this.on('complete', function(file) {