"Forward" user information to emoji parser

This commit is contained in:
Pierre HUBERT 2020-04-03 19:38:21 +02:00
parent 527f0a838c
commit 8d6adb336c
7 changed files with 27 additions and 13 deletions

View File

@ -231,7 +231,8 @@ const CommentsUI = {
//Parse emojies //Parse emojies
ComunicWeb.components.textParser.parse({ ComunicWeb.components.textParser.parse({
element: commentContent element: commentContent,
user: user
}); });
//Add comment image (if any) //Add comment image (if any)

View File

@ -891,10 +891,11 @@ const ConvChatWindow = {
}); });
//Load user informations //Load user informations
let userInfos;
if(conversationInfo.membersInfos["user-" + message.ID_user]){ if(conversationInfo.membersInfos["user-" + message.ID_user]){
//Get informations //Get informations
var userInfos = conversationInfo.membersInfos["user-" + message.ID_user]; userInfos = conversationInfo.membersInfos["user-" + message.ID_user];
//Replace poster name //Replace poster name
usernameElem.innerHTML = userInfos.firstName + " " + userInfos.lastName; usernameElem.innerHTML = userInfos.firstName + " " + userInfos.lastName;
@ -953,6 +954,7 @@ const ConvChatWindow = {
//Parse emojies in text message //Parse emojies in text message
ComunicWeb.components.textParser.parse({ ComunicWeb.components.textParser.parse({
element: textMessage, element: textMessage,
user: userInfos,
}); });

View File

@ -26,16 +26,22 @@ ComunicWeb.components.emoji.parser = {
* @info {HTMLElement} element The element to parse * @info {HTMLElement} element The element to parse
* @return {Boolean} True for a success * @return {Boolean} True for a success
*/ */
parse: function(infos){ parse: function(info){
//Peform string parsing //Peform string parsing
infos.element.innerHTML = this.shorcutToHTMLcode(infos.element.innerHTML); info.element.innerHTML = this.shorcutToHTMLcode(info.element.innerHTML);
// Parse custom semicolons
if(info.user)
console.log(info.user);//info.element.innerHTML = this.parseCustomEmojis(infos.elements.innerHTML)
else
console.error("User information are missing!")
//Perform colon conversion //Perform colon conversion
infos.element.innerHTML = this.colonConversion(infos.element.innerHTML); info.element.innerHTML = this.colonConversion(info.element.innerHTML);
//Perform Twitter parsing //Perform Twitter parsing
this.twitterEmojiesParsing(infos.element); this.twitterEmojiesParsing(info.element);
//Success //Success
return true; return true;

View File

@ -12,7 +12,7 @@ ComunicWeb.components.posts.ui = {
* @param {Object} infos Informations about the post * @param {Object} infos Informations about the post
* @param {HTMLElement} target The target for the post * @param {HTMLElement} target The target for the post
*/ */
display_post: function(info, target) { display_post: async function(info, target) {
//Check if it is required to create a post root element or not //Check if it is required to create a post root element or not
if(target.className.includes("post")) if(target.className.includes("post"))
@ -867,7 +867,8 @@ ComunicWeb.components.posts.ui = {
//Parse emojies //Parse emojies
ComunicWeb.components.textParser.parse({ ComunicWeb.components.textParser.parse({
element: postContent element: postContent,
user: await userInfo(info.userID)
}); });
//Add bottom elements container //Add bottom elements container

View File

@ -25,7 +25,8 @@ ComunicWeb.components.textParser = {
//Parse emojies //Parse emojies
ComunicWeb.components.emoji.parser.parse({ ComunicWeb.components.emoji.parser.parse({
element: info.element element: info.element,
user: info.user
}); });
//Parse users tags //Parse users tags

View File

@ -291,7 +291,8 @@ const ConversationPageConvPart = {
//Parse message content //Parse message content
ComunicWeb.components.textParser.parse({ ComunicWeb.components.textParser.parse({
element: messageContent element: messageContent,
user: this._conv_info.users["user-" + info.ID_user]
}); });
//Message image (if any) //Message image (if any)
@ -600,7 +601,7 @@ document.addEventListener("newConvMessage", (e) => {
}) })
// Register to message update events // Register to message update events
document.addEventListener("updatedConvMessage", (e) => { document.addEventListener("updatedConvMessage", async (e) => {
const msg = e.detail; const msg = e.detail;
const target = document.querySelector("[data-chatpage-msg-text-id='"+msg.ID+"'] .txt") const target = document.querySelector("[data-chatpage-msg-text-id='"+msg.ID+"'] .txt")
@ -617,7 +618,8 @@ document.addEventListener("updatedConvMessage", (e) => {
//Parse message content //Parse message content
ComunicWeb.components.textParser.parse({ ComunicWeb.components.textParser.parse({
element: newMessageContent element: newMessageContent,
user: await userInfo(info.ID_user)
}); });
target.replaceWith(newMessageContent) target.replaceWith(newMessageContent)

View File

@ -262,7 +262,8 @@ ComunicWeb.pages.userPage.profileInfos = {
//Parse text //Parse text
ComunicWeb.components.textParser.parse({ ComunicWeb.components.textParser.parse({
element: publicNotes element: publicNotes,
user: infos
}); });
//Add separator //Add separator