{"id":3385,"date":"2026-04-20T18:10:12","date_gmt":"2026-04-20T18:10:12","guid":{"rendered":"https:\/\/pst.lecentral.lu\/?page_id=3385"},"modified":"2026-04-20T20:59:16","modified_gmt":"2026-04-20T20:59:16","slug":"chatbox","status":"publish","type":"page","link":"https:\/\/pst.lecentral.lu\/chatbox\/","title":{"rendered":""},"content":{"rendered":"    <style>\r\n        .pst-chat-container { direction: rtl; background:#fff; padding:25px; border:1px solid #ccd0d4; max-width: 800px; margin: 20px auto; border-radius: 12px; font-family: sans-serif; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }\r\n        #pst-chat-window { height: 450px; overflow-y: auto; border: 1px solid #e2e8f0; padding: 20px; background: #f8fafc; margin-bottom: 20px; border-radius: 8px; display: flex; flex-direction: column; gap: 12px; }\r\n        .msg { max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 15px; line-height: 1.6; position: relative; }\r\n        .msg-ai { align-self: flex-start; background: #ffffff; color: #1d2327; border: 1px solid #e2e8f0; border-bottom-right-radius: 2px; }\r\n        .msg-user { align-self: flex-end; background: #2271b1; color: #ffffff; border-bottom-left-radius: 2px; }\r\n        \r\n        \/* Typing Animation *\/\r\n        .typing { display: flex; align-items: center; gap: 4px; padding: 10px 15px; background: #f0f0f0; border-radius: 15px; width: fit-content; align-self: flex-start; margin-bottom: 10px; }\r\n        .typing span { width: 6px; height: 6px; background: #999; border-radius: 50%; animation: blink 1.4s infinite both; }\r\n        .typing span:nth-child(2) { animation-delay: 0.2s; }\r\n        .typing span:nth-child(3) { animation-delay: 0.4s; }\r\n        @keyframes blink { 0%, 80%, 100% { opacity: 0; } 40% { opacity: 1; } }\r\n    <\/style>\r\n\r\n    <div class=\"pst-chat-container\">\r\n        <div style=\"text-align:center; margin-bottom: 20px;\">\r\n            <h2 style=\"margin:0; color:#1d2327;\">\u0627\u0644\u0623\u0631\u0634\u064a\u0641 \u0627\u0644\u0631\u0626\u0627\u0633\u064a \u0627\u0644\u0630\u0643\u064a<\/h2>\r\n            <p style=\"font-size:13px; color:#666;\">\u0627\u0633\u0623\u0644 \u0639\u0646 \u0627\u0644\u0648\u0639\u0648\u062f\u060c \u0627\u0644\u062a\u0648\u0627\u0631\u064a\u062e\u060c \u0623\u0648 \u0645\u062d\u062a\u0648\u0649 \u0627\u0644\u062e\u0637\u0627\u0628\u0627\u062a<\/p>\r\n        <\/div>\r\n        \r\n        <div id=\"pst-chat-window\">\r\n            <div class=\"msg msg-ai\">\u0645\u0631\u062d\u0628\u0627\u064b \u0628\u0643. \u0623\u0646\u0627 \u0645\u0633\u0627\u0639\u062f\u0643 \u0627\u0644\u0631\u0642\u0645\u064a \u0641\u064a \u0627\u0644\u0623\u0631\u0634\u064a\u0641 \u0627\u0644\u0631\u0626\u0627\u0633\u064a. \u0643\u064a\u0641 \u064a\u0645\u0643\u0646\u0646\u064a \u0645\u0633\u0627\u0639\u062f\u062a\u0643 \u0641\u064a \u0628\u062d\u062b\u0643 \u0627\u0644\u064a\u0648\u0645\u061f<\/div>\r\n        <\/div>\r\n\r\n        <div style=\"display: flex; gap: 10px;\">\r\n            <input type=\"text\" id=\"pst-chat-input\" placeholder=\"\u0627\u0643\u062a\u0628 \u0633\u0624\u0627\u0644\u0643 \u0647\u0646\u0627...\" style=\"flex-grow: 1; padding: 12px; border: 2px solid #e2e8f0; border-radius: 8px; outline:none;\" \/>\r\n            <button id=\"pst-chat-send\" style=\"padding: 10px 25px; background: #2271b1; color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; transition: 0.3s;\">\u0625\u0631\u0633\u0627\u0644<\/button>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <script>\r\n    jQuery(document).ready(function($) {\r\n        var ajaxurl = 'https:\/\/pst.lecentral.lu\/wp-admin\/admin-ajax.php';\r\n\r\n        function appendMessage(message, type) {\r\n            var msgClass = (type === 'ai') ? 'msg-ai' : 'msg-user';\r\n            var senderName = (type === 'ai') ? '\u0627\u0644\u0645\u0633\u0627\u0639\u062f' : '\u0623\u0646\u062a';\r\n            var msgHtml = '<div class=\"msg ' + msgClass + '\"><strong>' + senderName + ':<\/strong><br>' + message + '<\/div>';\r\n            $('#pst-chat-window').append(msgHtml);\r\n            $('#pst-chat-window').animate({ scrollTop: $('#pst-chat-window')[0].scrollHeight }, 500);\r\n        }\r\n\r\n        $('#pst-chat-send').on('click', function(e) {\r\n            e.preventDefault();\r\n            var userMsg = $('#pst-chat-input').val().trim();\r\n            if (!userMsg) return;\r\n\r\n            appendMessage(userMsg, 'user');\r\n            $('#pst-chat-input').val('');\r\n            $('#pst-chat-send').prop('disabled', true).css('opacity', '0.5');\r\n\r\n            \/\/ Add thinking animation\r\n            $('#pst-chat-window').append('<div id=\"pst-typing\" class=\"typing\"><span><\/span><span><\/span><span><\/span><\/div>');\r\n            $('#pst-chat-window').scrollTop($('#pst-chat-window')[0].scrollHeight);\r\n\r\n            $.ajax({\r\n                url: ajaxurl,\r\n                type: 'POST',\r\n                data: { action: 'pst_smart_chat_query', message: userMsg },\r\n                success: function(response) {\r\n                    $('#pst-typing').remove();\r\n                    if (response.success) {\r\n                        appendMessage(response.data.answer, 'ai');\r\n                    } else {\r\n                        appendMessage('\u0639\u0630\u0631\u0627\u064b\u060c \u062d\u062f\u062b \u062e\u0637\u0623 \u0641\u064a \u0645\u0639\u0627\u0644\u062c\u0629 \u0637\u0644\u0628\u0643.', 'ai');\r\n                    }\r\n                },\r\n                error: function() {\r\n                    $('#pst-typing').remove();\r\n                    appendMessage('\u062a\u0639\u0630\u0631 \u0627\u0644\u0627\u062a\u0635\u0627\u0644 \u0628\u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a.', 'ai');\r\n                },\r\n                complete: function() {\r\n                    $('#pst-chat-send').prop('disabled', false).css('opacity', '1');\r\n                }\r\n            });\r\n        });\r\n\r\n        $('#pst-chat-input').keypress(function(e) { if(e.which == 13) $('#pst-chat-send').click(); });\r\n\r\n        \/\/ ==========================================\r\n        \/\/ NEW: AUTO-TRIGGER FROM URL PARAMETER\r\n        \/\/ ==========================================\r\n        var urlParams = new URLSearchParams(window.location.search);\r\n        var askMsg = urlParams.get('ask');\r\n        \r\n        if (askMsg) {\r\n            \/\/ Type the message into the box\r\n            $('#pst-chat-input').val(askMsg);\r\n            \r\n            \/\/ Wait 800ms for a natural feel, then click send\r\n            setTimeout(function() {\r\n                $('#pst-chat-send').click();\r\n                \r\n                \/\/ Clean the URL so it doesn't re-trigger on page refresh\r\n                window.history.replaceState({}, document.title, window.location.pathname);\r\n            }, 800);\r\n        }\r\n    });\r\n    <\/script>\r\n    \n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3385","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/pages\/3385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/comments?post=3385"}],"version-history":[{"count":2,"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/pages\/3385\/revisions"}],"predecessor-version":[{"id":3393,"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/pages\/3385\/revisions\/3393"}],"wp:attachment":[{"href":"https:\/\/pst.lecentral.lu\/wp-json\/wp\/v2\/media?parent=3385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}