{"id":209,"date":"2023-07-12T17:34:11","date_gmt":"2023-07-12T22:34:11","guid":{"rendered":"https:\/\/pornstarmetrics.com\/?page_id=209"},"modified":"2023-10-15T07:47:32","modified_gmt":"2023-10-15T12:47:32","slug":"maraiya-chat","status":"publish","type":"page","link":"https:\/\/pornstarmetrics.com\/index.php\/maraiya-chat\/","title":{"rendered":"MARaiYA"},"content":{"rendered":"\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Responsive Layout<\/title>\n    <style>\n\n.myButton {\n    background-color: #EE4B69;\n    border: none;\n    color: white;\n    padding: 10px 20px; \/* Adjust padding to control the size of your button *\/\n    text-align: center;\n    text-decoration: none;\n    display: inline-block;\n    font-size: 14px; \/* Adjust font size to fit into your button *\/\n    margin: 4px 2px;\n    cursor: pointer;\n    border-radius: 12px; \/* Rounded corners *\/\n    box-shadow: 0 5px #999; \/* Shadow effect for 3D look *\/\n}\n\n.myButton:active {\n    box-shadow: 0 3px #999;\n    transform: translateY(4px); \/* Move button slightly down when clicked *\/\n}\n\n        body,\n        div,\n        img {\n            margin: 0;\n            padding: 0;\n        }\n\n        body {\n            font-family: Arial, sans-serif;\n        }\n\n        .responsive-layout {\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            width: 65%;\n            gap: 0%;\n            margin: 0 auto;\n        }\n\n        .image-container {\n            flex: 0.3333;\n            display: flex;\n            flex-direction: column;\n            gap: 0px;\n            align-items: center;\n        }\n\n        .image-container img {\n            max-width: 100%;\n            height: auto;\n        }\n\n        .chat-container {\n        flex: 0.6667;\n        flex-shrink: 0;  \/* Prevents shrinking *\/\n        overflow: hidden;  \/* Prevents the container from growing *\/\n        width: 100%;\n        box-sizing: border-box;\n        background-color: transparent;\n    }\n\n        #chat-container {\n            width: 100%;\n            border: none !important;\n            background-color: transparent;\n            box-shadow: none;\n            outline: 0 none !important;\n            margin: 0;\n        }\n\n        #chat-history {\n        max-height: 300px;  \/* Sets a maximum height *\/\n        min-height: 300px;  \/* Sets a minimum height *\/\n        overflow-y: auto;  \/* Enables vertical scrolling *\/\n        border: 1px solid #ccc;\n        margin-bottom: 10px;\n        padding: 10px;\n        background-color: white;\n    }\n\n        #user-input-form {\n            display: flex;\n        }\n\n        #user-input {\n            flex-grow: 1;\n            padding: 5px;\n            height: 4em;\n            border: 1px solid #ccc;\n            border-radius: 3px;\n            overflow-y: auto;\n            resize: none;\n            background-color: white;\n            outline: 0 none !important;\n        }\n\n        #user-input:focus {\n            outline: none !important;\n        }\n\n        .user {\n            color: black;\n        }\n\n.user {\n    color: black;\nmargin-top: 1em;  \/* <-- Add this line for space above user messages *\/\nmargin-bottom: 1em;  \/* <-- Add this line *\/\n}\n\n.user:first-child {\n    margin-top: 0;  \/* Removes space above the first user message *\/\n}\n\n        .response {\n            color: #EE4B69;\nmargin-top: 1em;  \/* <-- Add this line for space above agent messages *\/\nmargin-bottom: 1em;  \/* <-- Keep this line for space below agent messages *\/\n            }\n\n.response:first-child {\n    margin-top: 0;  \/* Removes space above the first agent message *\/\n}\n\n        .response-link {\n            color: #47141E !important;\n            text-decoration: underline;\n        }\n\n        .response-link:hover {\n            text-decoration: underline;\n        }\n\n.thinking {\n    display: inline-block;\n}\n\n.image-container {\n        flex: 0.3333;\n        flex-shrink: 0;  \/* <-- Add this line *\/\n        display: flex;\n        flex-direction: column;\n        gap: 0px;\n        align-items: center;\n    }\n\n    .chat-container {\n        flex: 0.6667;\n        flex-shrink: 1;  \/* <-- Add this line *\/\n        width: 100%;\n        box-sizing: border-box;\n        background-color: transparent;\n    }\n\n\/* Mobile layout *\/\n    @media (max-width: 768px) {\n        .responsive-layout {\n            flex-direction: column;\n            justify-content: center;\n            align-items: center;\n            width: 100%;\n        }\n\n        .image-container,\n        .chat-container {\n            width: 100%;\n            display: flex;\n            justify-content: center;\n            align-items: center;\n        }\n\n        .image-container img,\n        .chat-container {\n            max-width: 100%;\n            height: auto;\n        }\n\n@keyframes loadingEllipses {\n  0%, 20% { content: \".\"; }\n  40% { content: \"..\"; }\n  60% { content: \"...\"; }\n  80% { content: \"....\"; }\n  100% { content: \".....\"; }\n}\n\n.thinking, .loading {\n    display: inline-block;\n}\n\n.loading {\n    display: inline-block;\n}\n\n.loading::after {\n    content: \".\";\n    animation: loadingEllipses 2s steps(5, end) infinite;\n}\n\n    }\n\n    <\/style>\n\n<\/head>\n\n<body>\n    <div class=\"responsive-layout\">\n        <div class=\"image-container\">\n            <img decoding=\"async\" src=\"https:\/\/pornstarmetrics.com\/wp-content\/uploads\/2023\/07\/MARaiYA-Logo-1-1024x192.png\" alt=\"MARaiYA Logo\">\n            <img decoding=\"async\" src=\"https:\/\/pornstarmetrics.com\/wp-content\/uploads\/2023\/07\/MARaiYA-1024x1024.png\" alt=\"Image of MARaiYA\">\n        <\/div>\n\n        <div class=\"chat-container\">\n            <div id=\"chat-container\">\n                <div id=\"chat-history\">\n    <div id=\"initial-greeting\" class=\"response\">Hi, my name is MARaiYA. I\u2019m here to satisfy your thirst for adult performer data. You can start with a first and last name. If you don't know, just enter: Choose for me.<\/div>\n<\/div>\n                <form id=\"user-input-form\">\n                    <textarea id=\"user-input\" maxlength=\"1000\" placeholder=\"Type your question or request here.\"><\/textarea>\n<input type=\"submit\" value=\"Go for it\" class=\"myButton\">\n                <\/form>\n            <\/div>\n        <\/div>\n    <\/div>                 \n\n    <script src=\"https:\/\/code.jquery.com\/jquery-3.6.0.min.js\"><\/script>\n    <script>\n        console.log(\"jQuery version:\", jQuery.fn.jquery);\n\n        let isProcessing = false;\nlet isAnimating = false;  \/\/ Add this line\n\nlet ellipsisInterval;\nfunction startEllipsisAnimation($element) {\n    let dotCount = 0;\n    ellipsisInterval = setInterval(() => {\n        dotCount = (dotCount + 1) % 4;\n        const dots = '.'.repeat(dotCount);\n        $element.text(`MARaiYA: ${dots}`);\n    }, 500);\n}\n\nfunction stopEllipsisAnimation() {\n    clearInterval(ellipsisInterval);\n}\n\nfunction appendToChatHistory(message) {\n  const $chatHistory = $('#chat-history');\n  $chatHistory.append(message);\n  \n  const messageCount = $chatHistory.children().length;\n  if (messageCount > 100) {\n    $chatHistory.children().slice(0, messageCount - 100).remove();\n  }\n\n  $chatHistory.scrollTop($chatHistory[0].scrollHeight);\n}\n\nfunction selectivelyTypeHtmlText(element, text, className, callback) {\n    let index = 0;\n    let buffer = \"\";\n    let isTag = false;\n    let linkBuffer = \"\";\n    let isLink = false;\n    let currentStyle = \"\";\n    let isQuestion = false;\n\n    function typeNextCharacter() {\n        if (index < text.length) {\n            const char = text[index];\n            buffer += char;\n            index++;\n\n            if (char === \"<\") isTag = true;\n            if (char === \">\") isTag = false;\n\n            if (buffer.includes('\"')) {\n                isQuestion = !isQuestion; \/\/ Toggle the boolean when a quote is encountered\n            }\n\n            if (buffer.includes('<a ')) {\n                isLink = true;\n                linkBuffer = buffer;\n                buffer = \"\";\n            }\n            if (isLink) {\n                linkBuffer += char;\n            }\n\n            if (buffer.includes('<\/a>')) {\n                isLink = false;\n                let linkElement = document.createElement('span');\n                linkElement.className = className;\n                linkElement.innerHTML = linkBuffer;\n                element.appendChild(linkElement);\n                linkBuffer = \"\";\n                buffer = \"\";\n            }\n\n            if (!isTag && !isLink) {\n                const span = document.createElement('span');\n                span.className = className;\n\n                if (currentStyle) {\n                    span.style.cssText = currentStyle;\n                }\n\n                span.innerHTML = buffer;\n                element.appendChild(span);\n                buffer = \"\";\n\n                \/\/ Update the scroll position as each character is added\n                $('#chat-history').scrollTop($('#chat-history')[0].scrollHeight);\n\n                setTimeout(typeNextCharacter, 25);\n            } else {\n                setTimeout(typeNextCharacter, 0);\n            }\n        } else if (callback) {\n            callback();\n        }\n    }\n\n    typeNextCharacter();\n}\n\n       function convertUrlsToLinks(text) {\n    const urlRegex = \/(https?:\\\/\\\/[^\\s]+)\/g;\n    return text.replace(urlRegex, function(url) {\n        return '<a href=\"' + url + '\" target=\"_blank\" class=\"response-link\" style=\"white-space: nowrap;\">' + url + '<\/a> ';\n    });\n}\n\n    function getSessionID() {\n        let sessionID = document.cookie.replace(\/(?:(?:^|.*;\\s*)sessionID\\s*\\=\\s*([^;]*).*$)|^.*$\/, \"$1\");\n        if (!sessionID) {\n            sessionID = '_' + Math.random().toString(36).substr(2, 9);\n            document.cookie = `sessionID=${sessionID}; max-age=86400; path=\/`; \/\/ Set the cookie to expire in 24 hours\n        }\n        return sessionID;\n    }\n\n    function sendUserQuery(query) {\n    if (isProcessing) return;\n    isProcessing = true;\n\n    console.log(\"Sending user query:\", query);\n\n    const sessionID = getSessionID(); \/\/ Get the session ID\n    const userAgent = navigator.userAgent; \/\/ Get the user agent\n    const referrer = document.referrer; \/\/ Get the referring URL\n\n    const $chatHistory = $('#chat-history');\nappendToChatHistory('<div class=\"response thinking\">MARaiYA: <\/div>');\nconst $thinkingMessage = $chatHistory.children().last();\nstartEllipsisAnimation($thinkingMessage); \n$chatHistory.scrollTop($chatHistory[0].scrollHeight); \/\/ Add this line here\n    \n    $.ajax({\n        type: 'POST',\n        url: 'https:\/\/us-central1-psmbot.cloudfunctions.net\/psmbotchat',\n        contentType: \"application\/json; charset=utf-8\",\n        data: JSON.stringify({\n            text: query,\n            sessionID: sessionID, \/\/ Include the session ID in the request\n            userAgent: userAgent, \/\/ Include the user agent in the request\n            referrer: referrer, \/\/ Include the referring URL in the request\n        }),\n        dataType: \"json\",\n       success: function(response) {\n    console.log(response);\n\n    \/\/ Convert URLs to HTML anchor tags\n    const convertedText = convertUrlsToLinks(response.fulfillmentText);  \n\n    stopEllipsisAnimation();        \n    $thinkingMessage.remove();  \/\/ Remove the 'thinking' message\n    \n    const $chatHistory = $('#chat-history');\n    const newDiv = document.createElement('div');\n    newDiv.className = \"response\";\n    $chatHistory.append(newDiv);\n\n    \/\/ Animation starts\n    isAnimating = true;\n\n    \/\/ Use the converted HTML string\n    selectivelyTypeHtmlText(newDiv, 'MARaiYA: ' + convertedText, 'agent-response', function() {\n        $chatHistory.scrollTop($chatHistory[0].scrollHeight);\n\n        \/\/ Animation complete\n        isAnimating = false;  \/\/ Reset the flag here\n\n        \/\/ Processing is complete, ready for new input\n        isProcessing = false;  \/\/ Reset the flag here\n    });\n},\n\n    });\n}\n\n        function processInput() {\n    \/\/ If already processing or animating, return\n    if (isAnimating || isProcessing) return;\n\n    \/\/ Set the flag to prevent new queries\n    isAnimating = true;\n\n    $('#initial-greeting').remove();\n    const userInput = $('#user-input').val().trim();\n\n    if (!userInput) {\n        isAnimating = false;\n        return;\n    }\n\n    console.log(userInput);\n    $('#user-input').val('');\n    const $chatHistory = $('#chat-history');\n    appendToChatHistory('<div class=\"user\">You: ' + userInput + '<\/div>');\n    $chatHistory.scrollTop($chatHistory[0].scrollHeight);\n    \n    sendUserQuery(userInput);\n}\n\n        $(document).ready(function() {\n            $('#user-input-form').off('submit').on('submit', function(event) {\n                event.preventDefault();\n                processInput();\n            });\n            \n            $('#user-input').on('keypress', function(event) {\n                if (event.which === 13 && !event.shiftKey) {\n                    event.preventDefault();\n                    processInput();\n                }\n            });\n\n    const urlParams = new URLSearchParams(window.location.search);\n    const predefinedQuestion = urlParams.get('predefined_question');\n\n    if (predefinedQuestion) {\n        $('#user-input').val(decodeURIComponent(predefinedQuestion));\n        processInput();\n    }\n        });\n    <\/script>\n<\/body>\n\n<\/html>\n\n\n\n<div class=\"wp-block-columns has-medium-font-size is-layout-flex wp-container-2\" style=\"border-style:none;border-width:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n<div class=\"wp-block-column has-medium-font-size has-global-padding is-layout-constrained\" style=\"border-style:none;border-width:0px;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-text-align-center has-text-color has-link-color has-small-font-size wp-elements-e48d7c1a8fef52312dacf25741239e67\" style=\"color:#ee4b69;margin-top:0px;margin-right:100px;margin-left:100px\">[ <a href=\"https:\/\/pornstarmetrics.com\/index.php\/report-inaccuracies-and-recommend-additions\/\">Report Inaccuracies and Recommend Additions<\/a> ]<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p style=\"margin-top:0px;margin-right:100px;margin-bottom:0px;margin-left:100px\">MARaiYA strives to be your go-to virtual assistant for insights into your favorite adult entertainers. Simply ask, and MARaiYA will tell you what she knows. Keep in mind that she\u2019s a newcomer and has a lot to learn. She\u2019s also not the best conversationalist but hopes to improve with experience.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p style=\"margin-top:0px;margin-right:100px;margin-bottom:0px;margin-left:100px\">If she can\u2019t answer your question or doesn\u2019t recognize a name, please bring it to our attention. Our goal is to continuously update her knowledge so she\u2019s able to offer you whatever insights you are looking for about actors and industry.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-text-align-center has-small-font-size\" style=\"margin-right:100px;margin-left:100px\">&lt;&lt; <strong>Enhancements in MARaiYA 2.0 coming soon<\/strong> &gt;&gt;<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-center has-link-color wp-elements-3b605983ea6bdf848dc2b102dde2a4d8\" style=\"margin-top:0px;margin-right:50px;margin-bottom:0px;margin-left:50px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;font-size:clamp(0.9rem, 0.9rem + ((1vw - 0.48rem) * 0.577), 1.2rem);\"><a rel=\"noreferrer noopener\" href=\"mailto:pornstarmetrics@gmail.com\" target=\"_blank\">pornstarmetrics@gmail.com<\/a><\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-text-align-center\" style=\"margin-right:50px;margin-left:50px;font-size:12px\">MARaiYA Version 1.0 may produce inaccurate information about people, places, or facts.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Responsive Layout Hi, my name is MARaiYA. I\u2019m here to satisfy your thirst for adult performer data. You can start with a first and last name. If you don&#8217;t know, just enter: Choose for me. [ Report Inaccuracies and Recommend Additions ] MARaiYA strives to be your go-to virtual assistant for insights into your favorite [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/pages\/209"}],"collection":[{"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/comments?post=209"}],"version-history":[{"count":288,"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/pages\/209\/revisions"}],"predecessor-version":[{"id":1193,"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/pages\/209\/revisions\/1193"}],"wp:attachment":[{"href":"https:\/\/pornstarmetrics.com\/index.php\/wp-json\/wp\/v2\/media?parent=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}