Initial Commit
This commit is contained in:
@@ -0,0 +1,338 @@
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.0.3 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
// Standard vars
|
||||
var debugme = false;
|
||||
var openchat = document.getElementById("lcjak_openchat");
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
lcjak_engageChat();
|
||||
if (!localStorage.getItem('lcjak_engage')) lcjakint = setInterval(function(){lcjak_engageChat()}, 3000);
|
||||
});
|
||||
|
||||
if (openchat) openchat.addEventListener("click", function(event){
|
||||
event.preventDefault();
|
||||
lcjak_openchat(openchat);
|
||||
|
||||
});
|
||||
|
||||
function lcjak_engageChat() {
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Let's get the current status of the local storage
|
||||
lcjak_chatstatus = localStorage.getItem('lcjak_chatstatus');
|
||||
// Get the customer
|
||||
var lcjak_customer = "0";
|
||||
if (localStorage.getItem('lcjak_customer')) lcjak_customer = localStorage.getItem('lcjak_customer');
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
// Get the first visit
|
||||
var lcjak_firstvisit = "0";
|
||||
if (localStorage.getItem('lcjak_firstvisit')) lcjak_firstvisit = localStorage.getItem('lcjak_firstvisit');
|
||||
// Get the online status
|
||||
if (localStorage.getItem('lcjak_onlinestatus')) lcjak_onlinestatus = localStorage.getItem('lcjak_onlinestatus');
|
||||
// Last time online
|
||||
var lcjak_lastvisit = localStorage.getItem('lcjak_lastvisit');
|
||||
// Engage Status
|
||||
var lcjak_engage = "0";
|
||||
if (localStorage.getItem('lcjak_engage')) lcjak_engage = localStorage.getItem('lcjak_engage');
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=engage&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Some sort of an error, let's redo the send button
|
||||
xhrc.addEventListener( "error", function( event ) {
|
||||
if (debugme) console.log(event);
|
||||
});
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// We will need to refresh the last status
|
||||
if (data.lastvisit) localStorage.setItem('lcjak_lastvisit', data.lastvisit);
|
||||
|
||||
// We will need to current status of the chat
|
||||
if (data.onlinestatus) localStorage.setItem('lcjak_onlinestatus', data.onlinestatus);
|
||||
|
||||
// We reload the location
|
||||
lcjak_handleEngage(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// We will need to refresh the last status
|
||||
if (data.lastvisit) localStorage.setItem('lcjak_lastvisit', data.lastvisit);
|
||||
|
||||
// Debug
|
||||
if (debugme) console.log(data.error);
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
// Attach Data
|
||||
var formData = new FormData();
|
||||
formData.append("chatstatus", lcjak_chatstatus);
|
||||
formData.append("rlbid", lcjak_session);
|
||||
formData.append("firstvisit", lcjak_firstvisit);
|
||||
formData.append("customer", lcjak_customer);
|
||||
formData.append("onlinestatus", lcjak_onlinestatus);
|
||||
formData.append("lastvisit", lcjak_lastvisit);
|
||||
formData.append("engage", lcjak_engage);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(formData);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_handleEngage(data) {
|
||||
|
||||
// We have a widget change
|
||||
if (data.widget) {
|
||||
location.reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the knock knock
|
||||
if (data.knockknock) {
|
||||
|
||||
if (data.soundalert) {
|
||||
var lcjsound = new Howl({
|
||||
src: [base_url+'/'+data.soundalert+'.webm', base_url+'/'+data.soundalert+'.mp3']
|
||||
});
|
||||
lcjsound.play();
|
||||
}
|
||||
if (parent.postMessage) {
|
||||
parent.postMessage('knockknock::'+data.knockknock, cross_url);
|
||||
} else {
|
||||
alert(msg.knockknock);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// New Message Play the sound
|
||||
if (data.newmessage) {
|
||||
|
||||
if (data.soundalert) {
|
||||
var lcjsound = new Howl({
|
||||
src: [base_url+'/'+data.soundalert+'.webm', base_url+'/'+data.soundalert+'.mp3']
|
||||
});
|
||||
lcjsound.play();
|
||||
}
|
||||
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "closed") {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=closed";
|
||||
var repurl = "lc&sp=open";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/closed";
|
||||
repurl = "lc/open";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to open
|
||||
localStorage.setItem('lcjak_chatstatus', "open");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::open', cross_url);
|
||||
}
|
||||
|
||||
// Redirect to open the chat
|
||||
window.location = new_url;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Fire engage
|
||||
if (data.engage) {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
if (data.showalert == 1 && data.engagediv) {
|
||||
|
||||
// We load the div dynamically to show the engage
|
||||
var lccont = document.getElementById('lccontainersize');
|
||||
lccont.classList.remove('jak_roundbtn');
|
||||
lccont.removeAttribute("style");
|
||||
lccont.classList.add('jak_roundbtn_engage');
|
||||
var lcsize = lccont.getBoundingClientRect();
|
||||
var cswidth = lcsize.width;
|
||||
var csheight = lcsize.height;
|
||||
iframe_resize(cswidth, csheight, data.cposition, cross_url);
|
||||
|
||||
lccont.insertAdjacentHTML('beforeend', data.engagediv);
|
||||
|
||||
if (data.sound) {
|
||||
var lcjsound = new Howl({
|
||||
src: [base_url+'/'+data.sound+'.webm', base_url+'/'+data.sound+'.mp3']
|
||||
});
|
||||
lcjsound.play();
|
||||
}
|
||||
|
||||
clearInterval(lcjakint);
|
||||
lcjakint = null;
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=closed";
|
||||
var repurl = "lc&sp=open";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/closed";
|
||||
repurl = "lc/open";
|
||||
}
|
||||
|
||||
// Set the local storage to open
|
||||
localStorage.setItem('lcjak_chatstatus', "open");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::open', cross_url);
|
||||
}
|
||||
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
|
||||
// Redirect to open the chat
|
||||
window.location = new_url;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function lcjak_openchat(elm) {
|
||||
|
||||
elm.classList.add('animate__animated', 'animate__zoomOut');
|
||||
|
||||
elm.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to open
|
||||
localStorage.setItem('lcjak_chatstatus', "open");
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=closed";
|
||||
// special url for engage
|
||||
if (localStorage.getItem('lcjak_engage')) {
|
||||
searchurl = "lc&sp=engage";
|
||||
}
|
||||
var repurl = "lc&sp=open";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/closed";
|
||||
// special url for engage
|
||||
if (localStorage.getItem('lcjak_engage')) {
|
||||
searchurl = "lc/engage";
|
||||
|
||||
}
|
||||
repurl = "lc/open";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Finally remove the engage storage
|
||||
if (localStorage.getItem('lcjak_engage')) localStorage.removeItem('lcjak_engage');
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::open', cross_url);
|
||||
}
|
||||
|
||||
// Redirect to open the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_closechat(elm) {
|
||||
|
||||
elm.classList.add('animate__animated', 'animate__rotateOut');
|
||||
|
||||
elm.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "closed");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::closed', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
// special url for engage
|
||||
if (localStorage.getItem('lcjak_engage')) {
|
||||
searchurl = "lc&sp=engage";
|
||||
}
|
||||
var repurl = "lc&sp=closed";
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
// special url for engage
|
||||
if (localStorage.getItem('lcjak_engage')) {
|
||||
searchurl = "lc/engage";
|
||||
|
||||
}
|
||||
repurl = "lc/closed";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Finally remove the engage storage
|
||||
if (localStorage.getItem('lcjak_engage')) localStorage.removeItem('lcjak_engage');
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,242 @@
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 3.0 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
// Standard vars
|
||||
var debugme = false;
|
||||
var working = false;
|
||||
var loadbtn = document.getElementById("send_contact");
|
||||
|
||||
// We send the value from the text area
|
||||
if (loadbtn) loadbtn.addEventListener("click", function(event){
|
||||
event.preventDefault();
|
||||
lcjak_contactchat();
|
||||
});
|
||||
|
||||
function lcjak_contactchat() {
|
||||
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
loadbtn.classList.remove("fa-paper-plane");
|
||||
loadbtn.classList.add("fa-spinner","fa-pulse");
|
||||
document.querySelector('.lcjak_input').classList.remove("error");
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the geo data
|
||||
var lcjak_geodata = "0";
|
||||
if (localStorage.getItem('lcjak_geodata')) lcjak_geodata = localStorage.getItem('lcjak_geodata');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=sendcontact&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Some sort of an error, let's redo the send button
|
||||
xhrc.addEventListener( "error", function( event ) {
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
});
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
var lcform = document.getElementById('lcjak_formfields');
|
||||
|
||||
lcform.innerHTML = '';
|
||||
|
||||
lcform.insertAdjacentHTML('beforeend', data.successdiv);
|
||||
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
|
||||
var s = document.getElementById('send_c_button').style;
|
||||
s.opacity = 1;
|
||||
(function fade(){(s.opacity-=.1)<0?s.display="none":setTimeout(fade,40)})();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (debugme) console.log(data.error);
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
|
||||
for (var k in data.error) {
|
||||
if (debugme) console.log(data.error[k]);
|
||||
document.getElementById(k).classList.add("error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("geo", lcjak_geodata);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_closechat(anim) {
|
||||
|
||||
const element = document.querySelector('.lcb_close');
|
||||
element.classList.add('animate__animated', 'animate__rotateOut');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc&sp=big";
|
||||
}
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "contactform") {
|
||||
searchurl = "lc&sp=contactform";
|
||||
}
|
||||
var repurl = "lc&sp=closed";
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc/big";
|
||||
}
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "contactform") {
|
||||
searchurl = "lc/contactform";
|
||||
}
|
||||
repurl = "lc/closed";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "closed");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::closed', cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_bigchat(anim) {
|
||||
|
||||
const element = document.querySelector('.jaklcb_maximise');
|
||||
element.classList.add('animate__animated', 'animate__slideOutUp');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "big");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::big', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
var repurl = "lc&sp=big";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
repurl = "lc/big";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_smallchat(anim) {
|
||||
|
||||
const element = document.querySelector('.jaklcb_minimize');
|
||||
element.classList.add('animate__animated', 'animate__slideOutDown');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "open");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::open', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=big";
|
||||
var repurl = "lc&sp=open";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/big";
|
||||
repurl = "lc/open";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.0.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
// Standard vars
|
||||
var debugme = working = false;
|
||||
var loadbtn = document.getElementById("end_save");
|
||||
|
||||
/* modern browsers - will execute code once all elements are loaded onto the client */
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
// content is loaded, load the value from storage
|
||||
lcjak_loadprofile(); // call the function to perform
|
||||
});
|
||||
|
||||
// We send the value from the text area
|
||||
loadbtn.addEventListener("click", function(event){
|
||||
event.preventDefault();
|
||||
lcjak_endchat();
|
||||
});
|
||||
|
||||
function lcjak_loadprofile() {
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the customer
|
||||
var lcjak_customer = "0";
|
||||
if (localStorage.getItem('lcjak_customer')) lcjak_customer = localStorage.getItem('lcjak_customer');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=loadprofile&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// Set the avatar if we have any
|
||||
if (data.avatar) {
|
||||
|
||||
let radios = document.getElementsByName("avatar");
|
||||
let value = data.avatar;//value you want to compare radio with
|
||||
|
||||
for (let i = 0, length = radios.length; i < length; i++) {
|
||||
if (radios[i].value == value) {
|
||||
radios[i].checked = true;
|
||||
// only one radio can be logically checked, don't check the rest
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set the name
|
||||
if (data.name) document.querySelector('input[name="name"]').value = data.name;
|
||||
|
||||
// Set the email
|
||||
if (data.email) document.querySelector('input[name="email"]').value = data.email;
|
||||
|
||||
// Set the phone
|
||||
if (data.phone) document.querySelector('input[name="phone"]').value = data.phone;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Something went wrong
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("customer", lcjak_customer);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_endchat() {
|
||||
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
loadbtn.classList.remove("fa-save");
|
||||
loadbtn.classList.add("fa-spinner","fa-pulse");
|
||||
document.querySelector('.lcjak_input').classList.remove("error");
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the customer
|
||||
var lcjak_customer = "0";
|
||||
if (localStorage.getItem('lcjak_customer')) lcjak_customer = localStorage.getItem('lcjak_customer');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=sendfeedback&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Some sort of an error, let's redo the send button
|
||||
xhrc.addEventListener( "error", function( event ) {
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-save");
|
||||
});
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// Finally remove the customer storage
|
||||
if (localStorage.getItem('lcjak_customer')) localStorage.removeItem('lcjak_customer');
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('removedata::0', cross_url);
|
||||
}
|
||||
|
||||
var lcform = document.getElementById('lcjak_formfields');
|
||||
|
||||
lcform.innerHTML = '';
|
||||
|
||||
lcform.insertAdjacentHTML('beforeend', data.successdiv);
|
||||
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
|
||||
var sfb = document.getElementById('send_f_button').style;
|
||||
sfb.opacity = 1;
|
||||
(function fade(){(sfb.opacity-=.1)<0?sfb.display="none":setTimeout(fade,40)})();
|
||||
|
||||
var bfb = document.getElementById('back_f_button').style;
|
||||
bfb.opacity = 1;
|
||||
(function fade(){(bfb.opacity-=.1)<0?bfb.display="none":setTimeout(fade,40)})();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (debugme) console.log(data.error);
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-save");
|
||||
|
||||
for (var k in data.error) {
|
||||
console.log(data.error[k]);
|
||||
document.getElementById(k).classList.add("error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("customer", lcjak_customer);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_closechat(anim, fstatus, tstatus) {
|
||||
|
||||
const element = document.querySelector('.lcb_close');
|
||||
element.classList.add('animate__animated', 'animate__'+anim);
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp="+fstatus;
|
||||
var repurl = "lc&sp="+tstatus;
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/"+fstatus;
|
||||
repurl = "lc/"+tstatus;
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', tstatus);
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::'+tstatus, cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_windowchange(anim, fstatus, tstatus) {
|
||||
|
||||
const element = document.querySelector('.lcb_change');
|
||||
element.classList.add('animate__animated', 'animate__'+anim);
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp="+fstatus;
|
||||
var repurl = "lc&sp="+tstatus;
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/"+fstatus;
|
||||
repurl = "lc/"+tstatus;
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', tstatus);
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::'+tstatus, cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_backtochat(anim, fstatus, tstatus) {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
const element = document.querySelector('.lcb_back');
|
||||
element.classList.add('animate__animated', 'animate__'+anim);
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the customer
|
||||
var lcjak_customer = "0";
|
||||
if (localStorage.getItem('lcjak_customer')) lcjak_customer = localStorage.getItem('lcjak_customer');
|
||||
|
||||
// We set the chat to open
|
||||
var xhrc = new XMLHttpRequest();
|
||||
xhrc.open('POST', base_url+'include/chatcontrol.php?id='+lcjakwidgetid+'&run=backtochat&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp="+fstatus;
|
||||
var repurl = "lc&sp="+tstatus;
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/"+fstatus;
|
||||
repurl = "lc/"+tstatus;
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', tstatus);
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::'+tstatus, cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (debugme) console.log(data.error);
|
||||
}
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
// Attach Data
|
||||
var formData = new FormData();
|
||||
formData.append("rlbid", lcjak_session);
|
||||
formData.append("customer", lcjak_customer);
|
||||
|
||||
xhrc.send(formData);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.4 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
// Standard vars
|
||||
var debugme = false;
|
||||
var working = false;
|
||||
|
||||
/* modern browsers - will execute code once all elements are loaded onto the client */
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
// content is loaded, load the value from storage
|
||||
lcjak_loadprofile(); // call the function to perform
|
||||
});
|
||||
|
||||
// We send the value from the text area
|
||||
document.getElementById("profile_save").addEventListener("click", function(event){
|
||||
event.preventDefault();
|
||||
lcjak_saveprofile();
|
||||
});
|
||||
|
||||
function lcjak_loadprofile() {
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the customer
|
||||
var lcjak_customer = "0";
|
||||
if (localStorage.getItem('lcjak_customer')) lcjak_customer = localStorage.getItem('lcjak_customer');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=loadprofile&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// Set the avatar if we have any
|
||||
if (data.avatar) {
|
||||
|
||||
let radios = document.getElementsByName("avatar");
|
||||
let value = data.avatar;//value you want to compare radio with
|
||||
|
||||
for (let i = 0, length = radios.length; i < length; i++) {
|
||||
if (radios[i].value == value) {
|
||||
radios[i].checked = true;
|
||||
// only one radio can be logically checked, don't check the rest
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set the name
|
||||
if (data.name) document.querySelector('input[name="name"]').value = data.name;
|
||||
|
||||
// Set the email
|
||||
if (data.email) document.querySelector('input[name="email"]').value = data.email;
|
||||
|
||||
// Set the phone
|
||||
if (data.phone) document.querySelector('input[name="phone"]').value = data.phone;
|
||||
|
||||
// Set the language
|
||||
var countrylang = document.getElementById("profile_language");
|
||||
// Set the select element's value to the desired value
|
||||
countrylang.value = data.lang;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Something went wrong
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("customer", lcjak_customer);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_saveprofile() {
|
||||
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
var loadbtn = document.getElementById("profile_save");
|
||||
loadbtn.classList.remove("fa-save");
|
||||
loadbtn.classList.add("fa-spinner","fa-pulse");
|
||||
document.querySelector('.lcjak_input').classList.remove("error");
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the customer
|
||||
var lcjak_customer = "0";
|
||||
if (localStorage.getItem('lcjak_customer')) lcjak_customer = localStorage.getItem('lcjak_customer');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=changeprofile&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Some sort of an error, let's redo the send button
|
||||
xhrc.addEventListener( "error", function( event ) {
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-save");
|
||||
});
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// Finally update the customer storage
|
||||
if (localStorage.getItem('lcjak_customer')) localStorage.setItem('lcjak_customer', data.customer);
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('customerdata::'+data.customer, cross_url);
|
||||
}
|
||||
|
||||
// the new status
|
||||
var lstor = "open";
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=profile";
|
||||
var repurl = "lc&sp=big";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "bigprofile") {
|
||||
searchurl = "lc&sp=bigprofile";
|
||||
repurl = "lc&sp=big";
|
||||
lstor = "big";
|
||||
}
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/profile";
|
||||
repurl = "lc/open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "bigprofile") {
|
||||
searchurl = "lc/bigprofile";
|
||||
repurl = "lc/big";
|
||||
lstor = "big";
|
||||
}
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', lstor);
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::'+lstor, cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (debugme) console.log(data.error);
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-save");
|
||||
|
||||
for (var k in data.error) {
|
||||
console.log(data.error[k]);
|
||||
document.getElementById(k).classList.add("error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("customer", lcjak_customer);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_closechat(anim) {
|
||||
|
||||
const element = document.querySelector('.lcb_close');
|
||||
element.classList.add('animate__animated', 'animate__rotateOut');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "bigprofile") {
|
||||
searchurl = "lc&sp=bigprofile";
|
||||
}
|
||||
var repurl = "lc&sp=closed";
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "bigprofile") {
|
||||
searchurl = "lc/bigprofile";
|
||||
}
|
||||
repurl = "lc/closed";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "closed");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::closed', cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_bigchat(anim) {
|
||||
|
||||
const element = document.querySelector('.lcb_max');
|
||||
element.classList.add('animate__animated', 'animate__'+anim);
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to bigprofile
|
||||
localStorage.setItem('lcjak_chatstatus', "bigprofile");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::bigprofile', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=profile";
|
||||
var repurl = "lc&sp=bigprofile";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/profile";
|
||||
repurl = "lc/bigprofile";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_bigchatback(anim) {
|
||||
|
||||
const element = document.querySelector('.lcb_max');
|
||||
element.classList.add('animate__animated', 'animate__'+anim);
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to big
|
||||
localStorage.setItem('lcjak_chatstatus', "big");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::big', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=bigprofile";
|
||||
var repurl = "lc&sp=big";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/bigprofile";
|
||||
repurl = "lc/big";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_smallchat(anim) {
|
||||
|
||||
const element = document.querySelector('.lcb_backtochat');
|
||||
element.classList.add('animate__animated', 'animate__'+anim);
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=profile";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc&sp=bigprofile";
|
||||
}
|
||||
var repurl = "lc&sp=open";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/profile";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc/bigprofile";
|
||||
}
|
||||
repurl = "lc/open";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "open");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::open', cross_url);
|
||||
}
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.4 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
// Standard vars
|
||||
var debugme = false;
|
||||
var working = false;
|
||||
|
||||
/* modern browsers - will execute code once all elements are loaded onto the client */
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
// content is loaded, load the value from storage
|
||||
if (localStorage.getItem('lcjak_customvars')) lcjak_customvars(); // call the function to perform
|
||||
});
|
||||
|
||||
// We listen for the enter key on the textarea
|
||||
document.getElementById("quickstart_chat_msg").addEventListener("keyup", function(event) {
|
||||
event.preventDefault();
|
||||
if (event.keyCode === 13) {
|
||||
document.getElementById("start_chat_btn").click();
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("start_chat_btn").addEventListener("click", function(event){
|
||||
event.preventDefault();
|
||||
lcjak_startChat();
|
||||
});
|
||||
|
||||
// Emoticons
|
||||
document.getElementById("emoticons").addEventListener("click", function() {
|
||||
// get the button bubble
|
||||
likeBox = document.getElementById("emoticons_btn");
|
||||
|
||||
if (likeBox.style.display === '') {
|
||||
addCSS(likeBox);
|
||||
} else {
|
||||
removeCSS(likeBox);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function sendEmo(shortcode) {
|
||||
|
||||
// get the button bubble
|
||||
likeBox = document.getElementById("emoticons_btn");
|
||||
|
||||
// Add the text to the textarea
|
||||
var txta = document.getElementById("quickstart_chat_msg");
|
||||
txta.value += shortcode+' ';
|
||||
txta.focus();
|
||||
|
||||
// remove the emoticons box
|
||||
removeCSS(likeBox);
|
||||
|
||||
}
|
||||
|
||||
function addCSS(lb) {
|
||||
lb.style.display = 'block';
|
||||
// add class
|
||||
if (lb.classList) {
|
||||
lb.classList.add("animate__fadeInUp");
|
||||
} else {
|
||||
lb.className = lb.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
||||
}
|
||||
}
|
||||
|
||||
function removeCSS(lb) {
|
||||
// remove class
|
||||
if (lb.classList) {
|
||||
lb.classList.remove("animate__fadeInUp");
|
||||
} else {
|
||||
lb.className = lb.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
||||
}
|
||||
lb.style.display = '';
|
||||
}
|
||||
|
||||
function lcjak_customvars() {
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the customer
|
||||
var lcjak_customvars = "0";
|
||||
if (localStorage.getItem('lcjak_customvars')) lcjak_customvars = localStorage.getItem('lcjak_customvars');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=loadcustomvars&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// Set the name
|
||||
if (data.name) document.querySelector('input[name="start_name"]').value = data.name;
|
||||
|
||||
// Set the email
|
||||
if (data.email) document.querySelector('input[name="start_email"]').value = data.email;
|
||||
|
||||
// Set the chat message
|
||||
if (data.msg) document.querySelector('textarea[name="quickstart_chat_msg"]').value = data.msg;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Something went wrong
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("customvars", lcjak_customvars);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_startChat() {
|
||||
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
var msgfield = document.getElementById("quickstart_chat_msg");
|
||||
var loadbtn = document.getElementById("start_chat_load");
|
||||
loadbtn.classList.remove("fa-paper-plane");
|
||||
loadbtn.classList.add("fa-spinner","fa-pulse");
|
||||
msgfield.classList.remove("error");
|
||||
|
||||
// Let's get the current status of the local storage
|
||||
lcjak_chatstatus = localStorage.getItem('lcjak_chatstatus');
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the geo data
|
||||
var lcjak_geodata = "0";
|
||||
if (localStorage.getItem('lcjak_geodata')) lcjak_geodata = localStorage.getItem('lcjak_geodata');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=quickstart&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 0;
|
||||
|
||||
// Some sort of an error, let's redo the send button
|
||||
xhrc.addEventListener( "error", function( event ) {
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
});
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// We have a success we need to fire up the chat
|
||||
|
||||
// Make sure we have the correct client
|
||||
localStorage.setItem('lcjak_customer', data.customer);
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('customerdata::'+data.customer, cross_url);
|
||||
}
|
||||
|
||||
// We reload the location
|
||||
window.location = data.gotochat;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (debugme) console.log(data.error);
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
msgfield.classList.add("error");
|
||||
msgfield.setAttribute('placeholder', data.error['quickstart_chat_msg']);
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
// Additional Form Data
|
||||
FD.append("chatstatus", lcjak_chatstatus);
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("geo", lcjak_geodata);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_closechat(anim) {
|
||||
|
||||
const element = document.querySelector('.lcb_close');
|
||||
element.classList.add('animate__animated', 'animate__rotateOut');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc&sp=big";
|
||||
}
|
||||
var repurl = "lc&sp=closed";
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc/big";
|
||||
}
|
||||
repurl = "lc/closed";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "closed");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::closed', cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_bigchat(anim) {
|
||||
|
||||
const element = document.querySelector('.jaklcb_maximise');
|
||||
element.classList.add('animate__animated', 'animate__slideOutUp');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "big");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::big', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
var repurl = "lc&sp=big";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
repurl = "lc/big";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_smallchat(anim) {
|
||||
|
||||
const element = document.querySelector('.jaklcb_minimize');
|
||||
element.classList.add('animate__animated', 'animate__slideOutDown');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "open");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::open', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=big";
|
||||
var repurl = "lc&sp=open";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/big";
|
||||
repurl = "lc/open";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.4 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
// Standard vars
|
||||
var debugme = false;
|
||||
var working = false;
|
||||
|
||||
/* modern browsers - will execute code once all elements are loaded onto the client */
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
// content is loaded, load the value from storage
|
||||
if (localStorage.getItem('lcjak_customvars')) lcjak_customvars(); // call the function to perform
|
||||
});
|
||||
|
||||
// We listen for the enter key on the textarea
|
||||
if (document.getElementById('start_chat_msg')) {
|
||||
document.getElementById("start_chat_msg").addEventListener("keyup", function(event) {
|
||||
event.preventDefault();
|
||||
if (event.keyCode === 13) {
|
||||
document.getElementById("start_chat_btn").click();
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("start_chat_btn").addEventListener("click", function(event){
|
||||
event.preventDefault();
|
||||
lcjak_startChat();
|
||||
});
|
||||
}
|
||||
|
||||
function lcjak_customvars() {
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the customer
|
||||
var lcjak_customvars = "0";
|
||||
if (localStorage.getItem('lcjak_customvars')) lcjak_customvars = localStorage.getItem('lcjak_customvars');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=loadcustomvars&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 3000;
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// Set the name
|
||||
if (data.name) document.querySelector('input[name="start_name"]').value = data.name;
|
||||
|
||||
// Set the email
|
||||
if (data.email) document.querySelector('input[name="start_email"]').value = data.email;
|
||||
|
||||
// Set the chat message
|
||||
if (data.msg) document.querySelector('textarea[name="start_chat_msg"]').value = data.msg;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Something went wrong
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("customvars", lcjak_customvars);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_startChat() {
|
||||
|
||||
if (working) return false;
|
||||
working = true;
|
||||
|
||||
var loadbtn = document.getElementById("start_chat_btn");
|
||||
loadbtn.classList.remove("fa-paper-plane");
|
||||
loadbtn.classList.add("fa-spinner","fa-pulse");
|
||||
document.querySelector('.lcjak_input').classList.remove("error");
|
||||
|
||||
// Let's get the current status of the local storage
|
||||
lcjak_chatstatus = localStorage.getItem('lcjak_chatstatus');
|
||||
|
||||
// Get the session
|
||||
var lcjak_session = "0";
|
||||
if (localStorage.getItem('lcjak_session')) lcjak_session = localStorage.getItem('lcjak_session');
|
||||
|
||||
// Get the geo data
|
||||
var lcjak_geodata = "0";
|
||||
if (localStorage.getItem('lcjak_geodata')) lcjak_geodata = localStorage.getItem('lcjak_geodata');
|
||||
|
||||
var xhrc = new XMLHttpRequest();
|
||||
|
||||
// Bind the FormData object and the form element
|
||||
const lcjakform = document.getElementById("lcjak_ajaxform");
|
||||
const FD = new FormData(lcjakform);
|
||||
|
||||
// Call the file to verify and start the process
|
||||
xhrc.open('POST', base_url+'include/chatdata.php?id='+lcjakwidgetid+'&run=start&lang='+lcjak_lang, true);
|
||||
|
||||
// time in milliseconds
|
||||
xhrc.timeout = 0;
|
||||
|
||||
// Some sort of an error, let's redo the send button
|
||||
xhrc.addEventListener( "error", function( event ) {
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
});
|
||||
|
||||
// Request
|
||||
xhrc.onload = function() {
|
||||
if (xhrc.status >= 200 && xhrc.status < 400) {
|
||||
// Success!
|
||||
var data = JSON.parse(xhrc.responseText);
|
||||
|
||||
// We have data
|
||||
if (data.status) {
|
||||
|
||||
if (debugme) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
} else {
|
||||
|
||||
// We have a success we need to fire up the chat
|
||||
|
||||
// Make sure we have the correct client
|
||||
localStorage.setItem('lcjak_customer', data.customer);
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('customerdata::'+data.customer, cross_url);
|
||||
}
|
||||
|
||||
// We reload the location
|
||||
window.location = data.gotochat;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (debugme) console.log(data.error);
|
||||
loadbtn.classList.remove("fa-spinner","fa-pulse");
|
||||
loadbtn.classList.add("fa-paper-plane");
|
||||
|
||||
for (var k in data.error) {
|
||||
if (debugme) console.log(data.error[k]);
|
||||
document.getElementById(k).classList.add("error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We will make the form again
|
||||
working = false;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// We reached our target server, but it returned an error
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhrc.onerror = function() {
|
||||
// There was a connection error of some sort
|
||||
};
|
||||
|
||||
xhrc.ontimeout = function (e) {
|
||||
// XMLHttpRequest timed out. Do something here.
|
||||
};
|
||||
|
||||
// Additional Form Data
|
||||
FD.append("chatstatus", lcjak_chatstatus);
|
||||
FD.append("rlbid", lcjak_session);
|
||||
FD.append("geo", lcjak_geodata);
|
||||
|
||||
// Finally send the data
|
||||
xhrc.send(FD);
|
||||
|
||||
}
|
||||
|
||||
function lcjak_closechat(anim) {
|
||||
|
||||
const element = document.querySelector('.lcb_close');
|
||||
element.classList.add('animate__animated', 'animate__rotateOut');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc&sp=big";
|
||||
}
|
||||
var repurl = "lc&sp=closed";
|
||||
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
if (localStorage.getItem('lcjak_chatstatus') == "big") {
|
||||
searchurl = "lc/big";
|
||||
}
|
||||
repurl = "lc/closed";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "closed");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::closed', cross_url);
|
||||
}
|
||||
|
||||
// Redirect to close the chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_bigchat(anim) {
|
||||
|
||||
const element = document.querySelector('.jaklcb_maximise');
|
||||
element.classList.add('animate__animated', 'animate__slideOutUp');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "big");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::big', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=open";
|
||||
var repurl = "lc&sp=big";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/open";
|
||||
repurl = "lc/big";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lcjak_smallchat(anim) {
|
||||
|
||||
const element = document.querySelector('.jaklcb_minimize');
|
||||
element.classList.add('animate__animated', 'animate__slideOutDown');
|
||||
|
||||
element.addEventListener('animationend', () => {
|
||||
|
||||
// Set the local storage to closed
|
||||
localStorage.setItem('lcjak_chatstatus', "open");
|
||||
|
||||
// We also need to send the customer data to the other domain if
|
||||
if (cross_url && parent.postMessage) {
|
||||
parent.postMessage('chatstatus::open', cross_url);
|
||||
}
|
||||
|
||||
// Replace the current url with the new one /prevent ajax request
|
||||
let old_url = window.location.href;
|
||||
|
||||
// Let us check if we have rewrite enabled
|
||||
var searchurl = "lc&sp=big";
|
||||
var repurl = "lc&sp=open";
|
||||
if (base_rewrite == 1) {
|
||||
searchurl = "lc/big";
|
||||
repurl = "lc/open";
|
||||
}
|
||||
let new_url = old_url.replace(searchurl, repurl);
|
||||
if (debugme) console.log(new_url);
|
||||
|
||||
// Redirect to big chat
|
||||
window.location = new_url;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user