//////////////////////////////////////// // // PARTIE INTERFACE MOBILE // /////////////////////////////////////// var valinutil= "0"; var prg = "recup_http.cgi"; // Programme de photos /////////////////////////////////// /* * IMPORTANT!!! * REMEMBER TO ADD rel="external" to your anchor tags. * If you don't this will mess with how jQuery Mobile works */ // Fonction passe ajoutée pour eviter les erreurs sur les fiches sans photos (function(window, $, PhotoSwipe){ $(document).ready(function(){ var passe = "0"; // $('#Fiche-pseudo').live('pageshow', function(e){ $('#Fiche-pseudo').on('pageshow', function(e){ if ($(".gallery a").length>0) { passe = "1"; var currentPage = $(e.target), options = {allowUserZoom:false,backButtonHideEnabled:false,captionAndToolbarAutoHideDelay:0}, photoSwipeInstance = $(".gallery a", e.target).photoSwipe(options, currentPage.attr('id')); } return true; }) // .live('pagehide', function(e){ .on('pagehide', function(e){ if (passe == "1") { passe = "0"; var currentPage = $(e.target), photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id')); if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) { PhotoSwipe.detatch(photoSwipeInstance); } } return true; }); }); }(window, window.jQuery, window.Code.PhotoSwipe)); // Pour Android pas de transition ca peux poser problème var usera = navigator.userAgent.toLowerCase(); var isAndroid = usera.indexOf("android") > -1; if(isAndroid) { $.mobile.maxTransitionWidth = 1; } // Fonction perso //////////////////// // Position jQuery.fn.extend({ findPos : function() { obj = jQuery(this).get(0); var curleft = obj.offsetLeft || 0; var curtop = obj.offsetTop || 0; while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } return {x:curleft,y:curtop}; } }); // Val inutil function fct_inutil() { // Suite a problm de cache avec IE on fait une req diff var Digital=new Date() var hours=Digital.getHours() var minutes=Digital.getMinutes() var seconds=Digital.getSeconds() if (minutes<=9) { minutes="0"+minutes } if (seconds<=9) { seconds="0"+seconds } retour = hours + minutes + seconds; return retour; } // Memorisation des données /////////////////////////// //$("#page-cnx").live('pagehide', function(e) { $("#page-cnx").on('pagehide', function(e) { memorise('#page-cnx'); }); // Sauvegarde des infos login pass $("#page-cnx").find('input:checkbox').change(function () { memorise('#page-cnx'); }); function memorise(divcontent) { var divuser = divcontent+" #user"; var divpasswd = divcontent+" #passwd"; var divmemoriser = divcontent+" #memoriser"; val = $(divcontent).find('input:checkbox:checked').val(); if (val == "1") { localStorage.setItem('login', $(divuser).val()); localStorage.setItem('passwd', $(divpasswd).val()); localStorage.setItem('memoriser', '1'); } else { localStorage.setItem('login', ''); localStorage.setItem('passwd', ''); localStorage.setItem('memoriser', ''); } } function recupmemorise(divcontent) { var divuser = divcontent+" #user"; var divpasswd = divcontent+" #passwd"; var divmemoriser = divcontent+" #memoriser"; // Sortie du login + pass mémorisé var item = localStorage.getItem('login'); if (item == null) { item = ''; } else if (item.length === 0) { item = ''; } if (item != "") {$(divuser).val(item);} if (item == "") { item = infouser; $(divuser).val(item); } var item = localStorage.getItem('passwd'); if (item == null) { item = ''; } else if (item.length === 0) { item = ''; } if (item != "") {$(divpasswd).val(item);} var item = localStorage.getItem('memoriser'); if (item == null) { item = ''; } else if (item.length === 0) { item = ''; } if (item == "1") {$(divmemoriser).attr("checked",true).checkboxradio("refresh");} } // Session ///////////////// function sessionauto(session) { session = session; if (typeof(sessionlance) == 'undefined') {sessionlance = "0"}; if (sessionlance == "0") { var timersession = setTimeout(sessionrelance,"480000"); } sessionlance = "1"; } function sessionrelance() { //url_req = "https://www.entrecoquins.com/beta2/rep_all/sessionsmaj.cgi?session_user="+session; url_req = "sessionsmaj.cgi?version=mobile&session_user="+session; $.get(url_req,function(data){ // alert(data); },'html'); var timersession = setTimeout(sessionrelance,"480000"); } // Maj d'une page /////////////////// function maj_page(url_req,div,add,position,bouton_suite,bouton_divsuite) { $.mobile.showPageLoadingMsg(); $(bouton_suite).remove(); $.ajax({ type: "GET", url: url_req, error:function(msg){ // alert( "Error !: " + msg ); }, success:function(data){ //affiche le contenu du fichier dans le conteneur dédié if (add == "0") { $(div).empty(); } if (position == "") {} else { $.mobile.silentScroll(position); } // alert(data); $(div).append(data).listview("refresh"); $(div).find('div[data-role=collapsible]').collapsible({refresh:true}); $('#listedernminute a[data-role=button]').button({refresh:true}); $(div).find('div[data-role=controlgroup]').controlgroup({refresh:true}); $.mobile.hidePageLoadingMsg(); if ($(bouton_suite).attr('value') == 0) { $(bouton_divsuite).remove(); } }}); } // Supp d'une ligne avec req ///////////////////////////// function supp_commande(url_req,div_supp,div_retour) { div_supp = "#"+div_supp; div_retour = "#"+div_retour; $.mobile.showPageLoadingMsg(); $.ajax({ type: "GET", url: url_req, error:function(msg){ // alert( "Error !: " + msg ); }, success:function(data){ $(div_retour).html(data); divretourprog = div_retour+" #prog-retour"; if ($(divretourprog).attr('value') == "1") { $(div_supp).remove(); $('#retourajax').empty(); $.mobile.hidePageLoadingMsg(); } }}); } // Recup du nombre de courrier function http_nbrcourrier() { inutil = fct_inutil(); url_req = "recup_http.cgi?action=nbr_courrier&inutil=" + inutil; $.ajax({ type: "GET", url: url_req, error:function(msg){ // alert( "Error !: " + msg ); }, success:function(data){ // alert(data); data = parseInt(data); if (data >= 1) { $('.bullemess').removeClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullemess').hide(); $('.bullemess').text(data); $('.bullemess').addClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullemess').show(); // Suite a bug iphone on reforce $('.bullemess').removeClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullemess').hide(); $('.bullemess').text(data); $('.bullemess').addClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullemess').show(); } else { $('.bullemess').removeClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullemess').hide(); } }}); } // Recup du nombre de notifications ///////////////////////////////////// function maj_notif(valeur) { console.log("Notif :"+valeur); if (valeur != "0") { $('.bullenotif').removeClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullenotif').hide(); $('.bullenotif').text(valeur); $('.bullenotif').addClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullenotif').show(); // Suite a bug iphone on reforce $('.bullenotif').removeClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullenotif').hide(); $('.bullenotif').text(valeur); $('.bullenotif').addClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullenotif').show(); } else { $('.bullenotif').removeClass("ui-li-count ui-btn-corner-all countBubl"); $('.bullenotif').hide(); } } var boucle_notif; function recup_notif() { return nbr_notif; } function http_notif() { inutil = fct_inutil(); url = "recup_http.cgi?action=nbr_notif"; url_req = url + "&inutil=" + inutil; $.ajax({ type: "GET", url: url_req, error:function(msg){ }, success:function(data){ maj_notif(data); }}); clearTimeout(boucle_notif); boucle_notif = setTimeout(function(){ http_notif(); // 2 min //},120000); },10000); } // Module de map //////////////////////// function initialize_map() { geocoder = new google.maps.Geocoder(); //alert(latitude+" - "+longitude) var latlng = new google.maps.LatLng(latitude, longitude); var myOptions = { zoom: 14, center: latlng, streetViewControl : false, panControl : false, overviewMapControl : false, mapTypeControl : false, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map( document.getElementById("map_canvas"), myOptions); var myMarker = new google.maps.Marker({ position: new google.maps.LatLng(latitude, longitude), draggable: true }); myMarker.setMap(map); google.maps.event.addListener(myMarker, 'dragend', function(evt){ latitude = evt.latLng.lat().toFixed(6); longitude = evt.latLng.lng().toFixed(6); // alert(latitude+" - "+longitude); }); } var codepostal = "NC"; var ville = "NC"; var ville_3 = "NC"; var ville_2 = "NC"; var ville_1 = "NC"; var pays = "NC"; function codeLatLng(latlng) { var latlng = latitude+","+longitude; var latlng = new google.maps.LatLng(latitude, longitude); geocoder.geocode({'latLng': latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var searchAddressComponents = results[0].address_components, codepostal = "NC"; ville = "NC"; ville_3 = "NC"; ville_2 = "NC"; ville_1 = "NC"; pays = "NC"; $.each(searchAddressComponents, function(){ if(this.types[0]=="postal_code") {codepostal=this.short_name;} if(this.types[0]=="locality") {ville=this.short_name;} if(this.types[0]=="administrative_area_level_3"){ville_3=this.short_name;} if(this.types[0]=="administrative_area_level_2"){ville_2=this.short_name;} if(this.types[0]=="administrative_area_level_1"){ville_1=this.short_name;} if(this.types[0]=="country") {pays=this.short_name;} }); if (ville == "NC"){ ville = ville_3;} if (ville == "NC"){ ville = ville_2;} if (ville == "NC"){ ville = ville_1;} // alert(codepostal+" "+ville+" "+pays); // alert("envoi"); $.post("mobile-position.cgi", { action : "maj", lat : latitude, lng : longitude, ville : ville, cp : codepostal, pays : pays }, function(data){ // alert(data); $.mobile.hidePageLoadingMsg(); $.mobile.changePage( "./entree.cgi"); }); } else { // alert("Geocoder failed due to: " + status); alert("Votre emplacement n'est pas localisable"); $.mobile.hidePageLoadingMsg(); } }); } function geoloc_demposition() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( function (position) { // Did we get the position correctly? // alert (position.coords.latitude); // To see everything available in the position.coords array: // for (key in position.coords) {alert(key)} latitude = position.coords.latitude; longitude = position.coords.longitude; // alert(latitude+" -- "+longitude) initialize_map(); }, // next function is the error callback // Si Erreur, on utilise l'emplacement défini par l'utilisateur... function (error) { initialize_map(); switch(error.code) { case error.TIMEOUT: // alert ('Timeout'); break; case error.POSITION_UNAVAILABLE: // alert ('Position unavailable'); break; case error.PERMISSION_DENIED: // alert ('Permission denied'); break; case error.UNKNOWN_ERROR: // alert ('Unknown error'); break; } } ); } } //////////////////////////////////////// // // INSCRIPTION // /////////////////////////////////////// // Recherche et verif d'un pseudo ///////////////////////////////////////// var retourAJAX_pseudo = "0"; var verifdiv_user = ""; function recherche_pseudo(verifdiv_user) { $('#retour_pseudo').html(""); $('#retour_pseudo_erreur').html(""); var verif = check_pseudo(verifdiv_user); if (verif != false) { $('#retour_pseudo').html(""); inutil = fct_inutil(); url = prg+"?action=verif_pseudo&user="+$(verifdiv_user).attr('value'); url_req = url + "&inutil=" + inutil; $.ajax({ type: "GET", async: false, url: url_req, error:function(msg){ // alert("Erreur 2!"+msg); }, success:function(data){ //affiche le contenu du fichier dans le conteneur dédié $('#contenu_fichier_ajax').text(data); // alert(data); if (data == "1") { $('#retour_pseudo').html("