diff --git a/public/index.html b/public/index.html index 7e319da19..b995872b4 100644 --- a/public/index.html +++ b/public/index.html @@ -825,7 +825,7 @@ if(online_status != 'no_connection' && this_chid != undefined){ if(type != 'regenerate'){ var textareaText = $("#send_textarea").val(); - $("#send_textarea").val(''); + $("#send_textarea").val('').trigger('input'); }else{ var textareaText = ""; @@ -1704,7 +1704,38 @@ } }); saveSettings(); - + highlightSelectedAvatar(); + }); + $(document).on('click', '#user_avatar_block .avatar_upload', function() { + $('#avatar_upload_file').click(); + }); + $('#avatar_upload_file').on('change', function(e) { + const file = e.target.files[0]; + + if (!file) { + return; + } + + const formData = new FormData($("#form_upload_avatar").get(0)); + + jQuery.ajax({ + type: 'POST', + url: '/uploaduseravatar', + data: formData, + beforeSend: () => {}, + cache: false, + contentType: false, + processData: false, + success: function(data){ + if (data.path) { + appendUserAvatar(data.path); + } + }, + error: (jqXHR, exception) => {}, + }); + + // Will allow to select the same file twice in a row + $('#form_upload_avatar').trigger("reset"); }); $('#logo_block').click(function(event) { if(!bg_menu_toggle){ @@ -2431,7 +2462,7 @@ //console.log(getData.length); for(var i = 0; i < getData.length; i++) { //console.log(1); - $("#user_avatar_block").append('