Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 11408 | Rev 11583 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
11490 nelberth 1
<?php
2
use LeadersLinked\Model\ChatGroupUser;
3
 
4
$siteurl  = $this->url('home', [], ['force_canonical' => true]);
5
$audioogg  = $this->basePath('audio/chat.ogg');
6
$audiomp3 = $this->basePath('audio/chat.mp3');
11351 nelberth 7
$emojione_image_path_png  = $this->basePath('vendors/smiley/assets/png/');
11490 nelberth 8
$users_group_png = $this->basePath('images/users-group.png');
9
 
10
$flash_swf_url = $this->basePath('vendors/uploader/Moxie.swf');
11
$silverlight_xap_url = $this->basePath('vendors/uploader/Moxie.xap');
12
 
13
$this->inlineScript()->captureStart();
14
echo <<<EOT
15
var siteurl = '$siteurl';
16
var windowFocus = true;
17
var username;
18
var image_href;
19
var scrollcode;
20
var chatHeartbeatCount = 0;
21
var minChatHeartbeat = 800;
22
var maxChatHeartbeat = 33000;
23
var chatHeartbeatTime = minChatHeartbeat;
24
var originalTitle;
25
var blinkOrder = 0;
26
var audioogg = new Audio('$audioogg');
27
var audiomp3 = new Audio('$audiomp3');
28
var groupChatIcon = '$users_group_png';
29
 
30
var chatboxFocus = new Array();
31
var newMessages = new Array();
32
var newMessagesWin = new Array();
33
var newMessagesSender = new Array();
34
var chatBoxes = new Array();
35
var lastBeat;
36
 
37
emojione.imageType = 'png';
38
emojione.sprites = false;
39
emojione.ascii = true;
40
emojione.imagePathPNG = '$emojione_image_path_png';
41
//emojione.imagePathSVG = 'app/plugins/smiley/assets/svg/';
42
 
43
function msg_eventpl(chatboxtitle,sender,img,message_content,time,position){
44
    var zechat_eventpl = '<li class="clearfix m-t-10 conversers2">' +
45
        '<div class="conversation-text" data-toggle="tooltip" data-placement="left" data-html="true">' +
46
        '<div class="ctext-wrap"><p class="">'+message_content+' <br><i class="text-right">'+time+'</i></p></div></div></li>';
47
 
48
    if(position == "append"){
49
        $("#chatbox_"+chatboxtitle+" .chatboxcontent").append(zechat_eventpl);
50
        $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
51
    }
52
    else{
53
        $("#chatbox_"+chatboxtitle+" .chatboxcontent").prepend(zechat_eventpl);
54
    }
55
 
56
}
57
function msg_oddtpl(chatboxtitle,sender,img,message_content,time,position){
58
    var zechat_oddtpl = '<li class="clearfix m-t-10 odd conversers1">' +
59
        '<div class="conversation-text" data-toggle="tooltip" data-placement="right" data-html="true">' +
60
        '<div class="ctext-wrap"><p class="">'+message_content+'</p><i class="text-right">'+time+'</i></div></div></li>';
61
 
62
    if(position == "append"){
63
        $("#chatbox_"+chatboxtitle+" .chatboxcontent").append(zechat_oddtpl);
64
        $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
65
    }
66
    else{
67
        $("#chatbox_"+chatboxtitle+" .chatboxcontent").prepend(zechat_oddtpl);
68
    }
69
}
70
function typePlace() {
71
 
72
    if(!$('#textarea').html() == '')
73
    {
74
        $(".input-placeholder").css({'visibility':'hidden'});
75
    }
76
    else{
77
        $(".input-placeholder").css({'visibility':'visible'});
78
    }
79
}
80
 
81
$(document).ready(function(){
82
    $(document).on('click', ".e1", function (e){
83
 
84
        e.stopPropagation();
85
 
86
        e.preventDefault();
87
        var item = $(this).closest('.chatbox');
88
        var client = item.attr('client');
89
        //alert(client);
90
        var prevMsg = $("#chatbox_"+client+" .chatboxtextarea").val();
91
        var shortname = $(this).data('shortname');
92
 
93
        $("#chatbox_"+client+" .chatboxtextarea").val(prevMsg+' '+shortname+' ');
94
        $("#chatbox_"+client+" .chatboxtextarea").focus();
95
 
96
    });
97
 
98
    $(document).on('click', "#toggle-emoji", function (e){
99
 
100
        e.stopPropagation();
101
 
102
        e.preventDefault();
103
        var item = $(this).closest('.chatbox');
104
        var client = item.attr('client');
105
        //alert(client);
106
        $("#chatbox_"+client+" .target-emoji").slideToggle( 'fast', function(){
107
 
108
            if ($("#chatbox_"+client+" .target-emoji").css('display') == 'block') {
109
                $('#chatbox_'+client+' .btn-emoji').removeClass('ti-face-smile').addClass('ti-arrow-circle-down');
110
            } else {
111
                $('#chatbox_'+client+' .btn-emoji').removeClass('ti-arrow-circle-down').addClass('ti-face-smile');
112
            }
113
        });
114
        var heit = $('#resultchat').css('max-height');
115
    });
116
 
117
 
118
    $("#minmaxchatlist").click(function(){
119
        if(eval(localStorage.chatlist)){
120
            localStorage.chatlist = false;
121
            $("#showhidechatlist").css('display','none');
122
        }
123
        else{
124
            localStorage.chatlist = true;
125
            $("#showhidechatlist").css('display','block');
126
        }
127
    });
128
 
129
    $("#mute-sound").click(function(){
130
        if(eval(localStorage.sound)){
131
            localStorage.sound = false;
132
            $("#mute-sound").html('<i class="icon icon-volume-off"></i>');
133
        }
134
        else{
135
            localStorage.sound = true;
136
            $("#mute-sound").html('<i class="icon icon-volume-2"></i>');
137
            audiomp3.play();
138
            audioogg.play();
139
        }
140
    });
141
 
142
    if(eval(localStorage.chatlist)){
143
        $("#showhidechatlist").css('display','block');
144
    }
145
    else{
146
        $("#showhidechatlist").css('display','none');
147
    }
148
 
149
    if(eval(localStorage.sound)){
150
        $("#mute-sound").html('<i class="icon icon-volume-2"></i>');
151
    }
152
    else{
153
        $("#mute-sound").html('<i class="icon icon-volume-off"></i>');
154
    }
155
 
156
 
157
    originalTitle = document.title;
158
    startChatSession();
159
    loadGroups();
160
 
161
    $([window, document]).blur(function(){
162
        windowFocus = false;
163
    }).focus(function(){
164
        windowFocus = true;
165
        document.title = originalTitle;
166
    });
167
 
168
    $( "body" ).on( "click", "#new-chat-group", function() {
169
        $("#form-new-group").dialog({
170
            appendTo: 'body',
171
            title: "Nuevo Grupo",
172
            modal: true,
173
            resizable: false
174
        });
175
    });
176
 
177
    $( "body" ).on( "click", "#btn_submit_group", function() {
178
        var name = $("#group_name").val().trim();
179
        if(name!=""){
180
            $('#form-new-group').dialog("close");
181
            $("#group_name").val("");
182
            createGroupChatBox(create_UUID(),false,name);
183
        }
184
 
185
    });
186
});
187
 
188
function restructureChatBoxes() {
189
    align = 0;
190
    for (x in chatBoxes) {
191
        chatboxtitle = chatBoxes[x];
192
 
193
        if ($("#chatbox_"+chatboxtitle).css('display') != 'none') {
194
            if (align == 0) {
195
                $("#chatbox_"+chatboxtitle).css('right', '295px');
196
            } else {
197
                width = (align)*(273+7)+295;
198
                $("#chatbox_"+chatboxtitle).css('right', width+'px');
199
            }
200
            $("#chatbox_"+chatboxtitle).css('z-index',1);
201
            align++;
202
        }
203
    }
204
}
205
 
206
function chatWith(chatuser,chatheaderimg,status,name) {
207
 
208
 
209
    createChatBox(chatuser,chatheaderimg,status,0,name);
210
    $("#chatbox_"+chatuser+" .chatboxtextarea").focus();
211
}
212
 
213
function create_UUID(){
214
    var dt = new Date().getTime();
215
    var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
216
        var r = (dt + Math.random()*16)%16 | 0;
217
        dt = Math.floor(dt/16);
218
        return (c=='x' ? r :(r&0x3|0x8)).toString(16);
219
    });
220
    return uuid;
221
}
222
 
223
function chatGroup(uuid,name)
224
{
225
    createGroupChatBox(uuid,true,name);
226
    $("#chatbox_"+uuid+" .chatboxtextarea").focus();
227
}
228
 
229
function createChatBox(chatboxtitle,chatheaderimg,status,minimizeChatBox,name) {
230
    if ($("#chatbox_"+chatboxtitle).length > 0) {
231
        if ($("#chatbox_"+chatboxtitle).css('display') == 'none') {
232
            $("#chatbox_"+chatboxtitle).css('display','block');
233
            restructureChatBoxes();
234
        }
235
        $("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus();
236
        return;
237
    }
238
    var tipo = "single";
239
    $("<div />" ).attr("id","chatbox_"+chatboxtitle)
240
        .addClass("chatbox active-chat")
241
        .attr("client",chatboxtitle)
242
        .html('<div class="chatbox-icon" onclick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')" href="javascript:void(0)"><div class="contact-floating red"><img class="chat-image img-circle pull-left" src="'+chatheaderimg+'"><small class="unread-msg">2</small><small class="status"'+ status+'></small></div></div>' +
243
        '<div class="panel personal-chat"> ' +
244
        '<div class="panel-heading chatboxhead"> ' +
245
        '<div class="panel-title">' +
246
        '<img class="chat-image img-circle pull-left" height="36" width="36" src="'+chatheaderimg+'" alt="avatar-image"> ' +
247
        '<div class="header-elements">' +
248
        '<a href="">'+name+'</a>' +
249
        '</h3>' +
250
        '<br> ' +
251
        '<small class="status Offline"><b>Offline</b>' +
252
        '</small> ' +
253
        '<div class="pull-right options"> ' +
254
        '<!--<div class="btn-group uploadFile" id="uploadFile" data-client="'+chatboxtitle+'"><span><i class="fa fa-trash"></i></span></div>--> ' +
255
        '<!--<div class="btn-group" onclick="javascript:clearHistory(\''+chatboxtitle+'\')" href="javascript:void(0)"><span><i class="fa fa-trash"></i></span></div>--> ' +
256
        '<div class="btn-group" onclick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')" href="javascript:void(0)">' +
257
        '<span>' +
258
        '<i class="fa fa-minus-circle"></i>' +
259
        '</span>' +
260
        '</div> ' +
261
        '<div class="btn-group" onclick="javascript:closeChatBox(\''+chatboxtitle+'\')" href="javascript:void(0)">' +
262
        '<span><i class="fa fa-times-circle"></i></span>' +
263
        '</div> ' +
264
        '</div> ' +
265
        '</div> ' +
266
        '</div> ' +
267
        '</div> ' +
268
        '<div class="panel-body"><div id="uploader_'+chatboxtitle+'" style="display: none;height: 342px;"><p>Your browser does not have Flash, Silverlight or HTML5 support.</p></div>' +
269
        '<div class="chat-conversation"> ' +
270
        '<ul class="conversation-list chatboxcontent" id="resultchat_'+chatboxtitle+'"> </ul> ' +
271
        '<div class="wchat-footer wchat-chat-footer chatboxinput"> ' +
272
        '<div id="chatFrom"> ' +
273
        '<div class="block-wchat"> ' +
274
        '<button class="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile" id="uploadFile" data-client="'+chatboxtitle+'" style="display: block"></button> ' +
275
        '<button class="icon ti-face-smile font-24 btn-emoji" id="toggle-emoji"></button>' +
276
        '<div class="input-container"> ' +
277
        '<div class="input-emoji"> ' +
278
        '<div class="input-placeholder" style="visibility: hidden; display: none;">Escribe un mensaje</div> ' +
279
        '<textarea class="input chatboxtextarea" id="chatboxtextarea" name="chattxt" contenteditable="" spellcheck="true" style="resize:none;height:20px" placeholder="Escribe un mensaje" onkeydown="javascript:return checkChatBoxInputKey(event,this,\''+chatboxtitle+'\',\''+tipo+'\');"></textarea>' +
280
        '<input id="to_uname" name="to_uname" value="'+chatboxtitle+'" type="hidden">' +
281
        '<input id="from_uname" name="from_uname" value="Beenny" type="hidden"> ' +
282
        '</div> ' +
283
        '</div> ' +
284
        '</div> ' +
285
        '</div> ' +
286
        '<div class="wchat-box-items-positioning-container"><div class="wchat-box-items-overlay-container"><div class="target-emoji" style="display: none"><div id="include-smiley-panel"></div></div></div></div>'+
287
        '</div> ' +
288
        '</div> ' +
289
        '</div>' +
290
        '</div>')
291
        .appendTo($( "body" ));
292
 
293
    var scrollcode = $("#resultchat_"+chatboxtitle).scroll(function(){
294
        if ($("#resultchat_"+chatboxtitle).scrollTop() == 0){
295
 
296
            var client = $("#chatbox_"+chatboxtitle).attr("client");
297
 
298
            if($("#chatbox_"+client+" .pagenum:first").val() != $("#chatbox_"+client+" .total-page").val()) {
299
 
300
                $("#loader").show();
301
                var pagenum = parseInt($("#chatbox_"+client+" .pagenum:first").val()) + 1;
302
 
303
                var URL = siteurl+"chat/get-all-messages/" + client + "?page="+pagenum;
304
 
305
                get_all_msg(URL);
306
 
307
                $("#loader").hide();									// Hide loader on success
308
 
309
                if(pagenum != $("#chatbox_"+client+" .total-page").val()) {
310
                    setTimeout(function () {										//Simulate server delay;
311
 
312
                        $("#resultchat_"+chatboxtitle).scrollTop(100);							// Reset scroll
313
                    }, 458);
314
                }
315
            }
316
 
317
        }
318
    });
319
 
320
 
321
 
322
    $('<script type="text/javascript">scrollcode</' + 'script>').appendTo(document.body);
323
 
324
    get_all_msg(siteurl+"chat/get-all-messages/" + chatboxtitle + "?page=1");
325
 
326
    //lastseen(chatboxtitle);
327
 
328
    smiley_tpl(chatboxtitle);
329
 
330
    $("#chatbox_"+chatboxtitle).css('bottom', '0px');
331
 
332
    chatBoxeslength = 0;
333
    for (x in chatBoxes) {
334
        if ($("#chatbox_"+chatBoxes[x]).css('display') != 'none') {
335
            chatBoxeslength++;
336
        }
337
    }
338
 
339
    if (chatBoxeslength == 0) {
340
        $("#chatbox_"+chatboxtitle).css('right', '295px');
341
    } else {
342
        width = (chatBoxeslength)*(273+7)+295;
343
        $("#chatbox_"+chatboxtitle).css('right', width+'px');
344
    }
345
    $("#chatbox_"+chatboxtitle).css('z-index',1);
346
    chatBoxes.push(chatboxtitle);
347
 
348
    if (minimizeChatBox == 1) {
349
        minimizedChatBoxes = new Array();
350
 
351
        if ($.cookie('chatbox_minimized')) {
352
            minimizedChatBoxes = $.cookie('chatbox_minimized').split(/\|/);
353
        }
354
        minimize = 0;
355
        for (j=0;j<minimizedChatBoxes.length;j++) {
356
            if (minimizedChatBoxes[j] == chatboxtitle) {
357
                minimize = 1;
358
            }
359
        }
360
 
361
        if (minimize == 1) {
362
            $('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display','none');
363
            $('#chatbox_'+chatboxtitle+' .chatboxinput').css('display','none');
364
        }
365
    }
366
 
367
    chatboxFocus[chatboxtitle] = false;
368
 
369
    $("#chatbox_"+chatboxtitle+" .chatboxtextarea").blur(function(){
370
        chatboxFocus[chatboxtitle] = false;
371
        $("#chatbox_"+chatboxtitle+" .chatboxtextarea").removeClass('chatboxtextareaselected');
372
    }).focus(function(){
373
        chatboxFocus[chatboxtitle] = true;
374
        newMessages[chatboxtitle] = false;
375
        $('#chatbox_'+chatboxtitle+' .chatboxhead').removeClass('chatboxblink');
376
        $("#chatbox_"+chatboxtitle+" .chatboxtextarea").addClass('chatboxtextareaselected');
377
    });
378
 
379
 
380
    $("#chatbox_"+chatboxtitle).show();
381
 
382
}
383
 
384
function removeOfGroup(user, group) {
385
 
386
    var c = confirm("Esta seguro de eliminar este usuario de este grupo de chat?");
387
     if(c){
388
        var url = siteurl+"chat/remove-user-from-group/" + group + '/' + user;
389
        $.post(url, {} , function(data){
390
            showGroupContacts(group);
391
        });
392
    }
393
 
394
}
395
 
396
function createGroupChatBox(id,creado=false,name){
397
    if ($("#chatbox_"+id).length > 0) {
398
        if ($("#chatbox_"+id).css('display') == 'none') {
399
            $("#chatbox_"+id).css('display','block');
400
            restructureChatBoxes();
401
        }
402
        $("#chatbox_"+id+" .chatboxtextarea").focus();
403
        return;
404
    }
405
 
406
 
407
    var tipo = "group";
408
 
409
    $("<div />" ).attr("id","chatbox_"+id)
410
        .addClass("chatbox active-chat")
411
        .attr("client",id)
412
        .html('<div class="chatbox-icon" onclick="javascript:toggleChatBoxGrowth(\''+id+'\')" href="javascript:void(0)"><div class="contact-floating red"><img class="chat-image img-circle pull-left" src=""><small class="unread-msg">2</small><small class="status Online"></small></div></div>' +
413
        '<div class="panel personal-chat"> ' +
414
        '<div class="panel-heading chatboxhead"> ' +
415
        '<div class="panel-title">' +
416
        '<img class="chat-image img-circle pull-left" height="36" width="36" src="'+groupChatIcon+'" alt="avatar-image"> ' +
417
        '<div class="header-elements">' +
418
        '<a href="">'+name.substring(0, 12)+'</a>' +
419
        '</h3>' +
420
        '<br> ' +
421
        '<small class="status Online"><b>Online</b>' +
422
        '</small> ' +
423
        '<div class="pull-right options"> ' +
424
        '<div class="btn-group addUser" data-client="'+id+'" data-name="'+name+'"><span><i class="fa fa-user-plus"></i></span></div>' +
425
        '<div class="btn-group" onclick="javascript:toggleChatBoxGrowth(\''+id+'\')" href="javascript:void(0)">' +
426
        '<span>' +
427
        '<i class="fa fa-minus-circle"></i>' +
428
        '</span>' +
429
        '</div> ' +
430
        '<div class="btn-group" onclick="javascript:closeChatBox(\''+id+'\')" href="javascript:void(0)">' +
431
        '<span><i class="fa fa-times-circle"></i></span>' +
432
        '</div> ' +
433
        '</div> ' +
434
        '</div> ' +
435
        '</div> ' +
436
        '</div> ' +
437
        '<div class="panel-body"><div id="uploader_'+id+'" style="display: none;height: 342px;"><p>Your browser does not have Flash, Silverlight or HTML5 support.</p></div>' +
438
        '<div id="participants_'+id+'" style="display: none;height: 342px;"><div style="text-align:center;">Agregue integrantes al grupo</div>' +
439
        '<div class="participants_list"><ul id="contact-list-ul-gchat-'+id+'" class="ul-participants-list" style="padding-left:5px;"></ul></div>' +
440
        '<div class="participants_controls">' +
441
        '<a class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary closeAddUser" style="font-size: 14px; z-index: 1;margin-left:10px;" role="button" aria-disabled="false" data-client="'+id+'"><span class="ui-button-icon-primary ui-icon ui-icon-circle-close "></span><span class="ui-button-text">Cerrar</span></a></div>' +
442
        '</div>' +
443
        '<div class="chat-conversation"> ' +
444
        '<ul class="conversation-list chatboxcontent" id="resultchat_'+id+'"> </ul> ' +
445
        '<div class="wchat-footer wchat-chat-footer chatboxinput"> ' +
446
        '<div id="chatFrom"> ' +
447
        '<div class="block-wchat"> ' +
448
        '<button class="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile" id="uploadFile" data-client="'+id+'" style="display: block"></button> ' +
449
        '<button class="icon ti-face-smile font-24 btn-emoji" id="toggle-emoji"></button>' +
450
        '<div class="input-container"> ' +
451
        '<div class="input-emoji"> ' +
452
        '<div class="input-placeholder" style="visibility: hidden; display: none;">Escribe un mensaje</div> ' +
453
        '<textarea class="input chatboxtextarea" id="chatboxtextarea" name="chattxt" contenteditable="" spellcheck="true" style="resize:none;height:20px" placeholder="Escribe un mensaje" onkeydown="javascript:return checkChatBoxInputKey(event,this,\''+id+'\',\''+tipo+'\');"></textarea>' +
454
        '<input id="to_uname" name="to_uname" value="'+id+'" type="hidden">' +
455
        '<input id="from_uname" name="from_uname" value="Beenny" type="hidden"> ' +
456
        '</div> ' +
457
        '</div> ' +
458
        '</div> ' +
459
        '</div> ' +
460
        '<div class="wchat-box-items-positioning-container"><div class="wchat-box-items-overlay-container"><div class="target-emoji" style="display: none"><div id="include-smiley-panel"></div></div></div></div>'+
461
        '</div> ' +
462
        '</div> ' +
463
        '</div>' +
464
        '</div>')
465
        .appendTo($( "body" ));
466
 
467
        $('<script type="text/javascript">scrollcode</' + 'script>').appendTo(document.body);
468
        get_all_msg(siteurl+"chat/get-all-group-messages/" + id + "?page=1");
469
 
470
        smiley_tpl(id);
471
 
472
        $("#chatbox_"+id).css('bottom', '0px');
473
 
474
        chatBoxeslength = 0;
475
        for (x in chatBoxes) {
476
            if ($("#chatbox_"+chatBoxes[x]).css('display') != 'none') {
477
                chatBoxeslength++;
478
            }
479
        }
480
 
481
 
482
        if (chatBoxeslength == 0) {
483
            $("#chatbox_"+id).css('right', '295px');
484
        } else {
485
            width = (chatBoxeslength)*(273+7)+295;
486
            $("#chatbox_"+id).css('right', width+'px');
487
        }
488
        $("#chatbox_"+id).css('z-index',1);
489
        chatBoxes.push(id);
490
 
491
        chatboxFocus[id] = false;
492
 
493
        $("#chatbox_"+id+" .chatboxtextarea").blur(function(){
494
            chatboxFocus[id] = false;
495
            $("#chatbox_"+id+" .chatboxtextarea").removeClass('chatboxtextareaselected');
496
        }).focus(function(){
497
            chatboxFocus[id] = true;
498
            newMessages[id] = false;
499
            $('#chatbox_'+id+' .chatboxhead').removeClass('chatboxblink');
500
            $("#chatbox_"+id+" .chatboxtextarea").addClass('chatboxtextareaselected');
501
        });
502
 
503
        $("#chatbox_"+id).show();
504
 
505
        if(!creado){
506
            createChatGroup(id,name);
507
        }
508
 
509
 
510
 
511
}
512
 
513
function chatHeartbeat(){
514
 
515
    var itemsfound = 0;
516
    if (windowFocus == false) {
517
 
518
        var blinkNumber = 0;
519
        var titleChanged = 0;
520
        for (x in newMessagesWin) {
521
            if (newMessagesWin[x] == true) {
522
                ++blinkNumber;
523
                if (blinkNumber >= blinkOrder) {
524
                    document.title = newMessagesSender[x]+' dice...';
525
                    titleChanged = 1;
526
                    break;
527
                }
528
            }
529
        }
530
 
531
        if (titleChanged == 0) {
532
            document.title = originalTitle;
533
            blinkOrder = 0;
534
        } else {
535
            ++blinkOrder;
536
        }
537
 
538
    } else {
539
        for (x in newMessagesWin) {
540
            newMessagesWin[x] = false;
541
        }
542
    }
543
 
544
    for (x in newMessages) {
545
        if (newMessages[x] == true) {
546
            if (chatboxFocus[x] == false) {
547
                //FIXME: add toggle all or none policy, otherwise it looks funny
548
                $('#chatbox_'+x+' .chatboxhead').toggleClass('chatboxblink');
549
            }
550
        }
551
    }
552
 
553
    $.ajax({
554
        url: siteurl+"chat/heart-beat",
555
        cache: false,
556
        dataType: "json",
557
        success: function(data) {
558
            $.each(data.items, function(i,item){
559
                if (item)	{ // fix strange ie bug
560
                    var isGroup = false;
561
                    if(item.g){
562
                        isGroup = 1;
563
                        chatboxtitle = item.f;
564
                        sender = item.f;
565
                        senderimg = item.p;
566
                        img = item.p2;
567
                        status = item.st;
568
                        msgtype = item.mtype;
569
                        time = item.time;
570
                        id = item.g;
571
                        sender_name = item.n;
572
                        group_name = item.gn;
573
                    }else{
574
                        isGroup         = 0;
575
                        chatboxtitle    = item.f;
576
                        sender          = item.f;
577
                        senderimg       = item.p;
578
                        img             = item.p2;
579
                        status          = item.st;
580
                        msgtype         = item.mtype;
581
                        time            = item.time;
582
                        id              = item.x;
583
                        sender_name     = item.n;
584
                    }
585
 
586
 
587
                    console.log("heart-beat - #chatbox_"+id);
588
 
589
 
590
                    if ($("#chatbox_"+id).length <= 0) {
591
                        if(isGroup){
592
                            createGroupChatBox(id,true,group_name);
593
                        }else{
594
                            createChatBox(id,senderimg,status,"",sender_name);
595
                        }
596
                        if (eval(localStorage.sound)) {
597
                            //audiomp3.play();
598
                            //audioogg.play();
599
                        }
600
                        return;
601
                    }
602
                    if ($("#chatbox_"+id).css('display') == 'none') {
603
                        $("#chatbox_"+id).css('display','block');
604
                        restructureChatBoxes();
605
                    }
606
 
607
                    var message_content = item.m;
608
                    if (msgtype=="text") {
609
                        message_content = item.m;
610
                    } else {
611
                        var path = item.m
612
                        if (msgtype == "image") {
613
                            message_content = "<a url='" + path + "' onclick='trigq(this)'><img src='" + path + "' class='userfiles'/></a>";
614
                        }
615
                        else if (file_content.file_type == "video") {
616
                            message_content = '<video class="userfiles" controls>' +
617
                            '<source src="' + path + '" type="video/mp4">' +
618
                            'Your browser does not support HTML5 video.' +
619
                            '</video>';
620
                        }
621
                        else {
622
                            message_content = "<a href='" + path + "' class='download-link' download></a>";
623
                        }
624
 
625
                    }
626
 
627
                    if (msgtype == "text") {
628
                            message_content = emojione.shortnameToImage(message_content);  // Set imotions
629
                        }
630
                        newMessages[id] = true;
631
                        newMessagesWin[id] = true;
632
                        newMessagesSender[id] = sender_name;
633
                        msg_eventpl(id,sender,senderimg,message_content,time,"append");
634
 
635
                        if (eval(localStorage.sound)) {
636
                            audiomp3.play();
637
                            audioogg.play();
638
                        }
639
                    //}
640
 
641
                    itemsfound += 1;
642
                }
643
            });
644
 
645
            chatHeartbeatCount++;
646
 
647
            if (itemsfound > 0) {
648
                chatHeartbeatTime = minChatHeartbeat;
649
                chatHeartbeatCount = 1;
650
            } else if (chatHeartbeatCount >= 10) {
651
                chatHeartbeatTime *= 2;
652
                chatHeartbeatCount = 1;
653
                if (chatHeartbeatTime > maxChatHeartbeat) {
654
                    chatHeartbeatTime = maxChatHeartbeat;
655
                }
656
            }
657
            if (itemsfound > 0) {
658
                $("#chatbox_"+id+" .chatboxcontent").scrollTop($("#chatbox_"+id+" .chatboxcontent")[0].scrollHeight);
659
            }
660
        }});
661
    setTimeout('chatHeartbeat();',chatHeartbeatTime);
662
 
663
}
664
 
665
function get_all_msg(url){
666
    $.ajax({
667
        url: url,
668
        cache: false,
669
        dataType: "json",
670
        success: function(data) {
671
 
672
            $.each(data.items, function(i,item){
673
                if (item) {
674
                    chatboxtitle = item.f;
675
                    chatboximg = item.p2;
676
                    senderimg = item.p;
677
                    status = item.st;
678
                    sender = item.sender;
679
                    page = item.page;
680
                    pages = item.pages;
681
                    msgtype = item.mtype;
682
                    time = item.time;
683
 
684
                    if (item.page != "" && i == 0) {
685
                        $("#chatbox_" + chatboxtitle + " .chatboxcontent").prepend('<input type="hidden" class="pagenum" value="' + item.page + '" /><input type="hidden" class="total-page" value="' + pages + '" />');
686
                    }
687
 
688
                    if (item.s == 1) {
689
                        //item.f = username;
690
                    }
691
 
692
                    var message_content = item.m;
693
                    if (msgtype == "text") {
694
                        message_content = item.m;
695
                        message_content = emojione.shortnameToImage(message_content);
696
                    }
697
                    else {
698
                        var path = item.m;
699
 
700
                        if (msgtype=="image") {
701
                            message_content = "<a url='" + path + "' onclick='trigq(this)'><img src='" + path + "' class='userfiles'/></a>";
702
                        }
703
                        else if(msgtype == "video") {
704
                            message_content = '<video class="userfiles" controls>' +
705
                            '<source src="' + path + '" type="video/mp4">' +
706
                            'Your browser does not support HTML5 video.' +
707
                            '</video>';
708
                        }
709
                        else{
710
                            message_content = "<a href='"+path+"' class='download-link' download></a>";
711
                        }
712
 
713
                    }
714
 
715
                    if (item.s == 2) {
716
                        $("#chatbox_"+chatboxtitle+" .chatboxcontent").prepend('<div class="chatboxmessage"><div class="_5w-5"><div class="_5w-6"><abbr class="livetimestamp">'+item.m+'</abbr></div></div></div>');
717
                    } else {
718
                        if (item.u == 2) {
719
                            msg_eventpl(chatboxtitle,sender,senderimg,message_content,time,"prepend");
720
                        } else {
721
                            msg_oddtpl(chatboxtitle,sender,senderimg,message_content,time,"prepend");
722
                        }
723
                    }
724
                }
725
                if (page == 1) {
726
                    $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
727
                }
728
            });
729
 
730
        }});
731
 
732
 
733
}
734
 
735
function checkChatBoxInputKey(event,chatboxtextarea,chatboxtitle,tipo) {
736
    if(event.keyCode == 13 && event.shiftKey == 0)  {
737
        message = $(chatboxtextarea).val();
738
        message = message.replace(/^\s+|\s+$/g,"");
739
 
740
 
741
        $(chatboxtextarea).val('');
742
        $(chatboxtextarea).focus();
743
        $(chatboxtextarea).css('height','20px');
744
        if (message != '') {
745
            if(tipo=="single"){
746
                var url = siteurl+"chat/send/" + chatboxtitle;
747
            }else{
748
                var url = siteurl+"chat/send-group/" + chatboxtitle;
749
            }
750
            $.post(url, {message: message} , function(data){
751
                message = message.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;");
752
 
753
                var con = message;
754
                var words = con.split(' ');
755
                for (i in words) {
756
                    if (words[i].indexOf('http://') == 0 || words[i].indexOf('https://') == 0) {
757
                        words[i] = '<a href="' + words[i] + '">' + words[i] + '</a>';
758
                    }
759
                    else if (words[i].indexOf('www') == 0 ) {
760
                        words[i] = '<a href="' + words[i] + '">' + words[i] + '</a>';
761
                    }
762
                }
763
                message = words.join(' ');
764
                message = emojione.shortnameToImage(message); // Set imotions
765
 
766
                $('#chatbox_'+chatboxtitle+' .target-emoji').css({'display':'none'});
767
                $('#chatbox_'+chatboxtitle+' .btn-emoji').removeClass('ti-arrow-circle-down').addClass('ti-face-smile');
768
 
769
                msg_oddtpl(chatboxtitle,data.sender,data.sender_profile_img,message,"Ahora","append");
770
 
771
                $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
772
            });
773
        }
774
        chatHeartbeatTime = minChatHeartbeat;
775
        chatHeartbeatCount = 1;
776
 
777
        return false;
778
    }
779
 
780
    var adjustedHeight = chatboxtextarea.clientHeight;
781
    var maxHeight = 94;
782
 
783
    if (maxHeight > adjustedHeight) {
784
        adjustedHeight = Math.max(chatboxtextarea.scrollHeight, adjustedHeight);
785
        if (maxHeight)
786
            adjustedHeight = Math.min(maxHeight, adjustedHeight);
787
        if (adjustedHeight > chatboxtextarea.clientHeight)
788
            $(chatboxtextarea).css('height',adjustedHeight+8 +'px');
789
    } else {
790
        $(chatboxtextarea).css('overflow','auto');
791
    }
792
 
793
}
794
 
795
function lastseen(uname){
796
    $.ajax({
797
        url: siteurl + "chat/last_seen?uname="+uname,
798
        cache: false,
799
        type: "POST",
800
        success: function (data) {
801
            var data = data.trim().replace('"','').replace('"','');
802
            if(data == "Online"){
803
                $("#chatbox_"+uname+" .panel-heading .status").removeClass("Offline");
804
            } else{
805
                $("#chatbox_"+uname+" .panel-heading .status").removeClass("Online");
806
            }
807
            $("#chatbox_"+uname+" .panel-heading .status").addClass(data).html(data);
808
        },
809
        error: function( error )
810
        {
811
 
812
        }
813
    });
814
}
815
 
816
function startChatSession(){
817
    $.ajax({
818
        url: siteurl+"chat/start-session",
819
        cache: false,
820
        dataType: "json",
821
        success: function(data) {
822
 
823
            username = data.username;
824
 
825
            $.each(data.items, function(i,item){
826
                if (item)	{
827
 
828
                    chatboxtitle = item.f;
829
                    chatboximg = item.p;
830
                    sesimg = item.p2;
831
                    status = item.st;
832
 
833
                    if ($("#chatbox_"+chatboxtitle).length <= 0) {
834
                        createChatBox(chatboxtitle,chatboximg,status,1);
835
                    }
836
 
837
                    if (item.s == 1) {
838
                        item.f = username;
839
                    }
840
 
841
                    if (item.s == 2) {
842
 
843
                    } else {
844
 
845
                        if (item.u == 2) {
846
 
847
                        } else {
848
 
849
                        }
850
                    }
851
                }
852
            });
853
 
854
            for (i=0;i<chatBoxes.length;i++) {
855
                chatboxtitle = chatBoxes[i];
856
                $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
857
                setTimeout('$("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);', 100); // yet another strange ie bug
858
 
859
            }
860
 
861
            setTimeout('chatHeartbeat();',1000);
862
        }});
863
 
864
        setInterval(function () { globalUpdate(); }, 10000);
865
}
866
 
867
function globalUpdate(){
868
    onlineSignal();
869
    loadGroups();
870
    updateContacts();
871
    getContactStatus();
872
}
873
 
874
function onlineSignal(){
875
    var url = siteurl+"chat/online-signal";
876
    $.post(url, {} , function(data){
877
    });
878
}
879
 
880
function updateContacts(){
881
  if (typeof $("#live-search-box").val() !== 'undefined'){
882
    if($("#live-search-box").val().trim()==""){
883
        var url = siteurl+"chat/update-contacts";
884
        $.get(url, {} , function(response){
885
            if(response.success) {
886
                $("#contact-list-ul").html(response.data);
887
            }
888
        });
889
    }
890
  }
891
}
892
 
893
function getContactStatus()
894
{
895
    var url = siteurl+"chat/get-contact-status";
896
    $.get(url, {} , function(response){
897
 
898
        console.log('get-contact-status');
899
        console.log(response);
900
        if(response.success) {
901
            for(var i=0;i<response.data.length;i++){
902
                if(response.data[i].status == "Online"){
903
                    $("#chatbox_"+response.data[i].id+" .panel-heading .status").removeClass("Offline");
904
                    $("#chatbox_"+response.data[i].id+" .panel-heading .status").addClass("Online");
905
                    $("#chatbox_"+response.data[i].id+" .panel-heading .status").text("Online");
906
                } else{
907
                    $("#chatbox_"+response.data[i].id+" .panel-heading .status").removeClass("Online");
908
                    $("#chatbox_"+response.data[i].id+" .panel-heading .status").addClass("Offline");
909
                    $("#chatbox_"+response.data[i].id+" .panel-heading .status").text("Offline");
910
                }
911
            }
912
        }
913
    });
914
}
915
 
916
function closeChatBox(uuid) {
917
    $('#chatbox_'+uuid).css('display','none');
918
    restructureChatBoxes();
919
    var url = siteurl+"chat/close/" + uuid;
920
    $.post(url, {} , function(data){
921
    });
922
}
923
 
924
 
925
function clearHistory(uuid){
926
    var url = siteurl+"chat/clear/" + uuid;
927
    $.post(url, { } , function(data){
928
    });
929
}
930
 
931
function toggleChatBoxGrowth(chatboxtitle) {
932
 
933
    if ($('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display') == 'none') {
934
        var minimizedChatBoxes = new Array();
935
 
936
        if ($.cookie('chatbox_minimized')) {
937
            minimizedChatBoxes = $.cookie('chatbox_minimized').split(/\|/);
938
        }
939
 
940
        var newCookie = '';
941
 
942
        for (i=0;i<minimizedChatBoxes.length;i++) {
943
            if (minimizedChatBoxes[i] != chatboxtitle) {
944
                newCookie += chatboxtitle+'|';
945
            }
946
        }
947
 
948
        newCookie = newCookie.slice(0, -1)
949
 
950
 
951
        $.cookie('chatbox_minimized', newCookie);
952
        $('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display','block');
953
        $('#chatbox_'+chatboxtitle+' .chatboxinput').css('display','block');
954
        $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
955
    } else {
956
        var newCookie = chatboxtitle;
957
 
958
        if ($.cookie('chatbox_minimized')) {
959
            newCookie += '|'+$.cookie('chatbox_minimized');
960
        }
961
 
962
 
963
        $.cookie('chatbox_minimized',newCookie);
964
        $('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display','none');
965
        $('#chatbox_'+chatboxtitle+' .chatboxinput').css('display','none');
966
    }
967
 
968
}
969
 
970
jQuery.cookie = function(name, value, options) {
971
    if (typeof value != 'undefined') {
972
        options = options || {};
973
        if (value === null) {
974
            value = '';
975
            options.expires = -1;
976
        }
977
        var expires = '';
978
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
979
            var date;
980
            if (typeof options.expires == 'number') {
981
                date = new Date();
982
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
983
            } else {
984
                date = options.expires;
985
            }
986
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
987
        }
988
 
989
        var path = options.path ? '; path=' + (options.path) : '';
990
        var domain = options.domain ? '; domain=' + (options.domain) : '';
991
        var secure = options.secure ? '; secure' : '';
992
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
993
    } else {
994
        var cookieValue = null;
995
        if (document.cookie && document.cookie != '') {
996
            var cookies = document.cookie.split(';');
997
            for (var i = 0; i < cookies.length; i++) {
998
                var cookie = jQuery.trim(cookies[i]);
999
 
1000
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
1001
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
1002
                    break;
1003
                }
1004
            }
1005
        }
1006
        return cookieValue;
1007
    }
1008
};
1009
 
1010
var lastTypedTime = new Date(0);
1011
var typingDelayMillis = 5000;
1012
 
1013
function refreshTypingStatus(chatboxtitle){
1014
    /*if (!$('#textarea').is(':focus') || $('#textarea').val() == '' || new Date().getTime() - lastTypedTime.getTime() > typingDelayMillis) {
1015
        $("#typing_on").html('');
1016
    } else {
1017
        $.post(siteurl+"chat/chat.php?action=typingstatus", {to: chatboxtitle, typing: 1} , function(data){
1018
 
1019
        });
1020
    }*/
1021
}
1022
function updateLastTypedTime() {
1023
    lastTypedTime = new Date();
1024
}
1025
 
1026
function scrollDown2(chatboxtitle){
1027
    var wtf    = $("#chatbox_"+chatboxtitle+" .chatboxcontent");
1028
    var height = wtf[0].scrollHeight;
1029
    wtf.scrollTop(height);
1030
}
1031
 
1032
//Search User In contactList
1033
jQuery(document).ready(function(){
1034
    $('.live-search-list li').each(function(){
1035
        $(this).attr('data-search-term', $(this).text().toLowerCase());
1036
    });
1037
    $('.live-search-box').on('keyup', function(){
1038
        var searchTerm = $(this).val().toLowerCase();
1039
        var found = false;
1040
 
1041
        if($('#contact-list-ul:visible').length == 0){
1042
            $('.live-search-list-group li').each(function(){
1043
                if ($(this).filter('[data-search-term *= ' + searchTerm + ']').length > 0 || searchTerm.length < 1) {
1044
                    $(this).show();
1045
                    found = true;
1046
                } else {
1047
                    $(this).hide();
1048
                }
1049
            });
1050
        }else{
1051
 
1052
            $('.live-search-list li').each(function(){
1053
                if ($(this).filter('[data-search-term *= ' + searchTerm + ']').length > 0 || searchTerm.length < 1) {
1054
                    $(this).show();
1055
                    found = true;
1056
                } else {
1057
                    $(this).hide();
1058
                }
1059
            });
1060
        }
1061
        if(!found){
1062
            $("#search_result").show();
1063
        }else{
1064
            $("#search_result").hide();
1065
        }
1066
    });
1067
 
1068
 
1069
 
1070
});
1071
 
1072
function loadGroups()
1073
{
1074
 
1075
    var url = siteurl+"chat/group-list";
1076
    $.get(url, {} , function(response){
1077
 
1078
        if(response.success) {
1079
            $("#group-list-ul").html("");
1080
            $("#group-list-ul").html(response.data);
1081
        }
1082
    });
1083
}
1084
 
1085
function createChatGroup(uuid,name){
1086
    var url = siteurl+"chat/create-group";
1087
    $.post(url, {uuid: uuid,name:name} , function(response){
1088
        if(response.success) {
1089
            loadGroups();
1090
        }
1091
    });
1092
}
1093
 
1094
function deleteGroup(uuid){
1095
     var c = confirm("Esta seguro de eliminar este grupo de chat?");
1096
     if(c){
1097
        var url = siteurl+"chat/delete-group/" + uuid;
1098
        $.post(url, {} , function(response){
1099
            if(response.success) {
1100
                loadGroups();
1101
            }
1102
        });
1103
    }
1104
}
1105
 
1106
function outOfGroup(uuid){
1107
     var c = confirm("Esta seguro de salir de este grupo de chat?");
1108
     if(c){
1109
        var url = siteurl+"chat/leave/" + uuid;
1110
        $.post(url, {} , function(data){
1111
            loadGroups();
1112
        });
1113
    }
1114
}
1115
 
1116
function showGroupContacts(uuid){
1117
    var url = siteurl+"chat/contact-group-list/" + uuid;
1118
    $.get(url, {} , function(response){
1119
        if(response.success) {
1120
            $("#contact-group-list-ul").html("");
1121
            $("#contact-group-list-ul").html(response.data);
1122
 
1123
            $(".group-list").css({'display':'none'});
1124
            $(".contact-list").css({'display':'none'});
1125
            $(".group-contacts-list").css({'display':'block'});
1126
        }
1127
    });
1128
}
1129
 
1130
$(document).on('click', ".addUser", function (e){
1131
    var touname = $(this).data('client');
1132
    var name = $(this).data('name');
1133
    var url = siteurl+"chat/contacts-list/" + touname;
1134
    $.get(url, {} , function(response){
1135
        if(response.success) {
1136
            $("#contact-list-ul-gchat-"+touname).html("");
1137
            $("#contact-list-ul-gchat-"+touname).html(response.data);
1138
            $('#chatbox_'+touname+' .chat-conversation').css({'display':'none'});
1139
            $('#participants_'+touname).css({'display':'block'});
1140
        }
1141
    });
1142
 
1143
});
1144
 
1145
$(document).on('click', ".closeAddUser", function (e){
1146
    var touname = $(this).data('client');
1147
    $('#participants_'+touname).css({'display':'none'});
1148
    $('#chatbox_'+touname+' .chat-conversation').css({'display':'block'});
1149
 
1150
});
1151
 
1152
$(document).on('click', ".chat-contacts", function (e){
1153
    $(".chat-groups").removeClass('blue-color');
1154
    $(this).addClass('blue-color')
1155
    $(".group-list").css({'display':'none'});
1156
    $(".group-contacts-list").css({'display':'none'});
1157
    $(".contact-list").css({'display':'block'});
1158
 
1159
});
1160
 
1161
$(document).on('click', ".chat-groups", function (e){
1162
    $(".chat-contacts").removeClass('blue-color');
1163
    $(this).addClass('blue-color');
1164
    $(".contact-list").css({'display':'none'});
1165
    $(".group-contacts-list").css({'display':'none'});
1166
    $(".group-list").css({'display':'block'});
1167
});
1168
 
1169
 
1170
function addToGroup(uid,group,name){
1171
    var url = siteurl+"chat/add-user-to-group/" + group + "/" + uid;
1172
    var li = $("#li_user_" + uid  + '_group_' + group);
1173
    $.post(url, {} , function(response){
1174
        if(response.success) {
1175
            li.remove();
1176
        }
1177
    });
1178
}
1179
 
1180
function removeFromGroup(uid,group){
1181
    var url = siteurl+"chat/add-user-to-group/" + group + "/" + uid;
1182
    $.post(url, {} , function(response){
1183
        if(response.success) {
1184
            showGroupContacts( group );
1185
        }
1186
    });
1187
}
1188
 
1189
 
1190
function addMessageUploadFile(item) {
1191
    console.log('S1');
1192
 
1193
    if (item.hasOwnProperty('id')) {
1194
console.log('S2');
1195
console.log('item');
1196
console.log(item);
1197
 
1198
        var id = item.id;
1199
        var toName = item.toName;
1200
        var username = item.username;
1201
        var picname = item.picname;
1202
        var msgtype = item.type;
1203
 
1204
        var path = item.content;
1205
        if (msgtype=="image") {
1206
            message_content = "<a url='" + path + "' onclick='trigq(this)'><img src='" + path + "' class='userfiles'/></a>";
1207
        }
1208
        else if(msgtype == "video") {
1209
            message_content = '<video class="userfiles" controls>' +
1210
            '<source src="' + path + '" type="video/mp4">' +
1211
            'Your browser does not support HTML5 video.' +
1212
            '</video>';
1213
        }
1214
        else {
1215
            message_content = "<a href='"+path+"' class='download-link' download></a>";
1216
        }
1217
        msg_oddtpl(toName,username,picname,message_content,"Ahora","append");
1218
 
1219
        //$("#chatbox_"+toName+" .chatboxcontent").scrollTop($("#chatbox_"+toName+" .chatboxcontent")[0].scrollHeight);
1220
    }
1221
 
1222
    return false;
1223
}
1224
 
1225
 
1226
EOT;
1227
$this->inlineScript()->captureEnd();
1228
 
11351 nelberth 1229
?>
11490 nelberth 1230
<div id="drupalchat-wrapper">
1231
	<div id="drupalchat" style="">
1232
    	<div class="item-list" id="chatbox_chatlist">
1233
        	<ul id="mainpanel">
1234
          		<li id="chatpanel" class="first last">
1235
            		<div class="subpanel" style="display: block;">
1236
              			<div class="subpanel_title">
1237
                			<div style="width: 89%;height: 100%;" id="minmaxchatlist" >Chat</div>
1238
                			<span class="min localhost-icon-minus-1" id="mute-sound"><i class="icon icon-volume-2 text-20" aria-hidden="true"></i></span>
1239
                			<span class="min localhost-icon-minus-1" id="new-chat-group" style="margin-right:5%;" title="Crear grupo"><i class="fa fa-edit"></i></span>
1240
              			</div>
1241
              			<div id="showhidechatlist">
1242
                			<div class="drupalchat_search_main chatboxinput" style="background:#f9f9f9">
1243
                  				<div class="drupalchat_search" style="height:auto;">
1244
                    			<input class="drupalchat_searchinput live-search-box" id="live-search-box" placeholder="Buscar" value="" size="24" type="text">
1245
                    			<input class="searchbutton" id="searchbutton" title="" value="" style="height:30px;border:none;margin:0px; padding-right:13px; vertical-align: middle;" type="submit">
1246
                    			<div id="search_result" style="text-align:center;font-size:11px;display:none;">Sin resultados</div>
1247
                  			</div>
1248
                		</div>
1249
                		<div class="drupalchat_search_main chatboxinput" style="background:#f9f9f9">
1250
                  			<div style="width: 50%;float:left;display:inline-block;padding:5px;text-align:center;font-size:14px;">
1251
                    			<a href="#" class="blue-color chat-contacts">Contactos</a>
1252
                  			</div>
1253
                  			<div style="width: 50%;display:inline-block;padding:5px;text-align:center;font-size:14px;">
1254
                    			<a href="#" class="chat-groups">Grupos</a>
1255
                  			</div>
1256
                		</div>
1257
                		<div class="contact-list chatboxcontent">
1258
                  			<ul id="contact-list-ul" class="live-search-list">
1259
								<?php foreach($contacts as $contact) :
1260
 
1261
								$url_image = $this->url('storage', ['code' => $contact['id_encrypted'],  'type' =>  'user', 'filename' => $contact['image'] ]);
1262
 
1263
								?>
1264
  								<li class="iflychat-olist-item iflychat-ol-ul-user-img iflychat-userlist-room-item chat_options" data-search-term="<?php echo trim(strtolower($contact['name'])) ?>">
1265
             						<div class="drupalchat-self-profile">
1266
                						<span title="<?php echo $contact['status'] ?>" class="'. $status. ' statuso" style="text-align: right">
1267
                							<span class="statusIN"><i class="fa fa-circle" style="font-size:10px;margin-top:4px" aria-hidden="true"></i></span>
1268
                						</span>
1269
                						<div class="drupalchat-self-profile-div">
1270
                							<div class="drupalchat-self-profile-img + localhost-image-sprite-28">
1271
               									<img class="chat-image img-circle pull-left" height="36" width="36" src="<?php echo $url_image ?>" alt="image-image">
1272
                   							</div>
1273
                   						</div>
1274
               							<div class="drupalchat-self-profile-namdiv">
1275
                    						<a class="drupalchat-profile-un drupalchat_cng" href="javascript:void(0)" onclick="javascript:chatWith('<?php echo $contact['id'] ?>','<?php echo $url_image ?>','<?php echo $contact['status'] ?>','<?php echo $contact['name'] ?>')"><?php echo $contact['name'] ?></a>
1276
                    					</div>
1277
                					</div>
1278
                				</li>
1279
                				<?php endforeach; ?>
1280
 
1281
 
1282
                  			</ul>
1283
                		</div>
1284
                		<div class="group-list chatboxcontent" style="display:none;">
1285
                  			<ul id="group-list-ul" class="live-search-list-group">
1286
                  				<?php foreach($groups as $group) :
1287
                      				if($group['owner']){
1288
                      				    $action_icon = "fa fa-trash";
1289
                      				    $click_icon = 'javascript:deleteGroup(\'' . $group['id'] . '\')';
1290
                      				    $title_action = "Eliminar Grupo";
1291
                      				}else{
1292
                      				    $action_icon = "fa fa-sign-out";
1293
                      				    $click_icon = 'javascript:outOfGroup(\'' .$group['id'] . '\')';
1294
                      				    $title_action = "Salir del Grupo";
1295
                      				}
1296
                                ?>
1297
 
11351 nelberth 1298
 
11490 nelberth 1299
 
1300
                                <li class="iflychat-olist-item iflychat-ol-ul-user-img iflychat-userlist-room-item chat_options" data-search-term="<?php echo trim(strtolower($group['name'])) ?>">
1301
                                	<div class="drupalchat-self-profile">
1302
                                		<span style="text-align: right" class="Offline statuso">
1303
                                			<span class="statusIN"><i title="Integrantes" class="fa fa-users" style="font-size:14px;margin-top:4px;" aria-hidden="true"
1304
                                  				 onclick="javascript:showGroupContacts('<?php echo $group['id'] ?>')"></i>
1305
                                  			</span>
1306
                                  			<span class="statusIN">
1307
                                  				<i title="<?php echo $title_action ?>" class="<?php echo  $action_icon ?>" style="font-size:14px;margin-top:4px;" aria-hidden="true" onclick="<?php echo $click_icon ?>"></i>
1308
                                  			</span>
1309
                                  		</span>
1310
                                		<div class="drupalchat-self-profile-div">
1311
                                			<div class="drupalchat-self-profile-img + localhost-image-sprite-28">
1312
                                				<img class="chat-image img-circle pull-left" height="36" width="36" src="<?php echo $users_group_png ?>" alt="image-image">
1313
                                			</div>
1314
                                		</div>
1315
                                		<div class="drupalchat-self-profile-namdiv">
1316
                                			<a class="drupalchat-profile-un drupalchat_cng" href="javascript:void(0)" onclick="javascript:chatGroup('<?php echo $group['id'] ?>','<?php echo $group['name'] ?>')"> <?php echo $group['name'] ?> </a>
1317
                                		</div>
1318
                                	</div>
1319
                                </li>
1320
 
1321
                  				<?php endforeach; ?>
1322
                  			</ul>
1323
                		</div>
1324
                		<div class="group-contacts-list chatboxcontent" style="display:none;">
1325
                  			<div style="text-align:center;font-size:13px;">Integrantes del grupo</div>
1326
								<ul id="contact-group-list-ul" class="live-search-list"></ul>
1327
                			</div>
1328
              			</div>
1329
            		</div>
1330
          		</li>
1331
        	</ul>
1332
    	</div>
1333
	</div>
1334
</div>
1335
 
1336
<!--This div for modal light box chat box image-->
1337
<table id="lightbox" class="lightbox"  style="display: none;height: 100%">
1338
    <tr>
1339
        <td height="10px"><p><img src="<?php echo $this->basePath('images/close-icon-white.png')?>" width="30px" style="cursor: pointer"/></p></td>
1340
    </tr>
1341
    <tr>
1342
        <td valign="middle"><div id="content"><img src="#"/></div></td>
1343
    </tr>
1344
</table>
1345
<!--This div for modal light box chat box image-->
1346
<!--This div for modal light box chat box image-->
1347
<table id="lightbox_group" class="lightbox" style="display: none;height: 100%">
1348
    <tr>
1349
        <td height="10px"><p><img src="<?php echo $this->basePath('images/close-icon-white.png')?>" width="30px" style="cursor: pointer"/></p></td>
1350
    </tr>
1351
    <tr>
1352
        <td valign="middle"><div id="gcontent"></div></td>
1353
    </tr>
1354
</table>
1355
<!--This div for modal light box chat box image-->
1356
 
1357
<form id="form-new-group" style="display: none; z-index: 1000">
1358
  Nombre del grupo:
1359
  <input type="text" id="group_name" maxlength="50" />
1360
  <input type="button" id="btn_submit_group" value="Crear" class="pull-right">
1361
</form>