mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-10-30 17:54:59 +00:00 
			
		
		
		
	searchPrivate
This commit is contained in:
		| @@ -196,6 +196,10 @@ const ConvChatWindow = { | ||||
|  | ||||
| 		}); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		 | ||||
| 		// =========== SEND FILES =========== | ||||
| 		//Add image button | ||||
| 		const fileButton = createElem2({ | ||||
| 			appendTo: buttonGroup, | ||||
| @@ -229,6 +233,14 @@ const ConvChatWindow = { | ||||
| 				type: "i", | ||||
| 				class: "fa fa-send-o", | ||||
| 			}); | ||||
| 		 | ||||
| 		console.info(infosBox) | ||||
| 		//ConversationsUtils.registerInputToSendFile(, fileInput, formContainer); | ||||
| 		 | ||||
| 		// =========== /SEND FILES =========== | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 		//Prevent textarea from adding a new line when pressing enter | ||||
| 		$(inputText).keypress(function(event){ | ||||
|   | ||||
| @@ -237,9 +237,6 @@ const ConversationsInterface = { | ||||
| 			callback(result); | ||||
|  | ||||
| 		}); | ||||
|  | ||||
| 		//Success | ||||
| 		return true; | ||||
| 	}, | ||||
|  | ||||
| 	/** | ||||
|   | ||||
| @@ -210,6 +210,50 @@ const ConversationsUtils = { | ||||
| 					"2": users.get(msg.server_message.user_removed).fullName | ||||
| 				}); | ||||
| 		} | ||||
| 	}, | ||||
|  | ||||
| 	/** | ||||
| 	 * @param {number} convID  | ||||
| 	 * @param {HTMLInputElement} input  | ||||
| 	 * @param {HTMLElement} target  | ||||
| 	 */ | ||||
| 	registerInputToSendFile: function(convID, fileInput, splashScreenTarget){ | ||||
| 		fileInput.addEventListener("change", async (e) => { | ||||
| 			e.preventDefault(); | ||||
| 			 | ||||
| 			let el; | ||||
| 			 | ||||
| 			try { | ||||
|  | ||||
| 				if(fileInput.files.length == 0) | ||||
| 					return; | ||||
| 				 | ||||
| 				const file = fileInput.files[0]; | ||||
|  | ||||
| 				if (ServerConfig.conf.allowed_conversation_files_type.indexOf(file.type) < 0) { | ||||
| 					notify(tr("This file type is not allowed!"), "danger") | ||||
| 					return; | ||||
| 				} | ||||
|  | ||||
|  | ||||
| 				if (file.size > ServerConfig.conf.conversation_files_max_size) { | ||||
| 					notify(tr("This file is too big (max file size: %1%)", {"1": fileSizeToHuman(ServerConfig.conf.conversation_files_max_size)}), "danger"); | ||||
| 					return; | ||||
| 				} | ||||
|  | ||||
| 				el = Page.showTransparentWaitSplashScreen(splashScreenTarget); | ||||
|  | ||||
| 				await ConversationsInterface.sendMessage(convID, null, fileInput); | ||||
| 			} | ||||
|  | ||||
| 			catch(e) { | ||||
| 				console.error(e); | ||||
| 				notify(tr("Failed to send file!"), "danger"); | ||||
| 			} | ||||
|  | ||||
| 			el.remove(); | ||||
|  | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -445,42 +445,7 @@ const ConversationPageConvPart = { | ||||
| 				class: "fa fa-plus" | ||||
| 			}); | ||||
| 		 | ||||
| 		fileInput.addEventListener("change", async (e) => { | ||||
| 			e.preventDefault(); | ||||
| 			 | ||||
| 			let el; | ||||
| 			 | ||||
| 			try { | ||||
|  | ||||
| 				if(fileInput.files.length == 0) | ||||
| 					return; | ||||
| 				 | ||||
| 				const file = fileInput.files[0]; | ||||
|  | ||||
| 				if (ServerConfig.conf.allowed_conversation_files_type.indexOf(file.type) < 0) { | ||||
| 					notify(tr("This file type is not allowed!"), "danger") | ||||
| 					return; | ||||
| 				} | ||||
|  | ||||
|  | ||||
| 				if (file.size > ServerConfig.conf.conversation_files_max_size) { | ||||
| 					notify(tr("This file is too big (max file size: %1%)", {"1": fileSizeToHuman(ServerConfig.conf.conversation_files_max_size)}), "danger"); | ||||
| 					return; | ||||
| 				} | ||||
|  | ||||
| 				el = Page.showTransparentWaitSplashScreen(); | ||||
|  | ||||
| 				await ConversationsInterface.sendMessage(this._conv_info.id, null, fileInput); | ||||
| 			} | ||||
|  | ||||
| 			catch(e) { | ||||
| 				console.error(e); | ||||
| 				notify(tr("Failed to send file!"), "danger"); | ||||
| 			} | ||||
|  | ||||
| 			el.remove(); | ||||
|  | ||||
| 		}); | ||||
| 		ConversationsUtils.registerInputToSendFile(this._conv_info.id, fileInput, formContainer); | ||||
| 		// ==== /FILE INPUT ==== | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user