source: spip-zone/_plugins_/spipcatchat2/prive/javascript/prive-spipcatchat.js.html @ 87257

Last change on this file since 87257 was 87257, checked in by claude.codden@…, 6 years ago

Dépôt du répertoire prive

File size: 4.3 KB
Line 
1var URLplugin='#ENV{url_plugin}';
2var idAuteur=encodeURIComponent('#ID_AUTEUR');
3var charset=encodeURIComponent('#CHARSET');
4var nom=encodeURIComponent('#ENV{nom}');
5var langShowChat = new Array("<:spipcatchat:catchat_message:>");
6var catchatrefresh=[(#CONFIG{spipcatchat/refreshprive}||non)2000][(#CONFIG{spipcatchat/refreshprive}||oui)#CONFIG{spipcatchat/refreshprive}];
7var catchatrefreshstatut=125000;
8var idSalon=0;
9var scrollBar = false;
10var nombreMessage;
11function spipcatchatmessage(){t=[(#CONFIG{spipcatchat/refreshprive}|div{1000})];if(""==$("#message").val())$("#spipcatchatvide").css("display","block"),setTimeout(function(){$("#spipcatchatvide").css("display","none")},1E3);else if(timer){$("#spipcatchattimer").css("display","block");$("#spipcatchatcompt").html(t);var a=setInterval(function(){t--;if(t<0){t=0;}$("#spipcatchatcompt").html(t)},800);setTimeout(function(){$("#spipcatchattimer").css("display","none");clearTimeout(a)},catchatrefresh)}else if(120<$("#message").val().length){$("#spipcatchatroman").css("display","block");setTimeout(function(){$("#spipcatchatroman").css("display","none");},1E3);}else{timer=1, setTimeout(function(){timer=0},catchatrefresh),$("#spipcatchatpostmessage").submit(spipcatchatsetmessage(URLplugin, idAuteur,charset,catchatrefresh/1000))}}var timer;$(document).keypress(function(a){13==a.keyCode&&spipcatchatmessage()});$(document).keypress(function(a){if(13==a.keyCode)return!1});function spipcatchatShowChat(){$.ajax({url:URLplugin+"phpscripts/get-prive-autorisation.php",type:"POST",data:"id_auteur="+idAuteur+"&id_salon="+idSalon+"&nom="+nom+"&url="+URLplugin+"&char="+charset,success:function(e){startchat(catchatrefresh,catchatrefreshstatut,idSalon,idAuteur,URLplugin,langShowChat,charset);$("#spipcatchatselectsalon").css("display","block")}})}function getMessages(e,t,n,r,i){$.getJSON(n+"phpscripts/get-prive-message.php",{auteur:t,ref:e/1e3,aucunmessage:r[0],"char":i},function(e){var t=$("#text");$("#text").html(spipcatchattypo(e.messages,n));1!=scrollBar&&(t[0].scrollTop=t[0].scrollHeight,scrollBar=!0);void 0!==t&&t[0].childNodes.length>nombreMessage&&(t[0].scrollTop=t[0].scrollHeight,$("#soundGet").trigger("play"));void 0!==t&&(nombreMessage=t[0].childNodes.length)})}function spipcatchatsetmessage(e,t,n,r){var i=encodeURIComponent($("#message").val());$("#message").val("");$.ajax({type:"POST",url:e+"phpscripts/set-prive-message.php",data:"message="+i+"&auteur="+t+"&char="+encodeURIComponent(n)+"&ref="+encodeURIComponent(r),success:function(e){$("#soundPost").trigger("play");$("#soundGet").trigger("stop");1!=e&&$("#responsePost").html(e).slideDown("slow");$("#message").focus()},error:function(e){alert("Erreur - Set-Message")}})}function startchat(e,t,n,r,i,s,o){document.getElementById("message")&&(getOnlineUsers(n,r,i,s,o),statusStart=window.setInterval(function(){getOnlineUsers(n,r,i,s,o)},t),window.setInterval(function(){getMessages(e,r,i,s,o)},e),$("#message").focus())}function getOnlineUsers(e,t,n,r,i){$.getJSON(n+"phpscripts/get-prive-online.php",{auteur:t,salon:e},function(e){if(1==e.autorisation){var r="",i,s;for(s in e.list)"busy"==e.list[s].status?(texte="Occupé(e) [X]",i="inactive",t==e.list[s].id&&$("#SpipCatChatStatus option[value=2]").attr("selected","selected")):"inactive"==e.list[s].status?(texte=" Absent(e) [-] ",i="neutral",t==e.list[s].id&&$("#SpipCatChatStatus option[value=1]").attr("selected","selected")):(texte="En ligne [&radic;]",i="active",t==e.list[s].id&&$("#SpipCatChatStatus option[value=3]").attr("selected","selected")),r+='<span title="'+texte+'"><img src="'+n+"/images/status-"+i+'.png" /> '+e.list[s].login+"</span><br/>";$("#users").html(r)}else window.location=urlpage})}function SpipCatChatsetStatus(e,t,n){$.ajax({type:"POST",url:n+"phpscripts/set-prive-status.php",data:"status="+e+"&auteur="+t,success:function(e){$("#catchatprivestatut").addClass("spipcatchatpause");$("#spipcatchatpatientez").css("display","block");setTimeout(rmResponse,15e3)},error:function(e){alert("Erreur - Status");setTimeout(rmResponse,15e3)}})}function rmResponse(){$("#catchatprivestatut").removeClass("spipcatchatpause");$("#spipcatchatpatientez").css("display","none")}function spipcatchatrestartstatut(){setTimeout(function(){getOnlineUsers("0",idAuteur,URLplugin,langShowChat,charset)},6e3);setTimeout(function(){getOnlineUsers("0",idAuteur,URLplugin,langShowChat,charset)},12e3)}spipcatchatShowChat()
Note: See TracBrowser for help on using the repository browser.