1function getActiveId() { 2 if ($('#chat-archives').hasClass('hidden')) { 3 return '#un-validate-action'; 4 } else { 5 return '#validate-action'; 6 } 7} 8 9function showCloture() { 10 $(getActiveId()).removeClass('hidden'); 11} 12 13function hideCloture() { 14 $(getActiveId()).addClass('hidden'); 15} 16 17function clickLeFil(evt) { 18 $('#message-input').val(''); 19 evt.preventDefault(); 20 21 $('#back-button').removeClass('hidden'); 22 $('#sound-notif').addClass('hidden'); 23 $('#chat-profil').removeClass('hidden'); 24 $('#chat-title').addClass('hidden'); 25 26 var $target = $(evt.target); 27 var this_link = $target.parents('.clicklefil'); 28 if( !this_link.length ){ 29 var this_link = $target; 30 } 31 32 var conv_id = this_link.data('convId'); 33 var o_user_id = this_link.data('id'); 34 var user_id = connectedUserEmail + '@' + salon_id; 35 var otherPersonPhoto = this_link.find('img').attr('src'); 36 var skype_text = this_link.find('.skype').text(); 37 var archived = this_link.data('archived'); 38 var odoo_id = this_link.data('odoo_id'); 39 var url_visio = this_link.data('url_visio'); 40 var stand_name = this_link.data('standName'); 41 var name = this_link.find('.name').text(); 42 this_link.parent().removeClass('alert-conv'); 43 this_link.parent().removeClass('chat-alert'); 44 45 46 // Si la notification est cliquée on teste si id de la conv correspond à un id d'une conv dans list-convs 47 //et on agit sur le parent de la conv dans la list-convs 48// const targetConv = $('#list-convs .clicklefil'); 49// if (this_link.attr('data-conv-id') == targetConv.attr('data-conv-id')) { 50// targetConv.parent().removeClass('alert-conv') 51// } 52 53 54 // if (conv_id) { 55 // var convIndex = notifiedConvs.indexOf(conv_id); 56 // if (convIndex > -1) { 57 // notifiedConvs.splice(convIndex, 1); 58 // } 59 60 // showCloture(); 61 // openConversation(conv_id, user_id, myOwnPhoto, otherPersonPhoto); 62 // } else { 63 // openNewConversation(o_user_id); 64 // } 65 66 //Remise à zero des notifs pour une conversation 67 if (conversationsNotifArray.length > 0) { 68 for (let i = 0; i < conversationsNotifArray.length; i++) { 69 if (conv_id === conversationsNotifArray[i].convId) { 70 var decrement = conversationsNotifArray[i].notifLength; 71 var fromFil = true; 72 conversationsNotifArray[i].notifLength = 0; 73 console.log(decrement); 74 addNotification(true, decrement); 75 } 76 } 77 } 78 79 if (conv_id) { 80 var convIndex = notifiedConvs.indexOf(conv_id); 81 while (convIndex !== -1) { 82 notifiedConvs.splice(convIndex, 1); 83 convIndex = notifiedConvs.indexOf(conv_id); 84 } 85 86 showCloture(); 87 openConversation(conv_id, user_id, myOwnPhoto, otherPersonPhoto); 88 } else { 89 openNewConversation(o_user_id); 90 } 91 92 93 var profil_default = $t('profileLinkText'); 94 var profil_stand = $t('standLinkText'); 95 var ustand_id = this_link.data('standId'); 96 var profil_link = $('#profil-link'); 97 98 if (typeof ustand_id !== 'undefined') { 99 if ((stand_id + '@' + salon_id) == ustand_id) { 100 //profil_link.text(profil_default); 101 profil_link.attr('href', 'conseiller_' + odoo_id + '.html'); 102 profil_link.find('div.stand_visit').hide(); 103 profil_link.find('i').show(); 104 } else { 105 profil_link.find('div.stand_visit').text(profil_stand).show(); 106 profil_link.find('i').hide(); 107 if (ustand_id.indexOf('@') !== -1) ustand_id = ustand_id.split('@')[0]; 108 profil_link.attr('href', 'stand_' + ustand_id + '.html'); 109 } 110 } else { 111 //profil_link.text(profil_default); 112 profil_link.attr('href', 'conseiller_' + odoo_id + '.html'); 113 profil_link.find('div.stand_visit').hide(); 114 profil_link.find('i').show(); 115 } 116 117 if (odoo_id == 0) { 118 profil_link.addClass('hidden'); 119 } else { 120 profil_link.removeClass('hidden'); 121 } 122 123 $('#interlocutor_photo').attr('src', otherPersonPhoto); 124 $('#interlocutor_name').text(name); 125 $('#interlocutor_name').data('id', o_user_id); 126 $('#interlocutor_name').data('conv-id', conv_id); 127 //$('#interlocutor_function').text(this_link.find('.phrase').text()); 128 $('#interlocutor_stand_name').text(this_link.find('.phrase').text()); 129 130 if (typeof ustand_id !== 'undefined' && stand_name != name) 131 $('#interlocutor_stand').text(stand_name); 132 else 133 $('#interlocutor_stand').text(''); 134 135 if (skype_text != 'skype:null?call' && skype_text != 'skype:undefined?call' && skype_text != "") { 136 $('#skype').removeClass('hidden'); 137 } else { 138 $('#skype').addClass('hidden'); 139 } 140 $('#skype').attr('href', skype_text); 141 142 if (archived) {
143 $('#un-validate-action').removeClass('hidden'); 144 $('#validate-action').addClass('hidden'); 145 } else { 146 $('#un-validate-action').addClass('hidden'); 147 $('#validate-action').removeClass('hidden'); 148 } 149 150 if (url_visio) { 151 $('#visio-link').removeClass('hidden'); 152 $('#visio-link').data('user', o_user_id); 153 $('#visio-link').data('conv', conv_id); 154 } else { 155 $('#visio-link').addClass('hidden'); 156 } 157} 158 159function openConversation(conv_id, user_id, own_photo, other_photo) { 160 // This is the function we use to open a conversation 161 var lambda = new AWS.Lambda(); 162 var conversationInfo = { 163 conv_id: conv_id 164 }; 165 166 lambda.invoke({ 167 FunctionName: 'GetMessagesHandler', 168 Payload: JSON.stringify(conversationInfo) 169 }, function(err, data) { 170 if (data.FunctionError) console.log(data); 171 else { 172 $('#chat-fil').empty(); 173 174 var conversation = parse(data.Payload); 175 var messages = parse(conversation.messages); 176 messages.forEach(function(message, index) { 177 var message_class = ''; 178 var message_photo = ''; 179 180 if (message.author == user_id) { 181 message_class = 'send'; 182 message_photo = myOwnPhoto ? myOwnPhoto : 'assets/img/demo/avatar3.jpg'; 183 } else { 184 message_class = 'received'; 185 message_photo = other_photo; 186 } 187 188 renderMessage(message, message_class, message_photo); 189 }); 190 191 $('#fildiscussionsclick').click(); 192 } 193 }); 194 195 if ($('#chat-archives').hasClass('hidden')) { 196 $('#message-input').prop('disabled', true); 197 $('#file-input').prop('disabled', true); 198 } else { 199 $('#message-input').prop('disabled', false); 200 $('#file-input').prop('disabled', false); 201 } 202} 203 204function openNewConversation(o_user_id) { 205 $('#chat-fil').empty(); 206 $('#message-input').prop('disabled', false); 207 $('#file-input').prop('disabled', false); 208 209 var lambda = new AWS.Lambda(); 210 var conversationInfo = { 211 user_id: connectedUserEmail + '@' + salon_id, 212 show_id: salon_id, 213 archived: false, 214 o_user_id: o_user_id, 215 lang: _lang 216 }; 217 218 lambda.invoke({ 219 FunctionName: 'GetConversationHandler', 220 Payload: JSON.stringify(conversationInfo) 221 }, function(err, data) { 222 if (data.FunctionError) console.log(data); 223 else { 224 var conv = false; 225 var conversations = parse(data.Payload); 226 227 conversations.forEach(function(item) { 228 if (item.members.indexOf(o_user_id) !== -1) { 229 conv = item; 230 } 231 }); 232 233 if (conv) { 234 var res = getConvElement(conv); 235 res.find('.clicklefil').click(); 236 showCloture(); 237 reloadConversation('', false); 238 } else { 239 $('#fildiscussionsclick').click(); 240 } 241 } 242 }); 243} 244 245function reloadConversation(open, archived, conv_id) { 246 var lambda = new AWS.Lambda(); 247 var conversationInfo = { 248 user_id: connectedUserEmail + '@' + salon_id, 249 show_id: salon_id, 250 archived: archived, 251 lang: _lang 252 }; 253 254 lambda.invoke({ 255 FunctionName: 'GetConversationHandler', 256 Payload: JSON.stringify(conversationInfo) 257 }, function(err, data) { 258 if (data.FunctionError) console.log(data); 259 else { 260 $('#list-convs').empty(); 261 262 var conversations = parse(data.Payload); 263 conversations.forEach(function(item, index) { 264 if (item.id == conv_id) { 265 if ($('#chat-archives').hasClass('hidden')) { 266 $('#chat-archives').removeClass('hidden'); 267 $('#not-chat-archives').addClass('hidden'); 268 } 269 renderConversation(item, index, open, true); 270 } 271 else 272 renderConversation(item, index, open); 273 274 if (notifiedConvs.indexOf(item.id) != -1) { 275 addMessageNotification(item.id); 276 } 277 }); 278 } 279 }); 280} 281 282function reloadStandList() { 283 var lambda = new AWS.Lambda(); 284 lambda.invoke({ 285 FunctionName: 'StandListHandler', 286 Payload: JSON.stringify({show_id: salon_id}) 287 }, function(err, data) { 288 if (data.FunctionError) console.log(data); 289 else { 290 var listStands = $('#list-stands'); 291 listStands.empty(); 292 293 var stands = parse(data.Payload); 294 stands.sort(function(a, b) { 295 if( orderOnlineStandList == 'random' ){ 296 return Math.round(Math.random()) - 0.5; 297 }else{ 298 var textA = a.stand_name.toUpperCase(); 299 var textB = b.stand_name.toUpperCase(); 300 return (textA < textB) ? -1 : (textA > textB) ? 1 : 0; 301 } 302 }); 303 stands.forEach(renderStand); 304 } 305 }); 306} 307 308function sendMessage(messageObj, topic, clear) { 309 if (client.isConnected()) { 310 messageObj.lang = _lang; 311 console.log('Sending message', messageObj, topic); 312 var message = new Paho.MQTT.Message(stringify(messageObj)); 313 message.destinationName = topic; 314 client.send(message); 315 if (clear) 316 $('#message-input').val(''); 317 } 318} 319 320function archiveConv(conv_id) { 321 var messageObj = { 322 conv_id: conv_id, 323 type: 'archiving' 324 }; 325 326 var topic = 'salon/' + salon_id; 327
328 sendMessage(messageObj, topic, true); 329 $('#chat-fil').empty(); 330 archivedConv = conv_id; 331} 332 333function getUrl(filename) { 334 var lambda = new AWS.Lambda(); 335 lambda.invoke({ 336 FunctionName: 'AttachmentHandler', 337 Payload: JSON.stringify({'filename': encodeURIComponent(filename)}) 338 }, function(err, data) { 339 if (data.FunctionError) console.log(data); 340 else { 341 var links = parse(data.Payload); 342 var presignedLink = links[0], messageLink = links[1].replace(/%/g, '%25'), filename = links[2]; 343 sendFile($('#file-input')[0].files[0], presignedLink, messageLink, filename); 344 } 345 }); 346} 347 348function sendFile(file, url, message_url, filename) { 349 $.ajax({ 350 url: url, 351 type: 'PUT', 352 data: file, 353 success: function(result) { 354 $('#file-input').val(''); 355 $('#message-input').val(message_url + '////' + filename); 356 $('.envoyer').click(); 357 }, 358 contentType: 'binary/octet-stream', 359 processData: false, 360 headers: { 361 'X-AMZ-ACL': 'public-read' 362 } 363 }); 364} 365 366function askVisio(user, conv) { 367 const topic = 'salon/' + salon_id + (conv ? ('/conv/' + conv) : ('/user/' + user)); 368 369 const visioMessage = { 370 author: connectedUserEmail + '@' + salon_id, 371 author_name: connectedUserName, 372 content: 'Demande de visio', 373 to: user, 374 type: 'visio_msg', 375 show_id: salon_id, 376 stand_id: stand_id ? (stand_id + '@' + salon_id) : ('0@' + salon_id) 377 }; 378 379 const askMessage = { 380 author: connectedUserEmail + '@' + salon_id, 381 author_name: connectedUserName, 382 content: $t('askVisio'), 383 to: user, 384 type: conv ? 'current_conv' : 'new_conv', 385 show_id: salon_id, 386 stand_id: stand_id ? (stand_id + '@' + salon_id) : ('0@' + salon_id), 387 public: false 388 }; 389 390 if (conv) { 391 visioMessage.conv_id = conv; 392 askMessage.conv_id = conv; 393 } 394 395 sendMessage(visioMessage, topic, true); 396 sendMessage(askMessage, topic, true); 397 398 const visio_message = getActivityLogParams('visio_asked', salon_id, $('#interlocutor_name').text(), user, connectedUserEmail + '@' + salon_id); 399 sendSQSMessage(visio_message); 400}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.