PageSourceSearch

https://princeofwhales.com/wp-content/plugins/solaris-dev/scripts/modules/ui.js

js princeofwhales.com collected 2026-10-02 04:04:40 UTC 4,988 bytes, 131 lines download raw bytes

1export const loadingMessages = [
2    "Whale, whale, whale, your message is on the way!",
3    "I'm kraken on with loading your response!",
4    "Just squidding around while your response loads!",
5    "Response incoming with great porpoise!",
6    "Brace for a whale of a response!",
7    "Response breaching! Any second now...",
8    "Seas the day! Your message will soon surface.",
9    "Octo-pushing your message through the sea of data!",
10    "Don't be koi, I'm fishing out your response!",
11    "Dolphin-ately working on delivering your message!",
12    "This might take a tide, but I'm working on it!",
13    "Clam down, your message is swimming this way!",
14    "Something fintastic is on the horizon!",
15    "Surfing through the data waves to get your response!",
16    "I'm on a deep-sea dive into your request, brb!",
17    "Navigating through the ocean of information for you!",
18    "Making a splash with your upcoming response!",
19    "Casting a wide net to fetch your message!",
20    "Your message is just a wave away!",
21    "Shelling out responses at sea-speed!",
22    "I'm not squidding, your response is almost here!",
23    "Riding the current to bring you the best answer!"
24];
25
26export function updateProgress(chatProgress, totalSteps, container) {
27    chatProgress++;
28    const progressPercentage = (chatProgress / totalSteps) * 100;
29    const loadingArea = document.getElementById('solaris-loading-area');
30    const loadingContainer = loadingArea.querySelector('.loading-container');
31
32    if (loadingContainer) {
33        loadingContainer.style.width = `${progressPercentage}%`;
34        
35        const messageDiv = loadingArea.querySelector('.solaris_loading_messages');
36        const randomMessage = loadingMessages[Math.floor(Math.random() * loadingMessages.length)];
37        messageDiv.textContent = randomMessage;
38
39        if (progressPercentage >= 100) {
40            setTimeout(() => {
41                loadingArea.classList.remove('active');
42                setTimeout(() => {
43                    loadingArea.innerHTML = '';
44                }, 300); 
45            }, 200);
46        }
47    }
48
49    return chatProgress;
50}
51
52export function appendLoadingAnimation(container) {
53    const loadingArea = document.getElementById('solaris-loading-area');
54    
55    // Move loading area after the last message
56    const lastMessage = container.lastElementChild;
57    if (lastMessage && lastMessage !== loadingArea) {
58        container.insertBefore(loadingArea, lastMessage.nextSibling);
59    }
60    
61    loadingArea.innerHTML = ''; 
62    const loadingContainer = document.createElement('div');
63    loadingContainer.className = 'loading-container';
64    loadingArea.appendChild(loadingContainer);
65    
66    // Create message div immediately to prevent layout shift
67    const messageDiv = document.createElement('div');
68    messageDiv.className = 'solaris_loading_messages';
69    messageDiv.textContent = loadingMessages[Math.floor(Math.random() * loadingMessages.length)];
70    loadingArea.appendChild(messageDiv);
71    
72    requestAnimationFrame(() => {
73        loadingArea.classList.add('active');
74        // Small delay to ensure initial state is rendered
75        setTimeout(() => {
76            loadingContainer.classList.add('active');
77            container.scrollTop = container.scrollHeight;
78        }, 50);
79    });
80}
81
82export function cleanUpAssistantMessages(container) {
83    const lastAssistantMessage = container.querySelector('.solaris_assistant:last-child');
84
85    if (lastAssistantMessage) {
86        const unwantedTags = ['title', 'link', 'head', 'script', 'style', 'meta', 'iframe', 'noscript', 'base'];
87        unwantedTags.forEach(tagName => {
88            const elements = lastAssistantMessage.getElementsByTagName(tagName);
89            for (let i = elements.length - 1; i >= 0; i--) {
90                elements[i].parentNode.removeChild(elements[i]);
91            }
92        });
93    }
94}
95
96export function appendAssistantMessage(assistantMessage, container) {
97    let newDiv = document.createElement('div');
98    newDiv.classList.add('solaris_assistant');
99    newDiv.innerHTML = assistantMessage;
100    container.appendChild(newDiv);
101    cleanUpAssistantMessages(container);
102    container.scrollTop = container.scrollHeight;
103}
104
105export function appendUserInput(userInput, container) {
106    const div = document.createElement('div');
107    div.className = 'solaris_user';
108    div.textContent = userInput;
109    container.appendChild(div);
110}
111
112export function appendLinkTargetBlank(container) {
113    container.addEventListener("click", function (event) {
114        if (event.target.tagName === "A") {
115            event.target.setAttribute("target", "_blank");
116        }
117    });
118}
119
120export function toggleSendButton(dcSend, dcInput) {
121    if (dcInput.value.trim() !== "") {
122        dcSend.classList.add("enabled");
123    } else {
124        dcSend.classList.remove("enabled");
125    }
126}
127
128export function toggleChatWindow(chatWindow, bubble) {
129    chatWindow.classList.remove("active");
130    bubble.classList.remove("active");
131}

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.