PageSourceSearch

https://gr8.tech/wp-content/themes/pmtech/js-own/functions.js?x21192&v=1790875210

js gr8.tech collected 2026-10-03 20:24:34 UTC 24,985 bytes, 581 lines download raw bytes

1
2
3// var $ = jQuery;
4
5
6// var is_open = false; // chat starts closed
7// function toggleCrisp(forceOpen = null) {
8//     if (forceOpen === true || (!is_open && forceOpen !== false)) {
9//         $crisp.push(['do', 'chat:open']);
10//         is_open = true;
11//         console.log("Crisp chat opened");
12//     } else if (forceOpen === false || (is_open && forceOpen !== true)) {
13//         $crisp.push(['do', 'chat:close']);
14//         is_open = false;
15//         console.log("Crisp chat closed");
16//     }
17// }
18
19
20// $(document).ready(function($) {
21//     // var ajaxurl = "https://gr8-test.online/wp-admin/admin-ajax.php";
22//     var ajaxurl = myAjax.ajaxurl;
23//     console.log('==================================================AJAX URL:', ajaxurl);
24//     // console.log('Is jQuery loaded?', typeof jQuery);
25
26    
27//     // company: "Test 2",
28//     // email: "[email protected]",
29//     // fname: "test 2",
30//     // ggr: "0,5",
31//     // license: "Yes",
32//     // operation: "Yes",
33//     // solutions: "Full Platform",
34//     // session_id: sessionId || "not_available"
35    
36    
37    
38    
39    
40    
41    
42//     // const sessionId = getCrispSessionIdFromCookies();
43//     // const clientData = {
44//     //     company: "gr8 test ABCD",
45//     //     email: "[email protected]",
46//     //     fname: "Tigran",
47//     //     ggr: "0,5-1 M",
48//     //     license: "Yes",
49//     //     operation: "Yes",
50//     //     session_id: sessionId || "not_available",
51//     //     solutions: "Full Platform"
52//     // };
53//     // $.post(ajaxurl, { action: "send_to_crisp", ...clientData }, function(response) {
54//     //     console.log("Response:", response);
55//     // });
56
57
58
59
60    
61//     // $crisp.push(["set", "user:email", clientData.fname]);
62//     // $crisp.push(["set", "user:nickname", clientData.email]);
63
64//     // $("#crisp-chatbox-button").on('click', function(){
65//     //     $('#crisp-chatbox-chat').toggleClass('full-size');
66//     //     $('#crisp-chatbox-chat').toggleClass('hide-size');
67//     // })
68//     // $(".cc-q7alh.cc-qdda2").on('click', function(){
69//     //     $('#crisp-chatbox-chat').toggleClass('full-size');
70//     //     $('#crisp-chatbox-chat').toggleClass('hide-size');
71//     // })
72//     // var is_open = true;
73//     // function toggleCrisp() {
74//     //     if(is_open) {
75//     //         $crisp.push(['do', 'chat:open'])
76//     //         is_open = false
77//     //         console.log("bac");
78            
79//     //     } else {
80//     //         $crisp.push(['do', 'chat:close'])
81//     //         is_open = true
82//     //         console.log("pak");
83            
84//     //     }
85//     // }
86
87    
88
89//     $(document).on('click', '#crisp-chatbox-button', function() {
90//         toggleCrisp(true)
91//     });
92    
93//     $(document).on('click', '.cc-q7alh.cc-qdda2', function() {
94//         toggleCrisp(false)
95//     });
96
97//     // $('#crisp-chatbox-chat').addClass('full-size');
98//     // // $('div.crisp-client').addClass('show-crisp');
99//     // // $('div.crisp-client').css('display','block');
100//     // $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css('opacity', '0');
101//     // $(".gr8contact-form").removeClass("live-chat-blured");
102//     // $(".close-gr8contact-form").click();
103//     // $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
104//     // $crisp.push(['do', 'chat:show']);
105
106
107
108
109//     $(".yes-special").on('click', function () {
110//         $(".gr8contact-form .step").hide();
111//         $(".step-live-chat").css('display', 'flex');
112//         $(".gr8contact-form").addClass("live-chat-blured");
113
114//         var swiper = new Swiper(".managers_slider", {
115//             slidesPerView: 1,
116//             centeredSlides: true,
117//             loop: true,
118//             autoplay: {
119//                 delay: 3000,
120//             },
121//             breakpoints: {
122//                 961: {
123//                     slidesPerView: 3,
124//                 }
125//             }
126//         });
127//         swiper.update();
128
129        
130
131//         let all = window.formData[window.formData.length - 1];
132//         function findValue(keyword) {
133//             try {
134//                 if (!all || typeof all !== 'object') {
135//                     console.warn("findValue: 'all' is not defined or not an object");
136//                     return undefined;
137//                 }
138//                 const key = Object.keys(all).find(k => k.includes(keyword));
139//                 console.log(`findValue('${keyword}') found key:`, key);
140//                 return key ? all[key] : undefined;
141//             } catch (err) {
142//                 console.error("findValue error:", err);
143//                 return undefined;
144//             }
145//         }
146
147
148//         function waitForCrisp() {
149//             if ($('div.crisp-client').length) {
150//                 $('div.crisp-client').addClass('show-crisp');
151//             } else {
152//                 setTimeout(waitForCrisp, 500);
153//             }
154//         }
155        
156//         const sessionId = getCrispSessionIdFromCookies();
157//         console.log("Before creating clientData — is 'all' defined?", typeof all, all);
158
159//         const clientData = {
160//             fname:     findValue("firstname"), // || "fname",
161//             solutions: findValue("what_kind_of_solutions"), // || "solutions",
162//             operation: findValue("do_you_have_an_existing_igaming_operations"), // || "operation",
163//             ggr:       findValue("please_specify_a_volume_of_your_ggr"), // || "ggr",
164//             license:   findValue("do_you_have_a_license"), // || "license",
165//             company:   findValue("company"), // || "company",
166//             email:     findValue("email"), // || "[email protected]",
167
168//             region:    findValue("what_regions_are_you_interested"),
169//             country:   findValue("country") || 'not selected',
170//             phone:     findValue("phone"),
171//             messanger: findValue("messenger"),
172
173//             session_id: sessionId || "not_available"
174//         };
175
176
177//         $.post(ajaxurl, { action: "send_to_crisp", ...clientData }, function(response) {
178//             console.log('Sending to Crisp AJAX:', { action: "send_to_crisp", ...clientData });
179//             console.log("=======================================");
180//             console.log(clientData);
181//             console.log("=======================================");
182
183//             if (response.success) {
184//                 setTimeout(function() {
185//                     const sessionId = response.data.session_id || "not_available";
186        
187//                     console.log("Crisp session ID:", sessionId);
188
189//                     $crisp.push(['do', 'chat:show']);
190//                     $crisp.push(["set", "user:nickname", clientData.fname]);
191//                     $('body div.crisp-client').addClass('show-crisp').css('display','block');;
192//                     $('#crisp-chatbox-chat').addClass('full-size');
193//                     $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
194//                     toggleCrisp(true);
195//                     // $('#crisp-chatbox-button').click();
196//                     // waitForCrisp();
197//                     $('div.crisp-client').css('display','block');
198//                     // $('body').append('<iframe src="https://go.crisp.chat/chat/embed/?website_id=8e03ddab-f8b6-417a-a76c-bea476260889" class="crisp-client-iframe" width="350" height="600"></iframe>')
199//                     $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css('opacity', '0');
200//                     $(".gr8contact-form").removeClass("live-chat-blured");
201//                     $(".close-gr8contact-form").click();
202//                     $('body div.crisp-client').addClass('show-crisp').css('display','block');;
203//                     $('#crisp-chatbox-chat').addClass('full-size');
204//                     $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
205//                     toggleCrisp(true);
206//                     // $('#crisp-chatbox-button').click();
207//                     // waitForCrisp();
208//                     $('body div.crisp-client').css('display','block');
209//                     // $('body').append('<iframe src="https://go.crisp.chat/chat/embed/?website_id=8e03ddab-f8b6-417a-a76c-bea476260889" class="crisp-client-iframe" width="350" height="600"></iframe>')
210//                     $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css('opacity', '0');
211//                     $(".gr8contact-form").removeClass("live-chat-blured");
212//                     $(".close-gr8contact-form").click();
213//                 }, 7000);
214//             } 
215//             else {
216//                 console.error("Crisp error:", response);
217//             }
218//         })
219//         .done(function(response) {
220//             // $('body').append('<iframe src="https://go.crisp.chat/chat/embed/?website_id=8e03ddab-f8b6-417a-a76c-bea476260889?" class="crisp-client-iframe" width="350" height="600"></iframe>')
221//             console.log("Crisp success:", response);
222//         })
223//         .fail(function(xhr) {
224//             console.error("Crisp AJAX failed:", xhr.status, xhr.responseText);
225//             $crisp.push(['do', 'chat:show']);
226//             $('div.crisp-client').addClass('show-crisp').css('display','block');
227//             $('div.crisp-client.cc-162fn').addClass('show-crisp').css('display','block');
228//             $('#crisp-chatbox-chat').addClass('full-size');
229//             $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
230//             toggleCrisp(true);
231//             // $('#crisp-chatbox-button').click();
232//             // waitForCrisp();
233//             $('div.crisp-client').css('display','block');
234//             // $('body').append('<iframe src="https://go.crisp.chat/chat/embed/?website_id=8e03ddab-f8b6-417a-a76c-bea476260889" class="crisp-client-iframe" width="350" height="600"></iframe>')
235//             $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css('opacity', '0');
236//             $(".gr8contact-form").removeClass("live-chat-blured");
237//             $(".close-gr8contact-form").click();
238//             $('div.crisp-client').addClass('show-crisp').css('display','block');;
239//             $('#crisp-chatbox-chat').addClass('full-size');
240//             $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
241//             toggleCrisp(true);
242//             // $('#crisp-chatbox-button').click();
243//             // waitForCrisp();
244//             $('div.crisp-client').css('display','block');
245//             $('div.crisp-client.cc-162fn').addClass('show-crisp').css('display','block');
246//             // $('body').append('<iframe src="https://go.crisp.chat/chat/embed/?website_id=8e03ddab-f8b6-417a-a76c-bea476260889" class="crisp-client-iframe" width="350" height="600"></iframe>')
247//             $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css('opacity', '0');
248//             $(".gr8contact-form").removeClass("live-chat-blured");
249//             $(".close-gr8contact-form").click();
250//             // $crisp.push(["set", "user:email", clientData.email]);
251
252//             // $crisp.push(["set", "user:nickname", clientData.fname]);
253//             // $crisp.push(["set", "user:company", [clientData.company]]);
254//             // $crisp.push([
255//             // "set",
256//             // "session:data",
257//             // [
258//             //     ["Solutions", clientData.solutions],
259//             //     ["Operation", clientData.operation],
260//             //     ["GGR", clientData.ggr],
261//             //     ["License", clientData.license],
262//             //     ["Session ID", clientData.session_id]
263//             // ]
264//             // ]);
265//             function setCrispData() {
266//                 if (typeof $crisp !== "undefined" && $crisp.push) {
267//                     $crisp.push(["set", "user:email", clientData.email]);
268//                     $crisp.push(["set", "user:nickname", clientData.fname]);
269//                     $crisp.push(["set", "user:company", [clientData.company]]);
270//                     $crisp.push(["set", "session:data", [
271//                     ["Solutions", clientData.solutions || "N/A"],
272//                     ["Operation", clientData.operation || "N/A"],
273//                     ["GGR", clientData.ggr || "N/A"],
274//                     ["License", clientData.license || "N/A"],
275//                     ["Session ID", clientData.session_id || "N/A"]
276//                     ]]);
277//             } else {
278//                 setTimeout(setCrispData, 1000); // retry after 1 second
279//             }
280//             }
281//             setCrispData();
282//         });;
283//     });
284// });
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318var $ = jQuery;
319
320$(document).ready(function($) {
321    setTimeout(function(){
322        // $crisp.push(["do", "session:reset"])
323        $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
324    },2000)
325    restoreLiveChatState();
326
327    // ================================
328    // 1. CRISP LISTENERS (watch operator)
329    // ================================
330    function initializeCrispListener() {
331        if (typeof $crisp === 'undefined') {
332            setTimeout(initializeCrispListener, 500);
333            return;
334        }
335
336        // --- A) Operator sends a message ---
337        $crisp.push(["on", "message:received", function(message) {
338            if (message.from === "operator") {
339                console.log("Operator replied — hiding slider and opening chat.");
340
341                localStorage.setItem("gr8_live_chat_open", "1");
342
343                $(".step-live-chat").fadeOut(300);
344                $(".gr8contact-form").removeClass("live-chat-blured");
345                $(".close-gr8contact-form").click();
346                $('#hubspot-messages-iframe-container').addClass('hide-personal-assistent').css({'opacity': '0','display': 'none'});
347                $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css({'opacity': '0','display': 'none'});
348                $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
349                $("body > div.crisp-client").addClass("show-crisp-client");
350                console.log($("body > div.crisp-client"))
351
352                $crisp.push(["do", "chat:show"]);
353                $crisp.push(["do", "chat:open"]);
354            }
355        }]);
356
357        // --- B) Operator opens the conversation ---
358        $crisp.push(["on", "session:joined", function() {
359            console.log("Operator joined the chat — hiding slider and opening chat.");
360
361            $(".step-live-chat").fadeOut(300);
362            $(".gr8contact-form").removeClass("live-chat-blured");
363            $(".close-gr8contact-form").click();
364            $('#hubspot-messages-iframe-container').addClass('hide-personal-assistent').css({'opacity': '0','display': 'none'});
365            $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css({'opacity': '0','display': 'none'});
366            $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
367            $("body > div.crisp-client").addClass("show-crisp-client");
368            console.log($("body > div.crisp-client"))
369
370            $crisp.push(["do", "chat:show"]);
371            $crisp.push(["do", "chat:open"]);
372        }]);
373
374        // --- C) Every page load Crisp initializes again ---
375        $crisp.push(["on", "session:loaded", function () {
376            console.log("Crisp session loaded — checking restore flag...");
377            if (localStorage.getItem("gr8_live_chat_open") === "1") {
378                
379                $(".step-live-chat").fadeOut(300);
380                $(".gr8contact-form").removeClass("live-chat-blured");
381                $(".close-gr8contact-form").click();
382                $('#hubspot-messages-iframe-container').addClass('hide-personal-assistent').css({'opacity': '0','display': 'none'});
383                $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css({'opacity': '0','display': 'none'});
384                $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
385                $("body > div.crisp-client").addClass("show-crisp-client");
386
387                $crisp.push(["do", "chat:show"]);
388                // $crisp.push(["do", "chat:open"]);
389            }
390        }]);
391
392        // Chat stays hidden until operator joins
393        $crisp.push(["do", "chat:hide"]);
394    }
395    initializeCrispListener();
396
397    $(".yes-special").on('click', function () {
398        $(".gr8contact-form .step").hide();
399        $(".step-live-chat").css('display', 'flex'); 
400        $(".gr8contact-form").addClass("live-chat-blured");
401
402        // Initialize swiper variable at a higher scope
403        var swiper = null;
404        
405        // ========== SWIPER CAROUSEL ==========
406        function initializeSwiper() {
407            swiper = new Swiper(".managers_slider", {
408                slidesPerView: 1,
409                centeredSlides: true,
410                loop: true,
411                autoplay: { delay: 3000 },
412                breakpoints: { 961: { slidesPerView: 3 } }
413            });
414            swiper.update();
415        }
416        
417        // Initialize swiper immediately
418        initializeSwiper();
419        
420        // Timer to stop swiper after 2 minutes (120000 milliseconds)
421        var swiperTimer = setTimeout(function() {
422            if (swiper) {
423                // Stop autoplay
424                swiper.autoplay.stop();
425                // Destroy swiper instance to stop all functionality
426                swiper.destroy(true, true);
427                swiper = null;
428                
429                // Show alert that managers are busy
430                // alert("All our managers are currently busy. Please try again later or leave your contact details and we'll get back to you as soon as possible.");
431                
432                // Optional: Hide the slider or show a message
433                $(".gr8contact-form").removeClass("live-chat-blured");
434                $('.step-live-chat > h3').css('display', 'none')
435                $('.step-live-chat > p').css('display', 'none')
436                $('.step-live-chat').addClass('managers-busy')
437                $(".managers_slider").html(`
438                    <div class="busy-message" style="text-align: center; height:initial;color: #000000ff;">
439                        <p class="title-message">All our <br>managers are busy at the moment</p>
440                        <p class="message-text">Please book a meeting that suits your schedule - or we’ll contact you by email to follow up.</p>
441                        <a href="https://meetings-eu1.hubspot.com/kateryna-nechaieva/book" class="book-a-meeting">book a meeting</a>
442                    </div>
443                `);
444            }
445        }, 180000);
446
447        // ========== FORM DATA ==========
448        let all = (window.formData && window.formData.length > 0)
449            ? window.formData[window.formData.length - 1]
450            : {};
451
452        function safeStr(val) {
453            return (val && typeof val === 'string') ? val : "Not Provided";
454        }
455
456        function findValue(keyword) {
457            try {
458                if (!all || typeof all !== 'object') return undefined;
459                const key = Object.keys(all).find(k => k.includes(keyword));
460                return key ? all[key] : undefined;
461            } catch (err) {
462                return undefined;
463            }
464        }
465
466        const clientData = {
467            fname:     findValue("firstname"), // || "fname",
468            solutions: findValue("what_kind_of_solutions"), // || "solutions",
469            operation: findValue("do_you_have_an_existing_igaming_operations"), // || "operation",
470            ggr:       findValue("please_specify_a_volume_of_your_ggr"), // || "ggr",
471            license:   findValue("do_you_have_a_license"), // || "license",
472            company:   findValue("company"), // || "company",
473            email:     findValue("email"), // || "[email protected]",
474
475            region:    findValue("what_regions_are_you_interested"),
476            country:   findValue("country") || 'not selected',
477            phone:     findValue("phone"),
478            messanger: findValue("messenger"),
479        };      
480        
481
482        var messageText = `📩 New Inquiry from Website:
483
484    Name: ${clientData.fname}
485    Company: ${clientData.company}
486    Email: ${clientData.email}
487    Solutions: ${clientData.solutions}
488    Operation: ${clientData.operation}
489    GGR: ${clientData.ggr}
490    License: ${clientData.license}
491    Region: ${clientData.region}
492    Country: ${clientData.country}
493    Phone Number: ${clientData.phone}
494    Messanger: ${clientData.messanger}`;
495
496        console.log(messageText);
497
498        // ========== CRISP HANDSHAKE ==========
499        function triggerCrispHandshake() {
500            if (typeof $crisp === 'undefined') {
501                setTimeout(triggerCrispHandshake, 500);
502                return;
503            }
504
505            // Get values
506            var rawEmail = findValue("email");
507            var rawName = findValue("firstname");
508            var rawCompany = findValue("company");
509            var rawSolutions = findValue("what_kind_of_solutions");
510
511            // User Details
512            if (rawEmail) $crisp.push(["set", "user:email", rawEmail]);
513            if (rawName)  $crisp.push(["set", "user:nickname", rawName]);
514
515            // Session Info
516            $crisp.push(["set", "session:data", ["Company", safeStr(rawCompany)]]);
517            $crisp.push(["set", "session:data", ["Interest", safeStr(rawSolutions)]]);
518            $crisp.push(["set", "session:data", ["Status", "Waiting in Slider"]]);
519
520            // Hide chat panel behind slider
521            $crisp.push(["do", "chat:hide"]);
522
523            // Send initial message
524            setTimeout(function() {
525                $crisp.push([
526                    "do",
527                    "message:send",
528                    ["text", messageText]
529                ]);
530            }, 100);
531            
532            console.log("Handshake complete — waiting for the operator to join.");
533            
534            // Update Crisp status when timer expires
535            // setTimeout(function() {
536            //     if (typeof $crisp !== 'undefined') {
537            //         $crisp.push(["set", "session:data", ["Status", "Managers Busy - Waiting"]]);
538            //         $crisp.push(["do", "message:send", ["text", "All managers are currently busy. The customer is waiting for an available manager."]]);
539            //     }
540            // }, 120000);
541        }
542
543        triggerCrispHandshake();
544        
545        // Clean up timer if user leaves the page/component
546        $(window).on('beforeunload', function() {
547            if (swiperTimer) {
548                clearTimeout(swiperTimer);
549            }
550        });
551    });
552});
553
554
555function restoreLiveChatState() {
556    if (typeof $crisp === "undefined") {
557        return setTimeout(restoreLiveChatState, 500);
558    }
559
560    // If operator already replied earlier
561    if (localStorage.getItem("gr8_live_chat_open") === "1") {
562
563        console.log("Restoring live chat session after refresh.");
564
565        // UI restore
566        $(".step-live-chat").hide();
567        $(".gr8contact-form").removeClass("live-chat-blured");
568        $(".close-gr8contact-form").click();
569        $('#hubspot-messages-iframe-container').css({'opacity': '0','display': 'none'});
570        $('#hubspot-conversations-iframe').addClass('hide-personal-assistent').css({'opacity': '0','display': 'none'});
571        $("#crisp-chatbox-button .cc-1qbp0.cc-1o31k").html('<div class="chat-icon"><img src="https://gr8.tech/wp-content/uploads/2025/12/chat-icon.svg"><span>Live Chat</span></div>')
572        $("body > div.crisp-client").addClass("show-crisp-client");
573
574        // Crisp restore
575        $crisp.push(["do", "chat:show"]);
576        // $crisp.push(["do", "chat:open"]);
577    }
578}
579
580restoreLiveChatState();
581

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.