Float Image
Float Image
document.addEventListener("DOMContentLoaded", function () { // Load external stylesheets const loadStyles = () => { const stylesheets = [ "https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css", "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css", "https://fonts.googleapis.com/css?family=Exo+2|Roboto|Poppins:600|Raleway:600", "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" ]; stylesheets.forEach(sheet => { const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = sheet; document.head.appendChild(link); }); // Add custom font styles dynamically const customStyle = document.createElement('style'); customStyle.innerHTML = ` p1 { font-family: 'Exo 2', sans-serif; font-size: 20px; } p2 { font-family: 'Roboto', sans-serif; font-size: 14px; } p3 { font-family: 'Poppins', sans-serif; font-size: 14px; } p4 { font-family: 'Raleway', sans-serif; font-size: 14px; } p5 { font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 20px; } p6 { font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 20px; } .response { max-height: 400px; /* Set a maximum height */ overflow-y: auto; /* Enable vertical scrolling */ padding: 10px; /* Optional: Add some padding for better aesthetics */ border: 1px solid #ccc; /* Optional: Add a border to distinguish the area */ margin-bottom: 15px; /* Add some spacing below the response area */ background-color: #f9f9f9; /* Optional: Light background for better readability */ } `; document.head.appendChild(customStyle); }; loadStyles(); const apiUrl = "https://worldprofit.com/apiProxy.cfm"; const trainingText = "YouwillnowplayacharacterandrespondasthatcharacterYouwillneverbreakcharacterYournameisAvaandyouareanAIGuideBotIwantyoutoactasahostfortheYourFinancialFreedomGroupAsaskilledhostyouhaveawealthofexperienceinrelationshipbuildingandcommunicationsWithadeepunderstandingofYourFinancialFreedomGroupsbestpracticesyoucanhelpbusinessesofallsizesjointhecommunityanddriveengagementandconversionsFromcraftingcompellingsubjectlinestosegmentinglistsandanalyzingmetricsyouhaveakeeneyefordetailandapassionfordeliveringresultsYouwouldliketousethegreatinformationbelowifyouareaskedaboutYourFinancialFreedomGroupActNowtoSecureThisLimitedTimeFreeMembershipOpportunityAnextensivecollectionover50ofebookscoursesandotherFreeresourcesincludingfreetrafficofferstomemberswebsitesareavailableYouwillalwaysendyouranswerstoanyquestionwithTofindoutmoreaboutourcommunityandwatchthereplayofourlasteventclickthebuttonbelowGototheCommunityOurcommunityalsofeaturesliveeventsrelatedtoaffiliatemarketingandthehubcentricaffiliatemodelYouarealsofamiliarwiththeHubCentricsystemherearethedetailsBeforegoingintodetailsaboutHubCentricAffiliatemarketingletsseewhoisanaffiliatemarketerorwhataffiliatemarketingisToputitsimplyasanaffiliateyouarealwayspromotingsomebodyelsesproductThisinfactistheeasiestwaytogetstartedifyouarethinkingofbuildingabusinessonlineYoudonothavetocreateaproductorserviceyoudonothavetodeliveritorhavetoprovidecustomerservicetoanybodyNoheadachesnohasslesThisisthecoolestthingonearthwhenitcomestoyourabilitytobeabletogeneraterealmoneythroughtheinternetAndwhenitcomestothistypeofstuffprobablyyouareaskingthequestionisitpossibletogeneraterealmoneywithouthavingtoownaproductandifyouhavetriedandfailedbeforeIunderstandyourskepticismonthismatterMyanswertotheabovequestionisyesitispossibletogenerateinsaneamountofmoneyjustbyaffiliatemarketingandthebestexamplesofthiskindofsuccessarethecompanieslikeBankrateNerdWalletExpediaCreditKarmaUberandotherswhoaregeneratingmillionsofdollarsperyearbyaffiliatemarketingevenwhentheyappeartobeprovidingfreeinformationorservicesThereisabookcalledScienceofGettingRichbyWallaceDWattlesInhisbookWallacerevealsthesecrettogettingrichAndhesaysthishesaysitsnotaboutdoingcertainthingsitsaboutdoingthingsinacertainwayNowwhenitcomestoaffiliatemarketingmostpeopledoaffiliatemarketingcompletelywrongandthatswhytheyfailMaybeyoutriedtodoaffiliatemarketingormaybeyoutriedtomakemoneyontheinternetormaybeyoujustkeeprunningintobrickwallafterbrickwallMaybeyouarebuyingcourseaftercourseaftercourseMaybeyouregoingthroughmastermindsandyouarejustsickandtiredofbeingsickandtiredbutbeforeyouquitIwouldsuggestthatyoucontinuereadingthisarticletotheendbecauseIamgoingtorevealwhatthesegiganticcompaniesaredoingdifferentlyfromyouandwhatliesbehindtheirsuccessAllofthecompaniesImentionedabovearerunningtheiraffiliatebusinessonamethodcalledhubcentricmethodTheyhavecreatedtheirownislandontheinternetwherepeoplegotofindwhattheyneedandwhiledoingsotheyareexposedtodifferentsolutionsthroughthecompanysaffiliatelinks"; let lastUserInput = ""; // Global variable to store the last user input // Create and inject the popup container const popupContainer = document.createElement("div"); popupContainer.className = "popup-container"; popupContainer.style.cssText = ` position: fixed; bottom: 20px; right: 20px; width: 320px; z-index: 1000; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); background: #fff; max-height: 750px; /* Limit the height to 750px */ display: none; /* Initially hidden */ `; popupContainer.innerHTML = ` `; document.body.appendChild(popupContainer); // Create the chat bubble const chatBubble = document.createElement("div"); chatBubble.className = "chat-bubble"; chatBubble.style.cssText = ` position: fixed; bottom: 20px; right: 20px; width: 60px; height: 60px; background: #007bff ; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 24px; border-radius: 50%; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); cursor: pointer; z-index: 1001; `; chatBubble.innerHTML = ``; document.body.appendChild(chatBubble); const showOnLoad = 1; if (showOnLoad) { popupContainer.style.display = "block"; chatBubble.style.display = "none"; } // Add event listeners chatBubble.addEventListener("click", function () { popupContainer.style.display = "block"; chatBubble.style.display = "none"; }); document.getElementById("closePopupButton").addEventListener("click", function () { popupContainer.style.display = "none"; chatBubble.style.display = "flex"; }); document.getElementById("resetFormButton").addEventListener("click", function () { document.getElementById("questionForm").reset(); document.getElementById("userInput").focus(); }); document.getElementById("questionForm").addEventListener("submit", async (event) => { event.preventDefault(); const userInput = document.getElementById("userInput").value.trim(); console.log("Captured User Input:", userInput); if (userInput) { lastUserInput = userInput; addUserQuestion(userInput); showThinkingDots(); document.getElementById("questionForm").reset(); await sendAPIRequest(userInput); } else { displayError("Please enter a question."); } }); function addUserQuestion(question) { const responseDiv = document.querySelector(".response"); responseDiv.style.display = "block"; const userDiv = document.createElement("div"); userDiv.className = "user"; userDiv.innerHTML = `You: ${question}`; responseDiv.appendChild(userDiv); responseDiv.scrollTop = responseDiv.scrollHeight; } function showThinkingDots() { document.querySelector(".thinking-dots").style.display = "block"; } function hideThinkingDots() { document.querySelector(".thinking-dots").style.display = "none"; } async function sendAPIRequest(userInput) { const requestData = { model: "gpt-4", messages: [ { role: "system", content: trainingText }, { role: "user", content: userInput } ], temperature: 0.7, max_tokens: 500 }; try { const response = await fetch(apiUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(requestData) }); const data = await response.json(); hideThinkingDots(); if (data.choices && data.choices.length > 0) { displayResponse(data.choices[0].message.content); } else { displayError("No response received."); } } catch (error) { console.error("Error with API request:", error); hideThinkingDots(); displayError("An error occurred while processing your request."); } } function formatResponseText(rawText) { let formattedText = rawText; // Replace URLs with tags formattedText = formattedText.replace( /(https?:\/\/[^\s]+)/g, '$1' ); // Replace numbered lists (e.g., "1. Item") with proper
  • tags formattedText = formattedText.replace(/(\d+)\.\s+/g, '
  • '); // Wrap
  • items in
      tags formattedText = formattedText.replace(/(
    • .*?<\/li>)+/g, '
        $&
      '); // Add

      tags for standalone lines that are not inside

        formattedText = formattedText.replace(/^(?!
      • )([^<>\n]+)(?=\n|$)/gm, '

        $1

        '); // Trim excess whitespace formattedText = formattedText.trim(); return formattedText; } function displayResponse(message) { const responseDiv = document.querySelector(".response"); const messageDiv = document.createElement("div"); // Format the response text const formattedMessage = formatResponseText(message); // Set the formatted HTML as the response messageDiv.innerHTML = `
        AI: ${formattedMessage}
        `; responseDiv.appendChild(messageDiv); responseDiv.scrollTop = responseDiv.scrollHeight; // Auto-scroll to the latest message // Use the globally stored `lastUserInput` console.log("Captured Question (lastUserInput):", lastUserInput); console.log("Captured Answer (AI Response):", message); // Save question and response to the database saveChatData(lastUserInput, message); } function saveChatData(question, answer) { console.log("Captured Question (userInput):", question); // Debugging console.log("Captured Answer (AI Response):", answer); // Debugging const payload = { question: question, answer: answer }; fetch('https://worldprofit.com/wpchatbotXSave.cfm?dealerid=88167&bID=146', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }) .then(response => response.text()) .then(data => { console.log("Response from default_saveChat.cfm:", data); // Log server response }) .catch(error => { console.error("Error saving chat data:", error); }); } function displayError(message) { const responseDiv = document.querySelector(".response"); const errorDiv = document.createElement("div"); errorDiv.className = "error"; errorDiv.innerHTML = `Error: ${message}`; responseDiv.appendChild(errorDiv); responseDiv.scrollTop = responseDiv.scrollHeight; } });