{% extends '@CadolesCore/base.html.twig' %} {% block localstyle %} {% if framed %} {% if border %} #page-wrapper:last-of-type { //padding: 5px 25px 10px 15px; //background: transparent; } {% else %} #page-wrapper { //padding: 5px 25px 0px 15px; //background: transparent; } {% endif %} {% else %} #page-wrapper { padding-top:20px; padding-bottom:30px; } {% endif %} .message { padding:10px; margin-top: 5px; background-color: #{{ colorbodyback }}; color: #{{ colorbodyfont }}; } .msgavatar { float:left; height:40px; text-align: center; } .msgdiv { padding-left:60px; } .msgtitle { line-height: 12px; margin-bottom: 10px; } .bootstrap-switch{ margin-top:5px; } .labelswitch { line-height: 40px; float: right; margin-right: 10px; } #listtoavatar img { margin:0px 5px 5px 0px; cursor:pointer; } .cke_bottom{ display:none } {% endblock %} {% block pagewrapper %} {{ form_start(form) }}
{{ form_widget(form.message) }} Envoyer
{% for message in messages %}

{% if fgmanager or message.user == app.user %} {% endif %}
{{message.user.lastname}} {{message.user.firstname}}
{{message.submitdate|date('d/m/Y H:i')}}
{{message.topic | raw}}
{% endfor %}
{{ form_end(form) }} {% endblock %} {% block localexternalscript %} {% endblock %} {% block localjavascript %} $(document).ready(function(){ if (CKEDITOR.instances["chat_message"]) CKEDITOR.instances["chat_message"].destroy(); if (CKEDITOR.instances["chat_messagemail"]) CKEDITOR.instances["chat_messagemail"].destroy(); CKEDITOR.replace( 'chat_message', { toolbar: [ { name: 'custo01', items: [ 'Bold','Italic','Underline','RemoveFormat' ] }, { name: 'custo02', items: [ 'NumberedList','BulletedList' ] }, { name: 'custo03', items: [ 'Smiley','Link','Unlink' ]} ], height: 100 }); CKEDITOR.replace( 'chat_messagemail', { toolbar: [ { name: 'custo01', items: [ 'Bold','Italic','Underline','RemoveFormat' ] }, { name: 'custo02', items: [ 'NumberedList','BulletedList' ] }, { name: 'custo03', items: [ 'Smiley','Link','Unlink' ]} ], height: 150 }); $(".switch").bootstrapSwitch(); var dateoptions = {weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" }; $("#mymodal-sendmail").removeAttr("tabindex"); {% if websocket_activate and app.user %} var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}"; var webSocket = WS.connect(_WS_URI); var timer; webSocket.on("socket/connect", function (session) { // Reinit du tps de tentative de reco $('#modalinfo').modal('hide'); clearInterval(timer); //the callback function in "subscribe" is called everytime an event is published in that channel. session.subscribe("websocket/channel/{{groupid}}", function (uri, payload) { if(payload.msg) { html ="
"; html+="
"; html+="
"; if(payload.msg.userid=={{app.user.id}} || '{{ fgmanager }}'=='1') { html+=""; } html+="
"; html+="
" html+="
"+payload.msg.lastname+"
"+new Date(payload.msg.submitdate.date).toLocaleDateString("fr-FR", dateoptions)+"
"; html+="
"+payload.msg.message+"
"; html+="
"; html+="
"; $(".mychat").prepend(html); //console.log("Received message by "+payload.msg.userid+" = ",payload.msg); } if(payload.log) { console.log("Received message", payload.log); } if(payload.del) { $("#message-"+payload.del).remove(); } if(payload.alert) { alert(payload.alert); } }); $( "#sendbtn" ).click(function() { var data = CKEDITOR.instances["chat_message"].getData(); if($("#sendbymail").bootstrapSwitch('state')) { CKEDITOR.instances["chat_messagemail"].setData(data); $("#mailsuject").val("{{app.session.get('appname')}} = Notification {{ group.label }}"); $("#mailto").val(""); $("#listtoavatar").html(""); {% for user in group.users %} {%if(user.user!=app.user)%} $("#mailto").val($("#mailto").val()+";{{user.user.email}}"); $("#listtoavatar").append($("")); {%endif%} {% endfor %} $('#mymodal-sendmail').modal('show'); } else { if(data) { event={mykey: "{{userkey}}", type: "add", message: data}; session.publish("websocket/channel/{{groupid}}", event); CKEDITOR.instances["chat_message"].setData(''); /* Ne plus envoyer d'event compteur on passe par de l'ajax event={type: "add", group:{{groupid}}}; parent.parent.counter(event); */ } } }); $( "#sendbtnmail" ).click(function() { var data = CKEDITOR.instances["chat_messagemail"].getData(); var subject=$("#mailsuject").val(); var mailto=$("#mailto").val(); if(data&&subject&&mailto) { event={mykey: "{{userkey}}", type: "add", message: data, mail: "true", to: mailto, subject: subject}; session.publish("websocket/channel/{{groupid}}", event); CKEDITOR.instances["chat_message"].setData(''); event={type: "add", group:{{groupid}}}; parent.parent.counter(event); $("#sendbymail").bootstrapSwitch('state',false); $('#mymodal-sendmail').modal('hide'); } else alert("Sujet, corps et destinataire(s) obligatoire"); }); $(document).on('click', '.delmessage', function(){ id=$(this).data("id"); event={mykey: "{{userkey}}", type: "del", id: id}; session.publish("websocket/channel/{{groupid}}", event); }); $(document).on('click', '#listtoavatar img', function(){ var mail = ";"+$(this).data("mail"); $("#mailto").val($("#mailto").val().replace(mail, "")); $(this).remove(); }); }); webSocket.on("socket/disconnect", function(error){ laberror="Disconnected for " + error.reason + " with code " + error.code; console.log(laberror); $('#modalinfo').modal('show'); if(error.code==2) { $('#modalinfotext').html("
Impossible de se connecter au serveur.
Vous avez dépassé le nombre de reconnexion maximum

Veuillez retentez d'ici quelques secondes

"+laberror+"


Forcer la tentative de reconnexion
"); clearInterval(timer); var nbtentative=10; timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000); setTimeout(function(){ location.reload(true); }, 10000); } if(error.code==3) { $('#modalinfotext').html("
Impossible de se connecter au serveur.
Veuillez retentez d'ici quelques secondes

"+laberror+"


Forcer la tentative de reconnexion
"); clearInterval(timer); var nbtentative=10; timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000); setTimeout(function(){ location.reload(true); }, 10000); } if(error.code==6 || error.code==5) { $('#modalinfotext').html("
Impossible de se connecter au serveur.
Vous allez être reconnecté d'ici quelques secondes

"+laberror+"


Forcer la tentative de reconnexion
"); clearInterval(timer); var nbtentative=5; timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000); } }); {% endif %} }); {% endblock %}