function changeRadio(el){
var el = el,
input = el.find("input").eq(0);
var nm=input.attr("name");
jQuery(".niceRadio input, input.niceRadio").each(
function() {
if(jQuery(this).attr("name")==nm)
{
jQuery(this).parent().removeClass("radioChecked");
}
});
if(el.attr("class").indexOf("niceRadioDisabled")==-1)
{
//alert("radioChecked");
el.addClass("radioChecked");
//el.find("input").addClass("radioChecked");
input.attr("checked", true);
}
return true;
}
function changeVisualRadio(input)
{
var wrapInput = input.parent();
var nm=input.attr("name");
jQuery(".niceRadio input").each(
function() {
if(jQuery(this).attr("name")==nm)
{
jQuery(this).parent().removeClass("radioChecked");
}
});
if(input.attr("checked"))
{
wrapInput.addClass("radioChecked");
}
}
function dateDiff(date1, date2){
var diff = {} // Initialisation du retour
var tmp = date2 - date1;
tmp = Math.floor(tmp/1000); // Nombre de secondes entre les 2 dates
diff.sec = tmp % 60; // Extraction du nombre de secondes
tmp = Math.floor((tmp-diff.sec)/60); // Nombre de minutes (partie entière)
diff.min = tmp % 60; // Extraction du nombre de minutes
tmp = Math.floor((tmp-diff.min)/60); // Nombre d'heures (entières)
diff.hour = tmp % 24; // Extraction du nombre d'heures
tmp = Math.floor((tmp-diff.hour)/24); // Nombre de jours restants
diff.day = tmp;
return diff;
}
function changeRadioStart(el){
try{
var el = el,
radioName = el.attr("name"),
radioId = el.attr("id"),
radioChecked = el.attr("checked"),
radioDisabled = el.attr("disabled"),
radioTab = el.attr("tabindex"),
radioValue = el.attr("value");
if(radioChecked)
el.after(""+
" ");
else
el.after(""+
" ");
if(radioDisabled)
{
el.next().addClass("niceRadioDisabled");
el.next().find("input").eq(0).attr("disabled","disabled");
}
el.next().bind("mousedown", function(e) { changeRadio(jQuery(this)) });
if(jQuery.browser.msie) el.next().find("input").eq(0).bind("click", function(e) { changeVisualRadio(jQuery(this)) });
else el.next().find("input").eq(0).bind("change", function(e) { changeVisualRadio(jQuery(this)) });
el.remove();
}
catch(e)
{
}
return true;
}
function changeCheck(el) {
var input = el.find("input").eq(0);
var checkValue="undefined";
if(input.attr("readonly")=="readonly" || input.attr("readonly")=="true"){
return false;
}
for (i = 0; i < arguments.length; i++) {
if(i==1) checkValue=arguments[i];
}
if((checkValue != "undefined" && checkValue=="checked")){
el.css("background-position","0 -16px");
input.prop("checked", true)
}
else if((checkValue != "undefined" && checkValue!="checked")){
el.css("background-position","0 0");
input.prop("checked", false)
}
else if(!input.prop("checked") ) {
el.css("background-position","0 -16px");
input.prop("checked", true)
} else {
el.css("background-position","0 0");
input.prop("checked", false)
}
if(input.attr("submit")){
formName=input.attr("submit");
document.forms[formName].submit();
}
if(input.attr("name")=="days_all" ){
day_all();
}
if( input.attr("name")=="for_alls"){
for_all();
}
return true;
}
function changeCheckStart(el)
{
var el = el,
input = el.find("input").eq(0);
if(input.attr("checked")) {
el.css("background-position","0 -16px");
}
return true;
}
var contact_chat="";
var eclair_last=0;
var cur_chatID=0;
var timer_chat=null;
var main_chat=0;
var fast_chat=0;
var save_contact_chat1 ="";
var save_contact_chat2 ="";
var new_chat_refresh_process=null;
var new_compte_a_rebou_refresh_process=null;
var date_compte_a_rebour_expire=null;
var chat_alert_no_abo = false;
var shared_photo = "";
var contact_sex = "";
var chat_refresh_contact_id = "";
function testIfPopupTopUpgMsgIsDisplayed(){
if( $('#top-upgrade-msg').length > 0 ){
var popup_top = $('#top-upgrade-msg');
//console.log('popup_top : '+typeof( popup_top ));
if( popup_top.css('display') != 'none' ){
return true;
} else {
return false;
}
} else {
return false;
}
}
function testIfNewMsgWithAProfile( elem ){
if( elem.children().hasClass('fog')){
elem.children('.fog').css({'display':'none'});
elem.css({'background-color' : 'white'});
}
}
function click_on_profile( profile ){
$(profile).unbind().click(function(){
$('#right_chat_page').children().show();
$('#center_chat_page .actions .party-name, #center_chat_page .actions .status, #center_chat_page .actions .move-favorite_circle, #center_chat_page .actions .options_ico ').show();
$('#right_chat_page').css('background', '#ffffff');
// $('.move-favorite_circle').css('display','inline-block');
$('.move-favorite_circle').show();
var contact = $(this).attr('contact');
// console.log('contact ==> ' + contact);
var img_profile = $(this).find('img').prop('src');
var contact_id = $(this).data('id_friend');
var contact_status = $(this).data('status');
var contact_last_visite = $(this).data('visite');
var type_conv = "";
type_conv = $(this).data('type_conv');
chat_refresh_contact_id = contact_id;
contact_sex = $(this).data('sexe1');
switch ( type_conv ) {
case 'friends' :
$('#move-favorite').removeClass('no-active').addClass('active');
break;
}
$('#new_message').val('');
$('#new-my-messages .party-name').html('');
$('#new-my-messages .controls *').children().prop('disabled',false);
var btn_state_friend = "";
// var btn_state_trash = "";
var btn_state_black_list = "";
testIfNewMsgWithAProfile( $(this) );
// utilisation du local storage pour activer ou non les boutons d'actions du main chat
if( localStorage.getItem('move-favorite_' + contact_id)) {
//console.log('dans le if');
btn_state_friend = localStorage.getItem('move-favorite_' + contact_id);
$('#move-favorite').removeClass('no-active').removeClass('active');
$('#move-favorite').addClass(btn_state_friend);
} else{
//console.log("dans le else");
$('#move-favorite').removeClass('active').addClass('no-active');
}
// if( localStorage.getItem('move-trash_' + contact_id) ){
// btn_state_trash = localStorage.getItem('move-trash_' + contact_id);
// $('#move-trash').removeClass('no-active').removeClass('active');
// $('#move-trash').addClass(btn_state_trash);
// }else{
// $('#move-trash').removeClass('active').addClass('no-active');
// }
if( localStorage.getItem('move-black-list_' + contact_id) ){
btn_state_black_list = localStorage.getItem('move-black-list_' + contact_id);
$('#move-black-list').removeClass('no-active').removeClass('active');
$('#move-black-list').addClass(btn_state_black_list);
if( btn_state_black_list == "active" ){
$('#move-black-list').html(tabLang["del_to_Blist"]);
} else {
$('#move-black-list').html(tabLang["add_to_Blist"]);
}
}else{
$('#move-black-list').removeClass('active').addClass('no-active');
$('#move-black-list').html(tabLang["add_to_Blist"]);
}
// $('#move-trash, #move-black-list, #move-favorite, #new-my-messages .controls').show();
$('#move-favorite').data('id_contact', contact_id);
$('#move-favorite').data('type_conv',type_conv);
$('#move-trash').data('id_contact', contact_id);
$('#move-trash').data('type_conv',type_conv);
$('#center_chat_page #move-black-list').data('id_contact', contact_id);
$("#new-my-messages .msg-content .messages").html("");
$("#new-my-messages .msg-content #start-conversation-info, #new-my-messages .msg-content #select-person-info ").hide();
select_current_conversation( '#new-my-messages', $(this));
messages_contact($(this), false);
save_contact_chat1 = contact;
// console.log(' contact : ' +save_contact_chat1);
$("#new-my-messages .messages").data('contact',save_contact_chat1);
stop_timer_refresh_chats();
start_timer_refresh_chats();
// gestion page du profil selectionné dans la zone right_chat_page
$('#right_chat_page .right_chat_contact_name').prop('href',tabLang["htmembres"]+'_'+contact+'_'+contact_id+'.html');
$('#right_chat_page .right_chat_contact_name').text(contact);
$('#right_chat_page .preview .photo').prop('href',tabLang["htmembres"]+'_'+contact+'_'+contact_id+'.html');
$('#right_chat_page .status').removeClass('red').removeClass('green');
$('#right_chat_page .status').addClass(contact_status);
$('#right_chat_page .see_profile').prop('href',tabLang["htmembres"]+'_'+contact+'_'+contact_id+'.html');
$("#center_chat_page .messages").scrollTop(9999);
});
$("#center_chat_page .messages").scrollTop(9999);
}
function new_chat_refresh() {
//refresh des chat en continu
// console.log("!!!!!! test avant setInterval !!!!!!");
// console.log("****************** Dans refresh new ******************");
var last_msg_main = parseInt($('#new-my-messages .msg-content .msg').last().data('eclair_last'));
// var last_msg_fast = parseInt($('#new-messanger .messages .msg').last().data('eclair_last'));
//console.log('dernier msg ID du chat principal : ' +last_msg_main);
//console.log('dernier msg ID du chat rapide : ' +last_msg_fast);
if( last_msg_main != 0 /*&& last_msg_fast != 0 */) {
if (save_contact_chat1 != "" /*|| save_contact_chat2 != ""*/) {
if (typeof( save_contact_chat1 ) != 'unefined' && save_contact_chat1 != "" && typeof( chat_refresh_contact_id ) != 'undefined' && chat_refresh_contact_id != "") {
var last_msg = $('#new-my-messages .msg-content .msg').last().data('eclair_last');
// console.log('main_chat dans refresh');
// console.log();
$.ajax({
type: "GET",
url: "app/ajax/load_messages.php?contact=" + save_contact_chat1 + "&eclair_last=" + last_msg_main + "&contact_id=" + chat_refresh_contact_id,
dataType: "json",
success: function (json) {
put_eclairs(json, false, 1, save_contact_chat1, chat_refresh_contact_id);
if (json.eclairs.length > 0) {
$("#center_chat_page .messages").scrollTop(9999);
}
}
});
}
}
}
// }
}
function start_timer_refresh_chats () {
// console.log('Dans start timer refresh chats');
new_chat_refresh_process = setInterval(new_chat_refresh, 15000);
$("#center_chat_page .messages").scrollTop(9999);
}
function stop_timer_refresh_chats() {
// console.log('Dans stopt timer refresh chats');
clearInterval(new_chat_refresh_process);
}
function start_timer_refresh_compte_a_rebour() {
if( new_compte_a_rebou_refresh_process != null ) {
clearInterval(new_compte_a_rebou_refresh_process);
}
new_compte_a_rebou_refresh_process = setInterval(compte_a_rebour_refresh, 1000);
}
function stop_timer_refresh_compte_a_rebour() {
clearInterval(new_compte_a_rebou_refresh_process);
new_compte_a_rebou_refresh_process = null;
$('#compteur_a_rebour_content').hide();
}
function compte_a_rebour_refresh() {
if( date_compte_a_rebour_expire == null ) {
console.error("compte_a_rebour_refresh | return");
$('#compteur_a_rebour_content').hide();
return;
}
var date_now = new Date();
var diff_date = new Date(date_compte_a_rebour_expire - date_now)
// console.log("compte_a_rebour_refresh | valueOf : " + diff_date.valueOf());
// console.log("compte_a_rebour_refresh | valueOf : ");
// console.log("compte_a_rebour_refresh | valueOf : ");
// console.log("compte_a_rebour_refresh | valueOf : ");
// console.log("compte_a_rebour_refresh | valueOf : ");
if (diff_date.valueOf() > 0) {
var jj_restant = diff_date.getDate() - 1;
var hh_restant = parseInt(diff_date.getHours()) - 1;
var mm_restant = diff_date.getMinutes();
var ss_restant = diff_date.getSeconds();
mm_restant = (mm_restant < 10) ? '0'+mm_restant : mm_restant;
ss_restant = (ss_restant < 10) ? '0'+ss_restant : ss_restant;
// $("#center_chat_page .messages").html(jj_restant + " jours " + hh_restant + ":" + mm_restant + ":" + ss_restant + " restant");
$('#center_chat_page .controls').hide();
$('#compteur_a_rebour_content').find('.hh_restant').html(hh_restant);
$('#compteur_a_rebour_content').find('.mm_restant').html(mm_restant);
$('#compteur_a_rebour_content').find('.ss_restant').html(ss_restant);
$('#center_chat_page .messages #v2018_chat_alert').hide(); // Au cas ou car JB a eu les 2 popups superposees
$('#compteur_a_rebour_content').show();
}
}
function put_in_front( element_id ){
$(element).unbind().click(function(){
$(this).css({'z-index' : 99999});
});
}
function btn1(obj){
if ($(obj).hasClass('no-active')){
$(obj).removeClass('no-active').addClass('active');
try {
localStorage.setItem($(obj).prop('id')+'_'+$(obj).data('contact_id'),'active');
} catch (e) {
// Can't use sessionStorage !!!
}
return;
} else if ($(obj).hasClass('active')){
$(obj).removeClass('active').addClass('no-active');
try {
localStorage.setItem($(obj).prop('id')+'_'+$(obj).data('contact_id'),'no-active');
} catch (e) {
// Can't use sessionStorage !!!
}
return;
} else {
$(obj).removeClass('no-active').addClass('active');
try {
localStorage.setItem($(obj).prop('id')+'_'+$(obj).data('contact_id'),'active');
} catch (e) {
// Can't use sessionStorage !!!
}
return;
}
}
function store_delete_quick_chat_state( action ){
var object = 'quick_chat';
if( action == 'add'){
try {
localStorage.setItem(object,'active');
} catch (e) {
// Can't use sessionStorage !!!
}
} else if( action == 'del' ){
try {
localStorage.setItem(object,'no-active');
} catch (e) {
// Can't use sessionStorage !!!
}
}
}
$(window).on('load', function() {
if($('#new-msg-alert').css('display') != 'none' && !IS_MOBILE ) {
$('#alert').css({'right': '296px'});
$('#alert').css({'left':''});
}
});
$(window).resize( function() {
resizeFog();
})
function resizeFog(){
var fogMsgBox = $('.popup-fog-black');
var winH = $(document).height();
var winW = $(window).width();
fogMsgBox.css({'width':winW, 'height':winH});
return;
}
function GA_event(eventCategory, eventAction, eventLabel){
// console.log("Dans GA_event");
// console.log("eventCategory : " +eventCategory);
// console.log("eventAction : " +eventAction);
// console.log("eventLabel : " +eventLabel);
if( typeof(ga) != 'undefined' ){
ga('send', 'event', {
eventCategory: eventCategory,
eventAction: eventAction,
eventLabel: eventLabel
});
}
}
function handleVisibilityChange() {
if (document.hidden) {
pageVisible=0;
} else {
pageVisible=1;
}
}
var data_webcam = "";
var visibilityChange;
var pageVisible = 1;
$(document).ready(function(){
//mise en place de l'évènement qui détecte si la page est visible
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
visibilityChange = "visibilitychange";
} else if (typeof document.msHidden !== "undefined") {
visibilityChange = "msvisibilitychange";
} else if (typeof document.webkitHidden !== "undefined") {
visibilityChange = "webkitvisibilitychange";
}
if (typeof document.addEventListener === "undefined" || typeof document.hidden === "undefined") {
//This demo requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API
} else {
document.addEventListener(visibilityChange, handleVisibilityChange, false);
}
$('#new-add-photo .from-computer, #new-add-photo .from-webcam').unbind().click(function(){
var my_pseudo = "";
var my_id = "";
my_pseudo = $(this).data('pseudo');
my_id = $(this).data('id');
if( my_pseudo != "" && my_id != "" ) {
document.location= tabLang['htmembres'] + "_" + my_pseudo + "_" + my_id + ".html?show_photos=1";
} else {
$("#new-add-photo").hide();
}
});
if( typeof($('#center_chat_page .messages #v2018_chat_alert .upgrade_msg_slider')) != 'undefined' && !$('#center_chat_page .messages #v2018_chat_alert .upgrade_msg_slider').hasClass('slick-initialized')) {
$('#center_chat_page .messages #v2018_chat_alert .upgrade_msg_slider').slick({
autoplay: true,
arrows: false,
infinite: true,
slidesToScroll: 1,
slidesToShow: 1,
dots: true,
});
}
$('#h-myWall-btn, .myWall-ico').click(function(){
var nb_notifs_wall = 0;
if( typeof( user_id ) != 'undefined' && typeof( localStorage.getItem('nb_notifs_wall_'+user_id) ) != 'undefined' || localStorage.getItem('nb_notifs_wall_'+user_id) != null ) {
try {
localStorage.setItem('nb_notifs_wall_' + user_id, 0);
} catch (e) {
// Can't use sessionStorage !!!
}
}
$('.my_wall_cpt').html(nb_notifs_wall);
$('.my_wall_cpt').hide();
window.location='index.php?mod=wall';
return false;
});
if( typeof( user_id ) != 'undefined' && typeof( localStorage.getItem('nb_notifs_wall_'+user_id) ) != 'undefined' || localStorage.getItem('nb_notifs_wall_'+user_id) != null ) {
$('.my_wall_cpt').html(localStorage.getItem('nb_notifs_wall_'+user_id));
$('.my_wall_cpt').css('display','block');
$('.my_wall_cpt').show();
if( localStorage.getItem('nb_notifs_wall_'+user_id) == 0 || localStorage.getItem('nb_notifs_wall_'+user_id) == null || typeof( localStorage.getItem('nb_notifs_wall_'+user_id) ) == 'undefined'){
$('.my_wall_cpt').hide();
}
}
$('.online_members_top_list').unbind().click(function() {
window.location = $(this).data('click');
});
$('#send_question_btn').off('click').on('click', function(){
var contact = $(this).data('contact');
var contact_img = $(this).data('contact_img');
var contact_img_sqsmall = contact_img.replace(/sqmiddle/,'sqsmall');
var contact_id = $(this).data('contact_id');
var contact_state = $(this).data('contact_state');
if(!IS_MOBILE) {
askShare(contact);
}
});
$("#cancel_question_btn, .close_ask_priv").off('click').on('click',function(){
$('#ask_priv_photo_popup').hide();
});
$("#center_chat_page .messages").scrollTop(9999);
$(document).click(function(event) {
if($(event.target).closest('#center_chat_page .options_ico').length){
if( $('#center_chat_page .options_txt').hasClass('active') ) {
$('#center_chat_page .options_txt').hide();
$('#center_chat_page .options_txt').removeClass('active');
} else {
$('#center_chat_page .options_txt').show();
$('#center_chat_page .options_txt').addClass('active');
}
}
else if(!$(event.target).closest('#center_chat_page .options_txt').length){
if( $('#center_chat_page .options_txt').hasClass('active') ) {
$('#center_chat_page .options_txt').hide();
$('#center_chat_page .options_txt').removeClass('active');
}
}
});
$(document).click(function(e) {
var target = e.target;
if (e.target.class != 'content' && $('#new-right-menu').hasClass('show')) {
$('#new-right-menu').removeClass('show');
$('#h-profile').removeClass('active').addClass('no-active');
}
})
$('img.blur_strong, img.blur_light').parent().css('overflow','hidden');
// $('img.blur_strong, img.blur_light').parent().css('position','absolute');
// init de selectric pour la custo des select box
$('.sel86').selectric({
Width: 100
});
$('#popup_edit_infos .edit_my_profile, #popup_edit_want2meet .edit_my_profile').selectric({
Width: 296,
});
$("#popup_edit_my_infos select[name='day']").selectric({
width: 65
});
$("#popup_edit_my_infos select[name='month']").selectric({
width:115
});
$("#popup_edit_my_infos select[name='year']").selectric({
width: 75
});
// initialisation de slick ( slideshow gal top )
$('.online_members_slick').slick({
infinite: true,
slidesToScroll: 3,
slidesToShow: 25
});
$('.profile_gal_slick').slick({
infinite: true,
slidesToScroll: 1,
slidesToShow: 5,
dots: true
});
$('.preview_album_slick').slick({
infinite: true,
slidesToScroll: 1,
slidesToShow: 5
});
$('.photo_wall_slick').slick({
infinite: true,
slidesToScroll: 1,
slidesToShow: 4
});
$("#profile-photos .h5_edit.album_pub, #profile-photos .h5_edit.album_priv").unbind().click( function(){
$(document).scrollTop(50);
open_photo_block();
});
$("#top-upgrade-msg").hide();
$('#logo_v2016').unbind().click(function(){
reset_opacity_and_sessionStorage_header_ico();
});
if( typeof(sessionStorage.getItem('match-ico')) != 'undefined' && sessionStorage.getItem('match-ico') == "active" ){
$(".match-ico").removeClass('no-active');
$(".match-ico").addClass('active');
}
if( typeof(sessionStorage.getItem('myWall-ico')) != 'undefined' && sessionStorage.getItem('myWall-ico') == "active" ){
$(".myWall-ico").removeClass('no-active');
$(".myWall-ico").addClass('active');
}
if( typeof(sessionStorage.getItem('album-ico')) != 'undefined' && sessionStorage.getItem('album-ico') == "active" ){
$(".album-ico").removeClass('no-active');
$(".album-ico").addClass('active');
}
if( typeof(sessionStorage.getItem('votes-ico')) != 'undefined' && sessionStorage.getItem('votes-ico') == "active" ){
$(".votes-ico").removeClass('no-active');
$(".votes-ico").addClass('active');
}
if( typeof(sessionStorage.getItem('promotion-ico')) != 'undefined' && sessionStorage.getItem('promotion-ico') == "active" ){
$(".promotion-ico").removeClass('no-active');
$(".promotion-ico").addClass('active');
}
if( IS_MOBILE ){
$('#new-msg-alert, #new-messanger').hide();
// var device = navigator.userAgent.toLowerCase();
// var ios = device.match(/(iphone|ipod|ipad)/);
// if (ios) {
// $('.online_profiles_click').on('touchstart', function(e){
// $(this).find('a').click();
// });
// $('#messagers .messager1').on('touchstart', function(e){
// $(this).click();
// });
// }
}
/*$('#alert').addClass('popup_alert_left');*/
/**
* Utilisation du SESSIONSTORAGE pour gérer la popup upgrade, ainsi l'évènement est lié à la session de l'utilisateur et non plus au localstorage du browser
*/
if ( typeof( sessionStorage.getItem('top-upgrade-already-closed') ) != 'undefined' && sessionStorage.getItem('top-upgrade-already-closed') == 'active' ) {
var top_upgd_msg = $("#top-upgrade-msg");
if( typeof( top_upgd_msg ) != 'undefined' ){
top_upgd_msg.hide();
}
}
if ( typeof( sessionStorage.getItem('top-pub-already-closed') ) != 'undefined' && sessionStorage.getItem('top-pub-already-closed') == 'active' ) {
var top_pub_msg = $("#top-new-msg");
if( typeof( top_pub_msg ) != 'undefined' ){
top_pub_msg.hide();
}
}
/*if($("#iframeAlbum").length == 0){//patch qui vérifie qu'on n'est pas dans l'iframe de l'album photo
if( typeof(localStorage.getItem('quick_chat')) != 'undefined' && localStorage.getItem('quick_chat') == "active" ){
load_messages_new_messenger(0, 1);
$('#new-messanger').show();
} else if( typeof(localStorage.getItem('quick_chat')) != 'undefined' && localStorage.getItem('quick_chat') == "reduce" ){
load_messages_new_messenger(0, 1);
$('#new-messanger').show();
$("#new-messanger .action-2").unbind().click();
}
}*/
$('#chboxes3').hide();
$('#online_man_btn').hide();
$('#online_all_btn').hide();
$('#online_woman_btn').hide();
$('#online_couple_btn').hide();
//events google analytics + tag manager
// premium dans header
var event_name = "actionClickPremium";
$('#h-upgrade-btn').unbind().click(function(){
GA_event('upgrade btn','click', 'btn_upgrade_header');
});
// premium dans menu gauche
$('#l-upgrade-btn').unbind().click(function(){
GA_event('upgrade btn','click', 'btn_upgrade_menu');
});
$('.online_bar_profile').unbind().click(function(){
GA_event('online bar profile','click', 'click_online_bar_profile');
});
$("#alert #access_lnk a").unbind().click( function() {
GA_event('upgrade btn','click', 'btn_upgrade_chat');
popup_paiement('Alert_popup', $(this).data('pseudo'));
});
$("#preview-info #chat2").unbind().click(function(){
var datas = {
event: 'actionStartChatMemberPage'
};
dataLayer_generator( datas );
});
// Recherche rapide
$('#search-btn').unbind().click(function(){
GA_event('search btn','click', 'click_quick_search');
switch ( $("#new-quick-search .sex :selected").val() ) {
case '1' :
var searchGender = "Male";
break;
case '2' :
var searchGender = "Female";
break
case '3' :
var searchGender = "Couple";
break
default :
var searchGender = "";
break
}
if ( $("#new-quick-search #with_photo").is(':checked') ){
var searchWithPhoto = "Yes";
} else {
var searchWithPhoto = "No";
}
if ( $("#new-quick-search #online").is(':checked') ){
var searchState = "Online";
} else {
var searchState = "Offline";
}
var datas = {
searchGender : searchGender,
searchAge : $("#new-quick-search #sel_age_from").val() + ' - ' + $("#new-quick-search #sel_age_to").val(),
serachDistance : $("#new-quick-search #dist").val(),
searchWithPhoto : searchWithPhoto,
searchState : searchState,
event : 'siteSearch'
};
dataLayer_generator( datas );
});
// Recherche avancée
$('#search-btn.adv_search').unbind().click(function(){
switch ( $("#adv_search_form #sel_sex :selected").val() ) {
case '1' :
var searchGender = "Male";
break;
case '2' :
var searchGender = "Female";
break
case '3' :
var searchGender = "Couple";
break
default :
var searchGender = "";
break
}
if ( $("#adv_search_form #with_photo").is(':checked') ){
var searchWithPhoto = "Yes";
} else {
var searchWithPhoto = "No";
}
if ( $("#adv_search_form #online").is(':checked') ){
var searchState = "Online";
} else {
var searchState = "Offline";
}
var datas = { searchGender : searchGender,
searchCity: $("#adv_search_form #city").val(),
searchAge : $("#adv_search_form #sel_age_from").val() + ' - ' + $("#adv_search_form #sel_age_to").val(),
serachDistance : $("#adv_search_form #dist").val(),
searchWithPhoto : searchWithPhoto,
searchState : searchState,
event : 'siteSearchAdvanced'
};
dataLayer_generator( datas );
$('#adv_search_form').submit();
});
$(document).mouseup(function(e){
var menu_left = $('#new-left-menu');
var btn_menu_left = $('#l-menu-btn');
if ( !menu_left.is(e.target) // The target of the click isn't the container.
&& menu_left.has(e.target).length === 0 // Nor a child element of the container
&& !btn_menu_left.is(e.target)
)
{
menu_left.removeClass('show');
btn_menu_left.removeClass('active').addClass('no-active');
}
});
var scrollLimit = $('#top-upgrade-msg').height();
$(window).scroll(function() {
if($(window).scrollTop() > scrollLimit) {
$('#top-upgrade-msg').css('position','fixed');
} else {
$('#top-upgrade-msg').css('position','relative');
}
});
// $('#top-upgrade-msg .close').unbind().click( function(){
// $('#new-header').css('padding-top','0');
// });
// $('#new-my-messages').unbind().click(function(){
// $(this).css({'z-index' : 90000});
// $('#new-messanger').hide();
// });
//
// $('#new-messanger').unbind().click(function(){
// $(this).css({'z-index' : 90000});
// $('#new-my-messages').hide();
// });
//
// $('#show-photos').unbind().click(function(){
// $(this).css({'z-index' : 90000});
// $('#new-my-messages').css({'z-index' : 9999});
// });
//
// $('#p_attachment').unbind().click(function(){
// $(this).css({'z-index' : 90000});
// $('#new-my-messages').css({'z-index' : 9999});
// });
$('#move-favorite').unbind().click(function(){
add_del_friend_v2016($(this));
});
$('#move-trash').unbind().click(function(){
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setContact.php",
data: "target_id="+$(this).data('id_contact') + "&action=del",
success: function(f)
{
get_contacts_list_v2018( $(this), 0,1, true);
},
error: function(){
get_contacts_list_v2018( $(this), 0,1, true);
}
});
return false;
});
$('#move-black-list').unbind().click(function(){
add_Blist_v2016($(this));
});
if(typeof(no_modulo_search) == "undefined" || no_modulo_search==0){
block_user_modulo_search($('#ul_result li'));
}
// Pour cacher l'activité du site
$('#site_activity').hide();
/**
* Stéphan : pour FC v2 pour mettre à jour l'url dynamiquement !!!
*
* window.history.pushState({"html":"response.html","pageTitle":'toto'},"", "the_url_you_want.html");
*
*/
/**
* Ajouté par Laurent le 14/06/2016 pour masquer la recherche avancé sur tablette
*/
$("#marry_status, #orientation, #sexsual_pref, #name_surn, #user_name, #eye_color, #hair_type, #height_selection, #weight_selection, #go-small-search").hide();
// MAKE SURE YOUR SELECTOR MATCHES SOMETHING IN YOUR HTML!!!
$('#sel_timezone_1').change(function(){
var continent=$(this).val();
// alert("sel_timezone_1 "+continent);
$.ajax({
type: "POST",
url: "app/ajax/get_timezone_list.php",
data: { "continent": continent },
dataType: "json",
success: function(zones) {
// console.log(zones);
$("#sel_timezone").parents('.selectric-wrapper').find('.selectric-scroll ul').find('li').remove();
$("#sel_timezone").parents('.selectric-wrapper').find('.selectric-scroll ul').find('option').remove();
$("#sel_timezone").find('option').remove();
var flag=0;
jQuery.each(zones, function(index, z){
//addedSelect +=''+z+' ';
if(flag==0){
selected='selected';
flag=1;
$("#sel_timezone").val(z);
// $("#cuselFrame-sel_timezone .cuselText").html(z);
$("#sel_timezone").append(''+z+' ');
}
else {
selected = "";
$("#sel_timezone").append('' + z + ' ');
}
});
$('#sel_timezone').selectric('refresh');
var params = {
refreshEl: "#sel_timezone",
visRows: 8,
scrollArrows: true
};
cuSelRefresh(params);
},
error: function(ret) {
alert("impossible de récupérer les différentes timezone");
}
});
});
$('#my_profile').hover(
function(){ $('.myp').addClass('myphover') },
function(){ $('.myp').removeClass('myphover') }
);
$('#my_photo').hover(
function(){ $('.myph').addClass('myphhover') },
function(){ $('.myph').removeClass('myphhover') }
);
$('#my_messges').hover(
function(){ $('.mym').addClass('mymhover') },
function(){ $('.mym').removeClass('mymhover') }
);
$('#my_events').hover(
function(){ $('.mye').addClass('myehover') },
function(){ $('.mye').removeClass('myehover') }
);
$('#my_guests').hover(
function(){ $('.myg').addClass('myghover') },
function(){ $('.myg').removeClass('myghover') }
);
$('#my_wall').hover(
function(){ $('.myw').addClass('mywhover') },
function(){ $('.myw').removeClass('mywhover') }
);
$('#my_account').hover(
function(){ $('.mya').addClass('myahover') },
function(){ $('.mya').removeClass('myahover') }
);
$('#logout').hover(
function(){ $('.myl').addClass('mylhover') },
function(){ $('.myl').removeClass('mylhover') }
);
$('/*#logout*/ #logout_step2').unbind().click(function(){
sessionStorage.setItem('top-upgrade-already-closed','inactive');
sessionStorage.setItem('top-pub-already-closed','inactive');
var OneSignal = window.OneSignal;
if( typeof (OneSignal) != 'undefined' && OneSignal != '' && OneSignal != null ){
try{
OneSignal.getUserId().then(function(userId) {
if( userId != null ){
$.get( "index.php?mod=push_notify", { action_bis: 'delete_token_oneSignal'}, function( datas ) {});
}
});
}
catch(error){
//alert(error);
}
}
});
$('#photo_priv,#photo_priv img,#transparent_bg2').click(function(){
$("#transparent_bg2").hide();
$("#p_attachment").hide();
$(this).hide();
});
$('#for_top_photos li').each(function() {
$(this).qtip({
content: {
text: function(event, api) {
pseudo=$(this).attr("m_pseudo");
m_id=$(this).attr("m_id");
m_age=$(this).attr("m_age");
m_zone_str=$(this).attr("m_zone_str");
if( typeof( m_id ) != 'undefined' && m_id != "" && typeof( pseudo ) != 'undefined' && pseudo != "" ) {
return '
'; // Set some initial text
} else {
m_title=$(this).attr("m_title");
return ''+m_title+'
'; // Set some initial text
}
}
},
position: {
viewport: $(window),
at: 'bottom center',
my: 'top center'
},
hide: {
delay: 100,
fixed: true
},
style: {
classes: 'qtip_hover_icons'
}
});
});
$(".container1, .container4").clickCarousel({margin: 0});
$(".container4 .activity-text,.container4 .activity-date").click(function(){
return false;
});
$(".radio_label").click(function(){
var p=$(this).parent().find(".niceRadio");
//var r = p.find("input");
//alert(p.attr("class"));
changeRadio(p);
});
$('#about_tries .close4').click(function(){
$('#transparent_bg3').hide();
$('#about_tries').hide();
});
$('#about_try_again .close4').click(function(){
$('#transparent_bg3').hide();
$('#about_try_again').hide();
});
$('#about_try_success .close4').click(function(){
$('#transparent_bg3').hide();
$('#about_try_success').hide();
});
$('#search_nick_msg_close').click(function(){
$('#nick_msg_search').val('');
$('#search_nick_msg').click();
});
$('#all-msg-menu').unbind().click(function(){
Initialise_chat_page();
stop_timer_refresh_chats();
stop_timer_refresh_compte_a_rebour();
$('#search_nick_msg').attr('nick_filter', '1');
get_contacts_list_v2018( $(this), 0,1, false);
});
$('#friends-msg-menu').unbind().click(function(){
Initialise_chat_page();
stop_timer_refresh_chats();
stop_timer_refresh_compte_a_rebour();
$('#search_nick_msg').attr('nick_filter', '3');
get_contacts_list_v2018( $(this), 0,3, false);
});
$('#online-msg-menu').unbind().click(function(){
Initialise_chat_page();
stop_timer_refresh_chats();
stop_timer_refresh_compte_a_rebour();
$('#search_nick_msg').attr('nick_filter', '5');
get_contacts_list_v2018( $(this), 0,5, false);
});
$('#blocked-msg-menu').unbind().click(function(){
Initialise_chat_page();
stop_timer_refresh_chats();
stop_timer_refresh_compte_a_rebour();
$('#search_nick_msg').attr('nick_filter', '2');
get_contacts_list_v2018( $(this), 0,2, false);
});
$('#contacts-msg-menu').unbind().click(function(){
Initialise_chat_page();
stop_timer_refresh_chats();
stop_timer_refresh_compte_a_rebour();
$('#search_nick_msg').attr('nick_filter', '6');
get_contacts_list_v2018( $(this), 0,6, false);
});
$('#h-profile').unbind().click(function(){
$('#new-my-msg-block').hide();
$("#new-msg-alert").hide();
$('#new-messanger').hide();
GA_event('menu btn','click', 'btn_menu_right');
});
$('#l-menu-btn').unbind().click(function(){
stop_timer_refresh_chats();
$('#new-my-msg-block').hide();
$("#new-msg-alert").hide();
//$('#new-messanger').hide()
});
$('#my_messages').unbind().click(function(){
Initialise_chat_page();
stop_timer_refresh_chats();
get_contacts_list_v2018( $(this), 0,1);
return;
});
$('#h-chat-btn').unbind().click(function(){
Initialise_chat_page();
stop_timer_refresh_chats();
$('#search_nick_msg').attr('nick_filter', '1');
get_contacts_list_v2018( $(this), 0,1, false);
});
$('#search_nick_msg').unbind().click( function(){
var filter_nick = $(this).attr('nick_filter');
var nick_searched = $('#nick_msg_search').val();
get_contacts_list_v2018( $(this), 0, filter_nick, true, '', nick_searched);
});
$('#nick_msg_search').keypress(function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13') {
$('#search_nick_msg').click();
}
});
var el = document.getElementById("nick_msg_search");
if( typeof( el ) != 'undefined' && el != null ){
el.addEventListener("keydown", function(event) {
if ( ( event.key === "Delete" || event.key === "Backspace") && $(el).val().length > 0 && $(el).val().length < 2) {
$('#nick_msg_search').val('');
$('#search_nick_msg').click();
}
});
}
$('#new-msg-alert .close').unbind().click(function(){
$('#alert').removeClass('popup_alert_left');
fast_chat=0;
save_contact_chat2 = "";
$('#new-msg-alert').hide();
stop_timer_refresh_chats();
});
$('#new-messanger .action-1').unbind().click( function() {
$('#alert').removeClass('popup_alert_left');
$('#alert').css({'left':''});
$('#new-messanger').hide();
$('#new-msg-alert').hide();
store_delete_quick_chat_state('del');
if( IS_MOBILE ) {
open_messages();
} else {
get_contacts_list_v2016( $(this), 0,1);
}
});
$('#new-msg-alert .action').unbind().click(function(){
fast_chat=1;
$('#alert').addClass('popup_alert_left');
load_messages_new_messenger(0, 1);
});
// $('#alert').change( function(){
// if($('#new-msg-alert').css('display') == 'block' ){
// $('#alert').css({'left': '5px', 'bottom' : '5px'});
// } else if( $('#new-messanger').css('display') == 'block' ){
// $('#alert').css({'left': '5px', 'bottom' : '5px'});
// }
// });
$('#new-messanger .close').unbind().click(function(){
hChatBtnManager('close');
fast_chat=0;
save_contact_chat2 = "";
$('#new-messanger').hide();
stop_timer_refresh_chats();
store_delete_quick_chat_state('del');
$('#alert').removeClass('popup_alert_left');
});
$('#new-my-messages .close').unbind().click(function(){
hChatBtnManager('close');
main_chat = 0;
save_contact_chat1 = "";
$('#new-my-msg-block').hide();
$('#h-chat-btn').addClass('no-active');
$('#h-chat-btn').removeClass('active');
stop_timer_refresh_chats();
})
chat_rebind();
photos_rebind();
$('.read_message_btn').click(function(){
GA_event('nouveau message btn','click', 'btn_popup_new_msg');
if( $(this).attr('is_abo') == "false") {
popup_paiement('Chat', $(this).attr("contact"));
} else {
if(IS_MOBILE){
open_messages();
} else {
contact = $(this).attr("contact");
// tab_infos_user = new Array();
// tab_infos_user['pseudo'] = contact;
//open_messages(contact);
$('#new-messanger').hide();
// get_contacts_list_v2018( $(this), 0, 1, false, tab_infos_user);
Initialise_chat_page();
document.location='index.php?mod=chat_v2018&pseudo=' + contact;
return false;
}
}
close_alerte();
return false;
});
$('.view_profile_btn').click(function(){
contact = $(this).attr("contact");
document.location='membres_' + contact + '.html';
return false;
});
$('#messages_active').click(close_tchat_droite);
$( '#sidebar-right-users, #subscribe_block' ).bind( 'mousewheel DOMMouseScroll', function ( e ) {
var e0 = e.originalEvent,
delta = e0.wheelDelta || -e0.detail;
this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();
});
$( '#chat_small' ).bind( 'mousewheel DOMMouseScroll', function ( e ) {
var e0 = e.originalEvent,
delta = e0.wheelDelta || -e0.detail;
this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();
});
$('#send_message2 #new_message' ).keypress(function(e) {
if(e.which == 13 || e.keycode == 13) {
var parental = $(this).parents('form').attr('id');
var encours = $(this).attr('id');
submitChatForms(parental);
if(parental=='send_message2'){
messager1_rebind();
}
return false;
}
}).bind("cut copy paste drop",function(e) {
if(USER_PSEUDO != "admindusite") e.preventDefault();
});
$('#send_message #new_message').keypress(function(e) {
if(e.which == 13 || e.keycode == 13) {
var parental = $(this).parents('form').attr('id');
var encours = $(this).attr('id');
//console.log("parent : "+parental);
submitChatForms(parental);
if(parental=='send_message'){
messager1_rebind();
}
return false;
}
}).bind("cut copy paste drop",function(e) {
if(USER_PSEUDO != "admindusite") e.preventDefault();
});
$('#send_message, #send_message2').submit(function(event){
submitChatForms(this.id);
event.preventDefault();
});
$('.chat_user2').click(function(){
$('.chat_user2').css('background-color','#eeeeee');
$('.user-miniature-bg').css('width','60px');
$('#sidebar-right').css('width','505px');
$('.message_count2').show();
});
$('#for_account').click(function(){
try {
if( IS_MOBILE && localStorage.pop_open==1 ) {
close_messages();
return true;
}
}
catch(e) {}
$('#for_account').hide();
$('#for_account_active').show();
close_messages();
if(IS_MOBILE) $('#site_menu').hide();
$('#user_menu').show();
$('#messages_active').hide();
$('#messages').show();
$('#btn-left-menu-active').hide();
$('#btn-left-menu').show();
$('.account_name2').show();
$('.down-arrow2').show();
});
$('#for_account_active').click(function(){
$('#for_account_active').hide();
$('#for_account').show();
$('#user_menu').hide();
$('.account_name2').hide();
$('.down-arrow2').hide();
});
$('#btn-left-menu, #btn-p-left-menu-hover').click(function(){
$('#btn-left-menu').hide();
$('#btn-left-menu-active').show();
close_messages();
$('#user_menu').hide();
if(!IS_MOBILE)
$('#site_menu').hide();
else
$('#site_menu').show();
$('#messages_active').hide();
$('#messages').show();
$('#for_account_active').hide();
$('#for_account').show();
$("#for_top_photos").css("margin-top","0");
});
$('#btn-left-menu-active').click(function(){
$('#btn-left-menu-active').hide();
$('#btn-left-menu').show();
if(!IS_MOBILE)
$('#site_menu').show();
else
$('#site_menu').hide();
$("#for_top_photos").css("margin-top","42px");
});
$('a:not([target=_blank])').click(function(){
href=$(this).attr("href");
if(href != "#" && typeof(href) != "undefined") document.location=href;
return false;
});
$('article').click(function(){
if(IS_MOBILE) $('#site_menu').hide();
$("#context-menu").hide();
$('#user_menu').hide();
close_messages();
$('#messages_active, #for_account_active, #btn-left-menu-active').hide();
$('#messages, #for_account, #btn-left-menu').show();
});
$('#site_menu, #h-center,.context-menu__link').click(function(){
$("#context-menu").hide();
});
$('#return_messager').click( function(){
$('#messages-field').css({"top":'', "position":''});
$('.none3').css ({ "position":"absolute", "top":"-9999px;" });
$('#messager_search').removeClass('none3');
$('#messager_search').css({"position":''});
});
$('.carouselLeft2-b').click(function(){
filter=$('#messagers').attr('filter');
start=$(this).attr("start");
if(start > -1){
get_contacts_list(start,filter);
}
});
$('.carouselRight2-b').click(function(){
filter=$('#messagers').attr('filter');
start=$(this).attr("start");
if(start > -1){
get_contacts_list(start,filter);
}
});
$('.showMore').unbind().click(function(){
// console.log("dans showmore !!!");
filter=$('#messagers').attr('filter');
start=$(this).attr("start");
if(start > -1){
get_contacts_list(start,filter);
}
});
$('.send_mess').click(function(){
$(this).parent().parent().parent().click();
return false;
});
$('.close2,#transparent_bg3').click(function(){
if( typeof ( Webcam ) != 'undefined' ) {
Webcam.reset();
}
$('#transparent_bg, #transparent_bg2, #transparent_bg3, #add_photo_block, #add_photo_block_error, #member_photos_block, #about_tries,#about_try_again').hide();
$('#vote_photo_block').css("visibility","hidden");
$('#about_try_success').hide();
$('#vote_photo_block').css({"top":"-9999px"});
$('#vote_photo_block_priv').css("visibility","hidden");
$('#vote_photo_block_priv').css({"top":"-9999px"});
$('#edit_photo_block, #subscribe_block').css({"top":"-9999px"});
$("#p_attachment").hide();
var popoffre_visible=0;
if($('#popoffre1, #popoffre2, #popoffre3, #popoffreSuccess').is(":visible")){
popoffre_visible=1;
}
$(".popoffre").hide();
if(popoffre_visible){
var popOffreNum=0;
if(localStorage.getItem("popOffreNum")){
popOffreNum = localStorage.getItem("popOffreNum");
}
if(popOffreNum==0) popOffreNum = 1;
else if(popOffreNum==1) popOffreNum = 2;
else popOffreNum = 3;
//alert("close popoffre"+popOffreNum);
//Appel Ajax pour stats Opale
var date_now = new Date().getTime();
localStorage.setItem("popOffreNum",popOffreNum);
localStorage.setItem("popOffreLast",date_now);
}
});
$('.popoffre .btn-success').click(function(){
if(document.formPopOffre){
var popOffreNum=0;
if(localStorage.getItem("popOffreNum")){
popOffreNum = localStorage.getItem("popOffreNum");
}
popOffreNum++;
var date_now = new Date().getTime();
localStorage.setItem("popOffreNum",popOffreNum);
localStorage.setItem("popOffreLast",date_now);
document.formPopOffre.submit();
}
else{
if(document.formPopSuccessParams){
var urlApiPub=document.formPopSuccessParams.urlApiPub.value;
var popNum=document.formPopSuccessParams.popNum.value;
urlApiPub += "&popNum=" + popNum;
window.open(urlApiPub,"_blank");
}
}
});
contextmenu_rebind();
$("#album_photo_block .img_wrap img").on('load', function(){
$("#img_loader").hide();
$("#album_photo_block .img_wrap img").show();
h = parseInt($("#album_photo_block .img_wrap img").height());
if(!IS_MOBILE && h > 1) ResizeParent(h + 150);
photoName=basename($(this).attr("src"));
photoName=photoName.replace('_sqmiddle.jpg', '.jpg');
photoName=photoName.replace('_sqsmall.jpg', '.jpg');
if(photoName.indexOf("?") > 0) photoName = photoName.substr(0,photoName.indexOf("?"));
if(!inArray(photoName,PHOTOS_VOTED)){
$(".vote_notif").hide();
$('.vote_stars .stars_item').each(
function() {
$(this).removeClass("vote_star_checked");
$(this).addClass("vote_star");
});
$(".vote_stars").fadeIn();
}
else{
$(".vote_stars").hide();
$(".vote_notif").show();
$(".vote_notif").html(lang_notif_vote);
}
return false;
});
$('#edit_main_pic, #edit_main_pic2').click(function(){
open_photo_block();
});
$('#edit_main_pic3').click(function(){
//alert("call parent open_photo_block()");
$('#vote_photo_block',window.parent.document).css("visibility","hidden");
$('#vote_photo_block',window.parent.doc).css({"top":"-9999px"});
window.parent.open_photo_block();
});
$('#add_photos, #add_main_pic, #add_main_pic_large').click(function(){
open_photo_add();
});
$('.bt_new_photo').click(function(){
window.parent.open_photo_add();
});
$('#left_90').click(function(){
var imgGradius=$('#select_area_block img').attr("gradius");
if(imgGradius=="undefined" || !imgGradius){
imgGradius=0;
$('#select_area_block img').attr("gradius",imgGradius);
}
imgGradius=parseInt(imgGradius);
imgGradius +=90;
if(imgGradius >= 360) imgGradius = imgGradius - 360;
$('#select_area_block img').attr("gradius",imgGradius);
if(imgGradius==90)
$("#edit_photo_block2 #select_area_block").css({margin: "50px 0 0 0"});
else
$("#edit_photo_block2 #select_area_block").css({margin: 0});
$('#select_area_block').removeClass('left_90_css');
$('#select_area_block').removeClass('left_180_css');
$('#select_area_block').removeClass('left_270_css');
if(imgGradius > 0) $('#select_area_block').addClass('left_'+imgGradius+'_css');
$("#imgGradius").val(imgGradius);
if(imgGradius > 0) jcrop.disable();
else jcrop.enable();
});
$('#right_90').click(function(){
var imgGradius=$('#select_area_block img').attr("gradius");
if(imgGradius=="undefined" || !imgGradius){
imgGradius=0;
$('#select_area_block img').attr("gradius",imgGradius);
}
imgGradius=parseInt(imgGradius);
imgGradius =imgGradius - 90;
if(imgGradius < 0) imgGradius = imgGradius + 360;
$('#select_area_block img').attr("gradius",imgGradius);
if(imgGradius==90 || imgGradius==270)
$("#edit_photo_block2 #select_area_block").css({margin: "45px 0 0 0"});
else
$("#edit_photo_block2 #select_area_block").css({margin: 0});
$('#select_area_block').removeClass('left_90_css');
$('#select_area_block').removeClass('left_180_css');
$('#select_area_block').removeClass('left_270_css');
if(imgGradius > 0) $('#select_area_block').addClass('left_'+imgGradius+'_css');
$("#imgGradius").val(imgGradius);
if(imgGradius > 0) jcrop.disable();
else jcrop.enable();
});
$('#tags').unbind().click(function() {
getPopupx('tags', 'block_tags', -300, 0);
});
$('#int_edit').unbind().click(function(){
$('#popup_edit_interests').show();
// $('#int_list').hide();
// $('#int_edit_form').css({ "position":"relative", "top":"0px"});
});
$('#popup_edit_interests #inf_cancel_edit_btn, #popup_edit_interests .close').unbind().click(function() {
$('#popup_edit_interests').hide();
});
// $('#int_edit_btn').click(function(){
// $('#int_edit_form').css({ "position":"absolute", "top":"-9999px"});
// $('#int_list').show();
// });
$(".alert .close").click(function(){
$(this).parent().fadeOut();
});
$('#main_edit_btn').unbind().click(function(){
$('#popup_edit_my_infos').show();
//$('#information table').hide();
// $("#preview-from").hide();
// $("#preview-last-visit").hide();
//pos=$("#add_photos").position();
//$('#main_edit_form').css({ "position":"absolute", "top":(pos.top + 20)+"px"});
if(IS_MOBILE){
$('#main_edit_form').css({ "position":"relative", "top":"115px"});
}else{
// $('#main_edit_form').css({ "position":"relative", "top":"0px"});
}
//$('#lineForm').css({"display":""});
//$('#inf_edit_form').show();
});
$('#main_cancel_edit_btn, #popup_edit_my_infos .close').click(function(){
$('#popup_edit_my_infos').hide();
// $('#main_edit_form').css({ "position":"absolute", "top":"-9999px"});
// $('#lineForm').css({"display":"none"});
// $("#preview-from").show();
// $("#preview-last-visit").show();
});
$('#to_inf_edit_btn').unbind().click(function(){
$('#popup_edit_infos').show();
// $('#information table').hide();
// $('#inf_edit_form').css({ "position":"relative", "top":"0px"});
// //$('#inf_edit_form').show();
});
// $('#inf_cancel_edit_btn').click(function(){
// $('#inf_edit_form').css({ "position":"absolute", "top":"-9999px"});
// //$('#inf_edit_form').hide();
// $('#information table').show();
// });
$('#popup_edit_infos .close, #popup_edit_infos #inf_cancel_edit_btn').off().on('click',function (){
$('#popup_edit_infos').hide();
});
$('#to_want_edit_btn').click(function(){
$('#popup_edit_want2meet').show();
// $('#wanttomeet_edit table').hide();
// $('#want_edit_text').show();
// $('#want_edit_form').css({ "position":"relative", "top":"0px"});
});
$('#popup_edit_want2meet .close, #want_cancel_edit_btn').click(function(){
$('#popup_edit_want2meet').hide();
// $('#want_edit_text').hide();
// $('#want_edit_form').css({ "position":"absolute", "top":"-9999px"});
// $('#wanttomeet_edit table').show();
});
$('#to_descr_edit_btn').click(function(){
$('#popup_edit_descrip').show();
// $('#descr_text').hide();
// $('#descr_edit_form').show();
});
$('#popup_edit_descrip .close, #descr_cancel_edit_btn').off().on('click',function (){
$('#popup_edit_descrip').hide();
});
// $('#descr_cancel_edit_btn').click(function(){
// $('#descr_edit_form').hide();
// $('#descr_text').show();
// });
$('#to_meet_edit_btn').click(function(){
$('#popup_edit_meet').show();
// $('#meetings table').hide();
// $('#meet_edit_text').show();
// $('#meet_edit_form').css({ "position":"relative", "top":"0px"});
});
$('#popup_edit_meet .close, #meet_cancel_edit_btn').click(function(){
$('#popup_edit_meet').hide();
// $('#meet_edit_text').hide();
// $('#meet_edit_form').css({ "position":"absolute", "top":"-9999px"});
// $('#meetings table').show();
});
// function stopStream(stream) {
// console.log('stop called');
// stream.getVideoTracks().forEach(function (track) {
// track.stop();
// });
// }
$('#webcam_btn').unbind().click(function() {
$('#add_cam_submit').prop('disabled',true);
$("#block_start_cam").show();
Webcam.attach('#video_webcam');
Webcam.on( 'error', function(err) {
alert(Lang["webcam_error"]);
} );
Webcam.on('load', function() {
$('#add_cam_submit').prop('disabled',false);
});
function take_snapshot() {
Webcam.snap( function(data_uri) {
document.getElementById('canvas_webcam').innerHTML = ' ';
data_webcam = data_uri;
} );
}
$('#add_cam_submit').off().on('click',function () {
take_snapshot();
$("#block_start_cam").hide();
$("#block_valid_cam").show();
});
// (function() {
// console.log('Début fonction anonyme webcam')
// var streaming = false,
// video = document.querySelector('#video_webcam'),
// canvas = document.querySelector('#canvas_webcam'),
// startbutton = document.querySelector('#add_cam_submit'),
// width = 460,
// height = 320;
//
// navigator.getMedia = ( navigator.getUserMedia ||
// navigator.webkitGetUserMedia ||
// navigator.mozGetUserMedia ||
// navigator.msGetUserMedia);
//
// navigator.getMedia(
// {
// video: true,
// audio: false
// },
// function(stream) {
// if (navigator.mozGetUserMedia) {
// console.log('mozGetUserMedia !!!');
// video.mozSrcObject = stream;
// } else {
// var vendorURL = window.URL || window.webkitURL;
// video.src = vendorURL.createObjectURL(stream);
// console.log('video source ==> ' + video.src);
// }
// video.play();
// document.getElementById('add_cam_cancel').addEventListener('click', function () {
// stopStream(stream);
// });
// },
// function(err) {
// console.log("An error occured! " + err);
// }
// );
//
// video.addEventListener('canplay', function(ev){
// if (!streaming) {
// console.log("non stream addEventListener !!!")
// height = video.videoHeight / (video.videoWidth/width);
// video.setAttribute('width', width);
// video.setAttribute('height', height);
// canvas.setAttribute('width', width);
// canvas.setAttribute('height', height);
// streaming = true;
// }
// console.log("stream OK addEventListener !!!")
// }, false);
//
// function takepicture() {
// console.log('function takePicture !!!');
// canvas.width = width;
// canvas.height = height;
// canvas.getContext('2d').drawImage(video, 0, 0, width, height);
// console.log('canvas width ==> ' + canvas.width);
// console.log('canvas heigtht ==> ' + canvas.height);
// var ImageWebcam = new Image();
// ImageWebcam.src = canvas.toDataURL('image/png');
// console.log('ImageWebcam');
// console.log(ImageWebcam);
// }
//
// startbutton.addEventListener('click', function(ev){
// console.log('start button !!!');
// takepicture();
// $('#block_start_cam').hide();
// $('#block_valid_cam').show();
// ev.preventDefault();
// }, false);
//
// })();
$("#btn_select_file").hide();
//$("#add_cam_send").hide();
$("#webcam_btn").hide();
});
$('#take_snap').click(function() {
$('#video_webcam').hide();
$('#video_webcam .center').show();
});
$('#add_cam_send').click(function() {
//alert("send photo into the server");
saveCB(data_webcam);
$("#info_cam").hide();
$(this).attr("disabled", "disabled");
$('#add_cam_return').attr("disabled", "disabled");
//alert("photo sent");
$("#cam_loader").html(" ");
});
$('#add_cam_return').click(function(){
$("#block_valid_cam").hide();
$("#block_start_cam").show();
});
$('#add_cam_cancel').click(function() {
Webcam.reset();
//$("#webcam_block").hide();
$("#block_start_cam").hide();
$("#btn_select_file").show();
$("#webcam_btn").show();
});
$('.select_tablet').change(function(){
$('[name="'+$(this).attr("name_default")+'"]').val($(this).val());
if($(this).attr("submit")){
//alert("select_tablet submit");
formName=$(this).attr("submit");
document.forms[formName].submit();
}
if($(this).attr("name_default")=="timezone_1"){
var continent=$(this).val();
$.ajax({
type: "POST",
url: "app/ajax/get_timezone_list.php",
data: { "continent": continent },
dataType: "json",
success: function(zones) {
$('[name_default="timezone"]').find('option').remove();
var flag=0;
jQuery.each(zones, function(index, z){
if(flag==0){
$('[name="timezone"]').val(index);
selected="selected";
flag=1;
}
else selected="";
$('[name_default="timezone"]').append(''+z+' ');
});
},
error: function(ret) {
alert("impossible de récupérer les différentes timezone");
}
});
}
});
$('.top_submit').change(function(){
formName="form_top";
document.forms[formName].submit();
});
$('.messages_top_nav').click(function(){
$(this).removeClass('no_active1').addClass('active1');
$(this).siblings('a').removeClass('active1').addClass('no_active1');
$('.show_next').attr('page_cur','0');
});
$('#game1').click(function(){
flashs_show_home();
});
$('#game2').click(function(){
sg_elems=$("#game2_tab ul li");
if(sg_elems.length < 9){ noload=false;}//on check s'il ny a pas déjà des photos affichés dans cette rubrique
else noload=true;
flashs_show_game(noload);
});
$('#game3').click(function(){
flashs_show_finded();
});
$('#game4').click(function(){
flashs_show_myflashs();
});
$('.like_checked, .dislike_checked').click(function(){
});
$('.lnk_myflashs').click(function(){
myflashs_page=$(this).attr("page");
flashs_show_myflashs();
$('.lnk_myflashs').css("font-weight","normal");
$(this).css("font-weight","bolder");
});
$('.lnk_findedflashs').click(function(){
finded_page=$(this).attr("page");
flashs_show_finded();
$('.lnk_findedflashs').css("font-weight","normal");
$(this).css("font-weight","bolder");
});
$('.photos-count,.photos-count2,.photo_rate2,.small_preview2 img').unbind().click(function(){
// console.log( 'id abo ==> ' + has_an_abo);
if ( typeof( has_an_abo ) != 'undefined' && has_an_abo == 0 && $(this).hasClass('blur_strong') ){
to_paiement();
}else {
call_show_album($(this));
}
});
$('.addf_chat .chat').click(function(){
var user_sex_tag = $(this).data('sexe1');
if( user_sex_tag == 1 ){
user_sex_tag = "Male";
} else if( user_sex_tag == 2 ) {
user_sex_tag = "Female";
} else if( user_sex_tag == 3 ) {
user_sex_tag = "Couple";
}
var date_naissance_tag = $(this).data('birth').split('-');
var year_naissance_tag = date_naissance_tag[0];
var datas = {
event: 'actionStartChat',
perfilSex: user_sex_tag,
perfilPhotoNum: $(this).data('nb_photos'),
perfilBirthYear: year_naissance_tag,
perfilState: $(this).data('online')
};
dataLayer_generator( datas );
});
$('.add_friend').click(function(){
var user_sex_tag = $(this).data('sexe1');
if( user_sex_tag == 1 ){
user_sex_tag = "Male";
} else if( user_sex_tag == 2 ) {
user_sex_tag = "Female";
} else if( user_sex_tag == 3 ) {
user_sex_tag = "Couple";
}
var date_naissance_tag = $(this).data('birth').split('-');
var year_naissance_tag = date_naissance_tag[0];
var datas = {
event: 'actionAddFavory',
perfilSex: user_sex_tag,
perfilPhotoNum: $(this).data('nb_photos'),
perfilBirthYear: year_naissance_tag,
perfilState: $(this).data('online')
};
dataLayer_generator( datas );
call_add_friend($(this));
});
$('.un_friend').click(function(){
if(typeof($(this).attr("subscribe")) != "undefined"){
// document.location="Inscription.html";
document.location=""+tabLang["htInscription"];
}
else call_un_friend($(this));
});
$('.favourites_ul .un_friend').click(function(){
if(typeof($(this).attr("subscribe")) != "undefined"){
// document.location="Inscription.html";
document.location=""+tabLang["htInscription"];
}
else call_un_friend($(this));
window.location.reload();
});
$('#advanced-search').click(function(){
call_show_advanced_search($(this));
});
$('#go-small-search').click(function(){
$('#orientation,#marry_status, #sexsual_pref, #name_surn, #user_name, #eye_color, #hair_type, #height_selection, #weight_selection, #go-small-search, #adv_search_text,#new_line1,#new_line2').hide();
$('#gender, #age').css('padding-bottom','0px');
$('.container2').css('height','70px');
document.formSearch.searchAction.value="Simple";
$('#advanced-search').show();
});
$('#to_meet1').click(function(){
day_all();
});
$('.votephoto_next').unbind().click(function(){
vote_next();
});
$(".activity-text2,.activity-date2").click(function(){
//var href = $(this).first("a").attr("href");
//var el = $(this).parent().find("a");
var p=$(this).parent();
//var el = p.first(".user-miniature");
var el = p.find(".user-miniature").first();
//e=el[0];
//alert(el.html());
document.location=el.attr("href");
});
$('#pages_styles ul li div').click(function(){
$('#pages_styles ul li div').removeClass('style_item_active').addClass('style_item_noactive');
$(this).removeClass('style_item_noactive').addClass('style_item_active');
style_num=$(this).attr("style_num");
document.location="index.php?mod=p_style&ActionCgStyle=1&bg="+style_num;
});
$('#subscr_stop_bnt[class!="retry"]').click(function(){
$(this).css('visibility','hidden');
$('.stop_question, #confirm_or_cancel').show();
});
$('#stop_subsc_cancel').click(function(){
$('#subscr_stop_bnt').css('visibility','visible');
$('#confirm_or_cancel, .stop_question').hide();
$('#subscr_stop_bnt').show();
});
$('.show_next').click(function(){
var li_name="";
var mod=$(this).attr("mod");
if(mod=="secretgarden"){
mod="flashs";
li_name=$(this).attr("li_name");
}
$('#paginator_loader'+li_name).show();
var pas=parseInt($(this).attr("pas"));
var page_cur=parseInt($(this).attr("page_cur"));
var page_next=page_cur+1;
$(this).attr("page_cur",page_next);
var param_pagi=$(this).attr("param_pagi");
if($("#with_photo:checked").length){
param_pagi +="&is_photo=1";
}
if($("#online:checked").length){
param_pagi +="&is_online=1";
}
//alert(page_next);
if(param_pagi.indexOf("Top") != -1){
//patch pour ne pas afficher 2 fois les mêmes profils
pos_last_result=$("#ul_result").find(".photo_rate2").length - 9;
last_result="";
$(".photo_rate2").each(function(){
if(pos_last_result <= 0 && parseInt($(this).attr("id_target")) > 0){
if(last_result) last_result +=",";
last_result += $(this).attr("id_target");
}
pos_last_result--;
});
param_pagi +="&last_result=" + last_result;
}
$.ajax({
type: "GET",
url: "/app/ajax/load_"+mod+".php",
dataType: "json",
data: "page=" + page_next + param_pagi,
success: function(json) {
// console.log(json);
if(mod=="search" && page_cur < 100){
try {
var str = JSON.stringify(json);
if(sessionStorage.search_res != ""){
var temp=str.split(":[{");
if(temp.length > 1){
str1=sessionStorage.search_res;
str1=str1.replace("}]}","},");
str2="{"+temp[1];
sessionStorage.search_res=str1+str2;
}
}
else{
sessionStorage.search_res = str;
}
//console.log(sessionStorage.search_res);
}
catch(e) {}
}
display_next(json,mod,pas,page_cur,page_next,li_name);
},
error: function(ret){
//console.log(ret);
alert("Impossible d'afficher la suite");
}
});
});
$("#vote_id2 .img_wrap img").on('load', function(){
//alert("vote_id2 loaded");
//alert($("#vote_id2 .img_wrap img").height());
Hnew=($("#vote_id2 .img_wrap img").height() + 60);
if(Hnew < 240) Hnew=240;
//$(".voteforphoto_item2").css("height",Hnew + "px");
$(".voteforphoto_item2").animate({"height":Hnew + "px"},500);
});
$("#lnk_replay").click(function(){
$('#transparent_bg3').hide();
$('#about_try_success').hide();
flashs_show_game(false);
document.location="#";
});
$(".translate").click(function(){
mute_alerte();
});
$('.fr_contact, .fr_blacklist, .fr_remove').click(function(){
filter=$("#actions_for_messager").attr("filter");
contact_target=$("#actions_for_messager").attr("contact_target");
id_c=$("#actions_for_messager").attr("contact_id");
action=$(this).attr("action");
_url="index.php?mod=p_contact&filter="+filter+"&contact_target="+contact_target+"&id_c="+id_c+"&action=" + action;
//alert(_url);
document.location=_url;
return false;
});
$('#add_friend2,#del_friend2').unbind().click(function(){
id_c=$(this).attr("contact_id");
var friend_action = $(this).attr("action");
var is_good=0;
if(friend_action=="add" ){
is_good=1;
}
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setFriend.php",
data: "target_id="+id_c + "&is_good=" + is_good,
success: function(f) {
if(is_good){
var datas = {
event: 'actionAddFavoryMemberPage'
};
dataLayer_generator( datas );
$('#add_friend2').attr("action","del");
$('#add_friend2').attr("m_title",lang_friendDel);
$('#add_friend2').attr("id","del_friend2");
try {
localStorage.setItem('move-favorite_'+id_c,'active');
} catch (e) {
// Can't use sessionStorage !!!
}
}
else{
$('#del_friend2').attr("action","add");
$('#del_friend2').attr("m_title",lang_friendAdd);
$('#del_friend2').attr("id","add_friend2");
try {
localStorage.setItem('move-favorite_'+id_c,'no-active');
} catch (e) {
// Can't use sessionStorage !!!
}
}
},
error: function(ret){
alert("Error in setFriend.php");
}
});
return false;
});
$('#contact_book,#del_contact2').unbind().click(function(){
id_c=$(this).attr("contact_id");
var action_contact = $(this).attr("action");
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setContact.php",
data: "target_id="+id_c + "&action=" + action_contact,
success: function(f) {
if(action_contact == "add"){
var datas = {
event: 'actionAddContactMemberPage'
};
dataLayer_generator( datas );
$('#contact_book').attr("action","del");
$('#contact_book').attr("m_title",lang_contactDel);
$('#contact_book').attr("id","del_contact2");
}
else{
$('#del_contact2').attr("action","add");
$('#del_contact2').attr("m_title",lang_contactAdd);
$('#del_contact2').attr("id","contact_book");
}
},
error: function(ret){
alert("Error in setContact.php");
}
});
return false;
});
$('#chat2,#add_friend2,#del_friend2,#contact_book,#del_contact2,.tnote, #all-msg-menu, #online-msg-menu, #friends-msg-menu, #blocked-msg-menu, #contacts-msg-menu, .votes-ico, .msg-ico, .match-ico, .myWall-ico, .album-ico').each(function() {
$(this).qtip({
content: {
text: function(event, api) {
m_title=$(this).attr("m_title");
return ''+m_title+'
'; // Set some initial text
//api.set('content.text','Robert, 41 ans France, Moncuq');
}
},
position: {
viewport: $(window),
at: 'bottom center',
my: 'top center'
},
style: {
classes: 'qtip_hover_icons',
},
hide: {
fixed: true
}
});
});
$('#at_time0').click(function(){
if($(this).attr("checked") ){
$('input[name*="at_time\[\]"]').attr("checked",true);
}
});
$('#at_time1,#at_time2,#at_time3,#at_time4,#at_time5,#at_time6,#at_time7').click(function(){
if(!$(this).attr("checked") ){
$('#at_time0').attr("checked",false);
}
});
$('.faq_point a').click(function(){
$(this).nextAll().slideToggle();
});
try {
if (top.location == self.document.location){
if(localStorage.pop_open && localStorage.pop_open > 0){
if(localStorage.contact_target) {
//console.log('localStorage.contact_target');
open_messages(localStorage.contact_target);
}
else {
//console.log('NOT localStorage.contact_target');
open_messages();
}
}
}
if(localStorage.sound_disabled && localStorage.sound_disabled > 0){
mute_alerte();
}
}
catch(e) {}
//Close form Login
$('#sign_in_block .close').unbind().click(function() {
$('#sign_in').hide();
});
//Open Form lostpass
$('#pass_forgot').click(function(){
$('#sign_in_block').hide();
$('#signin3').show();
});
$('#signin3FormClose,#signin3 .close').click(function(){
$('#signin3').hide();
$('#sign_in_block').show();
return false;
});
/**
* Ajout Compteur Vu Pub
*
*/
var myArray = new Array();
$('.conteneur_pub').each(function(){
var idPub = 0;
if( typeof( $(this).data('idpub') ) != 'undefined' && $(this).data('idpub') > 0){
idPub = $(this).data('idpub');
} else if ( typeof($(this).attr('data-id')) != 'undefined' && $(this).attr('data-id') > 0 ){
idPub = $(this).attr('data-id');
}
if( idPub > 0 ){
myArray.push(idPub);
}
});
if( typeof(increment_cpt_viewArray) != 'undefined' ) {
increment_cpt_viewArray(myArray);
}
$('.conteneur_pub img, .contenur_pub a, #top-new-msg a, #site_activity2 .conteneur_pub a').unbind().click(function(e){
console.log('DANS CE CLICK');
e.stopPropagation();
var idPub = 0;
if( typeof( $(this).parents('.conteneur_pub').data('idpub') ) != 'undefined' && $(this).parents('.conteneur_pub').data('idpub') > 0){
idPub = $(this).parents('.conteneur_pub').data('idpub');
} else if ( typeof($(this).parents('.conteneur_pub').attr('data-id')) != 'undefined' && $(this).parents('.conteneur_pub').attr('data-id') > 0 ){
idPub = $(this).parents('.conteneur_pub').attr('data-id');
}
if( idPub > 0 ){
var tmpDiv = $('
');
tmpDiv.data('id',idPub)
increment_cpt_click_pub(tmpDiv);
}
});
/**
* Spécial smartphone
*/
if( IS_MOBILE ) {
smart_rebind_click_user_album();
// $('#my_messges').unbind().click(function() {
// open_messages("");
// return false;
// });
$("#messager_search").bind('swiperight', slide_menu_contact);
$("#messager_search").bind('swipeleft', slide_menu_contact);
$('#search-btn').unbind().click(function() {
$("#search").submit();
});
}
});
// function resize_pub() {
// return;
//
// var height_content_centered = $('#content-centered').height();
// height_content_centered -= 20;
// if( height_content_centered > 0 ) {
// $('#site_activity2').css({
// height: height_content_centered+'px',
// });
//
// var height_cumul_pub = 0;
// $.each( $('#zone_publicite .conteneur_pub'), function(i, elPub) {
// height_cumul_pub += parseInt($(elPub).height());
// height_cumul_pub += parseInt($(elPub).css('margin-bottom'));
// if( (height_cumul_pub - 20) > $('#zone_publicite').height() ) {
// $(elPub).hide();
// }
// });
// }
// }
function slide_menu_contact(event) {
switch(event.type) {
case 'swiperight':
var num_nav_menu_actuel = parseInt($('.messages_top_nav.menu_selec').attr('num_nav_menu'));
var menu_suivant = $('.messages_top_nav[num_nav_menu="'+(num_nav_menu_actuel-1)+'"]');
if( $(menu_suivant).length > 0 ) {
$(menu_suivant).click();
}
break;
case 'swipeleft':
var num_nav_menu_actuel = parseInt($('.messages_top_nav.menu_selec').attr('num_nav_menu'));
var menu_suivant = $('.messages_top_nav[num_nav_menu="'+(num_nav_menu_actuel+1)+'"]');
if( $(menu_suivant).length > 0 ) {
$(menu_suivant).click();
}
break;
}
}
function smart_rebind_click_user_album() {
//console.log("smart_rebind_click_user_album");
if( !IS_MOBILE ) { return false; }
//console.log("smart_rebind_click_user_album : " + $('.user-album .user_click_profil').length );
$('.user-album .user_click_profil, .nickname.name').unbind().click(function() {
var el=$(this);
if($(this).hasClass("nickname")){
//console.log('test1');
el = $(this).parent().children('.user-album').children('.user_click_profil');
}
if( !el.hasClass('is_show') ) {
//console.log('test2');
// smart_profil_unhover( $('.user-album .user_click_profil') );
smart_profil_unhover();
smart_profil_hover( el );
}
else {
//console.log('test3');
// smart_profil_unhover( $('.user-album .user_click_profil') );
smart_profil_unhover();
smart_profil_unhover( el );
}
return false;
});
}
function smart_profil_hover(that) {
if( !IS_MOBILE ) { return false; }
var addf_chat_el = $(that).parents(".album-point").children(".addf_chat");
$(addf_chat_el).show();
$(that).parent().children('.photos-count').css('top', '10px');
$(that).parent().children('.onlineState').css('top', '10px');
$(that).parent().children('.online1').css({top: '10px', bottom: 'auto'});
$(that).parent().children('.photo_rate2').css({top: '10px'});
$(that).parent().children('.rank').css({top: '10px'});
$(that).parents(".album-point").children('.like_dislike').show();
$(that).parent().children('.voirprofil').show();
$(that).parent().children('.voirprofil').unbind().click(function() {
window.location.href = $(that).prop('href');
return false;
});
$(that).addClass('is_show');
}
function smart_profil_unhover(that) {
if( !IS_MOBILE ) { return false; }
if( arguments[0] ) { that = arguments[0]; }
else { that = $('.user-album .user_click_profil'); }
var addf_chat_el = $(that).parents(".album-point").children(".addf_chat");
$(addf_chat_el).hide();
$(that).parent().children('.photos-count').css('top', 'auto');
$(that).parent().children('.onlineState').css('top', 'auto');
$(that).parent().children('.online1').css({top: 'auto', bottom: '10px'});
$(that).parent().children('.photo_rate2').css({top: 'auto'});
$(that).parent().children('.rank').css({top: 'auto'});
$(that).parent().children('.voirprofil').hide();
$(that).parents(".album-point").children('.like_dislike').hide();
$(that).removeClass('is_show');
}
function close_tchat_droite() {
if(IS_MOBILE){
//document.location="/profil_contacts.html";
document.location="/"+tabLang["htprofil_contacts"];
return false;
}
$('#messages_active').hide();
$('#messages').show();
close_messages();
}
function saveCB(){
var ImageDataWebcam = "";
if( typeof ( arguments[0] ) != 'undefined' ){
ImageDataWebcam = arguments[0];
}
$.ajax({
type: "POST",
url: "/app/ajax/upload_webcam.php",
dataType: "json",
data: "image=" + ImageDataWebcam,
success: function(json) {
//alert("photo saved");
$("#cam_loader").html("");
$("#edit_info").show();
$('#add_cam_send').removeAttr("disabled");
$('#add_cam_return').removeAttr("disabled");
//console.log(json);
document.location="/"+tabLang["htmembres"]+'_'+json.pseudo+"_"+json.id_membre+".html?my_photo=1&photo_num=" + json.photo_num;
},
error: function(ret){
//alert("photo no saved");
$('#add_cam_send').removeAttr("disabled");
$('#add_cam_return').removeAttr("disabled");
$("#cam_loader").html("Error: " + ret);
}
});
//alert("saveCB End");
}
function messager1_rebind(){
$('.messager1').unbind().click(function(){
$('.messager1').css({"background-color":"#ffffff"});
$(this).css({"background-color":"#eeeeee"});
if(!$('#messager_search').hasClass('dono')){
$('.none3').css({ "position":"relative", "top":"0px"});
}
$('#my_messages_block').css({ "padding-bottom":"0px"});
//$('#messager_search').addClass('none3');
//$('#messages_field').removeClass('none3');
var contact=$(this).attr('contact');
var contact_id=$(this).attr('contact_id');
if( IS_MOBILE ){
//document.formMessage.dest_message.value=contact;
$("#messages-flow #dest_message").val(contact);
}
$('#messager_fio_grey').html(""+ucfirst(contact)+" ");
if(IS_MOBILE){
$('#user_m').html("
");
}
$('#messager_fio').html(""+ucfirst(contact)+" ");
$('#actions_for_messager').show();
$('#actions_for_messager').attr("contact_target",contact);
$('#actions_for_messager').attr("contact_id",contact_id);
favoris_txt=$(this).find(".friend_mess").text();
favoris_action=$(this).find(".friend_mess").attr("action");
$('#actions_for_messager .fr_add').text(favoris_txt);
$('#actions_for_messager .fr_add').attr("action",favoris_action);
if(!$(this).find(".messages-count").hasClass("none")){
$(this).find(".messages-count").addClass("none");
}
load_messages1(contact,contact_id,0);
});
}
function load_messages1(contact,contact_id,start){
if(!start)
jspApi2.getContentPane().html(' ');
else
jspApi2.getContentPane().prepend(' ');
var elems_count=$(this).find(".messages-count");
$.ajax({
type: "GET",
url: "app/ajax/load_messages.php?contact=" + contact + "&contact_id=" + contact_id + "&start=" + start,
dataType: "json",
success: function(json) {
if(!parseInt(json.start)){
jspApi2.getContentPane().html("");
$("#day_last").val("");
}
else{
$(".chat_loader").hide();
$(".div_next").hide();
}
elems_count.hide();
put_eclairs2(json.eclairs,parseInt(json.start));
}
});
}
function menu_contact_rebind(){
$(".messages-menu").unbind().mouseenter(function(){
if( !IS_MOBILE){
if(($('.navContact').offset().top - $(this).offset().top) < 100){
var el=$(this).find(".messages-menu-points");
el.css({top:'-145px' });
}
}
});
$('.friend_mess,.fr_add').unbind().click(function(){
filter=$('#messagers').attr('filter');
if($(this).parent().parent().attr("id") == "actions_for_messager")
id_c=$(this).parent().parent().attr("contact_id");
else
id_c=$(this).parent().attr("contact_id");
//contact_target=$('#messagers').attr('contact_target');
//target_id=$('#messagers').attr('target_id');
action = $(this).attr("action");
var menu_id="menu" + id_c;
var is_good=0;
if(action=="add" ){
action="friend";
is_good=1;
}
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setFriend.php",
data: "target_id="+id_c + "&is_good=" + is_good,
success: function(f) {
if(filter == 1 || filter == 5){
$("#" + menu_id + " .friend_mess").html(is_good ? lang_friendDel : lang_friendAdd);
$("#" + menu_id + " .friend_mess").attr("action",(is_good ? "del" : "add"));
$("#actions_for_messager .fr_add").html(is_good ? lang_friendDel : lang_friendAdd);
$("#actions_for_messager .fr_add").attr("action",(is_good ? "del" : "add"));
}
else{
$("#" + menu_id).parent().hide();
}
},
error: function(ret){
alert("Error in setFriend.php");
}
});
return false;
});
$('.to_blacklist').unbind().click(function(){
filter=$('#messagers').attr('filter');
//alert(filter);
//start=$(this).parent().attr("start");
id_c=$(this).parent().attr("contact_id");
var action_ignore;
if(filter==2) action_ignore="del";
else action_ignore="add";
var menu_id="menu" + id_c;
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setIgnore.php",
data: "target_id="+id_c + "&action=" + action_ignore,
success: function(f) {
//alert("to_blacklist OK");
//$("#" + menu_id + " .to_blacklist").attr("action",action_ignore);
$("#" + menu_id ).parent().hide();
},
error: function(ret){
alert("Error in setIgnore.php");
}
});
return false;
});
$('.to_contact').unbind().click(function(){
filter=$('#messagers').attr('filter');
//alert(filter);
start=$(this).parent().attr("start");
id_c=$(this).parent().attr("contact_id");
contact_target=$('#messagers').attr('contact_target');
target_id=$('#messagers').attr('target_id');
//document.location="index.php?mod=p_contact&filter="+filter+"&contact_target="+contact_target+"&id_c="+id_c+"&contact_id="+target_id+"&start=" + start+"&action=contact";
var menu_id="menu" + id_c;
var action_contact="add";
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setContact.php",
data: "target_id="+id_c + "&action=" + action_contact,
success: function(f) {
$("#" + menu_id ).parent().hide();
},
error: function(ret){
alert("Error in setContact.php");
}
});
return false;
});
$('.delet_mess').unbind().click(function(){
filter=$('#messagers').attr('filter');
//alert(filter);
start=$(this).parent().attr("start");
id_c=$(this).parent().attr("contact_id");
contact_target=$('#messagers').attr('contact_target');
target_id=$('#messagers').attr('target_id');
//document.location="index.php?mod=p_contact&filter="+filter+"&contact_target="+contact_target+"&id_c="+id_c+"&contact_id="+target_id+"&start=" + start+"&action=contact";
var menu_id="menu" + id_c;
var action_contact="del";
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setContact.php",
data: "target_id="+id_c + "&action=" + action_contact,
success: function(f) {
$("#" + menu_id ).parent().hide();
},
error: function(ret){
alert("Error in setContact.php");
}
});
return false;
});
}
// 10198698
// function get_contacts_list_v2016( elem, start, filter, refresh, tab_from_chat_btn, nick) {
// var url = "";
// main_chat = 1;
// fast_chat=0;
//
// if( typeof(start) == 'undefined'){
// start = 0;
// }
//
// if( $(elem).hasClass('showMore') == false ){
// $('#main_chat_messages').html("");
// $('#main_chat_friends').html("");
// $('#main_chat_online').html("");
// $('#main_chat_blocked').html("");
// $('#main_chat_contacts').html("");
// $('#new-my-messages .msg-content .actions .party-name').html('');
// $('#move-trash, #move-black-list, #move-favorite, #new-my-messages .controls').hide();
// }
//
// $('#new-messanger').hide();
// stop_timer_refresh_chats();
//
// if( elem != "" && $(elem).prop('id') == "h-chat-btn" ) {
// if( $(elem).hasClass('no-active') ){
// $(elem).removeClass('no-active').addClass('active');
// } else if( ($(elem).hasClass('active')) ){
// $(elem).removeClass('active').addClass('no-active');
// main_chat=0;
// save_contact_chat1 = "";
// $('#new-my-msg-block').hide();
// return;
// }
// }
// $('#l-menu-btn, #h-profile').removeClass('active').addClass('no-active');
// $('#new-left-menu, #new-right-menu').removeClass('show');
//
// try {
// localStorage.contact_target=contact;
// }catch(e) {}
//
// if( typeof( nick ) != "undefined" && nick != ''){
// url = "app/ajax/load_contacts.php?start=" + start + "&filter=" + filter + "&nick=" + nick;
// } else {
// url = "app/ajax/load_contacts.php?start=" + start + "&filter=" + filter;
// }
//
// $("#showMore_load").show();
// $.ajax({
// type: "GET",
// url: url ,
// dataType: "json",
// success: function(json) {
// var html = "";
// var type_conversation = "";
// var contacts = json.contacts;
// var new_start = json.next;
// var cpt_pub = 0;
// jQuery.each(contacts, function(index,e){
// cpt_pub++;
// html += contact_lineHTML(e, 1);
// if( typeof(json.pub) != 'undefined' && json.pub != "" && json.pub != null && cpt_pub%5 == 0){
// html+= json.pub;
// }
// });
//
// // 1 => all || 2 => blocked || 3 => friends || 5 => online || 6 => contacts
// switch( parseInt(filter) ){
// case 1:
// type_conversation = "messages";
// break;
// case 2:
// type_conversation = "blocked";
// break;
// case 3:
// type_conversation = "friends";
// break;
// case 5:
// type_conversation = "online";
// break;
// case 6:
// type_conversation = "contacts";
// break;
// }
//
// if( refresh == true ){
// $("#main_chat_"+ type_conversation).html(html);
// } else {
// $("#main_chat_"+ type_conversation).append(html);
// }
//
// $("#main_chat_"+ type_conversation).ready(function() {
// if( $("#new-my-messages .navContact").length ) {
// $("#new-my-messages .navContact").remove();
// }
// if( json.next > 0 ) {
// var html_navContact = "";
// html_navContact += "';
// $("#new-my-messages .tab-content").append(html_navContact);
// } else {
// $("#main_chat_"+ type_conversation + " .navContact").remove();
// }
// var no_msg_clone = $('#select-person-info').clone();
// var start_conversation_clone = $('#start-conversation-info').clone();
//
// $("#new-my-messages .msg-content .messages").html(no_msg_clone);
// $("#new-my-messages .msg-content .messages #select-person-info").show();
// click_on_profile($('#new-my-messages .profile'));
// });
// $('.showMore').unbind().click(function(){
// filter=$(this).data('filter');
// start=$(this).attr("start");
// if(parseInt(start) > -1){
// get_contacts_list_v2016($(this), start, filter, '', '', '');
// }
// });
// $("html, body").scrollTop(10);
//
// //if( testIfPopupTopUpgMsgIsDisplayed() ){
// //$('#new-my-messages').css({'top':'121px'});
// //} else {
// if( $(window).height() > 600 ){
// $('#new-my-messages').css({'top':'61px'});
// }
// //}
// resizeFog();
// $('#new-my-msg-block').show();
// }
// });
// }
function get_contacts_list_v2018( elem, start, filter, refresh, tab_data, nick) {
var url = "";
var url_only_one = "";
main_chat = 1;
fast_chat=0;
var from_chat_search = false;
if( isset( $(elem).prop('id') ) && $(elem).prop('id') == "search_nick_msg" ) {
from_chat_search = true;
}
if( typeof(start) == 'undefined'){
start = 0;
}
if( $(elem).hasClass('showMore') == false ){
$('#main_chat_messages .left_contacts_list').html("");
$('#main_chat_friends .left_contacts_list').html("");
$('#main_chat_blocked .left_contacts_list').html("");
$('#center_chat_page .msg-content .actions .party-name').html('');
// $('#move-trash, #move-black-list, #move-favorite, #new-my-messages .controls').hide();
}
if( elem != "" && $(elem).prop('id') == "h-chat-btn" ) {
if( $(elem).hasClass('no-active') ){
$(elem).removeClass('no-active').addClass('active');
} else if( ($(elem).hasClass('active')) ){
$(elem).removeClass('active').addClass('no-active');
}
}
$('#l-menu-btn, #h-profile').removeClass('active').addClass('no-active');
try {
localStorage.contact_target=contact;
}catch(e) {}
if( typeof( nick ) != "undefined" && nick != '' && from_chat_search == true ){
url = "app/ajax/load_contacts.php?start=" + start + "&filter=" + filter + "&nick=" + nick;
} else {
url = "app/ajax/load_contacts.php?start=" + start + "&filter=" + filter;
}
$("#showMore_load").show();
$.ajax({
type: "GET",
url: url ,
dataType: "json",
success: function(json) {
// console.log('show more');
// console.log(json);
var html = "";
var type_conversation = "";
var contacts = json.contacts;
var new_start = json.next;
var cpt_pub = 0;
// 1 => all || 2 => blocked || 3 => friends || 5 => online || 6 => contacts
switch( parseInt(filter) ){
case 1:
type_conversation = "messages";
break;
case 2:
type_conversation = "blocked";
break;a
case 3:
type_conversation = "friends";
break;
default:
type_conversation = "messages";
break;
}
var contactsOpened=new Array();
if(!refresh) $("#main_chat_messages .left_contacts_list .profile").each(function(){ contactsOpened.push($(this).attr("contact"));});
jQuery.each(contacts, function(index,e){
if( index != "" ) {
if(contactsOpened.indexOf(e.pseudo) == -1 ){
cpt_pub++;
html += contact_lineHTML(e, 1);
if (typeof(json.pub) != 'undefined' && json.pub != "" && json.pub != null && cpt_pub % 5 == 0) {
html += json.pub;
}
switch (parseInt(filter)) {
case 1:
break;
case 2:
try {
localStorage.setItem('move-black-list_' + e.m_id, 'active');
} catch (e) {
// Can't use sessionStorage !!!
}
break;
case 3:
try {
localStorage.setItem('move-favorite_' + e.m_id, 'active');
} catch (e) {
// Can't use sessionStorage !!!
}
break;
}
}
}
});
if( refresh == true ){
$("#main_chat_"+ type_conversation + " .left_contacts_list").html(html);
} else {
$("#main_chat_"+ type_conversation + " .left_contacts_list").append(html);
}
if( typeof( nick ) != "undefined" && nick != '' && from_chat_search == false){
var html = "";
open_messages_v2016( nick, function( json ){
$("#left_chat_page #main_chat_"+ type_conversation).ready(function() {
var path_photo = "";
jQuery.each(json.contacts, function(index,e){
if( index == nick ){
path_photo = e.photo;
}
html+= "";
html += contact_lineHTML(e, 1);
html+= "
";
});
if (typeof(json.pub) != 'undefined' && json.pub != "" && json.pub != null && cpt_pub % 5 == 0) {
html += json.pub;
}
$("#left_chat_page #main_chat_" + type_conversation + " .left_contacts_list").html(html);
// console.log("#main_chat_" + type_conversation + " #contact_" + nick);
click_on_profile($("#main_chat_" + type_conversation + " .profile"));
$("#main_chat_" + type_conversation + " #contact_" + nick).click();
});
}, from_chat_search );
} else {
var no_msg_clone = $('#select-person-info').clone();
var start_conversation_clone = $('#start-conversation-info').clone();
$("#center_chat_page .msg-content .messages").html(no_msg_clone);
$("#center_chat_page .msg-content .messages #select-person-info").show();
click_on_profile($("#main_chat_" + type_conversation + " .profile"));
$("#main_chat_" + type_conversation + ' .profile').first().click();
$("#center_chat_page .messages").scrollTop(9999);
}
$("#main_chat_"+ type_conversation).ready(function() {
$("#left_chat_page #main_chat_" + type_conversation + " .left_contacts_list .profile").each(function(){
$(this).data('type_conv',type_conversation);
});
//$("#main_chat_" + type_conversation + ' .profile').first().click();//mis en commentaire par Benoit car ça génère un double appel à load_messages.php
if( $("#left_chat_page .navContact").length ) {
$("#left_chat_page .navContact").remove();
}
if( json.next > 0 ) {
var html_navContact = "";
html_navContact += "';
$("#left_chat_page #main_chat_"+ type_conversation).append(html_navContact);
} else {
$("#main_chat_"+ type_conversation + " .navContact").remove();
}
$('.showMore').unbind().click(function(){
// console.log('show more v2018');
filter=$(this).data('filter');
start=$(this).attr("start");
if(parseInt(start) > -1){
get_contacts_list_v2018($(this), start, filter, '', '', '');
}
});
$('.coreg-advert').off('click').on('click', function() {
coregEventAdmin($(this));
});
});
}
});
}
function get_contacts_list(start,filter){
h=$("#messagers").height();
w=$("#messagers").width();
//console.log(h);
$("#showMore_load").show();
//document.location="#showMore_bottom";
$.ajax({
type: "GET",
url: "app/ajax/load_contacts.php?start=" + start + "&filter=" + filter,
dataType: "json",
success: function(json) {
//console.log(json);
$('.carouselLeft2-b').attr("start",json.before);
//$('.carouselRight2-b').attr("start",json.next);
$('.showMore').attr("start",json.next);
if(parseInt(json.before) < 0) $('.carouselLeft2-b').hide();
else $('.carouselLeft2-b').show(0, function() { $(this).css('color', 'white')});
if(parseInt(json.next) < 0) $('.showMore').hide();
else $('.showMore').show();
contacts=json.contacts;
//$("#messagers").html("");
$("#showMore_load").hide();
for (var contact in data = contacts){
//console.log('contact');
//console.log(contact);
contactName=ucfirst(contact);
c=data[contact];
html = $("#templateContact").html();
html = html.replace("{contact}",contact);
html = html.replace("{contactName}",contactName);
html = html.replace('{photo}',' ');
html = html.replace("{online}",c['online']);
html = html.replace("{start}",json.start);
html = html.replace("{nb_new}",c['nb_new']);
html = html.replace(/{contact_id}/g,c['m_id']);
if(parseInt(c['nb_new']) == 0)
html = html.replace("{count_none}","none");
else
html = html.replace("{count_none}","");
//console.log("is_friend: " + c['is_friend']);
if(parseInt(c['is_friend']) == 0){
html = html.replace("{addFriend_txt}",lang_friendAdd);
html = html.replace("{addFriend_action}","add");
}
else{
html = html.replace("{addFriend_txt}",lang_friendDel);
html = html.replace("{addFriend_action}","del");
}
$("#messagers").append(html);
};
//document.location="#showMore_bottom";
$('#messagers_of').scrollTop($('#messagers')[0].scrollHeight);
messager1_rebind();
menu_contact_rebind();
}
});
}
function contextmenu_rebind(){
$('img').unbind("contextmenu").bind("contextmenu",function(e){
if(!IS_MOBILE){
var el=$(this).parent();
var href=el.attr("href");
if(href && href != "#"){
$("#context-menu").show();
$("a.context-menu__link").attr("href",href);
clickCoords = getPosition(e);
clickCoordsX = clickCoords.x;
clickCoordsY = clickCoords.y;
$("#context-menu").css({"left":clickCoordsX + "px","top":clickCoordsY + "px"});
}
}
return false;
});
}
function messages_contact(objContact, chat_rapide, start){
$("#day_last").val("");
$('.user-miniature-bg').css('background-color','#fff');
objContact.css('background-color','#eeeeee');
objContact.find('img').css('background-color','#fff');
$('.user-miniature-bg').css('width','60px');
var width_sidebar_right = (IS_MOBILE) ? '90%' : '536px';
$('#sidebar-right').css('width', width_sidebar_right);
$('#sidebar-right-users').css('width', 'auto');
$('#sidebar-right-users .sidebar-default').css('width', 'auto');
$('.message_count2').show();
objContact.find('.message_count2').hide();
objContact.find('.message_count2').text("");
if( typeof( start ) != 'undefined' && parseInt(start) > 0){
load_messages(objContact, chat_rapide, start);
}else {
load_messages(objContact, chat_rapide);
}
}
function load_messages(objContact, chat_rapide, start){
if( typeof( start ) == 'undefined' || start == '' ){
start = 0;
}
if( typeof (objContact ) != 'object' ){
load_messages_old(objContact);
} else {
var contact = objContact.attr('contact');
var img_profile = $(objContact).find('img').prop('src');
var id_objContact = $(objContact).data('id_friend');
var contact_status = $(objContact).data('status');
var contact_last_visite = $(objContact).data('visite');
var last_visite = null;
var blur_type = "";
blur_type = $(objContact).attr('blur_type');
$('#new-my-messages .msg-content .actions .party-name').html('');
try {
localStorage.contact_target = contact;
} catch (e) {
}
if (IS_MOBILE) {
$("#dest_message").val(contact);
}
eclair_last = 0;
if (chat_rapide == false) {
if (typeof(img_profile) != 'undefined' && typeof(id_objContact) != 'undefined' && img_profile != 'undefined' && img_profile != '') {
if (contact_status == 'red') {
if( contact_last_visite != '0000-00-00 00:00:00') {
//last_visite = tabLang["last_visite"] + ' : ' + contact_last_visite;
var dtVisite=new Date(contact_last_visite);
var options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute:'numeric' };
last_visite = tabLang["last_visite"] + ' : ' + dtVisite.toLocaleDateString(0,options);
} else {
last_visite = '';
}
} else {
last_visite = tabLang["online"];
}
$('#new-my-messages .msg-content .actions .party-name').html('' + contact + '
' + last_visite + '
');
}
$("#new-my-messages #dest_message").val(contact);
} else {
$("#new-messanger #dest_message").val(contact);
}
//chat_init(contact);
if (IS_MOBILE) {
$("#dest_message").val(contact);
}
//jspApi.getContentPane().html(" ");
$.ajax({
type: "GET",
url: "app/ajax/load_messages.php?contact=" + contact + "&contact_id=" + id_objContact + "&start=" + start,
dataType: "json",
success: function (json) {
// console.log('has_an_abo ==>' + has_an_abo);
// console.log('has_reserve ==>' + has_reserve);
// if (typeof( has_an_abo ) != 'undefined' && has_an_abo == 0 && has_reserve < 1) {
// // $('#center_chat_page .controls *').children().prop('disabled',true);
// $('#center_chat_page .controls').hide();
// } else {
// $('#center_chat_page .controls').show();
// }
put_eclairs(json, chat_rapide, false, contact, id_objContact, start, img_profile, true);
$('#center_chat_page .messages #popup_general_with_btns_answer_btn').unbind().click(function () {
var contact = "";
contact = $(this).attr('contact');
// console.log('contact ==> ' + contact);
acceptShare(contact);
});
$('#center_chat_page .messages #popup_general_with_btns_cancel_btn').unbind().click(function () {
var contact = "";
contact = $(this).attr('contact');
refuseShare(contact);
});
var wtf = $('#center_chat_page .messages');
var height = wtf[0].scrollHeight;
wtf.scrollTop(height);
//chat_start(contact, chat_rapide);
// }
}
});
}
}
function load_messages_old(contact){
try {
localStorage.contact_target=contact;
}catch(e) {}
eclair_last=0;
$("#dest_message").val(contact);
var args = load_messages_old.arguments;
var contact_id = 0;
if( typeof(args[3]) != 'undefined' ) {
contact_id = args[3];
}
if( typeof(args[4]) != 'undefined' ) {
var start = args[4];
}
if( contact_id > 0){
$.ajax({
type: "GET",
url: "app/ajax/load_messages.php?contact=" + contact + "&contact_id=" + contact_id + "&start=" + start,
dataType: "json",
success: function (json) {
if( typeof( start ) == 'undefiend' ) {
start = 0;
}
put_eclairs(json, false, false, contact, contact_id, start, '', true);
$('#center_chat_page .messages #popup_general_with_btns_answer_btn').unbind().click(function () {
var contact = "";
contact = $(this).attr('contact');
// console.log('contact ==> ' + contact);
acceptShare(contact);
});
$('#center_chat_page .messages #popup_general_with_btns_cancel_btn').unbind().click(function () {
var contact = "";
contact = $(this).attr('contact');
refuseShare(contact);
});
//chat_start(contact, chat_rapide);
// }
}
});
}
}
function click_profile_chat_rapide( that ){
testIfNewMsgWithAProfile( $(that) );
select_current_conversation( '#new-messanger', $(that));
fast_chat=1;
$("#new-messanger .messages").html("");
// if( typeof(start) != 'undefined' && parseInt(start) > 0 ){
// messages_contact($(that), false, start);
// }else{
messages_contact($(that), true);
// }
save_contact_chat2 = $(that).attr('contact');
// stop_timer_refresh_chats();
// start_timer_refresh_chats();
$("#new-messanger .messages").data('contact',save_contact_chat2);
if( $("#new-messanger .messages").is(':hidden') ){
$("#new-messanger .action-2").unbind().click();
}
$("#new-messanger .messages").scrollTop(99999);
}
function load_messages_new_messenger(start, filter, tab_from_chat_btn){
var refresh = true;
var args = load_messages_new_messenger.arguments;
if( typeof(args[3]) != 'undefined' ) {
refresh = args[3];
}
try {
localStorage.contact_target=contact;
}catch(e) {}
fast_chat=1;
var chat_rapide = true;
$.ajax({
type: "GET",
url: "app/ajax/load_contacts.php?start=" + start + "&filter=" + filter,
dataType: "json",
success: function(json) {
var html="";
// console.log(json);
contacts = json.contacts;
var new_start = json.next;
jQuery.each(contacts, function(index,e){
html += contact_lineHTML(e, filter);
});
if( refresh == true ){
$("#new-messanger .contacts").html(html);
} else {
$("#new-messanger .contacts").append(html);
}
$("#new-messanger .contacts").ready(function() {
var no_msg_clone = $('#select-person-info').clone();
var start_conversation_clone = $('#start-conversation-info').clone();
$("#new-messanger .messages").html(no_msg_clone);
$('#select-person-info .ico').css({'width':'190px','height':'190px'});
$("#new-messanger .messages #select-person-info").show();
if( $("#new-messanger .navContact").length ) {
$("#new-messanger .navContact").remove();
}
if( json.next > 0 ) {
var html_navContact = "";
html_navContact += "';
$("#new-messanger .contacts").append(html_navContact);
}
$('#new-messanger .profile').unbind().click(function(){
click_profile_chat_rapide($(this), start);
});
if( typeof(tab_from_chat_btn) != 'undefined' && tab_from_chat_btn != null && typeof( tab_from_chat_btn.m_id ) != 'undefined' && parseInt(tab_from_chat_btn.m_id) > 0 ) {
// console.log('dans ajax de tab_from_chat_btn');
var not_in_list_profile = true;
$.ajax({
type: "GET",
url: "app/ajax/load_messages.php",
data: {contact: contact, contact_id: tab_from_chat_btn.m_id},
dataType: "json",
success: function(json) {
if( json.eclairs.length > 0) {
$.each(json.eclairs, function(){
msg_last_user = json.eclairs.msg;
});
tab_from_chat_btn['tab_last_msg'] = msg_last_user;
var html = contact_lineHTML(tab_from_chat_btn, 1);
} else {
var html = contact_lineHTML(tab_from_chat_btn, 1);
}
$('#new-messanger .profile').each(function(){
// console.log("dans le div de : " +$(this).attr('contact'));
if( $(this).attr('contact') == contact ) {
not_in_list_profile = false;
}
});
var no_msg_clone = $('#select-person-info').clone();
var start_conversation_clone = $('#start-conversation-info').clone();
if (not_in_list_profile == true ) {
// console.log('not in list profile !!!!');
$('#new-messanger .contacts').prepend(html);
click_on_profile($('#contact_'+tab_from_chat_btn['pseudo']));
$('#new-messanger .contacts #contact_'+tab_from_chat_btn['pseudo']).click();
$('#new-messanger #select-person-info').hide();
if( json.eclairs.length < 1) {
$("#new-messanger .contacts .messages").html(start_conversation_clone);
$("#new-messanger .contacts .messages #start-conversation-info").show();
}
$('#new-messanger .messages .msg').last().focus();
} else {
click_on_profile($('#contact_'+tab_from_chat_btn['pseudo']));
$('#contact_'+tab_from_chat_btn['pseudo']).click();
$('#select-person-info').hide();
$('#new-messanger .messages .msg').last().focus();
}
$('#new-messanger .profile').unbind().click(function(){
click_profile_chat_rapide($(this));
});
$('#contact_'+tab_from_chat_btn['pseudo']).click();
}
});
}
$("#new-messanger").show();
});
$('.showMore').unbind().click(function(){
//console.log("dans showmore !!!");
filter=$(this).data('filter');
start=$(this).attr("start");
//console.log("Start : " + start);
if(parseInt(start) > -1){
//console.log("start > -1");
load_messages_new_messenger(start, filter, null, false);
}
});
}
});
}
function close_messages(){
$('#sidebar-right').css('top','-9999px');
$('#alert').css({"right":"20px","left":"auto"});
$('.first_msg').css('top','-9999px');
contact_chat="";
try {
localStorage.pop_open=0;
} catch(e) {
}
}
function open_messages_v2016( contact, callback, from_chat_search ){
var html = "";
var args = open_messages_v2016.arguments;
var cpt_pub = 0;
if( IS_MOBILE ) {
if(typeof(contact_target) != "undefined")
window.location = tabLang["htprofil_contacts"]+"?contact_target=" + contact_target;
else
window.location = ""+tabLang["htprofil_contacts"];
return true;
}
var url = "";
var url = "app/ajax/load_contacts.php?start=0&get_one_profile=" + contact;
if( typeof ( from_chat_search ) != 'undefined' ){
url += "&from_chat_search=" + from_chat_search;
}
$.ajax({
type: "GET",
url: "app/ajax/load_contacts.php?start=0&get_one_profile=" + contact + "&from_chat_search=" +from_chat_search,
dataType: "json",
success: function(json) {
// console.log('json : ');
// console.log(json);
jQuery.each(json.contacts, function(index,e){
html += contact_lineHTML(e, 1);
cpt_pub++;
});
if (typeof(json.pub) != 'undefined' && json.pub != "" && json.pub != null && cpt_pub % 5 == 0) {
html += json.pub;
}
// console.log(html);
if( typeof(args[1]) == "function" ) { args[1](json); }
}
});
return html;
}
function open_messages(contact_target) {
if( IS_MOBILE ) {
if(typeof(contact_target) != "undefined")
window.location = tabLang["htprofil_contacts"]+"?contact_target=" + contact_target;
else
window.location = ""+tabLang["htprofil_contacts"];
return true;
}
smart_profil_unhover();
smart_rebind_click_user_album();
//Si le bouton clignote, on le stoppe
alert_nouveau_message_stop();
$('#alert').css({"left":"20px","right":"auto"});
if(typeof(contact_target) == "undefined") contact_target="";
try {
localStorage.pop_open = 1;
localStorage.contact_target=contact_target;
} catch(e) {
}
//alert("pop_open :" + localStorage.pop_open);
$('#messages').hide();
$('#messages_active').show();
$('#user_menu').hide();
if(IS_MOBILE) $('#site_menu').hide();
$('#sidebar-right').css({'top':'80px','width':'280px'});
$('.user-miniature-bg').css('width','260px');
$('#for_account_active').hide();
$('#for_account').show();
$('#btn-left-menu-active').hide();
$('#btn-left-menu').show();
$('#sidebar-right-users').css('width', '280px');
// $("#sidebar-right-users .sidebar-default").html(" ");
$.ajax({
type: "GET",
url: "app/ajax/get_eclairs_new.php",
data: "contact_target=" + contact_target + "&eclair_last=0",
dataType: "json",
success: function(json) {
html="";
if(typeof(json.info) == undefined){
html= "Une erreur s'est produite";
}
else if(json.info != ""){
html= json.info;
}
else{
contacts=json.eclairs;
jQuery.each(contacts, function(index,e){
html += contact_lineHTML(e, 1);
});
}
$("#sidebar-right-users .sidebar-default").html(html).ready(function() {
$('.contact-qtip').each(function() {
$(this).unbind().qtip({
content: {
text: function(event, api) {
m_title=$(this).attr("m_title");
return ''+m_title+'
'; // Set some initial text
}
},
position: {
viewport: $(window),
at: 'center left',
my: 'center right'
},
style: {
classes: 'qtip-light qtip-shadow'
}
});
});
$('.user-miniature-bg').click(function(){
messages_contact($(this), false);
});
});
if(contact_target){
objContact=$('#contact_'+contact_target+' .user-miniature-bg');
messages_contact(objContact, false);
}
else{
chat_init("");
chat_start("", false);
}
}
});
return false;
}
// function open_messages(contact_target) {
// if( IS_MOBILE ) {
// if(typeof(contact_target) != "undefined")
// window.location = "profil_contacts.html?contact_target=" + contact_target;
// else
// window.location = "profil_contacts.html";
// return true;
// }
//
// smart_profil_unhover();
// smart_rebind_click_user_album();
//
// //Si le bouton clignote, on le stoppe
// alert_nouveau_message_stop();
// $('#alert').css({"left":"20px","right":"auto"});
//
// if(typeof(contact_target) == "undefined") contact_target="";
//
// try {
// localStorage.pop_open = 1;
// localStorage.contact_target=contact_target;
// } catch(e) {
//
// }
//
// //alert("pop_open :" + localStorage.pop_open);
//
// $('#messages').hide();
// $('#messages_active').show();
// $('#user_menu').hide();
// if(IS_MOBILE) $('#site_menu').hide();
// $('#sidebar-right').css({'top':'80px','width':'280px'});
// $('.user-miniature-bg').css('width','260px');
// $('#for_account_active').hide();
// $('#for_account').show();
// $('#btn-left-menu-active').hide();
// $('#btn-left-menu').show();
// $('#sidebar-right-users').css('width', '280px');
//
// $("#sidebar-right-users .sidebar-default").html(" ");
//
// $.ajax({
// type: "GET",
// url: "app/ajax/get_eclairs_new.php",
// data: "contact_target=" + contact_target + "&eclair_last=0",
// dataType: "json",
// success: function(json) {
// html="";
// if(typeof(json.info) == undefined){
// html= "Une erreur s'est produite";
// }
// else if(json.info != ""){
// html= json.info;
// }
// else{
// contacts=json.eclairs;
//
// jQuery.each(contacts, function(index,e){
// html += contact_lineHTML(e);
// });
// }
//
// $("#sidebar-right-users .sidebar-default").html(html).ready(function() {
// $('.contact-qtip').each(function() {
// $(this).unbind().qtip({
// content: {
// text: function(event, api) {
// m_title=$(this).attr("m_title");
//
// return ''+m_title+'
'; // Set some initial text
// }
// },
// position: {
// viewport: $(window),
// at: 'center left',
// my: 'center right'
// },
// style: {
// classes: 'qtip-light qtip-shadow'
// }
// });
// });
//
// $('.user-miniature-bg').click(function(){
// messages_contact($(this), false);
// });
//
// });
//
// if(contact_target){
// objContact=$('#contact_'+contact_target+' .user-miniature-bg');
// messages_contact(objContact, false);
// }
// else{
// chat_init("");
// chat_start("", false);
// }
// }
// });
//
// return false;
// }
// function chat_init(contact_target){
// if(timer_chat ) clearTimeout(timer_chat);
//// cur_chatID++;//on initialise un chat ID pour ne pas mélanger les messages entre eux
////
// contact_chat=contact_target;
// timer_chat = setTimeout(function() { chat_refresh(main_chat, fast_chat); },5000);
// }
//
// function chat_start(contact_target, chat_rapide){
// if(timer_chat) clearTimeout(timer_chat);
// //cur_chatID++;//on initialise un chat ID pour ne pas mélanger les messages entre eux
// contact_chat=contact_target;
//
// timer_chat = setTimeout(function() { chat_refresh(main_chat, fast_chat, chat_rapide); },5000);
// }
//
function add_del_friend_v2016(elem){
var id_friend=elem.data("id_contact");
$(elem).data('contact_id', id_friend);
var obj=elem;
var data_url = "";
if($(obj).hasClass('active')){
data_url = "action=del_friend&id=";
} else {
data_url = "action=add_friend&id=";
}
var type_conv = "";
type_conv = $(elem).data('type_conv');
$.ajax({
type: "POST",
url: "app/ajax/friends.php",
data: data_url + id_friend,
success: function(retour) {
//console.log('add_Blist ok');
// if( $(elem).hasClass('active') ){
// localStorage.setItem('move-favorite_'+id_friend,'no-active');
btn1(elem);
// } else {
// localStorage.setItem('move-favorite_'+id_friend,'active');
// }
switch( type_conv ) {
case 'friends' :
$('#friends-msg-menu').click();
break;
case 'blocked' :
$('#blocked-msg-menu').click();
break;
default :
break;
}
}
});
return false;
}
function add_Blist_v2016(elem){
var contact_id=elem.data("id_contact");
$(elem).data('contact_id', contact_id);
var action_Blist= "";
var type_conv = "";
type_conv = $(elem).data('type_conv');
if( $(elem).hasClass('active') ){
// console.log("active");
action_Blist = "del";
$(elem).html(tabLang["add_to_Blist"]);
} else {
// console.log("no-active");
action_Blist = "add";
$(elem).html(tabLang["del_to_Blist"]);
}
$.ajax({
type: "GET",
url: "app/ajax/setIgnore.php",
data: "action="+action_Blist+"&target_id="+ contact_id,
success: function(retour) {
btn1(elem);
//console.log('add_del_friend ok');
// if( $("#move-black-list").hasClass('active') ){
// localStorage.setItem('move-blask-list_'+contact_id,'active');
// } else {
// localStorage.setItem('move-blask-list_'+contact_id,'no-active');
// }
switch( type_conv ) {
case 'friends' :
$('#friends-msg-menu').click();
break;
case 'blocked' :
$('#blocked-msg-menu').click();
break;
default :
$('#all-msg-menu').click();
break;
}
}
});
return false;
}
function Initialise_chat_page(){
$('#new-my-messages .controls *').children().prop('disabled',true);
$('#right_chat_page').children().hide();
$('#center_chat_page .actions').children().hide();
$('#right_chat_page').css('background', '#f1f4f6');
var no_msg_clone = $('#select-person-info').clone();
$("#center_chat_page .msg-content .messages").html(no_msg_clone);
$("#center_chat_page .msg-content .messages #select-person-info").show();
}
function put_eclairs(json, chat_rapide, from_refresh, contact, contact_id, start, img_profile, ask_priv){
var args = put_eclairs.arguments;
// console.log(args);
var day_last=$("#day_last").val();
var blur_type = "";
var chat_input_msg_active = true;
// var contact_is_abo = "false";
// if (typeof( json.contact_infos ) != 'undefined' && typeof( json.contact_infos['is_abo']) != 'undefined' && json.contact_infos['is_abo'] != '' ) {
// contact_is_abo = json.contact_infos['is_abo'];
// }
if( from_refresh == false ) {
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2['main'] ) != 'undefined' && typeof( json.photos_v2['main_visibility'] ) != 'undefined') {
$('#right_chat_page .photo img').prop('src', json.photos_v2['main']);
$('#right_chat_page .photo img').removeAttr("class");
// if( typeof( has_an_abo ) != 'undefined' && has_an_abo == 1) {
// $('#right_chat_page .photo img').addClass('visible pie');
// } else {
$('#right_chat_page .photo img').addClass(json.photos_v2['main_visibility'] + ' pie');
// }
} else {
$('#right_chat_page .photo img').prop('src', json.photos_v2['avatar']);
$('#right_chat_page .photo img').removeAttr("class");
$('#right_chat_page .photo img').addClass('visible pie');
}
if (typeof( json.contact_infos) != 'undefined' && typeof( json.contact_infos['is_in_friend_list'] ) != 'undefined' && json.contact_infos['is_in_friend_list'] != "" && from_refresh == false ) {
$('#move-favorite').removeClass('active').removeClass('no-active');
if( parseInt( json.contact_infos['is_in_friend_list'] ) == 1 ){
$('#move-favorite').addClass('active');
try {
localStorage.setItem('move-favorite_'+contact_id,'active');
} catch (e) {
// Can't use sessionStorage !!!
}
} else {
$('#move-favorite').addClass('no-active');
try {
localStorage.setItem('move-favorite_'+contact_id,'no-active');
} catch (e) {
// Can't use sessionStorage !!!
}
}
}
if (typeof( json.contact_infos) != 'undefined' && typeof( json.contact_infos['blur_type'] ) != 'undefined' && json.contact_infos['blur_type'] != "" && from_refresh == false && typeof( has_an_abo ) != 'undefined' && has_an_abo == 0 ) {
blur_type = json.contact_infos['blur_type'];
}
if (typeof( json.contact_infos) != 'undefined' && typeof( json.contact_infos['gender'] ) != 'undefined' && json.contact_infos['gender'] != "" && from_refresh == false) {
var gender = '';
switch (json.contact_infos['gender']) {
case '1' :
gender = tabLang["Homme"];
break;
case '2' :
gender = tabLang["Femme"];
break;
case '3' :
gender = tabLang["Couple"];
break;
default :
gender = tabLang["Homme"];
break;
}
$('#right_chat_page .gender_ico').addClass('sexe_' + json.contact_infos['gender']);
$('#right_chat_page .gender_age').text(gender + ' - ' + json.contact_infos['age'] + ' ' + tabLang['ans']);
}
if (typeof( json.contact_infos ) != 'undefined' && typeof( json.contact_infos['location'] ) != 'undefined' && json.contact_infos['location'] != "" && from_refresh == false) {
$('#right_chat_page .contact_location').text(json.contact_infos['location']);
}
var array_all_photos = [];
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.public ) != 'undefined') {
$.each(json.photos_v2.public, function (i, el) {
if ( typeof( el ) != 'undefined' ) {
array_all_photos.push(el);
}
});
}
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.private ) != 'undefined') {
$.each(json.photos_v2['private'], function (i_p, el_p) {
if ( typeof( el_p ) != 'undefined' ) {
array_all_photos.push(el_p);
}
});
}
$('.photo_gal_user_right_chat').html('');
var ctp_nb_photos_chat_right = 0;
if (array_all_photos.length > 0) {
var html_gal = '';
$.each(array_all_photos, function (i, el) {
html_gal += "";
ctp_nb_photos_chat_right++;
});
$('.photo_gal_user_right_chat').html('');
$('.photo_gal_user_right_chat').html(html_gal);
$('.photo_gal_user_right_chat').show();
} else {
$('.photo_gal_user_right_chat').html('');
$('.photo_gal_user_right_chat').hide();
}
if ($('.photo_gal_user_right_chat').hasClass('slick-initialized')) {
// console.log('slick already exists');
$('.photo_gal_user_right_chat').removeClass("slick-initialized slick-slider");
$('.photo_gal_user_right_chat').slick();
} else {
// console.log('slick doesnt exists');
$('.photo_gal_user_right_chat').slick();
}
$("#right_chat_page .photos-count-rightChat").attr('id_target', contact_id);
$("#right_chat_page .photos-count-rightChat").html(ctp_nb_photos_chat_right);
$("#right_chat_page .photos-count-rightChat").css('display','block');
$("#right_chat_page .photos-count-rightChat").show();
if ( ctp_nb_photos_chat_right < 1) {
$("#right_chat_page .photos-count-rightChat").html('');
$("#right_chat_page .photos-count-rightChat").hide();
}
}
if( typeof( json.contact_infos) != 'undefined' && json.contact_infos != null && typeof( json.contact_infos.etat ) != 'undefined' && json.contact_infos.etat > 0 ) {
if(json.eclairs.length > 0) {
var flag = 0;
var need_rebind_img = 0;
var start = null;
html = "";
if (json.start == 'undefined') {
start = 0;
} else {
start = parseInt(json.start);
}
if (json.eclairs.length >= 20 && typeof( contact ) != 'undefined' && typeof( contact_id ) != 'undefined') {//on affiche un lien pour charger l'historique
html += '';
}
jQuery.each(json.eclairs, function (index, e) {
var from_who = (e['from_me'] == 1) ? "from_me" : "from_other";
var className = (e['from_me'] == 1) ? "name this" : "name other";
var url_fiche = (e['from_me'] == 1) ? "#" : tabLang["htmembres"] + '_' + e['exp'] + ".html";
var exp = ucfirst(e['exp']);
var print_compte_a_rebour = false;
if (typeof(e['notification']) != "undefined") {
if( typeof(e['tab_last_msg']) == "object" ) {
var tab_last_msg = e['tab_last_msg'];
var date_now = new Date().getTime();
var tabDateLM_Global = tab_last_msg.date.split(' ');
var tabDateLM_First = tabDateLM_Global[0].split('-');
var formatedLM_Date = tabDateLM_First[1]+'/'+tabDateLM_First[2] + '/' + tabDateLM_First[0] + ' ' + tabDateLM_Global[1];
date_compte_a_rebour_expire = new Date(formatedLM_Date).getTime();
date_compte_a_rebour_expire = parseInt(parseInt(date_compte_a_rebour_expire) + 3600000); // + 1 * 3600 * 1000 (ms)
var diff_date = new Date(date_compte_a_rebour_expire - date_now);
if (diff_date.valueOf() > 0) {
print_compte_a_rebour = true;
start_timer_refresh_compte_a_rebour();
stop_timer_refresh_chats();
start = 1;
var tb_date = e['tab_last_msg']['date'].split(' ');
var img_prof = "";
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2['main'] ) != 'undefined') {
img_prof = json.photos_v2['main'];
} else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2['avatar'] ) != 'undefined') {
img_prof = json.photos_v2['avatar'];
}
html += '' + tb_date[1] + "
";
html += '';
html += '
' + replace_smiley(e['tab_last_msg']['message']) + '
';
html += '
';
}
}
else {
date_compte_a_rebour_expire = null;
stop_timer_refresh_compte_a_rebour();
}
if( !print_compte_a_rebour ) {
date_compte_a_rebour_expire = null;
stop_timer_refresh_compte_a_rebour();
chat_input_msg_active = false;
// console.log('notification != undefined !!!');
var msg_alert = $('#v2018_chat_alert').clone();
msg_alert.css('display', 'inline-block');
msg_alert.data('pseudo', contact);
$('#center_chat_page .messages').html(msg_alert);
// console.log(msg_alert);
if (!$('#center_chat_page .messages #v2018_chat_alert .upgrade_msg_slider').hasClass('slick-initialized')) {
$('#center_chat_page .messages #v2018_chat_alert .upgrade_msg_slider').slick({
autoplay: true,
arrows: false,
infinite: true,
slidesToScroll: 1,
slidesToShow: 1,
dots: true,
});
}
$('#center_chat_page .messages #v2018_chat_alert').show();
stop_timer_refresh_chats();
start = 1;
}
} else {
if ( typeof e['date'] != "undefined" && e['date'].substring(0, 10) != day_last) {
day_last = e['date'].substring(0, 10);
html += '' + e['date_display'] + "
";
}
html += '';
var img_prof = "";
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2['main'] ) != 'undefined') {
img_prof = json.photos_v2['main'];
} else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2['avatar'] ) != 'undefined') {
img_prof = json.photos_v2['avatar'];
}
var show_day_last = 0;
if (e['msg'] != "") {
if (e['from_me'] == 1) {
html += '
' + replace_smiley(e['msg']) + '
';
} else {
html += '
' + replace_smiley(e['msg']) + '
';
}
}
else if (typeof(e['p_extra']) != "undefined") {
var txt_shared = (e['from_me'] == 1) ? lang_sharedPhotoMe : lang_sharedPhoto;
if (parseInt(e['from_me']) != 1) {
html += '
';
}
html += '';
if (parseInt(e['from_me']) != 1) {
html += '
';
}
need_rebind_img = 1;
} else if (typeof( e['album_share'] ) != 'undefined' && e['album_share'] != "") {
if (parseInt(e['from_me']) != 1) {
html += '
';
}
switch (e['album_share']) {
case "ask_sent":
// console.log(' ask_sent !!! ');
var ask_sent_html = $('#popup_general_clonable').clone();
var tmp_html = '' + Lang["Hello"] + '
' + contact + ' , ' + Lang["let_me_access_priv_gal"] + '';
// console.log(' tmp html ==> ' + tmp_html);
ask_sent_html.find('.popup_general_p').html(tmp_html);
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.private ) != 'undefined') {
var firstKey = Object.keys(json.photos_v2.private)[0];
if (typeof( json.photos_v2.private[firstKey].sq_middle ) != 'undefined') {
ask_sent_html.find('img').prop('src', json.photos_v2.private[firstKey].sq_middle);
}
} else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.avatar) != 'undefined') {
ask_sent_html.find('img').prop('src', json.photos_v2.avatar);
}
ask_sent_html.find('img').addClass('locked');
ask_sent_html.find('img').after("
");
ask_sent_html.addClass(from_who);
html += ask_sent_html.html();
break;
case "ask_opened":
var ask_opened = $('#popup_general_with_btns_clonable').clone();
var tmp_html = '
' + e["exp"] + ' ' + Lang["ask_for_access"] + '';
ask_opened.find('#popup_general_with_btns_txt').html(tmp_html);
// var url_photo_priv = URL_PHOTOS + e["exp"].substring(0, 1) + '/' + e["exp"] + '-'
if (typeof( json.first_private_pic ) != 'undefined' && json.first_private_pic != '') {
ask_opened.find('img').prop('src', json.first_private_pic);
}
ask_opened.find('img').addClass('locked');
ask_opened.find('#popup_general_with_btns_answer_btn').html(Lang["J'accepte"]);
ask_opened.find('#popup_general_with_btns_cancel_btn').html(Lang["Refuse"]);
ask_opened.find('#popup_general_with_btns_answer_btn').attr('contact', e["exp"]);
ask_opened.find('#popup_general_with_btns_cancel_btn').attr('contact', e["exp"]);
// ask_opened.css('display','block');
ask_opened.addClass(from_who);
html += ask_opened.html();
break;
case "ask_closed":
var ask_closed_html = $('#popup_general_clonable').clone();
var tmp_html = '
' + e["exp"] + ' ' + Lang["ask_closed"];
ask_closed_html.find('.popup_general_p').html(tmp_html);
if (typeof( json.first_private_pic ) != 'undefined' && json.first_private_pic != '') {
ask_closed_html.find('img').prop('src', json.first_private_pic);
} else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.avatar) != 'undefined') {
ask_closed_html.find('img').prop('src', json.photos_v2.avatar);
}
ask_closed_html.find('img').addClass('locked');
ask_closed_html.find('img').after("
");
ask_closed_html.addClass(from_who);
html += ask_closed_html.html();
break;
case "ask_accepted":
var ask_accepted_html = $('#popup_general_clonable').clone();
var tmp_html = '' + Lang["has given you access"] + Lang["son"] + ' ';
ask_accepted_html.find('.popup_general_p').html(tmp_html);
var btn_tmp = '';
ask_accepted_html.find('.popup_general_p').append(btn_tmp);
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.private ) != 'undefined') {
var firstKey = Object.keys(json.photos_v2.private)[0];
if (typeof( json.photos_v2.private[firstKey].sq_middle ) != 'undefined') {
ask_accepted_html.find('img').prop('src', json.photos_v2.private[firstKey].sq_middle);
}
}
else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.avatar) != 'undefined') {
ask_accepted_html.find('img').prop('src', json.photos_v2.avatar);
}
ask_accepted_html.find('#popup_general').addClass('ask_accepted');
ask_accepted_html.addClass(from_who);
html += ask_accepted_html.html();
break;
case "accept_sent":
var accept_sent_html = $('#popup_general_clonable').clone();
var tmp_html = '' + Lang["You give access"] + Lang["album privé"] + '';
accept_sent_html.find('.popup_general_p').html(tmp_html);
if (typeof( json.first_private_pic ) != 'undefined' && json.first_private_pic != '') {
// console.log('private OK !!!');
accept_sent_html.find('img').prop('src', json.first_private_pic);
} else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.avatar) != 'undefined') {
accept_sent_html.find('img').prop('src', json.photos_v2.avatar);
}
accept_sent_html.addClass(from_who);
html += accept_sent_html.html();
break;
case "ask_refused":
var ask_refused_html = $('#popup_general_clonable').clone();
var tmp_html = '
' + e["exp"] + ' ' + Lang["refused you access"] + ' ' + Lang["son"] + ' ' + Lang["album privé"] + '';
ask_refused_html.find('.popup_general_p').html(tmp_html);
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.private ) != 'undefined') {
var firstKey = Object.keys(json.photos_v2.private)[0];
if (typeof( json.photos_v2.private[firstKey].sq_middle ) != 'undefined') {
ask_refused_html.find('img').prop('src', json.photos_v2.private[firstKey].sq_middle);
}
} else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.avatar) != 'undefined') {
ask_refused_html.find('img').prop('src', json.photos_v2.avatar);
}
ask_refused_html.find('img').addClass('locked');
ask_refused_html.find('img').after("
");
ask_refused_html.addClass(from_who);
html += ask_refused_html.html();
break;
case "refus_sent":
var refus_sent_html = $('#popup_general_clonable').clone();
var tmp_html = '' + Lang["You forbade access"] + Lang["album privé"] + '';
refus_sent_html.find('.popup_general_p').html(tmp_html);
if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.private ) != 'undefined') {
var firstKey = Object.keys(json.photos_v2.private)[0];
if (typeof( json.photos_v2.private[firstKey].sq_middle ) != 'undefined') {
refus_sent_html.find('img').prop('src', json.photos_v2.private[firstKey].sq_middle);
}
} else if (typeof( json.photos_v2 ) != 'undefined' && typeof( json.photos_v2.avatar) != 'undefined') {
refus_sent_html.find('img').prop('src', json.photos_v2.avatar);
}
refus_sent_html.find('img').addClass('locked');
refus_sent_html.find('img').after("
");
refus_sent_html.addClass(from_who);
html += refus_sent_html.html();
break;
defaut:
break;
}
if (parseInt(e['from_me']) != 1) {
html += '
';
}
}
}
if( typeof e['date'] != "undefined" && e['date'].substring(0, 10) != day_last) {
show_day_last = 1;
day_last = e['date'].substring(0, 10);
//html +='
' + e['day_hour'] + "
";
html +='
' + e['day_hour'];
if(e['from_me']==1){
if(e['state']=="sent")
html +=' '+ lang_messageSent+' ';
else if(e['state']=="read")
html +=' '+ lang_messageRead+' ';
else
html +=' '+ lang_messageRead+' ';
}
html +="
";
html += '
';
}
show_sender=1;
if( typeof e['date'] != "undefined" && e['date'].substring(0,10)==day_last && show_day_last != 1) {
html += '
' + e['day_hour'];
if (e['from_me'] == 1) {
if (e['state'] == "sent")
html += ' ' + lang_messageSent + ' ';
else if (e['state'] == "read")
html += ' ' + lang_messageRead + ' ';
else
html += ' ' + lang_messageRead + ' ';
}
html += "
";
html += '
';
}
html += '
';
if (typeof(start) != 'undefined' && parseInt(start) > 0 && start != "undefined") {
show_msg = 0;
} else {
show_msg = 1;
}
if (eclair_last < parseInt(e['id'])) eclair_last = e['id'];
flag = 1;
});
if(show_msg){
// if(chat_rapide == true) {
// var chat2 = $("#new-messanger .messages");
// if( parseInt(from_refresh != 1 )) {
// // console.log('chat rapide true et from refresh != 1');
// chat2.html(html).ready(function(){
// $('#new-messanger #btn-chat').data('pseudo', contact);
// });
// } else {
// // console.log('chat rapide true et from refresh == 1');
// if(typeof(save_contact_chat2) != 'undefined' && typeof(save_contact_chat2) != ""){
// if( chat2.data('contact') == save_contact_chat2){
// $("#new-messanger .messages").append(html);
// $('#new-messanger #btn-chat').data('pseudo', contact);
// }
//
// }
// $('#new-messanger #btn-chat').data('pseudo', contact);
// }
// } else {
var chat1 = $("#new-my-messages .msg-content .messages");
if( parseInt(from_refresh != 1) || from_refresh != false ) {
// console.log('chat rapide false et from refresh != 1');
$("#new-my-messages .msg-content .messages").append(html);
} else {
if(typeof(save_contact_chat1) != 'undefined' && typeof(save_contact_chat1) != ""){
if( chat1.data('contact') == save_contact_chat1){
// console.log('==');
$("#new-my-messages .msg-content .messages").html(html);
}
}
// console.log('chat rapide false et from refresh == 1');
}
$('#new-my-messages #btn-chat').data('pseudo', contact);
// }
} else if( typeof(start) != 'undefined' && start != 'undefined' && parseInt(start) > 0 ){
// console.log('show msg not OK');
if(chat_rapide == true) {
$("#new-messanger .messages").prepend(html).ready(function() {
$('#new-messanger #btn-chat').data('pseudo', contact);
});
}else{
$("#new-my-messages .msg-content .messages").prepend(html);
}
}
$("#day_last").val(day_last);
refresh_function_on = false;
// jspApi.reinitialise();
// jspApi.scrollToBottom();
if(need_rebind_img) contextmenu_rebind();
if(!eclair_last) eclair_last=1;
}
else {
if( from_refresh == false ) {
var start_conv = $('#start-conversation-info').clone();
$('#center_chat_page .messages').html(start_conv);
$('#center_chat_page .messages #start-conversation-info').show();
}
}
if( chat_input_msg_active == false ){
$('#center_chat_page .controls').hide();
} else {
$('#center_chat_page .controls').show();
}
} else {
// console.log('dans else !!!');
$('#center_chat_page .messages').html('');
$('#center_chat_page .messages #contact_erased_msg').show();
$('#center_chat_page .controls').hide();
}
}
// function put_eclairs(eclairs){
// var day_last=$("#day_last").val();
//
// if(eclairs.length > 0){
// if($(".first_msg").length > 0){
// jspApi.getContentPane().html("");
// }
//
// var flag=0;
// var need_rebind_img=0;
//
// jQuery.each(eclairs, function(index,e){
// className = (e['from_me']==1)?"name4_me":"name4";
// url_fiche=(e['from_me']==1)?"javascript:void(0);":"/"+tabLang["htmembres"]+"_" + e['exp'] +".html";
//
// exp=ucfirst(e['exp']);
//
// html='';
// if(typeof(e['notification']) != "undefined"){
// if(e['notification']=="alert1")
// var msg_alert1 = $("#msg_alert1").html();
// else
// var msg_alert1 = $("#msg_alert2").html();
//
// html +='
'+ msg_alert1 +'
';
// }
// else{
// show_day_last=0;
// if(e['date'].substring(0,10)!=day_last){
// show_day_last=1;
// day_last=e['date'].substring(0,10);
// html +='
' + e['date_display'] + "
";
// }
//
// show_sender=1;
//
// if(e['date'].substring(0,10)==day_last){
// if(jspApi.getContentPane().html().indexOf("message_block") > -1){
// elems=jspApi.getContentPane().find(".message_block");
//
// for(var k=(elems.length- 1);k >= 0;k--){
// if(elems[k].innerHTML.indexOf("message_day_time") > -1 ){
// if(elems[k].innerHTML.indexOf(">"+exp+"<") > -1 && elems[k].innerHTML.indexOf(e['day_hour']) > -1 ){
// show_sender=0;
// }
// break;
// }
// }
// }
// }
//
// html +='
';
//
// if(show_sender){
// html += ''+exp+' \
// '+e['day_hour']+' ';
// }
//
// if(e['msg'] != ""){
// html +=' \
// '+replace_smiley(e['msg'])+' \
//
';
// }
// else if(typeof(e['p_extra']) != "undefined"){
// var txt_shared=(e['from_me']==1)?lang_sharedPhotoMe:lang_sharedPhoto;
// html +='
\
//
'+txt_shared.replace("__EXP__",exp)+' :\
//
\
// \
// ';
// need_rebind_img=1;
// }
// }
//
// html +='
';
//
// show_msg=1;
// if(typeof(e['notification']) != "undefined" && jspApi.getContentPane().html().indexOf("message_block") > -1){
// //si la notification est déjà affichée, alors on ne la montre pas une 2ème fois
// show_msg=0;
// }
//
// if(show_msg){
// //alert(html);
// jspApi.getContentPane().append(html);
// }
//
// if(eclair_last < parseInt(e['id'])) eclair_last=e['id'];
// flag=1;
//
// });
// $("#day_last").val(day_last);
//
// jspApi.reinitialise();
// jspApi.scrollToBottom();
// if(need_rebind_img) contextmenu_rebind();
//
// if(!eclair_last) eclair_last=1;
// }
// }
function put_eclairs2(eclairs,start){
// console.log("dans elcair 2");
var day_last=$("#day_last").val();
//if(eclairs.length > 0) console.log("put_eclairs");
var date_prec_display="";
if(eclairs.length > 0){
var contact = $('#actions_for_messager').attr("contact_target");
var contact_id = $('#actions_for_messager').attr("contact_id");
if(!start && eclairs.length >= 20) {//on affiche un lien pour charger l'historique
html= '';
jspApi2.getContentPane().append(html);
}
var need_rebind_img=0;
jQuery.each(eclairs, function(index, e){
className = (e['from_me']==1)?"name4_me":"name4";
url_fiche=(e['from_me']==1)?"javascript:void(0);":"/"+tabLang["htmembres"]+"_" + e['exp'] +".html";
exp=ucfirst(e['exp']);
html='';
if(typeof(e['notification']) != "undefined"){
if(e['notification']=="alert1"){
// console.log("alert 1 !!!!!");
msg_alert1 = $("#msg_alert1").html();
// console.log(msg_alert1);
}
else
msg_alert1 = $("#msg_alert2").html();
html ='
'+ msg_alert1 +'
';
}
else{
if(!start){
if( typeof e['date'] != "undefined" && e['date'].substring(0,10)!=day_last){
day_last=e['date'].substring(0,10);
html +='
' + e['date_display'] + "
";
}
}
if(e['msg']){
html +='
'+exp+' \
'+e['day_hour']+' \
\
'+replace_smiley(e['msg'])+' \
';
}
else if(typeof(e['p_extra']) != "undefined"){
var txt_shared=(e['from_me']==1)?lang_sharedPhotoMe:lang_sharedPhoto;
html +='
'+exp+' \
'+e['day_hour']+' \
\
'+txt_shared.replace("__EXP__",exp)+' : \
\
\
';
need_rebind_img=1;
}
if(start){
if( typeof e['date'] != "undefined" && e['date'].substring(0,10)!=day_last){
day_last=e['date'].substring(0,10);
html +='
' + date_prec_display + "
";
}
date_prec_display=e['date_display'];
}
}
html +='
';
show_msg=1;
if(typeof(e['notification']) != "undefined" && jspApi2.getContentPane().html().indexOf("message_block") > -1){
//si la notification est déjà affichée, alors on ne la montre pas une 2ème fois
show_msg=0;
}
if(show_msg){
if(!start){
jspApi2.getContentPane().append(html);
}
else
jspApi2.getContentPane().prepend(html);
}
if(eclair_last < parseInt(e['id'])) eclair_last=e['id'];
});
$("#day_last").val(day_last);
if(start){
html ='' + date_prec_display + "
";
jspApi2.getContentPane().prepend(html);
if(eclairs.length >= 20) {//on affiche un lien pour charger l'historique
html= '';
if(start)
jspApi2.getContentPane().prepend(html);
}
}
if(need_rebind_img) contextmenu_rebind();
if( IS_MOBILE ) {
var haut_tchat = 0;
$.each( $("#messages-flow").find(".chat_date_block"), function(i, el) {
haut_tchat += parseInt( $(el).height() );
//console.log( $(el).height() );
});
if(eclairs.length >= 20) haut_tchat += parseInt( $(".div_next").height() );
//console.log( "haut_tchat : " + haut_tchat );
$("#messages-flow").find('.scroll-pane2').css("height", haut_tchat + "px");
$("#messages-flow").find('.jspContainer').css("height", haut_tchat + "px");
$("#messages-flow").find('.jspTrack').css("height", parseInt(10 + haut_tchat) + "px");
}
jspApi2.reinitialise();
if(!start) jspApi2.scrollToBottom();
}
}
function contact_lineHTML(e, filter){
// console.log("e ==> ");
// console.log(e);
var last_visite = "";
var date_message = '';
var heure_last_mess = '';
if ( typeof( e.date_last ) != 'undefined' && e.date_last != null ){
last_visite = e.date_last;
date_message = e.date_last.substring(0, 10);
heure_last_mess = e.date_last.substring(11, 16);
} else if ( typeof( e.visite ) != 'undefined' && e.visite != null ){
heure_last_mess = e.visite.substring(12,16);
last_visite = e.visite;
}
var tab_good_date_message_syntax = '';
tab_good_date_message_syntax = date_message.split('-');
var good_date_message_syntax = '';
if( typeof( tab_good_date_message_syntax ) != 'undefined' && tab_good_date_message_syntax[0] != "" ) {
good_date_message_syntax = tab_good_date_message_syntax[2] + '-' + tab_good_date_message_syntax[1] + '-' + tab_good_date_message_syntax[0];
if( good_date_message_syntax == '00-00-0000') {
good_date_message_syntax = '';
}
}
var jour_message = tab_good_date_message_syntax[2];
var now = new Date();
var yesterday = now.getDate() - 1;
var twoDaysAgo = now.getDate() - 2;
var annee = now.getFullYear();
var mois = now.getMonth() + 1;
var jour = now.getDate();
var today = annee + "-" + mois + "-" + jour;
// console.log('yesterday ==> ' + yesterday);
// console.log('twoDaysAgo ==> ' + twoDaysAgo);
// console.log('jour ==> ' + jour);
var html="";
var need_blur = "";
if( typeof ( e["need_blur"] != 'undefined') ){
need_blur = e["need_blur"];
}
try {
if(localStorage.contact_target){
miniature_style="width:60px";
message_count2_style="display:block;";
}
else{
miniature_style="";
message_count2_style="";
}
} catch(e) {}
var need_status = 0;
if( e['online'] == 'online' || e['online'] == 'green'){
e['online'] = 'green';
need_status = 1;
} else if (e['online'] == 'offline' ){
e['online'] = 'red';
}
html +='';
}
/***
* Stephan le 16/02/2022
* Bug JB : pour réduire le pseudo quand la string qui affiche le délais est trop longue..
* https://trello.com/c/xXHvX8Q7
* @type {string}
*/
var new_pseudo_label = e['pseudo'];
if( date_message != today && jour_message != yesterday && jour_message != twoDaysAgo && typeof (e.date_last_label) == 'string' ) {
var size_pseudo = e['pseudo'].length;
var size_last_label = e.date_last_label.length;
var SIZE_char_pseudo = 8;
var SIZE_char_last_label = 5;
if( size_pseudo*SIZE_char_pseudo + size_last_label*SIZE_char_last_label >= 170 ) {
var max_size_pseudo = Math.trunc((170 - size_last_label*SIZE_char_last_label) / SIZE_char_pseudo) - 4;
new_pseudo_label = e['pseudo'].substring(0, max_size_pseudo)+'...';
}
}
html +=''+new_pseudo_label+'
';
if( typeof(filter) != 'undefined' && parseInt(filter) == 1){
var message_last = "";
if( typeof(e['tab_last_msg'] ) !== 'undefined'){
if( typeof(e['tab_last_msg']['message']) !== 'undefined' ){
message_last = e['tab_last_msg']['message'];
} else {
message_last = e['tab_last_msg'];
}
} else {
message_last = " ";
}
}
if ( date_message == today ){
html +=''+heure_last_mess+'
';
} else if( jour_message == yesterday ) {
html +='' + Lang["1_day_ago"] + '
';
} else if ( jour_message == twoDaysAgo ) {
html +='' + Lang["2_days_ago"] + '
';
} else if( typeof (e.date_last_label) == 'string' ) {
html +=''+e.date_last_label+'
';
} else if( typeof( good_date_message_syntax ) != 'undefined' ) {
html +=''+good_date_message_syntax+'
';
}
else {
html +='
';
}
var sizeMax = 22;
if( typeof( message_last ) != 'undefined' && message_last != null && message_last.length > sizeMax ){
message_last = message_last.substr(0, sizeMax);
message_last = message_last + ' ...';
}
html +=''+message_last+'
';
if(parseInt(e['nb_new']) > 0) {
html +='';
html +='';
}else {
html +='';
}
if( e["pseudo"] == "" || typeof( e["m_id"] ) == 'undefined' ) {
html = '';
}
return html;
}
function contact_lineHTML_old(e){
contact=ucfirst(e['contact']);
html="";
try {
if(localStorage.contact_target){
miniature_style="width:60px";
message_count2_style="display:block;";
}
else{
miniature_style="";
message_count2_style="";
}
} catch(e) {}
html +='';
return html;
}
function click_on_photo( photo, pseudo) {
if( typeof( photo ) != 'undefined' ){
photoName = $(photo).data("src_img");
switch( $(photo).prop('class') ){
case "locked" :
$('#ask_priv_photo_popup').show();
$('#ask_priv_photo_popup').css('visibility','visible');
$('#ask_priv_photo_popup').css('opacity',1);
$('#ask_priv_photo #send_question_txt_name').html( pseudo );
$('#ask_priv_photo img').prop( 'src', photoName );
$('#ask_priv_photo img').addClass('locked');
break;
case "blur_light" :
to_paiement();
break;
case "blur_strong" :
to_paiement();
break;
default :
photoName=$(photo).attr("src");
photoName=photoName.replace("_sqmiddle.jpg",".jpg");
photoName=photoName.replace("_sqsmall.jpg",".jpg");
temp=photoName.split('-');
photoNum=parseInt(temp[temp.length - 1]);
photo_num=photoNum;
if ( $(photo).data('type') == 'private' ){
$("#album_photo_block.private .img_wrap img").attr("src",photoName);
show_album('private');
frameAlbum_private.ShowPhotoInFrame(photoNum,photoName,pseudo);
} else {
$("#vote_photo_block .img_wrap img").attr("src",photoName);
show_album();
frameAlbum.ShowPhotoInFrame(photoNum,photo_main,pseudo, $(photo).prop('class'));
}
break;
}
}
}
function open_photo_block(){
//return false;
$('#add_photo_block').hide();
$('#transparent_bg3').show();
$('#edit_photo_block').css({"top":parseInt($('body').scrollTop() + 65) + "px"});
//console.log("scrollTop: " + $('body').scrollTop());
}
function flashs_show_home(){
//alert("flashs_show_home");
$('#game2_tab, #game3_tab, #game4_tab, #tries_count').hide();
$('#game1_tab').show();
$.ajax({
type: "GET",
url: "app/ajax/load_flashs.php",
data: "filter=0",
dataType: "json",
success: function(json) {
html ="";
}
});
}
function flashs_show_game(noload){
$('#game1_tab, #game3_tab, #game4_tab').hide();
$('#game2_tab, #tries_count').show();
if(!noload){
has_win=0;
$('#nb_chances').text("3");
$('#tries_count').css("background-color","#2ab37a");
$.ajax({
type: "GET",
url: "app/ajax/load_flashs.php",
data: "filter=1",
dataType: "json",
success: function(json) {
// console.log(json);
flashs=json.flashs;
$("#game2_tab ul").html("");
ul_html="";
//flashs.forEach(function(f){
jQuery.each(flashs, function(index, f){
if(f.response){
REPONSE=f;
}
$("#li_flashs2 img").attr("src",f.url_photo);
$("#li_flashs2 .photos-count").attr("id_target",f.id);
//alert(f.photo);
$("#li_flashs2 .photos-count").html(f.photo);
//alert(1);
$("#li_flashs2 .name").html(ucfirst(f.pseudo));
$("#li_flashs2 .age_place").text(f.age + ", "+ f.zone_name);
$("#li_flashs2 .guess").attr("pseudo",f.pseudo);
$("#li_flashs2 .guess").attr("membre_id",f.id);
//alert(4);
html=$("#li_flashs2").html();
ul_html +=html;
//alert(html);
});
if(!ul_html){
if($("#game2_tab .simple_text2").html().indexOf("nogames") == -1)
$("#game2_tab .simple_text2").append("" + lang_nogames + " ");
}
$("#game2_tab ul").append(ul_html);
if( typeof(REPONSE) != 'undefined' && typeof(REPONSE.pseudo) != 'undefined' ) {
pseudo_flasher=REPONSE.pseudo;
} else {
pseudo_flasher='';
}
if( typeof(REPONSE) != 'undefined' && typeof(REPONSE.id) != 'undefined' ) {
id_flasher=REPONSE.id;
} else {
id_flasher='';
}
if( typeof(REPONSE) != 'undefined' && typeof(REPONSE.url_photo) != 'undefined' ) {
url_photo=REPONSE.url_photo;
} else {
url_photo='';
}
if( typeof(REPONSE) != 'undefined' && typeof(REPONSE.sexe1) != 'undefined' ) {
sexe1_flasher=REPONSE.sexe1;
} else {
sexe1_flasher='';
}
if( typeof(REPONSE) != 'undefined' && typeof(REPONSE.age) != 'undefined' ) {
age_flasher=REPONSE.age;
} else {
age_flasher='';
}
if( typeof(REPONSE) != 'undefined' && typeof(REPONSE.zone_name) != 'undefined' ) {
zone_name_flasher=REPONSE.zone_name;
} else {
zone_name_flasher='';
}
$("#about_try_success img").attr("src",url_photo.replace("_sqmiddle",""));
$("#lnk_username").attr("href",tabLang["htmembres"]+'_'+pseudo_flasher+"_"+id_flasher+".html");
$("#lnk_username").removeClass('female');
$("#lnk_username").removeClass('male');
$("#lnk_username").removeClass('online');
$("#lnk_username").removeClass('offline');
if(sexe1_flasher==1) $("#lnk_username").addClass('male');
else $("#lnk_username").addClass('female');
$("#lnk_username").text(ucfirst(pseudo_flasher));
//$("#age_zone").text(REPONSE.age + ", " + REPONSE.city+", " + REPONSE.country);
$("#age_zone").text(age_flasher + ", " + zone_name_flasher);
flashs_rebind();
contextmenu_rebind();
}
});
}
}
function flashs_show_finded(){
$('#game1_tab, #game2_tab, #game4_tab, #tries_count').hide();
$('#game3_tab').show();
$.ajax({
type: "GET",
url: "app/ajax/load_flashs.php",
data: "filter=2&page="+finded_page,
dataType: "json",
success: function(json) {
flashs=json.flashs;
$("#game3_tab ul").html("");
//alert("load_flashs OKKK");
pas=parseInt($('.show_next').attr("pas"));
if(flashs.length >= pas)
$('.show_next').show();
else
$('.show_next').hide();
//flashs.forEach(function(f){
jQuery.each(flashs, function(index, f){
$("#li_flashs3 img").attr("src",f.url_photo);
$("#li_flashs3 .photos-count").attr("id_target",f.id);
$("#li_flashs3 .photos-count").text(f.photo);
//alert(1);
$("#li_flashs3 .name").text(ucfirst(f.pseudo));
//alert(2);
$("#li_flashs3 .age_place").text(f.age + ", "+ f.zone_name);
$("#li_flashs3 .photos-count").attr("id_target",f.id);
$("#li_flashs3 .chat").attr("contact",f.pseudo);
$("#li_flashs3 .add_friend").attr("id_friend",f.id);
$("#li_flashs3 .un_friend").attr("id_friend",f.id);
if(f.is_friend == 0){//si le contact n'est pas ami
$("#li_flashs3 .add_friend").css("display","block");
$("#li_flashs3 .un_friend").css("display","none");
}
else{
$("#li_flashs3 .add_friend").css("display","none");
$("#li_flashs3 .un_friend").css("display","block");
}
$("#li_flashs3 .user_click_profil").attr("href",tabLang["htmembres"] + '_' + f.pseudo + "_" + f.id + ".html");
if(f.is_online==0){
$("#li_flashs3 .onlineState").removeClass("online");
$("#li_flashs3 .onlineState").addClass("offline");
}
else{
$("#li_flashs3 .onlineState").removeClass("offline");
$("#li_flashs3 .onlineState").addClass("online");
}
html=$("#li_flashs3").html();
$("#game3_tab ul").append(html);
//alert(html);
});
flashs_rebind();
contextmenu_rebind();
}
});
}
function flashs_show_myflashs(){
$('#game1_tab, #game2_tab, #game3_tab, #tries_count').hide();
$('#game4_tab').show();
$.ajax({
type: "GET",
url: "app/ajax/load_flashs.php",
data: "filter=3&page="+myflashs_page,
dataType: "json",
success: function(json) {
flashs=json.flashs;
$("#game4_tab ul").html("");
//alert("load_flashs OKKK");
pas=parseInt($('.show_next').attr("pas"));
if(flashs.length >= pas)
$('.show_next').show();
else
$('.show_next').hide();
//flashs.forEach(function(f){
jQuery.each(flashs, function(index, f){
$("#li_flashs4 img").attr("src",f.url_photo);
$("#li_flashs4 .photos-count").attr("id_target",f.id);
$("#li_flashs4 .photos-count").text(f.photo);
//alert(1);
$("#li_flashs4 .name").text(ucfirst(f.pseudo));
//alert(2);
$("#li_flashs4 .age_place").text(f.age + ", "+ f.zone_name);
$("#li_flashs4 .photos-count").attr("id_target",f.id);
$("#li_flashs4 .fancy").attr("contact",f.pseudo);
$("#li_flashs4 .fancy").attr("membre_id",f.id);
$("#li_flashs4 .user_click_profil").attr("href",tabLang["htmembres"] + '_' + f.pseudo + "_" + f.id + ".html");
if(f.is_online==0){
$("#li_flashs4 .onlineState").removeClass("online");
$("#li_flashs4 .onlineState").addClass("offline");
}
else{
$("#li_flashs4 .onlineState").removeClass("offline");
$("#li_flashs4 .onlineState").addClass("online");
}
html=$("#li_flashs4").html();
$("#game4_tab ul").append(html);
//alert(html);
});
flashs_rebind();
contextmenu_rebind();
}
});
}
function call_show_album(elem){
if(parseInt(elem.text()) > 0 || elem.attr('id_target') > 0){
id_target=elem.attr('id_target');
// console.log('id target = ' + id_target);
num=0;
if(elem.attr('num') > 0) num=elem.attr('num');
$("#frameAlbum").attr('src',"index.php?mod=user_album&id=" + id_target + "&photo_num="+num);
$("#frameAlbum").on('load', function() {
$("#img_loader_photo_block").hide();
});
show_album();
return false;
}
}
function call_add_friend(elem){
if(typeof(elem.attr("subscribe")) != "undefined"){
// document.location="Inscription.html";
document.location=""+tabLang["htInscription"];
return false;
}
id_friend=elem.attr("id_friend");
var obj=elem;
$.ajax({
type: "POST",
url: "app/ajax/friends.php",
data: "action=add_friend&id=" + id_friend,
success: function(retour) {
obj.hide();
try {
localStorage.setItem('move-favorite_'+id_friend,'active');
} catch (e) {
// Can't use sessionStorage !!!
}
obj.parent().find(".un_friend").show();
}
});
}
function call_un_friend(elem){
id_friend=elem.attr("id_friend");
var obj=elem;
$.ajax({
type: "POST",
url: "app/ajax/friends.php",
data: "action=del_friend&id=" + id_friend,
success: function(retour) {
obj.hide();
try {
localStorage.setItem('move-favorite_'+id_friend,'no-active');
} catch (e) {
// Can't use sessionStorage !!!
}
obj.parent().find(".add_friend").show();
}
});
}
function call_show_advanced_search(elem){
//alert("call_show_advanced_search");
$('#orientation,#marry_status, #sexsual_pref, #name_surn, #user_name, #eye_color, #hair_type, #go-small-search, #adv_search_text, #height_selection, #weight_selection,#new_line1,#new_line2').show();
$('#height_selection, #weight_selection').css('top',"0px");
$('#height_selection, #weight_selection').css({'position':"relative",'top':0});
$('#gender, #age').css('padding-bottom','10px');
$('.container2').css('height','210px');
document.formSearch.searchAction.value="Advance";
var params = {
changedEl: ".lineForm2 select",
visRows: 8,
scrollArrows: true
};
cuSel(params);
//alert("refait sex_p");
elem.hide();
}
function vote_rebind(){
//friend_rebind();
//alert("vote_rebind");
$('.vote_stars .stars_item').hover(function(){
//alert($(this).attr("note"));
var noteHover=parseInt($(this).attr("note"));
var elems=$(this).parent().find('.stars_item');
//console.log(elems.length);
elems.each(
function() {
if(parseInt(jQuery(this).attr("note")) <=noteHover)
{
//jQuery(this).parent().removeClass("radioChecked");
jQuery(this).removeClass("vote_star");
jQuery(this).addClass("vote_star_checked");
}
});
},
function(){
var noteHover=parseInt($(this).attr("note"));
$(this).parent().find('.stars_item').each(
function() {
if(parseInt($(this).attr("note")) >= noteHover)
{
jQuery(this).removeClass("vote_star_checked");
jQuery(this).addClass("vote_star");
}
});
});
$(".vote_stars .vote_star").click(function(){
var datas = {
event: 'actionRates',
};
dataLayer_generator( datas );
temp=$("body").find("#album_photo_block");
var page_vote=0;
if(temp.length > 0){
target_id=$("#album_photo_block .img_wrap img").attr("target_id");
photoName=$("#album_photo_block .img_wrap img").attr("src");
}
else{
//alert("non album_photo_block");
//p=$(this).parent().parent().parent();
page_vote=1;
target_id=$(this).parents(".img_wrap").find("img.photo-to-vote").attr("target_id");
target_pseudo=$(this).parents(".img_wrap").find("img.photo-to-vote").attr("target_pseudo");
photoName=$(this).parents(".img_wrap").find("img.photo-to-vote").attr("src");
vote=$(this).parents(".img_wrap").find(".vote_val").text();
moyenne=$(this).parents(".img_wrap").find(".note_val").text();
age_place=$(this).parents(".img_wrap").find("img.photo-to-vote").attr("target_age");
}
if( typeof(photoName) != "undefined" ) {
temp=photoName.split('-');
if(temp.length > 1){
photoNum=parseInt(temp[temp.length - 1]);
if(photoNum >= 0){
note=parseInt($(this).attr("note"));
send_vote(target_id, photoNum, note,$(this));
photoVoted = basename(photoName.replace('_sqmiddle.jpg', '.jpg'));
if(photoVoted.indexOf("?") > -1) photoVoted = photoVoted.substring(0, photoVoted.indexOf("?"));
PHOTOS_VOTED[PHOTOS_VOTED.length] = photoVoted;
if(page_vote){
el=$("#vote_history ul li").last();
if(el){
if($("#vote_history ul li").length >= 3) el.remove();
}
el=$("#historic_bloc li");
if(el){
el.find(".name").html(ucfirst(target_pseudo));
photoName = photoName.replace('.jpg', '_sqmiddle.jpg');
el.find("img").attr("src",photoName);
el.find(".add_friend").attr("id_friend",target_id);
el.find(".un_friend").attr("id_friend",target_id);
el.find(".chat").attr("contact",target_pseudo);
el.find(".age_place").html(age_place);
el.find("a").first().attr("href",tabLang["htmembres"]+'_'+target_pseudo+"_"+target_id+".html");
//moyenne_new=Math.round(100 * (moyenne*vote + note)/(vote + 1)) / 100;
//alert(moyenne*vote);
moyenne_new=Math.round(100 * (parseFloat(moyenne)*parseInt(vote) + note)/(parseInt(vote) + 1))/100;
el.find(".photo_rate2").html(moyenne_new.toFixed(2) );
html='' + el.html() + ' ';
$("#vote_history ul").prepend(html);
friend_rebind();
}
}
}
}
}
});
}
function friend_rebind(){
$('.add_friend').unbind().click(function(){
call_add_friend($(this));
});
$('.un_friend').unbind().click(function(){
call_un_friend($(this));
});
$('.chat').unbind().click(function(){
contact=$(this).attr("contact");
//console.log("click sur chat");
Initialise_chat_page();
// stop_timer_refresh_chats();
document.location='index.php?mod=chat_v2018&pseudo=' + contact;
//load_messages(contact, false);
return false;
});
}
function photos_rebind(){
$('.photos-count,.photo_rate2, .photos-count-rightChat, #btn_match_voir_album').unbind().click(function(){
call_show_album($(this));
});
}
function chat_rebind(){
$('.chat,.chat2, #chat2').unbind().click(function(){
if ( $(this).prop('id') =="chat2") {
var datas = {
event: 'actionStartChatMemberPage'
};
dataLayer_generator( datas );
}
$('#new-messanger').hide();
if(typeof($(this).attr("subscribe")) != "undefined"){
//document.location="Inscription.html";
document.location=""+tabLang["htInscription"];
}
else{
var user_pseudo = $(this).attr('contact');
var user_img = $(this).attr('user_image');
var user_img_sqsmall = "";
if(typeof(user_img) != "undefined") user_img_sqsmall = user_img.replace(/sqmiddle/,'sqsmall');
var user_id = $(this).attr('user_id');
var user_state = $(this).attr('online');
var tab_data = new Array();
tab_data['pseudo'] = user_pseudo;
tab_data['photo'] = user_img_sqsmall;
tab_data['m_id'] = user_id;
tab_data['online'] = user_state;
contact=$(this).attr("contact");
if( !IS_MOBILE) {
//get_contacts_list_v2016( $(this), 0, 1, true, tab_data);
//load_messages_new_messenger(0, 1, tab_data);
Initialise_chat_page();
// stop_timer_refresh_chats();
document.location='index.php?mod=chat_v2018&pseudo=' + contact;
} else {
contact=$(this).attr("contact");
open_messages(contact);
return false;
}
}
return false;
});
}
function flashs_rebind(){
$('.like_nochecked, .dislike_nochecked').unbind().click(function(){
var datas = {
event: 'actionLikes',
};
dataLayer_generator( datas );
$(this).hide();
$(this).nextAll().show();
var is_good=parseInt($(this).attr("like"));
li_id=$(this).attr("li");
$.ajax({
type: "GET",
dataType: "json",
url: "app/ajax/setFlash.php",
data: "target_id="+$(this).attr('membre_id') + "&is_good=" + is_good + "&li_id=" + li_id,
success: function(f) {
li_id = f.li_id;
$("#" + li_id).remove();
$("#li_flashs1 img").attr("src",f.url_photo);
$("#li_flashs1 .photos-count").attr("id_target",f.id);
$("#li_flashs1 .photos-count").html(f.photo);
$("#li_flashs1 .name").html(ucfirst(f.pseudo));
$("#li_flashs1 .age_place").text(f.age + ", "+ f.city);
if(typeof(f.photo_x) != "undefined") $("#li_flashs1 img").addClass(f.photo_x);
else{
$("#li_flashs1 img").removeClass("blur_light");
$("#li_flashs1 img").removeClass("blur_strong");
$("#li_flashs1 img").removeClass("not_valid");
}
$("#li_flashs1 .like").attr("membre_id",f.id);
if(typeof(lang_sg_plait[f.sexe1]) != "undefined") $("#li_flashs1 .like").text(lang_sg_plait[f.sexe1]);
$("#li_flashs1 .dislike").attr("membre_id",f.id);
if(typeof(lang_sg_plait_pas[f.sexe1]) != "undefined") $("#li_flashs1 .dislike").text(lang_sg_plait_pas[f.sexe1]);
if(f.sexe1==1 && !$("#li_flashs1 li").hasClass("man")){
$("#li_flashs1 li").removeClass("woman");
$("#li_flashs1 li").removeClass("couple");
$("#li_flashs1 li").addClass("man");
}
if(f.sexe1==2 && !$("#li_flashs1 li").hasClass("woman")){
$("#li_flashs1 li").removeClass("man");
$("#li_flashs1 li").removeClass("couple");
$("#li_flashs1 li").addClass("woman");
}
if(f.sexe1==3 && !$("#li_flashs1 li").hasClass("couple")){
$("#li_flashs1 li").removeClass("woman");
$("#li_flashs1 li").removeClass("man");
$("#li_flashs1 li").addClass("couple");
}
$("#li_flashs1 li").attr("id",li_id);
$("#li_flashs1 .like_nochecked").attr("li",li_id);
$("#li_flashs1 .dislike_nochecked").attr("li",li_id);
$("#li_flashs1 .user_click_profil").attr("href",tabLang["htmembres"]+'_'+ + f.pseudo + "_" + f.id + ".html");
html=$("#li_flashs1").html();
$("#game1_tab ul").append(html);
if(is_good){
info_nb_flashs=parseInt($("#info_nb_flashs").text());
$("#info_nb_flashs").text(info_nb_flashs + 1);
}
flashs_rebind();
}
});
//}
});
friend_rebind();
photos_rebind();
smart_rebind_click_user_album();
$('#game2_tab .user-album img').unbind().click(function(){
elem=$(this).parent().parent().find(".guess");
//alert(elem.attr("membre_id"));
GuessFlash(elem);
});
$('.guess').unbind().click(function(){
GuessFlash($(this));
});
function GuessFlash(elem){
$('#transparent_bg3').show();
if(parseInt($('#nb_chances').text()) <= 0){
if(!IS_MOBILE) $('#about_tries').css({"top":($(document).scrollTop() + 180) + "px"});
$('#about_tries').show();
return false;
}
if(pseudo_flasher==elem.attr('pseudo') || has_win){//you win !!!
if(!IS_MOBILE) $('#about_try_success').css({"top":($(document).scrollTop() + 100) + "px"});
$('#about_try_success').show();
if(has_win == 0){
has_win=1;
info_nb_finded=parseInt($("#info_nb_finded").text());
$("#info_nb_finded").text(info_nb_finded + 1);
info_nb_games=parseInt($("#info_nb_games").text());
if(info_nb_games) $("#info_nb_games").text(info_nb_games - 1);
$.ajax({
type: "GET",
url: "app/ajax/setDeviner.php",
data: "id="+elem.attr('membre_id'),
success: function(retour) {
}
});
}
return false;
}
elem.removeClass('is_guess').addClass('not_guess');
$('#nb_chances').text(parseInt($('#nb_chances').text()) - 1);
if(parseInt($('#nb_chances').text()) == 2)
$('#tries_count').css("background-color","#E6943E");
else
$('#tries_count').css("background-color","#E14610");
if(parseInt($('#nb_chances').text()) <= 0){
if(!IS_MOBILE) $('#about_tries').css({"top":($(document).scrollTop() + 180) + "px"});
$('#about_tries').show();
return false;
}
else{
if(!IS_MOBILE) $('#about_try_again').css({"top":($(document).scrollTop() + 200) + "px"});
$('#about_try_again').show();
}
return false;
}
$('.fancy').unbind().click(function(){
class_lst=$(this).attr("class");
//alert(class_lst);
is_good=0;
if(class_lst.indexOf('no_fancy_checked') > -1){
is_good=1;
$(this).removeClass('no_fancy_checked').addClass('no_guess');
}
else{
$(this).removeClass('no_guess').addClass('no_fancy_checked');
}
$.ajax({
type: "GET",
url: "app/ajax/setFlash.php",
data: "target_id="+$(this).attr('membre_id') + "&is_good=" + is_good,
success: function(retour) {
}
});
});
}
function vote_next(){
var vote_sex=document.forms['form_top'].sex.value;
if($('#vote_id1 .img_wrap img').css("margin-top") != "200px"){
var url_votephoto1=$('#vote_id1 .img_wrap img').attr("src");
$('#vote_id1 .img_wrap img').attr("src","/public/img/load.gif");
$('#vote_id1 .img_wrap img').css("margin-top","200px");
$('#vote_id1 .name6').hide();
$('#vote_id1 .age_place3').hide();
$('#vote_id1 .vote_field').hide();
}
$.ajax({
type: "GET",
url: "app/ajax/load_votephoto.php",
data: "sex=" + vote_sex,
dataType: "json",
success: function(json) {
var HTML_VOTEPHOTO=$("#block_vote_copy").html();
infos=json.infos;
if(typeof(infos.url_photo) != "undefined"){
$("#block_vote img").attr("src",infos.url_photo);
$("#block_vote img").attr("target_id",infos.id);
$("#block_vote img").attr("target_pseudo",infos.pseudo);
$("#block_vote img").attr("target_age",infos.age + ", " + infos.zone_name);
$("#block_vote .vote_val").html(infos.vote);
$("#block_vote .note_val").html(Math.round(100*infos.moyenne/2)/100);
$("#block_vote .name6 a").html(ucfirst(infos.pseudo) + " " + infos.age + ", " + infos.zone_name);
html=$("#block_vote").html();
HTML_VOTEPHOTO = html + HTML_VOTEPHOTO;
$("#block_vote_copy").html(HTML_VOTEPHOTO);
$(".voteforphoto_item2").html(HTML_VOTEPHOTO);
vote_rebind();
$(".voteforphoto_item2").clickCarousel2({margin: 10});
$('#vote_id1 .img_wrap img').attr("src",url_votephoto1);
$('#vote_id1 .img_wrap img').css("margin-top","0");
$('#vote_id1 .name6').show();
$('#vote_id1 .age_place3').show();
$('#vote_id1 .vote_field').show();
//$('voteforphoto_item2').
//$(".voteforphoto_item2").scroller.scroll();
//carou.scroller.scroll();
}
}
});
return false;
}
function block_vote_loaded(elem){
//alert(elem.attr("src"));
el=$(".voteforphoto_item2 img").first();
//alert(el.attr("src"));
if(el.attr("src") == elem.attr("src") && elem.height() > 0){
//alert(elem.attr("src") + "\n" + el.attr("src") + "\n" + elem.height() );
Hnew=(elem.height() + 60);
if(Hnew < 240) Hnew=240;
//$(".voteforphoto_item2").css("height",Hnew + "px");
$(".voteforphoto_item2").animate({"height":Hnew + "px"},500);
}
}
function open_photo_add(){
//return false;
$('#transparent_bg3, #add_photo_block').show();
}
function SubmitKeyPress(elem,elem1){
thisID="#" + elem;
//thisID="#" + $('send_message2');
$(thisID + ' #new_message').focus();
var dest=$(thisID + " #dest_message").val();
var msg=$(thisID + " #new_message").val();
//var apiNum=$(elem).attr("apiNum");
var apiNum=$(thisID).attr("apiNum");
//console.log('dest : ' + dest);
$(thisID + " #new_message").val("");
$.ajax({
type: "POST",
url: "app/ajax/send_message.php",
/* data: "dest="+dest+"&msg="+msg, */
data: { dest: dest, msg: msg },
/**
* Stéphan (le 24/11/2014) :
* on utilise data: { dest: dest, msg: msg }, à la place de data: "dest="+dest+"&msg="+msg,
* Car sinon on a le bug qui affiche jQuery16109312836304306984_1416818130300 à la place d'un "?"
*/
dataType: "json",
success: function(json) {
if( elem == 'send_message' ){
display_msg_sent(thisID,apiNum,json, false);
if( $('#new-messanger #contact_'+dest).hasClass('active')){
//console.log('mini chat actif sur meme conversation');
display_msg_sent(thisID,apiNum,json, true);
}
} else{
if( IS_MOBILE ){
display_msg_sent2(thisID,apiNum,json, true);
}
//console.log('test 2 !!!!!!!');
if( $('#new-my-messages #contact_'+dest).hasClass('active')){
display_msg_sent(thisID,apiNum,json, false);
}
}
}
});
return false;
}
function submitChatForms(elem){
thisID="#" + elem;
//console.log("this ID ===> "+thisID);
$(thisID + ' #new_message').focus();
var dest=$(thisID + " #dest_message").val();
var msg=$(thisID + " #new_message").val();
//console.log("this dest ===> "+dest);
//console.log("this msg ===> "+msg);
var apiNum=$(thisID).attr("apiNum");
$(thisID + " #new_message").val("");
// if( typeof( user_id ) != 'undefined' && user_id != '' && typeof( dest ) != 'undefined' && dest != '' && typeof( msg ) != 'undefined' && msg != '') {
// $.get( "index.php?mod=push_notify", { action_bis: 'send_push_notification', user_id: user_id, one_signal: 1, contact: dest, msg: msg }, function( datas ) {
// console.log('sended >> ' + datas);
// }).fail(function() {
// console.log( "error !!!" );
// });
// }
$.ajax({
type: "POST",
url: "app/ajax/send_message.php",
/* data: "dest="+dest+"&msg="+msg, */
data: { dest: dest, msg: msg },
/**
* Stéphan (le 24/11/2014) :
* on utilise data: { dest: dest, msg: msg }, à la place de data: "dest="+dest+"&msg="+msg,
* Car sinon on a le bug qui affiche jQuery16109312836304306984_1416818130300 à la place d'un "?"
*/
dataType: "json",
success: function(json) {
//console.log("success de sent message !!!!!");
//console.log('id : ' + thisID);
if( thisID == '#send_message' ){
display_msg_sent(thisID,apiNum,json, false);
// if( $('#new-messanger #contact_'+dest).hasClass('active')){
// //console.log('mini chat actif sur meme conversation');
// display_msg_sent(thisID,apiNum,json, true);
// }
} else{
if( IS_MOBILE ){
display_msg_sent2(thisID,apiNum,json);
}else{
display_msg_sent(thisID,apiNum,json, true);
// if( $('#new-messanger #contact_'+dest).hasClass('active')){
// display_msg_sent(thisID,apiNum,json, true);
// }
}
}
}
});
return false;
}
function display_msg_sent(thisID,apiNum,json, chat_rapide){
$('#select-person-info').hide();
if( typeof( json ) != 'undefiend' && json != null ) {
var from_who = (json.from_me == 1) ? "from_me" : "from_other";
var className = (json.from_me == 1) ? "name this" : "name other";
var url_fiche = (json.from_me == 1) ? "#" : tabLang["htmembres"] + '_' + json.exp + ".html";
var exp = ucfirst(json.exp);
var eclair_last = '';
if (typeof(json.id) != "undefined") eclair_last = json.id;
var day_last = $( thisID + " #day_last").val();
// console.log('thisID ==> ' + thisID);
// console.log('day_last : ' + day_last);
html = '';
var msg_alert1 = "";
if (typeof(json.notification) != "undefined" && json.notification != "") {
if (json.notification == "alert1") {
var msg_alert1 = $("#msg_alert1").html();
}
else if (json.notification == "alert2") {
var msg_alert1 = $("#msg_alert2").html();
}
html += '
';
html += '
' + msg_alert1 + '
';
}
else {
html += '
';
var show_day_last = 0;
if (json.msg != "") {
html += '
' + replace_smiley(json.msg) + '
';
}
else if (typeof(json.p_extra) != "undefined") {
// var txt_shared=(e['from_me']==1)?lang_sharedPhotoMe:lang_sharedPhoto;
html += '';
need_rebind_img = 1;
}
// console.log("json date : " +json.date.substring(0,10));
if (json.date.substring(0, 10) != day_last) {
show_day_last = 1;
day_last = json['date'].substring(0, 10);
html += '
' + json.date_display + "
";
html += '
' + json.day_hour;
if(json['from_me']==1){
html +=' '+ lang_messageSent+' ';
}
html += '
';
}
show_sender = 1;
if (json.date.substring(0, 10) == day_last && show_day_last != 1) {
// console.log('dans jsondatesub day == day');
html += '
' + json.day_hour;
if (json['from_me'] == 1) {
html += ' ' + lang_messageSent + ' ';
}
html += '
';
}
var need_rebind_img = 0;
day_last = json.date.substring(0, 10);
$(thisID + " #day_last").val(day_last);
}
html += '
';
show_msg = 1;
if (show_msg) {
// $("#new-messanger .messages").append(html);
// $("#new-my-messages .msg-content .messages").append(html);
//
if (chat_rapide == true) {
var chat2 = $("#new-messanger .messages");
//console.log('chat rapide true et from refresh != 1');
chat2.append(html);
} else {
var chat1 = $("#new-my-messages .msg-content .messages");
//console.log('chat rapide false et from refresh != 1');
$("#new-my-messages .msg-content #start-conversation-info, #new-my-messages .msg-content #select-person-info ").hide();
$("#new-my-messages .msg-content .messages").append(html);
}
}
if (need_rebind_img) contextmenu_rebind();
if (msg_alert1) {
FaireClignoterAlert();
}
//if(!eclair_last) eclair_last=1;
$('#new-messanger .messages').scrollTop(9999);
$("#center_chat_page .messages").scrollTop(9999);
}
}
function display_msg_sent2(thisID,apiNum,json){
className = (json.from_me==1)?"name4_me":"name4";
exp=ucfirst(json.exp);
if(typeof(json.id) != "undefined") eclair_last=json.id;
day_last=$(thisID + " #day_last").val();
if($(".first_msg").length > 0){
jspApi.getContentPane().html("");
}
html='
';
if(apiNum==2) api=jspApi2;
else api=jspApi;
var msg_alert1="";
if(typeof(json.notification) != "undefined" && (json.notification=="alert1" || json.notification=="alert2")){
if(json.notification=="alert1")
msg_alert1 = $("#msg_alert1").html();
else
msg_alert1 = $("#msg_alert2").html();
if(api.getContentPane().html().indexOf("btn-danger") == -1){
html +='
'+ msg_alert1 +'
';
}
}
else{
if(json.date.substring(0,10)!=day_last)
html +='
' + json.date_display + "
";
show_sender=1;
if(json.date.substring(0,10)==day_last){
if(api.getContentPane().html().indexOf("message_block") > -1){
//elems=api.getContentPane().find(".message_block");
//alert(elems.length);
elems=api.getContentPane().find(".message_block");
for(var k=(elems.length- 1);k >= 0;k--){
if(elems[k].innerHTML.indexOf("message_day_time") > -1 ){
if(elems[k].innerHTML.indexOf(">"+exp+"<") > -1 && elems[k].innerHTML.indexOf(json.day_hour) > -1 ){
show_sender=0;
}
break;
}
}
}
}
html +='
-1 && json.date.substring(0,10)==day_last) html +='margin-top:15px;';
}
html +='">';
if(show_sender)
html += ''+exp+' \
'+json.day_hour+' ';
var need_rebind_img=0;
if(json.msg){
html += ' \
'+replace_smiley(json.msg)+' \
';
}
else if(typeof(json.p_extra) != "undefined"){
var txt_shared=(json.from_me==1)?lang_sharedPhotoMe:lang_sharedPhoto;
html +='
\
'+txt_shared.replace("__EXP__",exp)+' :\
\
\
';
need_rebind_img=1;
}
day_last = json.date.substring(0,10);
$(thisID + " #day_last").val(day_last);
}
api.getContentPane().append(html);
api.reinitialise();
api.scrollToBottom();
if(need_rebind_img) contextmenu_rebind();
if(msg_alert1){
FaireClignoterAlert();
}
if(!eclair_last) eclair_last=1;
}
function block_user_modulo_search( element ){
var nb_block_li_without_adcenter = element.not(':has(.pub_ad_center)').length;
//console.log('nb elem sans ad center : ' + nb_block_li_without_adcenter);
var moduloLimit = 0;
if( IS_MOBILE ) {
moduloLimit = 3;
} else {
moduloLimit = 4;
}
//console.log('moduloLimit : ' + moduloLimit);
if( nb_block_li_without_adcenter > moduloLimit && nb_block_li_without_adcenter % parseInt(moduloLimit) != 0){
var nb_block_to_hide = nb_block_li_without_adcenter % parseInt(moduloLimit) ;
//console.log('nb eleme to hide : ' + nb_block_to_hide);
while(nb_block_to_hide > 0){
//console.log('dans while');
element.not(':hidden').last().hide();
nb_block_to_hide--;
//console.log('nb eleme to hide : ' + nb_block_to_hide);
}
}
}
function display_next(json,mod,pas,page_cur,page_next,li_name){
//On récup les positions des dernières pub affichées :
var last_ad_profile = $('.ad_profile_block').last();
var position_last_ad_profile = parseInt($('#ul_result li').index( $(last_ad_profile) )) + 1;
// console.log( "position_last_ad_profile : " + position_last_ad_profile);
var nb_block_li_without_adcenter = parseInt($('#ul_result li').not(':has(.pub_ad_center)').length);
$.each($('#ul_result li'),function(){
if( $(this).is(':hidden') ){
$(this).show();
}
});
$('#paginator_loader' + li_name).hide();
// console.log(json);
if(typeof(json.flashs) != "undefined") res=json.flashs;
else res=json.result;
if(page_cur==-1){
page_cur=Math.floor(res.length/pas) - 1;
if(page_cur < 0) page_cur=0;
page_next=page_cur + 1;
$(".show_next").attr("page_cur",page_next);
}
if(res.length < pas){
has_next=0;
if(typeof(json.has_next)!= "undefined") has_next=parseInt(json.has_next);
if(!has_next) $('.show_next').hide();
}
var iRes=0;
var iPagi=page_next+"3";
var li="li_" + mod;
if(li_name) li="li_" + li_name;
$.each(res,(function(iii, r){
// if ( (parseInt(nb_block_li_without_adcenter) % 8) == 0 && typeof(json.tab_pub) == 'object' && typeof(json.tab_pub.ad_center) != "undefined" ) {
// // console.log( "PRINT ad_center");
// html = '
' + json.tab_pub.ad_center[0] + ' ';
// if(li_name) $('#ul_' + li_name).append(html);
// else $('#ul_result').append(html);
// delete json.tab_pub.ad_center[0];
//// console.log(json.tab_pub.ad_center);
// }
//
// if ( (parseInt(nb_block_li_without_adcenter)) % 7 == 0 && typeof(json.tab_pub) == 'object' && typeof(json.tab_pub.ad_profile) != "undefined" && typeof(json.tab_pub.ad_profile) != "" ) {
// console.log( "PRINT ad_profile");
// console.log('*************************************');
// console.log(json.tab_pub.ad_profile);
// var firstKey = Object.keys(json.tab_pub.ad_profile)[0];
//// console.log('firstKey');
//// console.log(firstKey);
// html = '
' + json.tab_pub.ad_profile[firstKey] + ' ';
// if(li_name) $('#ul_' + li_name).append(html);
// else $('#ul_result').append(html);
// delete json.tab_pub.ad_profile[firstKey];
// //nb_block_li_without_adcenter++;
//// console.log(json.tab_pub.ad_profile);
//// console.log('*************************************');
// } else {
//
// if( typeof(r.ad_center) != 'undefined' && r.ad_center != '' ){
// console.log('dans display next de ad_center');
//
// html = '
' + r.ad_center + ' ';
// if(li_name) $('#ul_' + li_name).append(html);
// else $('#ul_result').append(html);
// }
//else
if( typeof(r.ad_profile) != 'undefined' && r.ad_profile != '' ){
// console.log('dans display next de ad_profile');
html = '
' + r.ad_profile + ' ';
if(li_name) $('#ul_' + li_name).append(html);
else $('#ul_result').append(html);
return true;
}
// console.log('li ==> ' + li);
// else {
// nb_block_li_without_adcenter++;
// }
// console.log('photo_x ==> ' + r.photo_x);
iRes++;
$("#"+li+" li img").attr("src",r.url_photo);
if( typeof ( r.photo_x ) != 'undefined' ){
$("#"+li+" li img").removeClass('blur_strong');
$("#"+li+" li img").removeClass('blur_light');
$("#"+li+" li img").removeClass('not_valid');
if( parseInt(r.photo_x) == 1 && typeof( can_see_pic ) != 'undefined' && can_see_pic != true ) {
r.photo_x = "blur_strong";
} else if ( r.photo_x != "" && typeof( can_see_pic ) != 'undefined' && can_see_pic != true) {
} else {
r.photo_x = 'visible';
}
$("#"+li+" li img").addClass(r.photo_x);
}
$("#"+li+" .photos-count").attr("id_target",r.id);
if(parseInt(r.photo) > 0){
$("#"+li+" .photos-count").removeClass("none");
$("#"+li+" .photos-count").text(r.photo);
}
else{
$("#"+li+" .photos-count").addClass("none");
}
$("#"+li+" .photos-count").html(r.photo);
$("#"+li+" .name").html(ucfirst(r.pseudo));
$("#"+li+" .age_place").text(r.age + ", "+ r.zone_name);
$("#"+li+" .add_friend").attr("id_friend",r.id);
$("#"+li+" .un_friend").attr("id_friend",r.id);
$("#"+li+" .chat").attr("contact",r.pseudo);
$("#"+li+" .chat").attr("user_id",r.id);
$("#"+li+" .chat").attr("user_image",r.url_photo);
if($("#"+li+" .rank").length){
$("#"+li+" .rank span").html(iRes + pas*page_next);
$("#"+li+" .photo_rate2").html((Math.round(100*r.moyenne/2)/100).toFixed(2));
$("#"+li+" .photo_rate2").attr("id_target",r.id);
}
if($("#"+li+" .mark").length){
$("#"+li+" .mark").html(r.note + "/10");
}
if(r.is_online==0){
$("#"+li+" .onlineState").removeClass("online");
$("#"+li+" .onlineState").addClass("offline");
}
else{
$("#"+li+" .onlineState").removeClass("offline");
$("#"+li+" .onlineState").addClass("online");
}
if( typeof ( r.chat_hh ) != 'undefined' && r.chat_hh ){
$("#"+li+" .chat").addClass("chat_hh");
$("#"+li+" .add_friend").hide();
$("#"+li+" .un_friend").hide();
}
else{
if(r.is_friend==0){
$("#"+li+" .add_friend").show();
$("#"+li+" .un_friend").hide();
}
else{
$("#"+li+" .add_friend").hide();
$("#"+li+" .un_friend").show();
}
}
if(mod=="flashs"){
$("#" + li + " .user_click_profil").attr("href",tabLang["htmembres"] + '_' + r.pseudo + "_" + r.id + ".html");
}
html = $('#'+li).html();
html = html.replace("{membre_pseudo}",r.pseudo);
html = html.replace("{membre_id}",r.id);
html = html.replace("{membre_sexe}",r.sexe1);
//console.log('membre id : ' +r.id);
html = html.replace("a0", "a"+iPagi);
if(r.sexe1 == "1"){
html = html.replace("sq_girl.png","sq_boy.png");
html = html.replace("woman","man");
}
if(r.sexe1 == "3"){
html = html.replace("sq_girl.png","sq_couple.png");
html = html.replace("woman","couple");
}
if(mod=="albums"){
var num_carou = $("#ul_result").find(".small_preview2").length + 1;
html = html.replace("{carou0}","carou" + num_carou);
var html_photos ="";
photos_preview=r.photos_preview;
photos_visible=r.photos_visible;
photos_preview.forEach(function(p,index){
imgClass=photos_visible[index];
html_photos += '
';
});
html = html.replace("{photos_preview}",html_photos);
}
if(li_name) $('#ul_' + li_name).append(html);
else $('#ul_result').append(html);
iPagi++;
photos_rebind();
friend_rebind();
chat_rebind();
if(mod=="albums"){
$(".carou" +num_carou+ " .small_preview2").clickCarousel2({margin: 10});
$('.small_preview2 img').unbind().click(function(){
call_show_album($(this));
});
}
// smart_rebind_click_user_album();
// }
nb_block_li_without_adcenter++;
$("#"+li+" li img").removeClass("blur_strong");
}));
smart_rebind_click_user_album(); //MAJ click profil pour smartphone
if(mod=="search") {
//cacher le dernier block user pour conserver 4 block par ligne dans la recherche
//block_user_modulo_search($('#ul_result li'));
contextmenu_rebind();
}
}
function show_p_extra(p_extra){
$("#transparent_bg2").show();
$("#photo_priv").html("
");
$("#photo_priv").css("line-height",parseInt($("#photo_priv").height()) + "px")
$("#photo_priv").show();
contextmenu_rebind();
}
function show_attachment(elem){
$("#transparent_bg2").show();
$("#p_attachment").fadeIn();
$("#chat_attachment").val(elem);
$.ajax({
type: "POST",
url: "app/ajax/get_photos.php",
dataType: "json",
success: function(json) {
//display_msg_sent(thisID,apiNum,json);
var html0="";
var html1="";
if(typeof(json.photos0) != "undefined"){
jQuery.each(json.photos0, function(index, p){
html0 +="
";
});
}
if(typeof(json.info0) != "undefined"){
html0 +=json.info0 ;
}
if(typeof(json.photos1) != "undefined"){
jQuery.each(json.photos1, function(index, p){
html1 +="
";
});
}
if(typeof(json.info1) != "undefined"){
html1 +=json.info1 ;
}
$(".attachment_list0").html(html0);
$(".attachment_list1").html(html1);
},
error: function(ret){
alert("Can't load your photo album");
//console.log(ret);
}
});
return false;
}
function sharePhoto(num,id_photo,elem){
a=confirm(lang_confirmShare);
if(a){
$("#transparent_bg2").hide();
$("#p_attachment").hide();
var elem=$("#chat_attachment").val();
var thisID='#'+elem;
var dest=$(thisID+' #dest_message').val();
var apiNum=$(thisID).attr("apiNum");
//var dest=$("#dest_attachment").val();
var msg="";
var id_extra="p_" + id_photo;
$.ajax({
type: "POST",
url: "app/ajax/send_message.php",
data: { dest: dest, msg: msg,id_extra: id_extra },
dataType: "json",
success: function(json) {
if( typeof(elem) != 'undefined' && elem == 'send_message2') {
display_msg_sent(thisID,apiNum,json,true);
} else {
display_msg_sent(thisID,apiNum,json,false);
}
}
});
}
}
function askShare(dest){
var msg="";
var id_extra="a0";
$.ajax({
type: "POST",
url: "app/ajax/send_message.php",
data: { dest: dest, msg: msg,id_extra: id_extra },
dataType: "json",
success: function(json) {
// console.log("La Demande de partage d'album a bien été envoyé.");
Initialise_chat_page();
// stop_timer_refresh_chats();
document.location='index.php?mod=chat_v2018&pseudo=' + dest;
}
});
}
function acceptShare(dest){
var msg="";
var id_extra="a1";
$.ajax({
type: "POST",
url: "app/ajax/send_message.php",
data: { dest: dest, msg: msg,id_extra: id_extra },
dataType: "json",
success: function(json) {
Initialise_chat_page();
// stop_timer_refresh_chats();
document.location='index.php?mod=chat_v2018&pseudo=' + dest;
}
});
}
function refuseShare(dest){
//Fonction à complèter...
var msg="";
var id_extra="a-1";
$.ajax({
type: "POST",
url: "app/ajax/send_message.php",
data: { dest: dest, msg: msg,id_extra: id_extra },
dataType: "json",
success: function(json) {
Initialise_chat_page();
// stop_timer_refresh_chats();
document.location='index.php?mod=chat_v2018&pseudo=' + dest;
}
});
}
function getPosition(e) {
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
} else if (e.clientX || e.clientY) {
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
return {x: posx,y: posy};
}
function reset_opacity_and_sessionStorage_header_ico(){
$("#h-chat-btn .msg-ico, #h-match-btn .match-ico, #h-myWall-btn .myWall-ico, #h-album-btn .album-ico, #h-votes-btn .votes-ico").each(function(){
$(this).removeClass('active');
$(this).css('opacity',0.6);
sessionStorage.setItem($(this).prop('class').split(" ")[0],'');
});
}
function hChatBtnManager(){
if( arguments[0] == 'close' ){
$('#h-chat-btn .msg-ico').removeClass('active');
$('#h-chat-btn .msg-ico').addClass('no-active');
}
else if( $('#h-chat-btn .msg-ico').hasClass('no-active'))
{
$('#h-chat-btn .msg-ico').removeClass('no-active');
$('#h-chat-btn .msg-ico').addClass('active');
sessionStorage.setItem($('#h-chat-btn .msg-ico').prop('class').split(" ")[0],'active');
}
}
function match_dislike() {
var id_target = $('#picture_to_like').data('id_target');
if( id_target > 0 ) {
$.ajax({
type: "GET",
dataType: "json",
url: "index.php",
data: "mod=match&action=set_dislike&id_user=" + id_target
});
}
match_show_next_profil();
}
function match_like() {
var id_target = $('#picture_to_like').data('id_target');
if( id_target > 0 ) {
$.ajax({
type: "GET",
dataType: "json",
url: "index.php",
data: "mod=match&action=set_like&id_user=" + id_target,
success: function(data)
{
if( data!=null && typeof(data) == 'object' && typeof(data.result) == "string" && data.result == "match" ) {
show_popup_v3({'custom': "match",
'content': lang_alert_nouveau_match,
'action': function() { window.location = lang_htMesMatch; },
'img_match': $('#picture_to_like').attr('src')});
}
match_show_next_profil();
},
error: function(){
match_show_next_profil();
}
});
}
}
function match_show_next_profil() {
var next_ok = false;
$("#game_tab #img_loader").show();
$.each(TAB_NEXT_PROFIL, function(ii, nextProfil) {
if( nextProfil!=null ) {
// alert(" next profil : " + ii + " | " + nextProfil['id'] + " | " + nextProfil['pseudo']);
$('#picture_to_like').data('id_target', nextProfil['id']);
$('#picture_to_like').removeClass('visible').removeClass('blur_light').removeClass('blur_strong').addClass( nextProfil['visibility_photo'] );
$('#picture_to_like').attr('src', nextProfil['url_photo']).load(function() {
$("#game_tab #img_loader").hide();
});
$('#btn_match_voir_album').attr('id_target', nextProfil['id']);
$("#game_tab .infos .pseudo").text(nextProfil['pseudo']);
$("#game_tab .infos .age_ville .age").text(nextProfil['age']);
$("#game_tab .infos .age_ville .zone_name").text(nextProfil['zone_name']);
next_ok = true;
TAB_NEXT_PROFIL[ii] = null;
return false;
}
});
if( next_ok == false ) {
// console.error("Plus de profil, il faut recharger .....");
$.ajax({
type: "GET",
dataType: "json",
url: "index.php",
data: "mod=match&action=get_profile&force_json=1",
success: function (data) {
TAB_NEXT_PROFIL = new Array();
if( typeof(data) == 'object' && data!=null && typeof(data.result) == 'object' ) {
$.each( data.result, function(i, objNext) {
TAB_NEXT_PROFIL[i] = new Array();
var url_photo = (typeof(objNext.photos_v2.public[1]['sq_430'])=='string' && objNext.photos_v2.public[1]['sq_430']!='') ? objNext.photos_v2.public[1]['sq_430'] : objNext.photos_v2.public[1]['sq_middle'];
var id_photo_print = 1;
$.each( objNext.photos_v2.public, function(iPhoto, sTabPhoto) {
if( sTabPhoto.visibility == 'visible' ) {
id_photo_print = iPhoto;
url_photo = (typeof(sTabPhoto.sq_430)=='string' && sTabPhoto.sq_430!='') ? sTabPhoto.sq_430 : sTabPhoto.sq_middle;
return false;
}
});
TAB_NEXT_PROFIL[i]['id'] = objNext.id;
TAB_NEXT_PROFIL[i]['pseudo'] = objNext.pseudo;
TAB_NEXT_PROFIL[i]['age'] = objNext.age;
TAB_NEXT_PROFIL[i]['zone_name'] = objNext.zone_name;
TAB_NEXT_PROFIL[i]['url_photo'] = url_photo;
TAB_NEXT_PROFIL[i]['visibility_photo'] = objNext.photos_v2.public[id_photo_print].visibility;
});
match_show_next_profil();
}
}
});
}
}
function show_popup_v3(obj_infos) {
var popup_v3 = $('#popup_v3').clone();
var left_part = $(popup_v3).find(".left-custom").find( "." + obj_infos.custom );
// console.log( $(left_part) );
$(popup_v3).find(".left-part").html( $(left_part) );
$(popup_v3).find(".content").html( obj_infos.content );
$(popup_v3).prop("id", '');
if( obj_infos.custom == "match" ) {
$(popup_v3).find(".img-match").prop('src', obj_infos.img_match)
}
$(popup_v3).unbind().click( function() {
obj_infos.action();
return false;
});
$(popup_v3).find(".icon_closed").unbind().click( function() {
$(popup_v3).remove();
return false;
});
$('#content-centered').prepend( $(popup_v3) );
}
function submit_pseudo_change(){
$("#error-txt").text("");
$.ajax({
type: "GET",
url: "app/ajax/check_pseudo.php?pseudo=" + $("#pseudo_new").val(),
dataType: "json",
success: function (json) {
if(typeof(json.pseudo_accepted) != "undefined"){
if(json.pseudo_accepted == 1){
$('#change_pseudo_form').submit();
}
else{
$("#error-txt").html(json.error);
}
}
}
});
}