function getCookie_bak(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } function setCookie_bak(c_name,value,expiredays) { console.log('setCookie()',c_name); var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } function setCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } //document.cookie = name + "=" + (value || "") + expires + "; path=/"; // Use the global variable this_top_domain to set the domain var domain = this_top_domain; //document.cookie = name + "=" + (value || "") + expires + "; path=/"; // Set the cookie with SameSite=None and Secure attributes document.cookie = name + "=" + (value || "") + expires + "; path=/; domain=" + domain + "; SameSite=None; Secure"; } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; } var lookfor_messages_every = 15000; var lookfor_messages_every2 = 5000; //var messages2_perpage=30; var messages2_addatatime=10; var ajax_pipes=new Array(); ajax_pipes[1]='faces'; ajax_pipes[2]='pm'; ajax_pipes[3]='_heartbeat_ofjoy'; ajax_pipes[4]='checkonln'; ajax_pipes[5]='hitprofile'; //ajax_pipes[6]='pm2'; ajax_pipes[7]='new_set_onlinness'; for (xol in ajax_pipes) { var joystring = 'var req' + ajax_pipes[xol] + '; function loadXMLDoc' + ajax_pipes[xol] + '(url) {if (window.XMLHttpRequest) {req' + ajax_pipes[xol] + ' = new XMLHttpRequest(); req' + ajax_pipes[xol] + '.onreadystatechange = processReqChange' + ajax_pipes[xol] + '; req' + ajax_pipes[xol] + '.open("GET", url, true); req' + ajax_pipes[xol] + '.send(null);} else if (window.ActiveXObject){req' + ajax_pipes[xol] + ' = new ActiveXObject("Microsoft.XMLHTTP"); if (req' + ajax_pipes[xol] + ') {req' + ajax_pipes[xol] + '.onreadystatechange = processReqChange' + ajax_pipes[xol] + ';req' + ajax_pipes[xol] + '.open("GET", url, true);req' + ajax_pipes[xol] + '.send();}}}'; eval(joystring); } var body_is_loaded = 0; function letusknowthatbodisloaded() { body_is_loaded = 1; } // function showtext(button_left, button_top, wanted_text, textdiv_id) // { // if(body_is_loaded == 1) // { // newdiv_innerHTML = '
 ' + wanted_text + " 
"; // newdiv_top = Math.abs(button_top) - 5; // newdiv_left = Math.abs(button_left) + 30; // pop_div(textdiv_id,"absolute",140,'none','none',newdiv_innerHTML,newdiv_top,newdiv_left,'no'); // document.getElementById(textdiv_id).onmouseout=function(){ // remove_element_by_id(textdiv_id); // } // } // } function hitprofile(u) { var urlz = "xmlhit?u=" + u; loadXMLDochitprofile(urlz); } function processReqChangehitprofile() { //do nothing... } // function putfaces(wantcode) // { // var pagewidth = screen.width; // var spacefor1face = 103; // var howmanyputfaces = Math.floor(pagewidth/spacefor1face); // var urlz = "xmlfaces?want=" + wantcode + "&boxes=" + howmanyputfaces; // loadXMLDocfaces(urlz); // } // function processReqChangefaces() // { // if (reqfaces.readyState == 4) // { // if (reqfaces.status == 200) // { // var response = reqfaces.responseXML.documentElement; // var result = response.getElementsByTagName("result")[0].firstChild.data; // if(result=='ok') // { // var resultstring = '
'; // var howmanyfaces = response.getElementsByTagName("howmanyfaces")[0].firstChild.data; // var countfaceputting = 0; // while (countfaceputting < howmanyfaces) // { // countfaceputting++; // var userID_name = "userID_" + countfaceputting; // var screen_name_name = "screen_name_" + countfaceputting; // var official_picID_name = "official_picID_" + countfaceputting; // var official_picserver_name = "official_picserver_" + countfaceputting; // var userID = response.getElementsByTagName(userID_name)[0].firstChild.data; // var screen_name = response.getElementsByTagName(screen_name_name)[0].firstChild.data; // var official_picID = response.getElementsByTagName(official_picID_name)[0].firstChild.data; // var official_picserver = response.getElementsByTagName(official_picserver_name)[0].firstChild.data; // if(official_picID == '0' || official_picserver == '') // { // var picshown = ''; // } // else // { // var picshown = ''; // } // var arrangedscreen_name = screen_name; // var lenghtofthisbuddysname = screen_name.length; // var maxwantedlenghtfornames = 15; // if(lenghtofthisbuddysname>maxwantedlenghtfornames) // { // arrangedscreen_name = '' + screen_name.substring(0,(maxwantedlenghtfornames-2)) + '...'; // } // resultstring = resultstring + ''; // } // resultstring = resultstring + '
' + picshown + '
' + arrangedscreen_name + '
'; // document.getElementById('headcase').innerHTML = resultstring; // } // } // } // } function sho_profcomp_num_div() { document.getElementById("profcomp_num_div").style.visibility="visible"; document.getElementById("profcomp_num_div1").style.visibility="visible"; document.getElementById("profcomp_num_div2").style.visibility="visible"; document.getElementById("profcomp_num_div3").style.visibility="visible"; document.getElementById("profcomp_num_div4").style.visibility="visible"; } function hide_profcomp_num_div() { document.getElementById("profcomp_num_div").style.visibility="hidden"; document.getElementById("profcomp_num_div1").style.visibility="hidden"; document.getElementById("profcomp_num_div2").style.visibility="hidden"; document.getElementById("profcomp_num_div3").style.visibility="hidden"; document.getElementById("profcomp_num_div4").style.visibility="hidden"; } var lookformessagesisre = 0; function lookformessages() { if(lookformessagesisre == 0) { lookformessages_re(); lookformessagesisre = 1; } } function lookformessages_re() { var url = "xmllookfor_pm"; loadXMLDocpm(url); var t=setTimeout("lookformessages_re()",lookfor_messages_every); } var idsofdivtoflash = new Array(); function processReqChangepm() { if (reqpm.readyState == 4) { if (reqpm.status == 200) { response = reqpm.responseXML.documentElement; var result = response.getElementsByTagName("result")[0].firstChild.data; if(result == "ok") { var totalmessages = response.getElementsByTagName("totalmessages")[0].firstChild.data; var count = 0; var finalmessagesstring=''; while(count < totalmessages) { count++; var this_message_pubid_name = "message_pubid_" + count; var this_message_screen_name_name = "message_screen_name_" + count; var this_user_gender_name = "message_gender_" + count; var this_message_ip_name = "message_ip_" + count; var this_message_pubid = response.getElementsByTagName(this_message_pubid_name)[0].firstChild.data; var this_message_screen_name = response.getElementsByTagName(this_message_screen_name_name)[0].firstChild.data; var this_user_gender = response.getElementsByTagName(this_user_gender_name)[0].firstChild.data; var this_message_ip = response.getElementsByTagName(this_message_ip_name)[0].firstChild.data; var this_message_screen_name_forshow = wordwrap(this_message_screen_name, 18, ' ', true); var gender_icon = ''; var bulle = ''; var thismessagestring = '
' + gender_icon + this_message_screen_name_forshow + bulle + '
'; finalmessagesstring = finalmessagesstring + thismessagestring; idsofdivtoflash[this_message_pubid]='blinker_' + this_message_pubid; } if(totalmessages >= 1) { finalmessagesstring = '
' + finalmessagesstring + '
'; } document.getElementById('you_got_messages').innerHTML = finalmessagesstring; for (xu in idsofdivtoflash) { startblinker(idsofdivtoflash[xu]); } } } } } function openpm(pubid,screen_name,gender,ip,embed=0) { //console.log('openpm()',pubid,screen_name,gender,ip,embed); var append_ip = ''; if(ip && ip != ''){ append_ip = '&ip=' + ip; } var append_embed = ''; if(embed==1){ append_embed = '&embed=1&multipartyporter='+multipartyporter; } var pm_windowname = 'pm_' + pubid; var gotostring = 'pm?pubid=' + pubid + '&screen_name=' + encodeURIComponent(unescape(screen_name)) + '&gender=' + gender + append_ip + append_embed; if (top.location!=self.location){ pop_url(sites_base_address+gotostring,pm_windowname,site_colors); }else{ window.open(gotostring,pm_windowname); } } var startedblinkers = new Array(); function startblinker(div_id) { if(startedblinkers[div_id]!=div_id) { startedblinkers[div_id]=div_id; var execmystring = 'blinkz("' + div_id + '")'; var t=setTimeout(execmystring,blinkspeed); } } var blinkspeed = 500; function blinkz(div_id) { var mystupid_div = document.getElementById(div_id); if(mystupid_div != null) { if(mystupid_div.style.visibility=="hidden") { mystupid_div.style.visibility="visible"; } else { mystupid_div.style.visibility="hidden"; } var execmystring = 'blinkz("' + div_id + '")'; var t=setTimeout(execmystring,blinkspeed); } } function wordwrap( str, int_width, str_break, cut ) { // http://kevin.vanzonneveld.net // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + improved by: Nick Callen // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Sakimori // * example 1: wordwrap('Kevin van Zonneveld', 6, '|', true); // * returns 1: 'Kevin |van |Zonnev|eld' // * example 2: wordwrap('The quick brown fox jumped over the lazy dog.', 20, '
\n'); // * returns 2: 'The quick brown fox
\njumped over the lazy
\n dog.' // * example 3: wordwrap('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'); // * returns 3: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod \ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim \nveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea \ncommodo consequat.' // PHP Defaults var m = ((arguments.length >= 2) ? arguments[1] : 75 ); var b = ((arguments.length >= 3) ? arguments[2] : "\n" ); var c = ((arguments.length >= 4) ? arguments[3] : false); var i, j, l, s, r; str += ''; if (m < 1) { return str; } for (i = -1, l = (r = str.split("\n")).length; ++i < l; r[i] += s) { for(s = r[i], r[i] = ""; s.length > m; r[i] += s.slice(0, j) + ((s = s.slice(j)).length ? b : "")){ j = c == 2 || (j = s.slice(0, m + 1).match(/\S*(\s)?$/))[1] ? m : j.input.length - j[0].length || c == 1 && m || j.input.length + (j = s.slice(m).match(/^\S*/)).input.length; } } return r.join("\n"); } var heartbeetfreq = 10000; var restarted = 0; function send_heartbeat_ofjoy() { if(restarted == 0) { send_heartbeat_ofjoy_re(); restarted = 1; } } function send_heartbeat_ofjoy_re() { var url = "xmlheartbeat_ofjoy"; loadXMLDoc_heartbeat_ofjoy(url); var t=setTimeout("send_heartbeat_ofjoy_re()",heartbeetfreq); } function processReqChange_heartbeat_ofjoy() { //do nothing } // var checkfreq = 10000; // function set_onlinness(u_or_g,persons_numba,initial_on_or_off,screen_name,gender,showbubbleornot) // { // display_onlinness(u_or_g,persons_numba,screen_name,initial_on_or_off,gender,showbubbleornot) // var recallexrpss = "doonlinnesscheck('" + u_or_g + "','" + persons_numba + "','" + initial_on_or_off + "','" + escape(screen_name) + "','" + gender + "','" + showbubbleornot + "')"; // var gofortimewait = Math.ceil((Math.random() * 2) * checkfreq); // var t=setTimeout(recallexrpss,gofortimewait); // } // function doonlinnesscheck(u_or_g,persons_numba,initial_on_or_off,screen_name,gender,showbubbleornot) // { // var url = "xmlcheckifon?uorg=" + u_or_g + "&pn=" + persons_numba + "&sn=" + encodeURIComponent(unescape(screen_name)) + "&gen=" + gender + "&sb=" + showbubbleornot; // loadXMLDoccheckonln(url); // var recallexrpss = "doonlinnesscheck('" + u_or_g + "','" + persons_numba + "','" + initial_on_or_off + "','" + screen_name + "','" + gender + "','" + showbubbleornot + "')"; // var gofortimewait = Math.ceil((Math.random() * 2) * checkfreq); // var t=setTimeout(recallexrpss,gofortimewait); // } // function processReqChangecheckonln() // { // if (reqcheckonln.readyState == 4) // { // if (reqcheckonln.status == 200) // { // response = reqcheckonln.responseXML.documentElement; // var result = response.getElementsByTagName("result")[0].firstChild.data; // if(result == "ok") // { // var u_or_g = response.getElementsByTagName("u_or_g")[0].firstChild.data; // var persons_numba = response.getElementsByTagName("persons_numba")[0].firstChild.data; // var screen_name = response.getElementsByTagName("screen_name")[0].firstChild.data; // var gen = response.getElementsByTagName("gen")[0].firstChild.data; // var sb = response.getElementsByTagName("sb")[0].firstChild.data; // var state = response.getElementsByTagName("state")[0].firstChild.data; // display_onlinness(u_or_g,persons_numba,screen_name,state,gen,sb); // } // } // } // } // function display_onlinness(u_or_g,persons_numba,screen_name,on_or_off,gender,showbubbleornot) // { // shoscreen_name = unescape(screen_name); // var picname; // var word; // var showonliner; // if(on_or_off=='on') // { // picname = 'online.png'; // word = 'online'; // showonliner = '' + word; // } // else if(on_or_off=='off') // { // picname = 'offline.png'; // word = 'offline'; // showonliner = ''; // } // var bubblestring = ''; // if(showbubbleornot==1 && on_or_off=='on') // { // var goforpubid = u_or_g + '_' + persons_numba; // bubblestring = ' | PM send instant message'; // } // var rezu_string = showonliner + bubblestring; // var idofdivtodispl = 'onliner_' + u_or_g + '_' + persons_numba; // document.getElementById(idofdivtodispl).innerHTML = rezu_string; // } // function check_prereg_form() // { // var goodpic = ''; // var badpic = ''; // document.getElementById("rezu_gender").innerHTML = ""; // var errors = 0 // var currentgender = document.getElementById("gender").value; // if(currentgender == "man" || currentgender == "woman" || currentgender == "couple_man_and_woman" || currentgender == "couple_2_man" || currentgender == "couple_2_woman" || currentgender == "group" || currentgender == "ts_tv_tg") // { // document.getElementById("rezu_gender").innerHTML = goodpic; // } // else // { // errors++; // document.getElementById("rezu_gender").innerHTML = badpic; // } // var screen_name = document.getElementById("screen_name").value; // var screen_name_length = screen_name.length; // if(screen_name_length<2) // { // errors++; // document.getElementById("rezu_screen_name").innerHTML = badpic + " too short"; // } // else // { // if(nameisavailable!="ok") // { // errors++; // document.getElementById("rezu_screen_name").innerHTML = badpic + " this name is taken"; // } // } // var about_me = document.getElementById("about_me").value; // var about_me_length = about_me.length; // if(about_me_length<10) // { // errors++; // document.getElementById("rezu_about_me").innerHTML = badpic + " too short"; // } // else // { // document.getElementById("rezu_about_me").innerHTML = goodpic; // } // var currentbd_d = document.getElementById("bd_d").value; // if(currentbd_d == "?") // { // errors++; // document.getElementById("rezu_bd_d").innerHTML = badpic; // } // else // { // document.getElementById("rezu_bd_d").innerHTML = goodpic; // } // var currentbd_m = document.getElementById("bd_m").value; // if(currentbd_m == "?") // { // errors++; // document.getElementById("rezu_bd_m").innerHTML = badpic; // } // else // { // document.getElementById("rezu_bd_m").innerHTML = goodpic; // } // var currentbd_y = document.getElementById("bd_y").value; // if(currentbd_y < 2010 && currentbd_y > 1800) // { // document.getElementById("rezu_bd_y").innerHTML = goodpic; // } // else // { // errors++; // document.getElementById("rezu_bd_y").innerHTML = badpic; // } // if(errors>=1) // { // return false; // } // else // { // setCookie('invite_message',prereg_invite_message,50) // } // } // var globaltheme = 'nabolister'; // function set_thatheme(setted_theeme) // { // globaltheme = setted_theeme; // } // function pop_prereg_form() // { // if(body_is_loaded == 1) // { // do_pop_prereg(); // } // else // { // var t=setTimeout("do_pop_prereg()",2000); // } // } // var browser=navigator.appName; // var fade_level = 0; // var prereg_invite_message = ''; // function do_pop_prereg() // { // // if(mycity=='') // // {var saylocation="in your area";} // // else // // {var saylocation="in " + mycity;} // // // // var refereee_cookivalu = getCookie("refereee"); // // var prereg_invite_messages_array=new Array(); // // // // prereg_invite_messages_array[0] = 'Meet some people in ' + saylocation + ', 100% Free:'; // // if(refereee_cookivalu=="yassarafat") // // { // // //prereg_invite_messages_array[28] = 'Meet some people to watch movies with ' + saylocation + ' :P'; // // } // // // // // // var chosen_message_key = Math.floor(Math.random()*prereg_invite_messages_array.length); // // prereg_invite_message = prereg_invite_messages_array[chosen_message_key]; // var prereg_invite_message = "Create your account now:"; // //var maxmind = '
This product includes GeoLite data created by MaxMind, available from maxmind.com.
'; // var maxmind = ''; // var theformitself = '
' + // '

choose a name: (or login)

' + // '

tell us a little something about yourself:

' + // '

what is your gender?

i am/we are a:
' + // '

how old are you?

my birth date is:
day
month
year
' + // '' + // '*you must be 18 years of age or older.' + // '
Go
Go
' + maxmind + '
'; // var theformitself = '
' + // 'i am/we are a:

' + // 'my birth date is:
day
month
year
' + // '' + // '
a man
'+ // 'a woman
'+ // 'a couple (man and woman)
'+ // 'a couple (2 men)
'+ // 'a couple (2 women)
'+ // 'a group
'+ // 'ts/tv/tg
'+ // '
'+ // 'from years old
'+ // 'to years old
'+ // '
'+ // 'friends
'+ // '
' + // '

username: (or login)

' + // ''+ // ''+ // ''+ // '
Go
Go
' + maxmind + '
'; // var closediv = '
[x]
'; // var headerdiv = '
' + prereg_invite_message + '
'; // var formdiv = '
' + closediv + '
' + headerdiv + theformitself + '
'; // var thing_top = 200; // var thing_left = 240; // var form_html = '
 
' + // '
' + // '
' + formdiv + '
'; // if(document.getElementById('prereg_form_div')==null) // { // pop_div("prereg_form_div","absolute",140,'none','none',form_html,0,0,'no'); // } // else // { // document.getElementById('prereg_form_div').innerHTML = form_html; // } // //alert(browser); // //set opa to 0 and kickin fadein // fade_level = 0; // if(browser=="Microsoft Internet Explorer") // { // //document.getElementById('prereg_form_div').style.filter = 'Alpha(Opacity=50)'; // } // else // { // document.getElementById('prereg_form_div').style.opacity=0; // } // fade_in_prereg_windo(); // } // function fade_in_prereg_windo() // { // if(fade_level<1) // { // fade_level = fade_level + 0.1; // ie_fade_level = fade_level * 100; // if(browser=="Microsoft Internet Explorer") // { // //document.getElementById('prereg_form_div').style.filter = 'alpha(opacity='+ie_fade_level+')'; // } // else // { // document.getElementById('prereg_form_div').style.opacity=fade_level; // } // var to=setTimeout("fade_in_prereg_windo()",100); // } // } // function close_prereg() // { // var oldelem = document.getElementById('prereg_form_div'); // if(oldelem != null) // { // oldelem.innerHTML = ""; // //document.body.removeChild(oldelem); // var ti=setTimeout("pop_prereg_form()",60000); // } // } function findPosX(obj) { var curleft = 0; if(obj.offsetParent) while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.x) curleft += obj.x; return curleft; } function findPosY(obj) { var curtop = 0; if(obj.offsetParent) while(1) { curtop += obj.offsetTop; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.y) curtop += obj.y; return curtop; } function urlencode(str) { return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40'); } function urldecode(str) { return unescape(str.replace('+', ' ')); } function remove_element_by_id(element_id) { var oldelem = document.getElementById(element_id); oldelem.innerHTML = ''; document.body.removeChild(oldelem); } function pop_div(newdiv_id,newdiv_position,newdiv_zIndex,newdiv_width,newdiv_height,newdiv_innerHTML,newdiv_top,newdiv_left,makedraggable) { var newdiv = document.createElement("div"); newdiv.setAttribute("id",newdiv_id); document.body.appendChild(newdiv); newdiv.style.position = newdiv_position; newdiv.style.zIndex = newdiv_zIndex; if(newdiv_width!='none') { newdiv.style.width = newdiv_width + "px"; } if(newdiv_height!='none') { newdiv.style.height = newdiv_height + "px"; } newdiv.innerHTML = newdiv_innerHTML; newdiv.style.top = newdiv_top + "px"; newdiv.style.left = newdiv_left + "px"; if(makedraggable=='yes') { makeDraggable(newdiv); } } function makeDraggable(item){$(item).draggable()} var blink_memory = new Array(); function blink_newmess_num(id) //launcher { if(!blink_memory[id] || blink_memory[id]=='stopped') {do_blink_mess(id);} } function do_blink_mess(id) { var thisnumelem=document.getElementById(id); if(thisnumelem==null) {blink_memory[id]='stopped';} else { if(blink_memory[id]!='hidden') {blink_memory[id]='hidden';} else {blink_memory[id]='visible';} thisnumelem.style.visibility=blink_memory[id]; t=setTimeout("do_blink_mess('"+id+"')",1500); } } //var soundbox = document.createElement("div"); //soundbox.innerHMLT = ''; function playsound(soundname) { if(sound_on_or_off=='on') { var elsound = new Audio("/sounds/"+soundname); elsound.play(); } } var sound_on_or_off='on'; function togglesound() { //var togglesound_button=document.getElementById("togglesound_button"); var togglesound_icon=document.getElementById("sound-control-icon"); var togglesound_icon_i = togglesound_icon.getElementsByTagName("i")[0]; if(sound_on_or_off=='on') { sound_on_or_off='off'; //togglesound_button.className='soundcontrol soundoff'; //togglesound_button.className='soundcontrol soundoff fa fa-volume-off'; togglesound_icon_i.className='fa fa-volume-mute'; togglesound_icon_i.style.color='gray'; togglesound_icon_i.title='Chat sounds: off'; setCookie('soundcontrol','off',365); showMiniChatSoundsPopup("Chat sounds: off"); } else { sound_on_or_off='on'; //togglesound_button.className='soundcontrol soundon'; //togglesound_button.className='soundcontrol soundon fa fa-volume-up'; togglesound_icon_i.className='fa fa-volume-up'; togglesound_icon_i.style.color='green'; togglesound_icon_i.title='Chat sounds: on'; setCookie('soundcontrol','on',365); showMiniChatSoundsPopup("Chat sounds: on"); } } var cookie_soundcontrol=getCookie('soundcontrol'); if(cookie_soundcontrol=='off') {sound_on_or_off='off';} /** * Show a mini popup near the sound-control-icon. * @param {string} message - The message to display in the popup. */ function showMiniChatSoundsPopup(message) { var soundControlIcon = document.getElementById("sound-control-icon"); var popup = document.createElement("div"); popup.className = "mini-chatsounds-popup"; popup.innerText = message; // Position the popup near the sound-control-icon var rect = soundControlIcon.getBoundingClientRect(); popup.style.position = "absolute"; popup.style.top = rect.top + window.scrollY + 30 + "px"; // Adjust position above the icon popup.style.left = rect.left + window.scrollX + "px"; // Add the popup to the body document.body.appendChild(popup); // Remove the popup after 2 seconds setTimeout(function () { popup.remove(); }, 2000); } //-----------------private messages view--------------------------// //--------this powers messages view in 2 different headers--------// //--------normal header, and embed chatroom header----------------// var lookformessagesisre2 = 0; function lookformessages2(embed=0) { if(lookformessagesisre2 == 0) { lookformessages_re2(embed); lookformessagesisre2 = 1; } } var lookformessages_re2_timeout; function lookformessages_re2(embed=0) { var append_embed = ''; if(embed==1){ append_embed = '?embed=1&multipartyporter='+multipartyporter; } //var url = "xmllookfor_pm2?perpage="+messages2_perpage; var url = "xmllookfor_pm2"+append_embed; //window.open(url); loadXMLDocpm2(url,embed); lookformessages_re2_timeout=setTimeout(function(){lookformessages_re2(embed);},lookfor_messages_every2); } var reqpm2; function loadXMLDocpm2(url,embed=0) { if (window.XMLHttpRequest) { reqpm2 = new XMLHttpRequest(); //reqpm2.onreadystatechange = processReqChangepm2; reqpm2.onreadystatechange = (event) => {processReqChangepm2(embed)}; reqpm2.open("GET", url, true); reqpm2.send(null); } else if (window.ActiveXObject){ reqpm2 = new ActiveXObject("Microsoft.XMLHTTP"); if (reqpm2) { //reqpm2.onreadystatechange = processReqChangepm2; reqpm2.onreadystatechange = (event) => {processReqChangepm2(embed)}; reqpm2.open("GET", url, true); reqpm2.send(); } } } var totalnewmessages=0; var totalnewmenunotifications=0; var totalyesnomaybenotifications=0; var originaltitle=document.title; function set_title() { var respNewMess=document.getElementById("respNewMess"); if(totalnewmessages==0) { if(document.title!=originaltitle){document.title=originaltitle;} if(respNewMess!=null){respNewMess.innerHTML="";} } else { if(document.title=='...' || document.title==originaltitle) { var messagesS='s'; if(totalnewmessages==1) {messagesS='';} document.title='('+totalnewmessages+') new message'+messagesS; var unseens="
"+ ""+ "
"+totalnewmessages+"
"+ "
"; if(respNewMess!=null){respNewMess.innerHTML=unseens;} } else { document.title='...'; if(respNewMess!=null){respNewMess.innerHTML="";} } } var respMenuNotif=document.getElementById("respMenuNotif"); if(totalnewmenunotifications==0){ if(respMenuNotif!=null){ respMenuNotif.innerHTML=""; } }else{ if(respMenuNotif.innerHTML==''){ var unseens="
"+ ""+ "
"+totalnewmenunotifications+"
"+ "
"; if(respMenuNotif!=null){ respMenuNotif.innerHTML=unseens; } }else{ if(respMenuNotif!=null){ respMenuNotif.innerHTML=""; } } } var respYNMNotif=document.getElementById("respYNMNotif"); if(totalyesnomaybenotifications==0){ if(respYNMNotif!=null){ respYNMNotif.innerHTML=""; } }else{ if(respYNMNotif.innerHTML==''){ var unseens="
"+ ""+ "
"+totalyesnomaybenotifications+"
"+ "
"; if(respYNMNotif!=null){ respYNMNotif.innerHTML=unseens; } }else{ if(respYNMNotif!=null){ respYNMNotif.innerHTML=""; } } } t=setTimeout("set_title()",1500); } set_title(); //investigate why this is always running!: Normal, it checks new messages numbers and make the tab text flash accordingly!! var last_the_post_message = null; function processReqChangepm2(embed=0) { if (reqpm2.readyState == 4) { if (reqpm2.status == 200) { response = reqpm2.responseXML.documentElement; var result = response.getElementsByTagName("result")[0].firstChild.data; if(result == "ok") { var totalmessages = response.getElementsByTagName("totalmessages")[0].firstChild.data; var countnewmessages = 0; var thereismore = response.getElementsByTagName("thereismore")[0].firstChild.data; var beepfornew = response.getElementsByTagName("beepfornew")[0].firstChild.data; var count = 0; var finalmessagesstring=''; var todisplay_onlinness = new Array; let is_talking_to_you_array = new Array; while(count < totalmessages) { count++; var this_message_pubid = response.getElementsByTagName("message_pubid_" + count)[0].firstChild.data; var this_last_message_time = response.getElementsByTagName("last_message_time_" + count)[0].firstChild.data; var this_howmanynew = Math.abs(response.getElementsByTagName("howmanynew_" + count)[0].firstChild.data); countnewmessages+=this_howmanynew; //var this_message_seen_ornot = response.getElementsByTagName("message_seen_ornot_" + count)[0].firstChild.data; var this_message_start = response.getElementsByTagName("message_start_" + count)[0].firstChild.data; var this_u_or_g=this_message_pubid.substr(0,1); var this_userID=this_message_pubid.substr(2); //var this_screen_name = response.getElementsByTagName("screen_name_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; //var this_gender = response.getElementsByTagName("gender_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; //var this_official_picID = response.getElementsByTagName("official_picID_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; //var this_official_picserver = response.getElementsByTagName("official_picserver_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; var this_screen_name; var this_user_pic; var screen_name_tag=response.getElementsByTagName("screen_name_" + this_u_or_g + "_" + this_userID)[0]; let icon_badge; if(typeof screen_name_tag!="undefined" && screen_name_tag!=null) { //alert(typeof screen_name_tag); this_screen_name=screen_name_tag.firstChild.data; var this_gender = response.getElementsByTagName("gender_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; var this_official_picID = response.getElementsByTagName("official_picID_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; var this_official_picserver = response.getElementsByTagName("official_picserver_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; var this_online = response.getElementsByTagName("online_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; if(this_u_or_g=='u'){ var this_phone_number_validated = response.getElementsByTagName("phone_number_validated_" + this_u_or_g + "_" + this_userID)[0].firstChild.data; if(this_phone_number_validated==1){ icon_badge = icon_badges_for_javascript['verified_user']; }else{ icon_badge = icon_badges_for_javascript['user']; } }else if(this_u_or_g=='g'){ icon_badge = icon_badges_for_javascript['guest']; }else if(this_u_or_g=='e'){ icon_badge = icon_badges_for_javascript['embed_chatroom_user']; } if(this_official_picID==0) {this_user_pic="https://"+this_top_domain+"/new_pics/nopicface2_"+this_gender+".png";} else {this_user_pic="https://"+this_official_picserver+"."+this_top_domain+"/thumbs/"+this_official_picID+"_thumb.jpg";} set_onlinness_array[this_message_pubid]="yes"; todisplay_onlinness[this_message_pubid]=this_online; } else { if(this_u_or_g=='u') {this_screen_name="deleted user"} else {this_screen_name="deleted guest"} this_user_pic="https://"+this_top_domain+"/new_pics/nopicface2_unknown.png"; this_online='off'; icon_badge=''; } var unseens = ""; let unseens_id="unseens_"+this_message_pubid; if(this_howmanynew>0) { var visibility_clause=''; if(blink_memory[unseens_id]) {visibility_clause='visibility:'+blink_memory[unseens_id]+';';} //visibility_clause='visibility:hidden;'; //unseens=" 
"+this_howmanynew+"
"; unseens="
"+ ""+ "
"+this_howmanynew+"
"+ "
"; setTimeout("blink_newmess_num('"+unseens_id+"')",(Math.random()*1000)+1); } //var bgnum = (count%2)+1; //reverse that.. var bgnum = ((count-1)%2)+1; let rembed_forlink = ''; let target_for_link = ''; if(embed==1){ rembed_forlink = '&embed=1&multipartyporter='+multipartyporter; target_for_link = ' target="_blank"'; } let this_pm_url = "https://"+this_top_domain+"/pm?pubid="+this_message_pubid+rembed_forlink let this_pm_href = " href=\""+this_pm_url+"\""+target_for_link+""; if (top.location!=self.location){ this_pm_href = ' onclick="pop_url(\''+this_pm_url+'\',\'pm_'+this_message_pubid+'\',site_colors)" style="cursor:pointer;"'; } //chat bubble + pic let chat_bubble_and_pic = "
"+ //user_pic ""+ //chat bubble "\"PM\""+ //online light "
"+ //unseens "
"+unseens+"
"+ "
"; let display_last_message_time = maketimus(this_last_message_time); finalmessagesstring += ""+ ""+ ""+ "
"+ chat_bubble_and_pic + ""+ "
"+ //persons name //""+this_screen_name+""+ icon_badge+" "+this_screen_name+""+ "
"+ //last message start "
"+this_message_start+"
"+ "
"+ //last message time "
"+display_last_message_time+"
"+ "
"+ "
"+ "
"; let is_talking_to_you_data = { message_pubid: this_message_pubid, screen_name: this_screen_name, gender: this_gender, user_pic: this_user_pic, pm_url: this_pm_url, online: this_online, howmanynew: this_howmanynew, //eliminate this from this data //to allow cache to work //rebuild on the other side instead form data //chat_bubble_and_pic: chat_bubble_and_pic, message_start: this_message_start, last_message_time: display_last_message_time, unseens_id: unseens_id, target_for_link: target_for_link, top_domain: this_top_domain, sitename: this_sitename, site_colors: site_colors }; is_talking_to_you_array.push(is_talking_to_you_data); } if(thereismore==1) { //finalmessagesstring += ""; let link_href = "href=\"/history\""; if(embed==1){ let this_history_url = "https://"+this_top_domain+"/history?embed=1&multipartyporter="+multipartyporter; link_href = 'onclick="pop_url(\''+this_history_url+'\',\'history\',site_colors);return false;" style="cursor:pointer;"'; } finalmessagesstring += "
messages history
"; } if(count==0) {finalmessagesstring+="no messages yet...";} if (document.querySelector('#conversations_overview_box')){ document.getElementById("conversations_overview_box").innerHTML = finalmessagesstring; } for(x in todisplay_onlinness) {new_display_onlinness(x,todisplay_onlinness[x]);} totalnewmessages=countnewmessages; if(beepfornew==1) {playsound("newmessage.wav");} //now if embed, send is_talking_to_you_array via postMessage if (top.location!=self.location){ //console.log('is framed! might send is_talking_to_you_array via postMessage'); let the_post_message = { type: "is_talking_to_you", is_talking_to_you_array: is_talking_to_you_array }; //console.log('the_post_message',the_post_message); the_post_message = JSON.stringify(the_post_message); if(the_post_message==last_the_post_message){ //console.log('data has not changed, not sending'); }else{ //console.log('data has changed, sending!!'); //console.log('the_post_message',the_post_message) //console.log('last_the_post_message',last_the_post_message); window.parent.postMessage(the_post_message, '*'); last_the_post_message = the_post_message; } } //menu_notification_count let menu_notifications_enabled = response.getElementsByTagName("menu_notifications_enabled")[0].firstChild.data; if(menu_notifications_enabled==1){ let amount_of_unseen_their_yes_answers = response.getElementsByTagName("amount_of_unseen_their_yes_answers")[0].firstChild.data; let amount_of_unseen_matches = response.getElementsByTagName("amount_of_unseen_matches")[0].firstChild.data; let yesnomaybe_total_unseen = response.getElementsByTagName("yesnomaybe_total_unseen")[0].firstChild.data; let menu_notification_count = response.getElementsByTagName("menu_notification_count")[0].firstChild.data; totalnewmenunotifications = menu_notification_count; totalyesnomaybenotifications = yesnomaybe_total_unseen; } } } } } function pop_url(url,id,site_colors){ console.log('pop_url(url,id,site_colors)','url',url,'id',id,'site_colors',site_colors); let the_post_message = { type: "pop_url", data: { url: url, id: id, site_colors: site_colors } }; the_post_message = JSON.stringify(the_post_message); window.parent.postMessage(the_post_message, '*'); } // function addmoremessages() // { // clearInterval(lookformessages_re2_timeout); // messages2_perpage+=messages2_addatatime; // lookformessages_re2(); // } //----------end of private messages view-----------------// function maketimus(timestampz) { var linktime = new Date(timestampz * 1000); var linkday = linktime.getDate(); var freakingmonths=new Array(); freakingmonths[0]="jan"; freakingmonths[1]="feb"; freakingmonths[2]="mar"; freakingmonths[3]="apr"; freakingmonths[4]="may"; freakingmonths[5]="jun"; freakingmonths[6]="jul"; freakingmonths[7]="aug"; freakingmonths[8]="sep"; freakingmonths[9]="oct"; freakingmonths[10]="nov"; freakingmonths[11]="dec"; var linkmonthnum = linktime.getMonth(); var linkmonth = freakingmonths[linkmonthnum]; var linkyear = linktime.getFullYear(); var linkhour = linktime.getHours(); var linkminute = linktime.getMinutes(); if (linkminute < 10) {linkminute = "0" + linkminute;} var fomratedtime = linkday + linkmonth + linkyear + " " + linkhour + ":" + linkminute + "h"; return fomratedtime; } function toggle_save_search() { var saved_searchdiv = $("#saved_search_name_box"); var input = $('#saved_search_name'); var text = $('#saved_search_name_text').val(); if($('#saved_search_checkbox').is(":checked")) { input.val(text); saved_searchdiv.show(500); } else { input.val(""); saved_searchdiv.hide(500); } } function update_saved_search_name() { var input = $('#saved_search_name'); var text = $('#saved_search_name_text').val(); input.val(text); } function toggle_advanced() { var advanceddiv = $("#advanced_search_parameters"); var xpandbuttz=$("#advanced_search_parameters_xpandbuttz"); var input=$("#advanced_search_input"); if(advanceddiv.is(":hidden")) { xpandbuttz.html(""); input.val("on"); } else { xpandbuttz.html(""); input.val("off"); } advanceddiv.toggle(500); } function toggle_search_options() { var advanceddiv = $("#search_options"); var xpandbuttz=$("#search_options_xpandbuttz"); var input=$("#search_options_input"); if(advanceddiv.is(":hidden")) { xpandbuttz.html(""); input.val("on"); } else { xpandbuttz.html(""); input.val("off"); } advanceddiv.toggle(500); } function toggle_classquestio(question_name) { var advanceddiv = $("#classquestio_"+question_name); var xpandbuttz=$("#classquestio_input_"+question_name+"_xpandbuttz"); var input=$("#classquestio_input_"+question_name); if(advanceddiv.is(":hidden")) { xpandbuttz.html(""); classquestio_setval(question_name); } else { xpandbuttz.html(""); input.val("none"); } advanceddiv.toggle(500); } function classquestio_setval(question_name) { var checkstring="checkbox_"+question_name+"_"; var checkstringlen=checkstring.length; var allinputs=document.getElementsByTagName("input"); var resultz=new Array(); var alreadyseen=new Array(); var countchecked=0; var countunchecked=0; for(x in allinputs) { if(allinputs[x]!=null && allinputs[x].id!=null) { if(!alreadyseen[allinputs[x].id]) { alreadyseen[allinputs[x].id]='seen'; if(allinputs[x].id.indexOf(checkstring)!=-1) { var thisvalue = allinputs[x].id.substr(checkstringlen); if(allinputs[x].checked) { resultz.push(thisvalue); countchecked++; } else {countunchecked++;} } } } } if(countchecked==0) {finalrezult='none';} else if(countunchecked==0) {finalrezult='all';} else {finalrezult=resultz.join(",");} var input=$("#classquestio_input_"+question_name); input.val(finalrezult); } function writein_saved_searches(toggleafter) { $.get('saved_searches',function(data){ var buildstring = ''; var totalinpage=Math.abs($(data).find('totalinpage').text()); if(totalinpage==0) {buildstring='you have no saved searches';} else { $(data).find('saved_search').each(function(){ var $node = $(this); var ID = $node.find('searchID').text(); var name = $node.find('name').text(); var data = $node.find('data').text(); var time = $node.find('time').text(); buildstring+=''+name+'('+maketimus(time)+')x
'; }); } $('#saved_searches_box').html(buildstring); if(toggleafter=='yes') {$('#saved_searches_box').toggle(500);} }); } function toggle_saved_searches() { var donot_toggle=0; var saved_searches_box=$('#saved_searches_box'); var saved_searches_xpandbuttz=$('#saved_searches_xpandbuttz'); if(saved_searches_box.is(":hidden")) { saved_searches_xpandbuttz.html(""); if(saved_searches_box.html()=='') { donot_toggle=1; writein_saved_searches('yes'); } } else {saved_searches_xpandbuttz.html("");} if(donot_toggle==0) {saved_searches_box.toggle(500);} } function erase_saved_search(ID,name,time) { var r=confirm("Are you sure that you want to erased the saved search named "+name+" from "+maketimus(time)) if (r==true) { $.get('erase_saved_search?searchID='+ID,function(data){ var resultzz=$(data).find('resultzz').text(); if(resultzz=='ok') {writein_saved_searches();} }); } } function toggleLeftDiv(){ var theDiv=document.getElementById("leftDiv"); var theDiv2=document.getElementById("rightDiv"); var theDiv_container=document.getElementById("leftDiv_container"); var theDiv2_container=document.getElementById("rightDiv_container"); var theToggle=document.getElementById("toggleLeftDiv"); var theToggle2=document.getElementById("toggleRightDiv"); var theIcon = theToggle.querySelector("i"); // if(theDiv.style.display!="block"){ // theDiv.style.display="block"; // theDiv2.style.display="none"; // }else{ // theDiv.style.display="none"; // } // if(theDiv.style.width!="100%"){ // theDiv.style.width="100%"; // theDiv2.style.width="0"; // }else{ // theDiv.style.width="0"; // } if(theDiv.style.left!="0" && theDiv.style.left!="0px" && theDiv.style.left!="0%"){ //console.log('showing left div'); theDiv.style.left="0"; theDiv_container.style.width="240px"; theDiv2.style.right="-240px"; theDiv2_container.style.width="0"; theToggle.className = theToggle.className + " toggleActive"; theToggle2.className = theToggle.className.replace(/toggleActive/g,''); // Rotate the hamburger icon theIcon.style.transition = "transform 0.3s ease"; theIcon.style.transform = "rotate(90deg)"; // Scroll page to the top of the left div theDiv.scrollIntoView({ behavior: 'smooth', block: 'start' }); // Add event listener to close the div when clicking outside document.addEventListener('click', closeLeftDivOnClickOutside); }else{ //console.log('hiding left div'); theDiv.style.left="-240px"; theDiv_container.style.width="0"; theToggle.className = theToggle.className.replace(/toggleActive/g,''); // Rotate the hamburger icon back theIcon.style.transition = "transform 0.3s ease"; theIcon.style.transform = "rotate(0deg)"; // Remove event listener document.removeEventListener('click', closeLeftDivOnClickOutside); } } function closeLeftDivOnClickOutside(event) { var theDiv = document.getElementById("leftDiv"); var theToggle = document.getElementById("toggleLeftDiv"); var theIcon = theToggle.querySelector("i"); if (!theDiv.contains(event.target) && !theToggle.contains(event.target)) { // Hiding left div theDiv.style.left = "-240px"; document.getElementById("leftDiv_container").style.width = "0"; theToggle.className = theToggle.className.replace(/toggleActive/g, ''); // Rotate the hamburger icon back theIcon.style.transition = "transform 0.3s ease"; theIcon.style.transform = "rotate(0deg)"; // Remove event listener document.removeEventListener('click', closeLeftDivOnClickOutside); } } function toggleRightDiv(){ var theDiv=document.getElementById("rightDiv"); var theDiv2=document.getElementById("leftDiv"); var theDiv_container=document.getElementById("rightDiv_container"); var theDiv2_container=document.getElementById("leftDiv_container"); var theToggle=document.getElementById("toggleRightDiv"); var theToggle2=document.getElementById("toggleLeftDiv"); var theIcon = theToggle.querySelector("i"); // if(theDiv.style.display!="block"){ // theDiv.style.display="block"; // theDiv2.style.display="none"; // }else{ // theDiv.style.display="none"; // } // if(theDiv.style.width!="100%"){ // theDiv.style.width="100%"; // theDiv2.style.width="0"; // }else{ // theDiv.style.width="0"; // } if(theDiv.style.right!="0" && theDiv.style.right!="0px" && theDiv.style.right!="0%"){ //console.log('showing right div'); theDiv.style.right="0"; theDiv_container.style.width="240px"; theDiv2.style.left="-240px"; theDiv2_container.style.width="0"; theToggle.className = theToggle.className + " toggleActive"; theToggle2.className = theToggle.className.replace(/toggleActive/g,''); // Rotate the hamburger icon theIcon.style.transition = "transform 0.3s ease"; theIcon.style.transform = "rotate(-90deg)"; // Scroll page to the top of the left div theDiv.scrollIntoView({ behavior: 'smooth', block: 'start' }); // Add event listener to close the div when clicking outside document.addEventListener('click', closeRightDivOnClickOutside); }else{ //console.log('hiding right div'); theDiv.style.right="-240px"; theDiv_container.style.width="0"; theToggle.className = theToggle.className.replace(/toggleActive/g,''); // Rotate the hamburger icon back theIcon.style.transition = "transform 0.3s ease"; theIcon.style.transform = "rotate(0deg)"; // Remove event listener document.removeEventListener('click', closeRightDivOnClickOutside); } } function closeRightDivOnClickOutside(event) { var theDiv = document.getElementById("rightDiv"); var theToggle = document.getElementById("toggleRightDiv"); var theIcon = theToggle.querySelector("i"); if (!theDiv.contains(event.target) && !theToggle.contains(event.target)) { // Hiding right div theDiv.style.right = "-240px"; document.getElementById("rightDiv_container").style.width = "0"; theToggle.className = theToggle.className.replace(/toggleActive/g, ''); // Rotate the hamburger icon back theIcon.style.transition = "transform 0.3s ease"; theIcon.style.transform = "rotate(0deg)"; // Remove event listener document.removeEventListener('click', closeRightDivOnClickOutside); } } function popup_ask_for_info(session_gender,searcher_want_array,user_pics_arg,session_user_id){ //console.log('popup_ask_for_info()',session_gender,searcher_want_array,session_user_id); let has_gender = (session_gender=='unknown' || session_gender=='')?false:true; let want_something = false; for (const [key, value] of Object.entries(searcher_want_array)) { //console.log(key,value); if(value==1){ want_something = true; break; } } let has_pics = false; if( (user_pics_arg['mypicamount_withnudity']>0 && user_pics_arg['nudity']!='disallow') || user_pics_arg['mypicamount']>0 ){ has_pics = true; } if(!has_gender){ //ask for gender popup setTimeout(function(){popup_ask_for_gender();},askforinfo_times['gender']*1000); }else if(!want_something){ //ask for want stuff popup setTimeout(function(){popup_ask_for_want();},askforinfo_times['want']*1000); }else if(!has_pics){ //ask for pic! setTimeout(function(){popup_ask_for_pic();},askforinfo_times['pic']*1000); }else if(!session_user_id){ //ask for email to retrieve account setTimeout(function(){popup_ask_for_email();},askforinfo_times['email']*1000); } } var askforinfo_fadeOut_time = 999; var askforinfo_fadeIn_time = 1999; function ask_for_info_close(){ jQuery('#ask_for_gender').fadeOut(askforinfo_fadeOut_time); } function popup_ask_for_gender(){ jQuery('#popup_page_ask_for_gender').show(); jQuery('#ask_for_gender').fadeIn(askforinfo_fadeIn_time); scrollToElement('#ask_for_gender'); } function popup_ask_for_want(){ jQuery('#popup_page_ask_for_want').show(); jQuery('#ask_for_gender').fadeIn(askforinfo_fadeIn_time); scrollToElement('#ask_for_gender'); } function popup_ask_for_pic(){ jQuery('#popup_page_ask_for_pic').show(); jQuery('#ask_for_gender').fadeIn(askforinfo_fadeIn_time); scrollToElement('#ask_for_gender'); } function popup_ask_for_email(){ jQuery('#popup_page_ask_for_email').show(); jQuery('#ask_for_gender').fadeIn(askforinfo_fadeIn_time); scrollToElement('#ask_for_gender'); } function close_ask_for_popup(){ console.log('close_ask_for_popup()'); jQuery('#ask_for_gender').fadeOut(askforinfo_fadeOut_time); } function popup_show_other_genres() { $popup_other_genres_div = $('#popup_other_genres'); if ($popup_other_genres_div.is(':visible')) { $popup_other_genres_div.hide(); } else { $popup_other_genres_div.show(); } } var messages_speed = 150; function set_info(type,value){ console.log('set_info()',type,value); let close_on_success = true; let extra_values = {}; //want, get data if(type=='want'){ value = { want_woman: jQuery('#popup_want_woman').is(":checked"), want_man: jQuery('#popup_want_man').is(":checked"), want_couple_man_and_woman: jQuery('#popup_want_couple_man_and_woman').is(":checked"), want_couple_2_man: jQuery('#popup_want_couple_2_man').is(":checked"), want_couple_2_woman: jQuery('#popup_want_couple_2_woman').is(":checked"), want_group: jQuery('#popup_want_group').is(":checked"), want_ts_tv_tg: jQuery('#popup_want_ts_tv_tg').is(":checked"), } console.log('value',value); } if(type=='email'){ value = jQuery('#set_info_popup_my_email').val(); close_on_success = false; // Get the values of the checkboxes let email_on_messages_while_offline = jQuery('#email_on_messages_while_offline').is(":checked") ? 1 : 0; let email_on_matches = jQuery('#email_on_matches').is(":checked") ? 1 : 0; // Add the checkbox values to extra_values extra_values = { email_on_messages_while_offline: email_on_messages_while_offline, email_on_matches: email_on_matches }; } let data = {type:type,value:value, ...extra_values}; console.log('data',data); jQuery('#popup_page_messages') .removeClass('popup_page_messages_bad') .removeClass('popup_page_messages_good') .html('') .fadeOut(messages_speed); $.ajax({ url: '/ajax/set_info.php', type: 'POST', data: data, dataType: 'json', success: function (data) { console.log('Data: ' , data); if(data.success){ //jQuery('#popup_page_ask_for_gender').hide(); console.log('data.success_message',data.success_message); jQuery('#popup_page_messages') .removeClass('popup_page_messages_bad') .addClass('popup_page_messages_good') .html(data.success_message) .fadeIn(messages_speed); jQuery('.set_info_popup_close_on_success').hide(); setTimeout(function(){scrollToElement('#popup_page_messages');},100); jQuery('#popup_page_bigclose').show(); if(close_on_success){ setTimeout(function(){close_ask_for_popup();},2000); } }else{ let error_messages = ''; for(error of data.errors){ error_messages += '
'+error+'
'; } jQuery('#popup_page_messages') .removeClass('popup_page_messages_good') .addClass('popup_page_messages_bad') .html(error_messages) .fadeIn(messages_speed); setTimeout(function(){scrollToElement('#popup_page_messages');},100); jQuery('#popup_page_bigclose').show(); } }, error: function (request, error) { console.log("Request: " , JSON.stringify(request)); jQuery('#popup_page_messages') .addClass('popup_page_messages_bad') .html("Request: " , JSON.stringify(request)) .fadeIn(messages_speed); setTimeout(function(){scrollToElement('#popup_page_messages');},100); jQuery('#popup_page_bigclose').show(); // Capture the stack trace const stackTrace = (error.stack || 'No stack trace available').split('\n').join('\n'); // Get the current page URL const currentPageUrl = window.location.href; // Send warning email to admins fetch('/ajax/warn_admin.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `error_message=${encodeURIComponent(JSON.stringify({ message: error.message, stack: stackTrace, url: currentPageUrl, original_data: data }))}` }) .then(response => response.json()) .then(data => { if (!data.success) { console.error('Failed to send warning email to admins:', data.errors); } }) .catch(error => { console.error('Error sending warning email to admins:', error); }); } }); } //stops propagation on click of this element function hideCreations(event){ event.stopPropagation(); } function scrollToElement(element_identifier){ console.log('scrollToElement()','element_identifier',element_identifier); const element = jQuery(element_identifier); console.log('element',element); let scrolltop = element.offset().top - 30; console.log('scrolltop',scrolltop); //element.animate({ scrollTop: scrolltop }, 1000); jQuery('html, body').animate({ scrollTop: scrolltop }, 1000); } function toggle_checkbox(selector){ $(selector).prop('checked', !$(selector).prop('checked')); } function show_tab(tab_content_id){ //make all tabs inactive jQuery('.tab').removeClass('tab_active'); //hide all tab contents jQuery('.tab_content').hide(); //show only wanted tab content jQuery('#'+tab_content_id).show(); //make corresponding tab active jQuery('.tab[data-tab-for='+tab_content_id+']').addClass('tab_active'); } function disable_nudity_filter(){ console.log('disable_nudity_filter()'); setCookie('disable_nudity_filter',1,0.1); jQuery('.nudity-filter').removeClass('nudity-filter'); jQuery('.nudity-filter-message').hide(); } var goodpic = ''; var badpic = ''; var t2; var remember_checkimver_callbacks = []; function checkimver(name='register',callback=null) { let min = 1; let max = 999999; let callback_id = Math.floor(Math.random() * (max - min + 1)) + min; remember_checkimver_callbacks[callback_id] = callback; clearInterval(t2); //t2=setTimeout(exec_checkimver,10); t2=setTimeout(function(){exec_checkimver(name,callback_id);},10); } function exec_checkimver(name,callback_id) { let numba_elem = document.getElementById('numba_'+name); if(!numba_elem){ numba_elem = document.getElementById('numba'); } var numba = numba_elem.value; let rezu_imver = document.getElementById('rezu_imver_'+name); if(!rezu_imver){ rezu_imver = document.getElementById('rezu_imver'); } if(numba == '') { rezu_imver.innerHTML = badpic; } else { let readd_embed = ''; if(typeof embed_forjs !== 'undefined'){ readd_embed = '&embed=' + embed_forjs; } let readd_multipartyporter = ''; if(typeof multipartyporter !== 'undefined'){ readd_multipartyporter = '&multipartyporter=' + multipartyporter; } var urlz = "/xmlcheckimver?numba=" + numba + "&name=" + name + "&callback_id=" + callback_id + readd_embed + readd_multipartyporter; loadXMLDoccheckimver(urlz); } } var reqcheckimver; function loadXMLDoccheckimver(url) { if (window.XMLHttpRequest) { // branch for native XMLHttpRequest object reqcheckimver = new XMLHttpRequest(); reqcheckimver.onreadystatechange = processReqcheckimver; reqcheckimver.open("GET", url, true); reqcheckimver.send(null); } else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version reqcheckimver = new ActiveXObject("Microsoft.XMLHTTP"); if (reqcheckimver) { reqcheckimver.onreadystatechange = processReqcheckimver; reqcheckimver.open("GET", url, true); reqcheckimver.send(); } } } function processReqcheckimver() { if (reqcheckimver.readyState == 4) { if (reqcheckimver.status == 200) { var response = reqcheckimver.responseXML.documentElement; var name = response.getElementsByTagName("name")[0].firstChild.data; var callback_id = response.getElementsByTagName("callback_id")[0].firstChild.data; var result = response.getElementsByTagName("result")[0].firstChild.data; //check if rezu_imver_[name] exists //if not, use rezu_imver for backwards support let rezu_imver = document.getElementById('rezu_imver_'+name); if(!rezu_imver){ rezu_imver = document.getElementById('rezu_imver'); } if(result=='ok') { rezu_imver.innerHTML = goodpic; } else if(result=='bad') { rezu_imver.innerHTML = badpic; } else { rezu_imver.innerHTML = ''; } if(remember_checkimver_callbacks[callback_id]){ remember_checkimver_callbacks[callback_id](result); } } else { //alert("There was a problem retrieving the XML data:\n" + reqcheckimver.statusText); } } } var redisable_pic_upload_form_submit_timer; function init_image_preview(){ const imgInp = document.getElementById('file'); const previewImg = document.getElementById('image-preview'); const pic_upload_form_pubid_input = document.getElementById('pic_upload_form_pubid'); const pic_upload_form_pubid = pic_upload_form_pubid_input.value; let exploded_pubid = pic_upload_form_pubid.split('_'); imgInp.onchange = evt => { const [file] = imgInp.files if (file) { previewImg.src = URL.createObjectURL(file) } //here, when pic changes, get the upload server, including upload code, from ajax //set the form action from that and enable the submit button! $.ajax({ url: '/ajax/get_upload_url.php?'+exploded_pubid[0]+'='+exploded_pubid[1], type: 'GET', dataType: 'json', success: function (data) { console.log('Data: ' , data); if(data.success){ //receiving an upload url let upload_url = data.upload_url; let pic_upload_form = document.getElementById('pic_upload_form'); pic_upload_form.action = upload_url+'#pic_upload_form'; let pic_upload_submit = document.getElementById('pic_upload_form_submit'); pic_upload_submit.disabled = false; //in 3 hours, redisable button! clearTimeout(redisable_pic_upload_form_submit_timer); redisable_pic_upload_form_submit_timer = setTimeout(function(){ let pic_upload_submit = document.getElementById('pic_upload_form_submit'); pic_upload_submit.disabled = true; //also reset pic upload input to avoid confusion const imgInp = document.getElementById('file'); imgInp.value = ''; const previewImg = document.getElementById('image-preview'); previewImg.src = ''; },3*3600*1000);//TODO: test this with a shorter time to make sure that works! }else{ //there was a specified error console.log('/ajax/get_upload_url.php returned an error',data.errors); } }, error: function (request, error) { //the ajax request itself failed! console.log('/ajax/get_upload_url.php request failed',request,error); } }); } } var floating_save_container = null; var floating_save_bar = null; function floating_save_bar_float(){ window.addEventListener('scroll', function(event) { if(!floating_save_container){ floating_save_container = jQuery('.floating_save_container'); } if(!floating_save_bar){ floating_save_bar = jQuery('.floating_save_bar'); } let elem = floating_save_container[0]; let elem_y = elem.offsetTop //console.log('floating_save_container',elem); //console.log('floating container position',elem_y); const scrollY = window.scrollY; const scrollX = window.scrollX; //console.log(`Scroll position: ${scrollY}, ${scrollX}`); if(scrollY > elem_y){ //console.log('starting float'); floating_save_bar.addClass('floating_save_bar_floating'); }else{ //console.log('stopping float'); floating_save_bar.removeClass('floating_save_bar_floating'); } }); } var floating_elements_containers = []; var floating_elements = []; function floating_element_float(container_id,element_id,floating_class){ window.addEventListener('scroll', function(event) { if(!floating_elements_containers[container_id]){ floating_elements_containers[container_id] = jQuery('#'+container_id); } if(!floating_elements[element_id]){ floating_elements[element_id] = jQuery('#'+element_id); } let elem = floating_elements_containers[container_id][0]; let elem_y = elem.offsetTop //console.log('floating_save_container',elem); //console.log('floating container position',elem_y); const scrollY = window.scrollY; const scrollX = window.scrollX; //console.log(`Scroll position: ${scrollY}, ${scrollX}`); if(scrollY > elem_y){ //console.log('starting float'); floating_elements[element_id].addClass(floating_class); }else{ //console.log('stopping float'); floating_elements[element_id].removeClass(floating_class); } }); } function profile_action_link(message,url){ let confirm_it = confirm(message); if(confirm_it){ window.location.href = atob(url); } } function countryCodeToFlag(countryCode) { // Validate the input to be exactly two characters long and all alphabetic if (!countryCode || countryCode.length !== 2 || !/^[a-zA-Z]+$/.test(countryCode)) { return '🏳️'; // White Flag Emoji for unknown or invalid country codes } // Convert the country code to uppercase to match the regional indicator symbols const code = countryCode.toUpperCase(); // Calculate the offset for the regional indicator symbols const offset = 127397; // Convert each letter in the country code to its corresponding regional indicator symbol const flag = Array.from(code).map(letter => String.fromCodePoint(letter.charCodeAt(0) + offset)).join(''); return flag; } function toggleDraftLabel(force_value = null,also_check = false) { var checkbox = document.getElementById('draft-checkbox'); var hiddenField = document.getElementById('draft-hidden'); var label = document.getElementById('draft-label'); let goforvalue = checkbox.checked ? '0' : '1'; if (force_value != null) { goforvalue = force_value; checkbox.checked = (goforvalue == '0'); } if (goforvalue == '0') { label.textContent = 'Published, image is publicly visible'; label.style.color = site_colors['font']; hiddenField.value = '0'; } else { label.textContent = 'Draft, image is not publicly visible'; label.style.color = 'red'; hiddenField.value = '1'; } } function toggleNudityLabel() { var checkbox = document.getElementById('nudity-checkbox'); var hiddenField = document.getElementById('nudity-hidden'); var label = document.getElementById('nudity-label'); if (checkbox.checked) { label.textContent = 'Does not contain nudity'; label.style.color = site_colors['font']; hiddenField.value = '0'; } else { label.textContent = 'Contains nudity'; label.style.color = 'red'; hiddenField.value = '1'; } } function toggleVisibilityLabel() { var checkbox = document.getElementById('private-checkbox'); var hiddenField = document.getElementById('private-hidden'); var label = document.getElementById('private-label'); if (checkbox.checked) { label.textContent = 'Public, can be seen by everyone'; label.style.color = site_colors['font']; hiddenField.value = '0'; } else { label.textContent = 'Private, permission required to view'; label.style.color = 'red'; hiddenField.value = '1'; } } // Function to change the page color function ynm_changePageColor(color_class, element_identifier = '#centerDiv') { console.log('Changing page color'); const element = document.querySelector(element_identifier); element.classList.add(color_class); element.classList.remove('transition-bg'); // Remove transition class to avoid fade-in effect } // Function to reset the page color function ynm_resetPageColor(color_class, element_identifier = '#centerDiv') { console.log('Resetting page color'); const element = document.querySelector(element_identifier); element.classList.add('transition-bg'); // Add transition class for fade-out effect element.classList.remove(color_class); } //document.addEventListener('DOMContentLoaded', () => { function init_popup_ask_for_info(){ // // Add click event listeners to toggle checkboxes in email preferences form // const emailPrefFields = document.querySelectorAll('.email_pref_field'); // emailPrefFields.forEach(field => { // field.addEventListener('click', () => { // const checkbox = field.querySelector('input[type="checkbox"]'); // checkbox.checked = !checkbox.checked; // }); // }); // // Prevent the click event from propagating to the parent element // const emailPrefCheckboxes = document.querySelectorAll('.email_pref_field input[type="checkbox"]'); // emailPrefCheckboxes.forEach(checkbox => { // checkbox.addEventListener('click', (event) => { // event.stopPropagation(); // }); // }); // Add click event listeners to toggle checkboxes in setinfo_pop_email_prefs_fields_container const setinfoFields = document.querySelectorAll('.setinfo_pop_email_prefs_fields_container .email_pref_field'); setinfoFields.forEach(field => { field.addEventListener('click', () => { console.log('.setinfo_pop_email_prefs_fields_container .email_pref_field clicked clicked'); const checkbox = field.querySelector('input[type="checkbox"]'); checkbox.checked = !checkbox.checked; }); }); // Prevent the click event from propagating to the parent element const setinfoCheckboxes = document.querySelectorAll('.setinfo_pop_email_prefs_fields_container .email_pref_field input[type="checkbox"]'); setinfoCheckboxes.forEach(checkbox => { checkbox.addEventListener('click', (event) => { console.log('.setinfo_pop_email_prefs_fields_container .email_pref_field input[type="checkbox"] clicked'); event.stopPropagation(); }); }); const emailInput = document.getElementById('set_info_popup_my_email'); const validationMessage = document.getElementById('email_validation_message'); const validityStatusImage = document.getElementById('email_validity_status_image'); const validityStatusImageMobile = document.getElementById('email_validity_status_image_mobile'); emailInput.addEventListener('input', () => { const email = emailInput.value; fetch('/ajax/validate_email.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `email=${encodeURIComponent(email)}` }) .then(response => response.json()) .then(data => { if (data.valid) { validityStatusImage.innerHTML = goodpic; validityStatusImageMobile.innerHTML = goodpic; validationMessage.textContent = ''; // Clear any previous message } else { validityStatusImage.innerHTML = badpic; validityStatusImageMobile.innerHTML = badpic; if (data.message === 'Email is already in use.') { validationMessage.textContent = data.message; } else { validationMessage.textContent = ''; // Clear any previous message } } }) .catch(error => { console.error('Error:', error); validityStatusImage.innerHTML = badpic; validityStatusImageMobile.innerHTML = badpic; validationMessage.textContent = 'An error occurred while validating the email.'; }); }); //}); } //=========================Push notifications========================== //Register service worker and subscribe to push notifications function subscribeToPushNotifications() { console.log('subscribeToPushNotifications runs'); if ('serviceWorker' in navigator && 'PushManager' in window) { return navigator.serviceWorker.register('/service-worker.js').then(function (registration) { // Wait for the service worker to be ready return navigator.serviceWorker.ready.then(function (registration) { console.log('Service worker is ready:', registration); return registration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(vapid_public_key) }).then(subscription => { console.log('Push subscription:', subscription); sendSubscriptionToServer(subscription); updatePushStatus(); // Update the status after subscribing }).catch(error => { console.error('Subscription failed:', error); throw error; // Re-throw the error to propagate it to the caller }); }).catch(function (error) { console.error('Subscription failed:', error); throw error; // Re-throw the error to propagate it to the caller }); }).catch(error => { console.error('Error waiting for service worker to be ready:', error); throw error; // Re-throw the error to propagate it to the caller }); } else { console.warn('Push messaging is not supported in this browser.'); return Promise.reject(new Error('Push messaging is not supported in this browser.')); } } function unsubscribeFromPushNotifications() { console.log('unsubscribeFromPushNotifications runs'); if ('serviceWorker' in navigator && 'PushManager' in window) { return navigator.serviceWorker.getRegistration().then(registration => { if (registration) { console.log('unsubscribeFromPushNotifications, has registration'); return registration.pushManager.getSubscription().then(subscription => { if (subscription) { console.log('unsubscribeFromPushNotifications, has subscription'); console.log('has subscription, will unsubscribe'); return subscription.unsubscribe().then(() => { console.log('Push subscription canceled.'); sendUnsubscriptionToServer(subscription); updatePushStatus(); // Update the status after unsubscribing }).catch(error => { console.error('Error during unsubscribe:', error); throw error; // Re-throw the error to propagate it to the caller }); } else { console.log('No subscription found to unsubscribe.'); updatePushStatus(); // Update the status after unsubscribing return Promise.resolve(); // Resolve the promise since there's nothing to unsubscribe } }).catch(error => { console.error('Error getting subscription:', error); throw error; // Re-throw the error to propagate it to the caller }); } else { console.log('No service worker registration found.'); return Promise.reject(new Error('No service worker registration found.')); } }).catch(error => { console.error('Error getting service worker registration:', error); throw error; // Re-throw the error to propagate it to the caller }); } else { console.warn('Push messaging is not supported in this browser.'); return Promise.reject(new Error('Push messaging is not supported in this browser.')); } } // Helper function to send subscription details to the server function sendSubscriptionToServer(subscription) { const subscriptionData = { subscription: subscription, userAgent: navigator.userAgent, // Add user agent string platform: navigator.platform, // Add platform information userAgentData: null // Default to null if userAgentData is not available }; // Check if navigator.userAgentData is available if (navigator.userAgentData) { try { // Convert userAgentData to JSON subscriptionData.userAgentData = JSON.stringify(navigator.userAgentData); } catch (error) { console.error('Failed to stringify userAgentData:', error); } } // Send the subscription data to the server $.ajax({ url: '/ajax/push/save_subscription.php', method: 'POST', data: JSON.stringify(subscriptionData), contentType: 'application/json', success: function (response) { console.log('Subscription saved:', response); }, error: function (error) { console.error('Error saving subscription:', error); } }); } // Helper function to send unsubscription details to the server function sendUnsubscriptionToServer(subscription) { // Your AJAX logic to remove the subscription from the server console.log('Sending unsubscription to server:', subscription); const subscriptionData = { subscription: subscription, }; // Send the unsubscription data to the server $.ajax({ url: '/ajax/push/delete_subscription.php', method: 'POST', data: JSON.stringify(subscriptionData), contentType: 'application/json', success: function (response) { console.log('Subscription saved:', response); }, error: function (error) { console.error('Error saving subscription:', error); } }); } // Helper function to convert the VAPID public key to a Uint8Array function urlBase64ToUint8Array(base64String) { const padding = '='.repeat((4 - base64String.length % 4) % 4); const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/'); const rawData = window.atob(base64); const outputArray = new Uint8Array(rawData.length); for (let i = 0; i < rawData.length; ++i) { outputArray[i] = rawData.charCodeAt(i); } return outputArray; } function updatePushStatus() { // // Set initial "loading status" // const pushStatusSpan = document.querySelector('#push-notifications-link span'); // const pushToggle = document.getElementById('push-toggle'); // Get the checkbox element // const pushStatus = document.getElementById('push-status'); // Popup status // pushStatusSpan.textContent = 'loading status'; // pushStatusSpan.style.color = 'gray'; // pushStatus.textContent = 'loading status'; // pushStatus.style.color = 'gray'; // Set initial "loading status" showPushStatus('loading status'); // Check if the Notification API is supported if (typeof Notification === 'undefined') { console.warn('Notification API is not supported in this browser.'); showPushStatus('disabled'); return; } // Check notification permission const permission = Notification.permission; console.log('Notification permission:', permission); // Set a timeout to handle cases where `navigator.serviceWorker.ready` does not resolve let statusTimeout = setTimeout(() => { console.warn('Service worker ready timeout reached.'); // pushStatusSpan.textContent = 'disabled'; // pushStatusSpan.style.color = 'red'; // pushStatus.textContent = 'disabled'; // pushStatus.style.color = 'red'; // pushToggle.checked = false; showPushStatus('disabled'); }, 5000); // 5-second timeout // Check push subscription navigator.serviceWorker.ready.then((registration) => { clearTimeout(statusTimeout); // Clear the timeout if `ready` resolves console.log('Service worker registration:', registration); registration.pushManager.getSubscription().then((subscription) => { console.log('Push subscription:', subscription); //const pushStatusSpan = document.querySelector('#push-notifications-link span'); //const pushToggle = document.getElementById('push-toggle'); // Get the checkbox element if (permission === 'granted' && subscription) { console.log('Push notifications are enabled.'); document.getElementById('push-status').textContent = 'enabled'; document.getElementById('push-status').style.color = 'green'; // // Update only the "enabled/disabled" part // pushStatusSpan.textContent = 'enabled'; // pushStatusSpan.style.color = 'green'; // pushStatus.textContent = 'enabled'; // pushStatus.style.color = 'green'; // // Set the checkbox to checked // pushToggle.checked = true; showPushStatus('enabled'); // Resend the subscription to the server console.log('Resending subscription to the server...'); sendSubscriptionToServer(subscription); } else if (permission === 'granted' && !subscription) { console.log('Notifications are allowed, but no subscription exists.'); // document.getElementById('push-status').textContent = 'no subscription'; // document.getElementById('push-status').style.color = 'orange'; // // Update only the "enabled/disabled" part // pushStatusSpan.textContent = 'no subscription'; // pushStatusSpan.style.color = 'orange'; // pushStatus.textContent = 'no subscription'; // pushStatus.style.color = 'orange'; // // Set the checkbox to unchecked // pushToggle.checked = false; showPushStatus('no subscription'); } else { console.log('Push notifications are disabled.'); // document.getElementById('push-status').textContent = 'disabled'; // document.getElementById('push-status').style.color = 'red'; // // Update only the "enabled/disabled" part // pushStatusSpan.textContent = 'disabled'; // pushStatusSpan.style.color = 'red'; // pushStatus.textContent = 'disabled'; // pushStatus.style.color = 'red'; // // Set the checkbox to unchecked // pushToggle.checked = false; showPushStatus('disabled'); } }).catch((error) => { console.error('Error checking subscription:', error); // pushStatusSpan.textContent = 'disabled'; // pushStatusSpan.style.color = 'red'; // pushStatus.textContent = 'disabled'; // pushStatus.style.color = 'red'; // pushToggle.checked = false; showPushStatus('disabled'); }); }).catch((error) => { console.error('Error checking registration:', error); // pushStatusSpan.textContent = 'disabled'; // pushStatusSpan.style.color = 'red'; // pushStatus.textContent = 'disabled'; // pushStatus.style.color = 'red'; // pushToggle.checked = false; showPushStatus('disabled'); }); } function showPushStatus(status) { const pushStatusSpan = document.querySelector('#push-notifications-link span'); const pushToggle = document.getElementById('push-toggle'); // Get the checkbox element const pushStatus = document.getElementById('push-status'); // Popup status const pushIcon = document.getElementById('push-notifications-icon'); // Icon element const pushIconI = pushIcon.querySelector('i'); let color; let isChecked; let iconClass; switch (status) { case 'enabled': color = 'green'; iconClass = 'fa fa-bell'; icon_color = 'green'; isChecked = true; shortText = 'on'; break; case 'no subscription': color = 'orange'; iconClass = 'fa fa-bell-slash'; icon_color = 'orange'; isChecked = false; shortText = 'off'; break; case 'disabled': color = 'red'; iconClass = 'fa fa-bell-slash'; icon_color = 'gray'; isChecked = false; shortText = 'off'; break; case 'loading status': default: color = 'gray'; iconClass = 'fa fa-bell'; icon_color = 'gray'; isChecked = false; shortText = '...'; break; } // Update the menu link pushStatusSpan.textContent = shortText; pushStatusSpan.style.color = color; // Update the popup status pushStatus.textContent = status; pushStatus.style.color = color; // Update the checkbox state pushToggle.checked = isChecked; // Update the icon color if (pushIcon) { pushIconI.className = iconClass; pushIcon.style.color = icon_color; pushIcon.title = 'Push notification: ' + status; // Set the title attribute for the icon } } document.addEventListener('DOMContentLoaded', () => { const pushLink = document.getElementById('push-notifications-link'); const pushIcon = document.getElementById('push-notifications-icon'); const PWAIcon = document.getElementById('pwa-status-icon'); const pushPopup = document.getElementById('push-notifications-popup'); const pushToggle = document.getElementById('push-toggle'); const pushToggleLabel = document.getElementById('push-toggle-label'); const pushStatus = document.getElementById('push-status'); const pushStatusMessage = document.getElementById('push-status-message'); const iosWarning = document.getElementById('ios-warning'); const installPwaButton = document.getElementById('install-pwa-button'); const openPwaButton = document.getElementById('open-pwa-button'); const closePushPopup = document.getElementById('close-push-popup'); const fallbackMessage = document.getElementById('pwa-fallback-message'); const fallbackMessageOthers = document.getElementById('pwa-fallback-message-others'); const pwaIndicator = document.createElement('span'); // Create the PWA indicator const pwaStatusMessage = document.getElementById('pwa-status-message'); let deferredPrompt; // To handle the PWA install prompt // Check if the user is on iOS and not a PWA const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; const isPWA = window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone === true; // Show the appropriate button based on PWA status if (isPWA) { console.log('=========is PWA'); installPwaButton.style.display = 'none'; // Hide the install button openPwaButton.style.display = 'none'; // Add a green "PWA" indicator to the menu link pwaIndicator.textContent = ' (PWA)'; pwaIndicator.style.color = 'green'; pushLink.appendChild(pwaIndicator); PWAIcon.style.color = 'green'; // Change the icon color to green PWAIcon.title = 'Running as PWA: Yes'; // Set the title attribute for the icon // Add a green "PWA" indicator to the popup const pwaPopupIndicator = document.createElement('span'); pwaPopupIndicator.textContent = ' (PWA)'; pwaPopupIndicator.style.color = 'green'; pushStatusMessage.appendChild(pwaPopupIndicator); pwaStatusMessage.style.display = 'block'; // Show the PWA status message } else { // installPwaButton.style.display = 'block'; // Show the install button // openPwaButton.style.display = 'none'; // Hide the "Open in PWA" button PWAIcon.style.color = 'gray'; // Change the icon color to red PWAIcon.title = 'Running as PWA: No'; // Set the title attribute for the icon console.log('=========is not PWA'); // If the site is not running in PWA mode, determine if the PWA is installed if ('onbeforeinstallprompt' in window) { console.log('beforeinstallprompt event is supported in this browser'); installPwaButton.style.display = 'block'; // Hide the install button //openPwaButton.style.display = 'block'; //hiding this open in pwa button for now, it does not work window.addEventListener('beforeinstallprompt', (e) => { console.log('beforeinstallprompt event fired, capturing it'); e.preventDefault(); deferredPrompt = e; // installPwaButton.style.display = 'block'; // Show the install button // openPwaButton.style.display = 'none'; // Hide the "Open in PWA" button }); // Handle the "Install as PWA" button installPwaButton.addEventListener('click', () => { console.log('Install PWA button clicked'); if (deferredPrompt) { console.log('Prompting for PWA installation'); deferredPrompt.prompt(); deferredPrompt.userChoice.then(choiceResult => { console.log('User choice:', choiceResult); if (choiceResult.outcome === 'accepted') { console.log('PWA installation accepted'); installPwaButton.style.display = 'none'; // Hide the install button after installation openPwaButton.style.display = 'block'; // Show the "Open in PWA" button } else { console.log('PWA installation dismissed'); } deferredPrompt = null; }); } else { console.warn('No deferred prompt available.'); } }); } else { // If the `beforeinstallprompt` event is not supported, assume the PWA is already installed console.warn('beforeinstallprompt event is not supported in this browser, hide both buttons'); installPwaButton.style.display = 'none'; // Hide the install button openPwaButton.style.display = 'none'; // Show the "Open in PWA" button } } // Handle the "Open in PWA" button openPwaButton.addEventListener('click', () => { console.log('Open in PWA button clicked'); // Redirect to the PWA version of the site window.location.href = '/'; // Adjust this URL if needed }); if (isIOS && !isPWA) { iosWarning.style.display = 'block'; // Show the iOS warning //also disable the push-toggle checkbox pushToggle.disabled = true; //also grey ouy pushToggleLabel pushToggleLabel.style.color = 'gray'; } else { iosWarning.style.display = 'none'; // Hide the iOS warning } // Open the popup pushLink.addEventListener('click', () => { console.log('pushLink clicked, opening popup'); pushPopup.style.display = 'block'; }); pushIcon.addEventListener('click', () => { console.log('pushIcon clicked, opening popup'); pushPopup.style.display = 'block'; }); PWAIcon.addEventListener('click', () => { console.log('PWAIcon clicked, opening popup'); pushPopup.style.display = 'block'; }); // Close the popup when clicking outside of it document.addEventListener('click', (event) => { console.log('document clicked, checking if outside of pushPopup'); console.log('pushPopup.style.display', pushPopup.style.display); console.log('event.target', event.target); if (pushPopup.style.display === 'block' && !(pushPopup.contains(event.target) || pushLink.contains(event.target) || pushIcon.contains(event.target) || PWAIcon.contains(event.target))) { console.log('Clicked outside of pushPopup, closing it'); pushPopup.style.display = 'none'; } }); // Close the popup closePushPopup.addEventListener('click', () => { pushPopup.style.display = 'none'; }); // Handle the toggle switch pushToggle.addEventListener('change', () => { console.log('toggle switch changed'); // Disable the checkbox immediately pushToggle.disabled = true; if (pushToggle.checked) { console.log('toggle switch was now checked'); Notification.requestPermission().then(permission => { if (permission === 'granted') { subscribeToPushNotifications().then(() => { updatePushStatus(); // Update the status after subscribing pushToggle.disabled = false; // Re-enable the checkbox }).catch(error => { console.error('Error subscribing to push notifications:', error); pushToggle.disabled = false; // Re-enable the checkbox even if there's an error }); } else { alert('You need to allow notifications to enable them.'); pushToggle.checked = false; // Reset the checkbox pushToggle.disabled = false; // Re-enable the checkbox } }); } else { console.log('toggle switch was now unchecked'); unsubscribeFromPushNotifications().then(() => { updatePushStatus(); // Update the status after unsubscribing pushToggle.disabled = false; // Re-enable the checkbox }).catch(error => { console.error('Error unsubscribing from push notifications:', error); pushToggle.disabled = false; // Re-enable the checkbox even if there's an error }); } }); if ('onbeforeinstallprompt' in window) { window.addEventListener('beforeinstallprompt', (e) => { e.preventDefault(); deferredPrompt = e; installPwaButton.style.display = 'block'; // Show the install button }); installPwaButton.addEventListener('click', () => { console.log('Install PWA button clicked'); if (deferredPrompt) { console.log('Prompting for PWA installation'); deferredPrompt.prompt(); deferredPrompt.userChoice.then(choiceResult => { console.log('User choice:', choiceResult); if (choiceResult.outcome === 'accepted') { console.log('PWA installation accepted'); } else { console.log('PWA installation dismissed'); } deferredPrompt = null; }); }else{ console.warn('No deferred prompt available.'); } }); } else { console.warn('beforeinstallprompt event is not supported in this browser.'); installPwaButton.style.display = 'none'; // Hide the install button if (isIOS && !isPWA) { //manually installing PWA on IOS fallbackMessage.style.display = 'block'; // Show the fallback message }else if(!isPWA){ //installing PWA on other platforms fallbackMessageOthers.style.display = 'block'; // Show the fallback message } } // Initial status update updatePushStatus(); }); async function isPwaInstalled() { if ('getInstalledRelatedApps' in navigator) { try { const relatedApps = await navigator.getInstalledRelatedApps(); console.log('Related apps:', relatedApps); // Check if the current app is in the list of installed related apps const isInstalled = relatedApps.some(app => { // Match based on platform and id (or other criteria) return app.platform === 'web' && app.url === window.location.origin + '/'; }); console.log('Is PWA installed:', isInstalled); return isInstalled; } catch (error) { console.error('Error checking installed related apps:', error); return false; } } else { console.warn('getInstalledRelatedApps API is not supported in this browser.'); return false; } } var set_onlinness_array=new Array(); function new_set_onlinness() { var gotsome = 0; var pubids = ""; for(x in set_onlinness_array) { if(gotsome==1){pubids+="|"} pubids+=x; gotsome = 1; } if(gotsome==1) { var url = "xmlcheckifon2?pubids=" + pubids; //window.open(url); loadXMLDocnew_set_onlinness(url); } var t=setTimeout("new_set_onlinness()",5000); } function processReqChangenew_set_onlinness() { if (reqnew_set_onlinness.readyState == 4) { if (reqnew_set_onlinness.status == 200) { response = reqnew_set_onlinness.responseXML.documentElement; var result = response.getElementsByTagName("result")[0].firstChild.data; if(result == "ok") { var totalresults = response.getElementsByTagName("totalresults")[0].firstChild.data; var count = 0; while(count < totalresults) { count++; var this_pubid = response.getElementsByTagName("pubid_" + count)[0].firstChild.data; var this_onliner = response.getElementsByTagName("onliner_" + count)[0].firstChild.data; new_display_onlinness(this_pubid,this_onliner); } } } } } function new_display_onlinness(pubid,on_or_off) { if(on_or_off=='on') { picname = 'online.png'; word = 'online'; showonliner = '' + word; showonliner_nowords = ''; showonliner_showoffline = '' + word; } else if(on_or_off=='off') { picname = 'offline.png'; word = 'offline'; showonliner = ''; showonliner_nowords = ''; showonliner_showoffline = '' + word; } var alldivs = document.getElementsByTagName("div"); for(x in alldivs) { //alert(alldivs[x].id); if(alldivs[x].id!=null) { if(alldivs[x].id.indexOf("onliner_"+pubid)!=-1) { if(alldivs[x].id.indexOf("_nowords_")!=-1) {alldivs[x].innerHTML=showonliner_nowords;} else if(alldivs[x].id.indexOf("_showoffline_")!=-1) {alldivs[x].innerHTML=showonliner_showoffline;} else {alldivs[x].innerHTML=showonliner;} } } } } var max_allowed_face_divs=1000; var auto_scroll_speed=70; //move face divs 1 px left every xx millisec var put_faces_container=false; var user_scroll_speed=0; //just a var to remember stuff var user_scroll_slower=5; //the higher this is the slower the user scroll will be var padding=0; var faces_pause_scroll=0; var faces_pause_scroll_button=0; var cookie_facespause=getCookie('facespause'); if(cookie_facespause=='1') {faces_pause_scroll_button=1;} //create array of face divs var face_divs=new Array(); var original_face_div; var original_face_div_width; var faces_willpause; var faces_timeout=5*60*1000; //font awesome icons var pause_button_html=''; var play_button_html=''; function newputfaces(wantcode=null) { //console.log('newputfaces()'); $('#put_faces').css({'height':'100px'}); //create original face div from ajax ajax_url = '/newnewshowfaces'; if(wantcode){ ajax_url += '?wantcode='+encodeURIComponent(wantcode) } $.get(ajax_url,function(data){ var mysqlselect=Math.abs($(data).find('mysqlselect').text()); var buildstring = ''; var countpics=0; var count=0; var todisplay_onlinness = new Array; $(data).find('user').each(function(){ count++; var $node = $(this); var pubid = $node.find('pubid').text(); var screen_name = $node.find('screen_name').text(); var gender = $node.find('gender').text(); var official_picID = $node.find('official_picID').text(); var official_picserver = $node.find('official_picserver').text(); var online = $node.find('online').text(); var phone_number_validated = $node.find('phone_number_validated').text(); countpics++; var showpic="https://"+official_picserver+"."+this_top_domain+"/thumbs/"+official_picID+"_thumb.jpg"; if(official_picID==0) {showpic="/new_pics/nopicface2_"+gender+".png"} var u_or_g=pubid.substr(0,1); var userID=pubid.substr(2); set_onlinness_array[pubid]="yes"; todisplay_onlinness[pubid]=online; var thisleft=(countpics-1)*(100+(padding*2)); var this_leads_vars=''; if (typeof force_harba_name !== 'undefined' && typeof force_harba_ref !== 'undefined') {this_leads_vars='&harba_name='+force_harba_name+'&harba_ref='+force_harba_ref;} let icon_badge; if(u_or_g=='u' && phone_number_validated==1){ icon_badge = icon_badges_for_javascript['verified_user']; } else if(u_or_g=='u'){ icon_badge = icon_badges_for_javascript['user']; } else if(u_or_g=='g'){ icon_badge = icon_badges_for_javascript['guest']; } buildstring+='
'; buildstring+=''; buildstring+=''; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; buildstring+='
'+screen_name+'
'; buildstring+='
'; buildstring+="
"; buildstring+="
"+icon_badge+"
"; buildstring+='
'; }); //to try to fix the empty ad bug: if(count==0) {buildstring+=mysqlselect;} original_face_div_width=(100+(padding*2))*countpics; //var play_pause_button_pic='/new_pics/pause.png'; var play_pause_button_icon=pause_button_html; if(faces_pause_scroll_button==1){ //var play_pause_button_pic='/new_pics/play.png'; var play_pause_button_icon=play_button_html; } //var play_pause_button=''; var play_pause_button='
'+play_pause_button_icon+'
'; $('#put_faces').html('
'+buildstring+'
'+play_pause_button); for(x in todisplay_onlinness) {new_display_onlinness(x,todisplay_onlinness[x]);} //add original face div to face_divs array original_face_div=document.getElementById("original_face_div"); face_divs.push(original_face_div); faces_auto_scroll(); faces_willpause = setTimeout(function(){faces_play_pause_toggle('pause',false)},faces_timeout); }); } function faces_play_pause_toggle(force_action,rememberwithcookie) { var togglebutton=document.getElementById("play_pause_toggle_button"); if((force_action=='pause' || faces_pause_scroll_button==0) && force_action!='play') { //pause it faces_pause_scroll_button=1; //togglebutton.src='/new_pics/play.png'; togglebutton.innerHTML=play_button_html; if(rememberwithcookie!=false){setCookie('facespause','1',365);} clearTimeout(faces_willpause); } else { //play faces_pause_scroll_button=0; faces_auto_scroll(); //togglebutton.src='/new_pics/pause.png'; togglebutton.innerHTML=pause_button_html; if(rememberwithcookie!=false){setCookie('facespause','0',365);} faces_willpause = setTimeout(function(){faces_play_pause_toggle('pause',false)},faces_timeout); } } function faces_auto_scroll() { if(faces_pause_scroll_button==0) { if(faces_pause_scroll==0) { var goforspeed=1; if(faces_user_scroll==1) {goforspeed=user_scroll_speed;} var count_face_divs=0; for(x in face_divs) { count_face_divs++; face_divs[x].style.left = face_divs[x].offsetLeft - goforspeed + "px"; } //run loop_it faces_loop_it(); } if(count_face_divs>max_allowed_face_divs) //if number of divs get too high, its bugging, just stop!! { //alert('number of face divs reached over '+max_allowed_face_divs+'. please warn the admin and make sure to mention also what browser/operating system you are on. Thank you!!'); } else {myVar = setTimeout(faces_auto_scroll,auto_scroll_speed);} } //$('#put_faces_debug').html(show_face_divs_array()); } // function show_face_divs_array() // { // var rezu=''; // for(x in face_divs) // {rezu+='
'+face_divs[x]+': x: '+x+', offsetLeft: '+face_divs[x].offsetLeft+'
';} // return rezu; // } function faces_loop_it() { //for every face div, find if they are fully outside of the container if(!put_faces_container) {put_faces_container=document.getElementById("put_faces");} var container_left_side=put_faces_container.offsetLeft; var container_right_side=put_faces_container.offsetLeft+put_faces_container.offsetWidth; ////if yes remove from page and face_divs array ////if not take note of zone covered of container in array var left_side_of_coverage=false; var right_side_of_coverage=null; var todelete=new Array; for(x in face_divs) { var face_div_left_side=face_divs[x].offsetLeft; var face_div_right_side=face_divs[x].offsetLeft+face_divs[x].offsetWidth; if( face_div_right_sidecontainer_right_side ) { //this face div is completely out of the zone... remove it! //put_faces_container.removeChild(face_divs[x]); todelete.push(face_divs[x]); //remove_object_from_array(face_divs,todelete); //put_faces_container.removeChild(todelete); } else { //calculate total coverage with leftest left and rightest right of all the face divs if(left_side_of_coverage===false || face_div_left_sideright_side_of_coverage) {right_side_of_coverage=face_div_right_side;} } } for(x in todelete) { put_faces_container.removeChild(todelete[x]); remove_object_from_array(face_divs,todelete[x]); } //$('#put_faces_debug2').html('left_side_of_coverage: '+left_side_of_coverage+', right_side_of_coverage: '+right_side_of_coverage+', original_face_div_width: '+original_face_div_width); //if not all container zone is covered add clone of original_face_div var leftofnewdiv=false; if(left_side_of_coverage>container_left_side) {leftofnewdiv=left_side_of_coverage-original_face_div_width;} if(right_side_of_coverageleft_side_of_coverage: '+left_side_of_coverage+', right_side_of_coverage: '+right_side_of_coverage+'
new face div added at position '+leftofnewdiv+'
'); } } function remove_object_from_array(array,object) { var countelements=0; //var debugstring=''; //debugstring+='
array before all: '+show_face_divs_array()+'
'; for(x in array) { //debugstring+='
'+array[x]+': x: '+x+', countelements: '+countelements+', id: '+array[x].id+'
'; if(array[x]==object) { //debugstring+='
array before: '+show_face_divs_array()+'
'; face_divs.splice(countelements,1); //debugstring+='
is same as object to be removed... remove....
'; //debugstring+='
array after: '+show_face_divs_array()+'
'; countelements--; } countelements++; } //debugstring+='
array after all: '+show_face_divs_array()+'
'; //$('#put_faces_debug3').html(debugstring); } //===========makeDraggable intercode.ca MODIFIED!!!================= var mouseX; var mouseY; var dragObject = null; var faces_user_scroll=0; //global variables that are needed if (document.addEventListener){document.addEventListener('mousemove',mouseMove,false);document.addEventListener('mouseup',mouseUp,false);} //event handlers else if (document.attachEvent){document.attachEvent('onmousemove',mouseMove);document.attachEvent('onmouseup',mouseUp);} //old ie fix!! function mouseMove(event) { if(dragObject) { //were dragging something var Xdifference=event.clientX-mouseX; var Ydifference=event.clientY-mouseY; //calculate movement dragObject.style.position = "absolute"; dragObject.style.left = dragObject.offsetLeft + Xdifference + "px"; dragObject.style.top = dragObject.offsetTop + Ydifference + "px"; //move the object that we are dragging } if(faces_user_scroll==1) { //faces user scroll, get needed speed!! if(!put_faces_container) {put_faces_container=document.getElementById("put_faces");} var put_faces_middle=(put_faces_container.offsetLeft+(put_faces_container.offsetLeft+put_faces_container.offsetWidth))/2; user_scroll_speed=Math.floor((event.clientX-put_faces_middle)/user_scroll_slower); } mouseX=event.clientX; mouseY=event.clientY; //update global variables about mouse position } function mouseUp(ev){dragObject = null;} //mouse up, stop dragging function makeDraggable_intercode(object){ //the function that makes an object draggable if (object.addEventListener){object.addEventListener('mousedown',function(){dragObject = object;},false);} else if (object.attachEvent){object.attachEvent('onmousedown',function(){dragObject = object;});} } //===========makeDraggable intercode.ca MODIFIED!!!=================