From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1695548772; bh=va0Q7ecDkBW0N8KsdOzHSYWCTkVeKKWmWWqtM1VdG6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jti35M3RAgTl+KFbsCHHg6oWNOx6K/TGgrRA+dWWLJFEmSWYEdFTZWh+QBco16Qfs jvKLAVPJVb7EGEg8uiBMNc7e69Kx0gnQkDAETCE+vPuU+GaVye42cD1wX+eZMAF9MR QXJaw5D7bEAd9tl8rrJwY/LiV605Rq+Ry12MHQo6vxLMj9ttlodH+6gwlLA/RKraQ6 CCOGSpvtdNV8WN6HiwNFO4B53hhUmNNBMouIhrKfO3Vnx37+ixZsFGFC+L/b+TTbtr c9a2Bp9/zchJaS+ekHQO7FfsUTTeFPCxroHYdxivDE4ateOdAwdyM3+9b0/xv+KE9R qupuB5V1LTDHw== Received: from localhost.localdomain (unknown [101.128.125.146]) by gnuweeb.org (Postfix) with ESMTPSA id 2E14424B72E; Sun, 24 Sep 2023 16:46:10 +0700 (WIB) From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , Arthur Lapz , Memet Zx , GNU/Weeb Mailing List Subject: [PATCH v3 11/11] feat(page): implement chat bubble message rendering Date: Sun, 24 Sep 2023 16:45:32 +0700 Message-Id: <20230924094532.1662-12-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230924094532.1662-1-kiizuha@gnuweeb.org> References: <20230924094532.1662-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This commit introduces several key functions for rendering chat bubble messages: - `hashCode()`: Code reference: https://github.com/boringdesigners/boring-avatars/blob/40a8be0d08f1a0d3aa318ef981fedbb2262d91fb/src/lib/utilities.js#L1 Generates fixed numerical values based on alphabet characters - `getFixedRandomColor()` Code reference: https://github.com/boringdesigners/boring-avatars/blob/40a8be0d08f1a0d3aa318ef981fedbb2262d91fb/src/lib/utilities.js#L35-L37 This function is responsible for determining both the text color and border color. - `cleanMessageText()` A simple utility function that removes newline characters ('\n') from a given string. This function is used to prepare message text for rendering. - `setupUserName()` This function handles for trimming user `first_name` and `last_name`. - `getRecentMessages()` This function handles the retrieval of recent Telegram group messages through an API. It also restructures the data to make it more accessible and readable for rendering. - `renderRecentMessages()` The primary function responsible for rendering the chat bubble messages on the page. Please note that the code may appear somewhat repetitive. Despite my limited experience with vanilla JS for web development, I've made the best effort to maintain clarity. Any suggestions or feedback for improving code organization or readability are greatly appreciated. Your expertise in this area is invaluable! Signed-off-by: Muhammad Rizki --- index.html | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 255 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e47a36f..64e5884 100644 --- a/index.html +++ b/index.html @@ -305,6 +305,8 @@ -- Muhammad Rizki