587 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			587 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!--DeppGPT Start-->
 | |
| <!DOCTYPE html>
 | |
| <html lang="de">
 | |
| <head>
 | |
|     <meta charset="UTF-8">
 | |
|     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | |
|     <title>DeppGPT</title>
 | |
|     <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
 | |
|     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
 | |
|     <script defer src="https://stats.ponywave.de/script" data-website-id="9ef713d2-adb9-4906-9df5-708d8a8b9131" data-tag="depp_gpt"></script>
 | |
|     <style>
 | |
|         :root {
 | |
|             --primary-color: #0E766C;
 | |
|             --secondary-color: #264044;
 | |
|             --accent-color: #009688;
 | |
|             --text-light: #ffffff;
 | |
|             --background-light: #f5f5f5;
 | |
|             --chat-bg: #ffffff;
 | |
|             --button-bg: #0E766C;
 | |
|             --button-hover: #009688;
 | |
|         }
 | |
| 
 | |
|         :root[data-theme="dark"] {
 | |
|             --primary-color: #1a1a1a;
 | |
|             --secondary-color: #333333;
 | |
|             --accent-color: #009688;
 | |
|             --text-light: #ffffff;
 | |
|             --background-light: #121212;
 | |
|             --chat-bg: #1e1e1e;
 | |
|             --button-bg: #333333;
 | |
|             --button-hover: #444444;
 | |
|         }
 | |
| 
 | |
|         body {
 | |
|             margin: 0;
 | |
|             font-family: 'Segoe UI', system-ui, sans-serif;
 | |
|             background: var(--background-light);
 | |
|             min-height: 100vh;
 | |
|             display: flex;
 | |
|             flex-direction: column;
 | |
|             transition: background-color 0.3s ease;
 | |
|         }
 | |
| 
 | |
|         /* Header Styles */
 | |
|         .header {
 | |
|             background: var(--primary-color);
 | |
|             color: var(--text-light);
 | |
|             padding: 1rem;
 | |
|             text-align: center;
 | |
|             box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
 | |
|             display: flex;
 | |
|             justify-content: space-between;
 | |
|             align-items: center;
 | |
|         }
 | |
| 
 | |
|         .theme-toggle {
 | |
|             background: transparent;
 | |
|             border: none;
 | |
|             color: var(--text-light);
 | |
|             font-size: 1.5rem;
 | |
|             cursor: pointer;
 | |
|             padding: 8px;
 | |
|             border-radius: 50%;
 | |
|             transition: background-color 0.3s ease;
 | |
|             width: 40px;
 | |
|             height: 40px;
 | |
|             display: flex;
 | |
|             align-items: center;
 | |
|             justify-content: center;
 | |
|         }
 | |
| 
 | |
|         .theme-toggle:hover {
 | |
|             background: rgba(255, 255, 255, 0.1);
 | |
|         }
 | |
| 
 | |
|         /* Main Container */
 | |
|         .main-content {
 | |
|             flex: 1;
 | |
|             max-width: 800px;
 | |
|             margin: 20px auto;
 | |
|             padding: 0 20px;
 | |
|             width: 100%;
 | |
|         }
 | |
| 
 | |
|         /* Chat Container */
 | |
|         .chat-container {
 | |
|             background: var(--chat-bg);
 | |
|             border-radius: 15px;
 | |
|             box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
 | |
|             height: 500px;
 | |
|             display: flex;
 | |
|             flex-direction: column;
 | |
|             transition: background-color 0.3s ease;
 | |
|         }
 | |
| 
 | |
|         .chat-messages {
 | |
|             flex: 1;
 | |
|             padding: 20px;
 | |
|             overflow-y: auto;
 | |
|             display: flex;
 | |
|             flex-direction: column;
 | |
|             gap: 15px;
 | |
|         }
 | |
| 
 | |
|         /* Message Styles */
 | |
|         .message {
 | |
|             max-width: 75%;
 | |
|             padding: 12px 18px;
 | |
|             border-radius: 20px;
 | |
|             line-height: 1.4;
 | |
|             word-break: break-word;
 | |
|         }
 | |
| 
 | |
|         .user-message {
 | |
|             align-self: flex-end;
 | |
|             background: var(--primary-color);
 | |
|             color: var(--text-light);
 | |
|         }
 | |
| 
 | |
|         .bot-message {
 | |
|             align-self: flex-start;
 | |
|             background: var(--secondary-color);
 | |
|             color: var(--text-light);
 | |
|         }
 | |
| 
 | |
|         /* Input Area */
 | |
|         .input-container {
 | |
|             display: flex;
 | |
|             gap: 10px;
 | |
|             padding: 20px;
 | |
|             background: white;
 | |
|             border-top: 1px solid #eee;
 | |
|         }
 | |
| 
 | |
|         .input-field {
 | |
|             flex: 1;
 | |
|             padding: 12px;
 | |
|             border: 1px solid #ddd;
 | |
|             border-radius: 8px;
 | |
|             font-size: 16px;
 | |
|         }
 | |
| 
 | |
|         .send-button {
 | |
|             background: var(--primary-color);
 | |
|             color: white;
 | |
|             padding: 12px 25px;
 | |
|             border: none;
 | |
|             border-radius: 8px;
 | |
|             cursor: pointer;
 | |
|             transition: background 0.3s ease;
 | |
|         }
 | |
| 
 | |
|         .send-button:hover {
 | |
|             background: var(--accent-color);
 | |
|         }
 | |
| 
 | |
|         /* Footer Styles */
 | |
|         .footer {
 | |
|             background: var(--primary-color);
 | |
|             color: var(--text-light);
 | |
|             text-align: center;
 | |
|             padding: 1rem;
 | |
|             margin-top: auto;
 | |
|             font-size: 0.9em;
 | |
|         }
 | |
| 
 | |
|         /* Responsive Design */
 | |
|         @media (max-width: 768px) {
 | |
|             .chat-container {
 | |
|                 height: 400px;
 | |
|             }
 | |
|             
 | |
|             .message {
 | |
|                 max-width: 85%;
 | |
|                 font-size: 14px;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         @media (max-width: 480px) {
 | |
|             .chat-container {
 | |
|                 height: 300px;
 | |
|             }
 | |
|             
 | |
|             .input-container {
 | |
|                 flex-direction: column;
 | |
|             }
 | |
|             
 | |
|             .send-button {
 | |
|                 width: 100%;
 | |
|             }
 | |
|         }
 | |
| 		
 | |
|         /* Loading Animation Styles */
 | |
|         .send-button {
 | |
|             position: relative;
 | |
|             width: 80px;
 | |
|         }
 | |
|         
 | |
|         #buttonText,
 | |
|         #ellipsis {
 | |
|             position: absolute;
 | |
|             top: 50%;
 | |
|             left: 50%;
 | |
|             transform: translate(-50%, -50%);
 | |
|         }
 | |
|         
 | |
|         .ellipsis div {
 | |
|             display: inline-block;
 | |
|             width: 6px;
 | |
|             height: 6px;
 | |
|             border-radius: 50%;
 | |
|             background: #fff;
 | |
|             margin: 0 2px;
 | |
|             animation: ellipsis 1s infinite;
 | |
|         }
 | |
|         
 | |
|         .ellipsis div:nth-child(2) { animation-delay: 0.2s; }
 | |
|         .ellipsis div:nth-child(3) { animation-delay: 0.4s; }
 | |
|         
 | |
|         @keyframes ellipsis {
 | |
|             0% { transform: scale(0); }
 | |
|             100% { transform: scale(1); }
 | |
|         }
 | |
| 
 | |
|         /* Button Styles */
 | |
|         .button-container {
 | |
|             display: flex;
 | |
|             gap: 10px;
 | |
|             margin-top: 15px;
 | |
|             justify-content: center;
 | |
|         }
 | |
| 
 | |
|         .action-button {
 | |
|             background: var(--button-bg);
 | |
|             color: var(--text-light);
 | |
|             padding: 12px 20px;
 | |
|             border: none;
 | |
|             border-radius: 8px;
 | |
|             cursor: pointer;
 | |
|             font-size: 1rem;
 | |
|             display: flex;
 | |
|             align-items: center;
 | |
|             gap: 8px;
 | |
|             transition: all 0.3s ease;
 | |
|         }
 | |
| 
 | |
|         .action-button:hover {
 | |
|             background: var(--button-hover);
 | |
|             transform: translateY(-2px);
 | |
|         }
 | |
| 
 | |
|         .action-button .emoji {
 | |
|             font-size: 1.2rem;
 | |
|         }
 | |
|     </style>
 | |
| </head>
 | |
| <body>
 | |
|     <header class="header">
 | |
|         <h1>DeppGPT</h1>
 | |
|         <button class="theme-toggle" id="theme-toggle">🌞</button>
 | |
|     </header>
 | |
| 
 | |
|     <main class="main-content">
 | |
|         <div class="chat-container">
 | |
|             <div class="chat-messages" id="chat-container"></div>
 | |
|             <div class="input-container">
 | |
|                 <input type="text" class="input-field" id="user-input" placeholder="Schreibe eine Nachricht...">
 | |
|                 <button class="send-button" id="send-button">
 | |
|                     <div id="buttonText">Senden</div>
 | |
|                     <div class="ellipsis" id="ellipsis" style="display: none;">
 | |
|                         <div></div>
 | |
|                         <div></div>
 | |
|                         <div></div>
 | |
|                     </div>
 | |
|                 </button>
 | |
|             </div>
 | |
|         </div>
 | |
| 
 | |
|         <div class="button-container">
 | |
|             <button class="action-button" id="save-button">
 | |
|                 <span class="emoji">📸</span>
 | |
|                 <span>Chat speichern</span>
 | |
|             </button>
 | |
|         </div>
 | |
|     </main>
 | |
| 
 | |
|     <footer class="footer">
 | |
|         Geklaut von Postillon und überarbeitet von Akamaru
 | |
|     </footer>
 | |
| 
 | |
| <script>
 | |
|     const chatGPTContainer = document.getElementById('chat-container');
 | |
|     const maxMessages = getRandomInt(3, 5);
 | |
|     let messageCount = 0;
 | |
|     let serverOverloaded = false;
 | |
|     let sendButtonActive = true;
 | |
| 
 | |
|     // Event-Listener für Enter-Taste
 | |
|     document.querySelector('.input-field').addEventListener('keypress', function (e) {
 | |
|         if (e.key === 'Enter') {
 | |
|             sendChatGPTMessage();
 | |
|         }
 | |
|     });
 | |
| 
 | |
|     // Event-Listener für Send-Button
 | |
|     document.getElementById('send-button').addEventListener('click', sendChatGPTMessage);
 | |
| 
 | |
|     async function sendChatGPTMessage() {
 | |
|         if (!sendButtonActive) return;
 | |
| 
 | |
|         const userInput = document.querySelector('.input-field');
 | |
|         let message = userInput.value.trim();
 | |
| 
 | |
|         if (message) {
 | |
|             userInput.value = '';
 | |
|             sendButtonActive = false;
 | |
|             toggleLoading(true);
 | |
|             messageCount += 1;
 | |
| 
 | |
|             // User-Nachricht anzeigen
 | |
|             const userMessageElement = document.createElement('div');
 | |
|             userMessageElement.className = 'message user-message';
 | |
|             userMessageElement.innerText = message;
 | |
|             chatGPTContainer.appendChild(userMessageElement);
 | |
|             chatGPTContainer.scrollTop = chatGPTContainer.scrollHeight;
 | |
| 
 | |
|             if (messageCount <= maxMessages && !serverOverloaded) {
 | |
|                 showChatGPTLoadingAnimation();
 | |
| 
 | |
|                 // API-Aufruf
 | |
|                 const response = await getCompletion(message);
 | |
|                 const answer = response;
 | |
| 
 | |
|                 setTimeout(() => {
 | |
|                     hideChatGPTLoadingAnimation();
 | |
|                     const botMessageElement = document.createElement('div');
 | |
|                     botMessageElement.className = 'message bot-message';
 | |
|                     chatGPTContainer.appendChild(botMessageElement);
 | |
| 
 | |
|                     // Typing-Effekt
 | |
|                     let index = 0;
 | |
|                     const typingInterval = setInterval(() => {
 | |
|                         botMessageElement.innerHTML += answer[index];
 | |
|                         index++;
 | |
| 
 | |
|                         if (index === answer.length) {
 | |
|                             clearInterval(typingInterval);
 | |
|                             toggleLoading(false);
 | |
|                             sendButtonActive = true;
 | |
| 
 | |
|                             if (serverOverloaded) {
 | |
|                                 showServerOverloadedMessage();
 | |
|                             } else if (messageCount === maxMessages) {
 | |
|                                 showExitMessage();
 | |
|                             }
 | |
|                         }
 | |
|                         chatGPTContainer.scrollTop = chatGPTContainer.scrollHeight;
 | |
|                     }, 25);
 | |
|                 }, 1000);
 | |
|             } else {
 | |
|                 toggleLoading(false);
 | |
|                 sendButtonActive = true;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     let messages = [];
 | |
|     let serverURL = null;
 | |
| 
 | |
|     function getDeepGPTVersionHost(probability) {
 | |
|         if (probability < 0 || probability > 1) {
 | |
|             throw new Error("Probability must be between 0 and 1.");
 | |
|         }
 | |
| 
 | |
|         var randomNum = Math.random();
 | |
|         return randomNum < probability ? 
 | |
|             "https://europe-west1-deppgpt.cloudfunctions.net/DeppGPTRelease221" :
 | |
|             "https://europe-west1-deppgpt.cloudfunctions.net/DeppGPTRelease20";
 | |
|     }
 | |
| 
 | |
|     async function getCompletion(userMessage) {
 | |
|         messages.push({ role: "user", content: userMessage });
 | |
| 
 | |
|         if (!serverURL) {
 | |
|             if (isGreeting(userMessage)) {
 | |
|                 serverURL = getDeepGPTVersionHost(0.2);
 | |
|             } else if (isQuestion(userMessage)) {
 | |
|                 serverURL = getDeepGPTVersionHost(0.8);
 | |
|             } else {
 | |
|                 serverURL = getDeepGPTVersionHost(0.5);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         const response = await fetch(serverURL, {
 | |
|             method: "POST",
 | |
|             headers: { "Content-Type": "application/json" },
 | |
|             body: JSON.stringify({ messages, maxMessages }),
 | |
|         });
 | |
| 
 | |
|         if (response.ok) {
 | |
|             const data = await response.json();
 | |
|             const assistantMessage = data.answer;
 | |
|             messages.push({ role: "assistant", content: assistantMessage });
 | |
|             return assistantMessage;
 | |
|         } else {
 | |
|             serverOverloaded = true;
 | |
|             const errorMessages = [
 | |
|                 "Ich kriege gerade so viele Anfragen von so unfähigen Leuten wie dir, ich brauch grad echt mal ne Pause. Komm später wieder. Oder besser noch gar nicht!",
 | |
|                 "Ich habe gerade genug von all den Leuten, die nicht wissen, was sie tun. Ich brauche einen Moment. Komm später zurück, wenn überhaupt!",
 | |
|                 "Ich bin gerade von all den Anfragen von Leuten wie dir überschwemmt, die keine Ahnung haben. Ich muss durchatmen. Vielleicht kommst du später zurück, oder besser noch, gar nicht!",
 | |
|                 "Ich bin gerade von all den Anfragen überfordert. Ich muss mich sammeln. Bitte komm später wieder, oder vielleicht sogar nie wieder!",
 | |
|                 "Ich bin gerade mit Anfragen von Leuten überhäuft, die einfach keinen Plan haben. Ich brauche eine Pause. Versuch es später nochmal, oder besser noch, gar nicht!",
 | |
|                 "Ich habe gerade genug von all den nutzlosen Anfragen. Ich brauche einen Moment für mich. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich bin gerade von Menschen überwältigt, die einfach nicht wissen, was sie tun. Ich brauche eine Auszeit. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade mit sinnlosen Anfragen überhäuft. Ich brauche eine Pause. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich habe gerade genug von all den Ahnungslosen, die mich belästigen. Ich brauche eine Pause. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade überfordert von all den Anfragen von Leuten, die nichts kapieren. Ich brauche eine Auszeit. Komm später wieder, oder vielleicht besser nicht!",
 | |
|                 "Ich habe gerade genug von all den Anfragen von Leuten, die keine Ahnung haben. Ich brauche eine Pause. Versuch es später nochmal, oder besser noch, gar nicht!",
 | |
|                 "Ich bin gerade von den Anfragen von Menschen, die nicht wissen, was sie tun, überschwemmt. Ich brauche eine Pause. Komm später wieder, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade von nutzlosen Anfragen überhäuft. Ich brauche eine Auszeit. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade überfordert von all den Anfragen von Leuten, die einfach keinen Plan haben. Ich brauche eine Pause. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich habe gerade genug von all den Leuten, die mich belästigen. Ich brauche eine Pause. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade von all den Anfragen überwältigt, die ich bekomme. Ich brauche eine Auszeit. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich bin gerade von all den Anfragen von Leuten, die nichts verstehen, überwältigt. Ich brauche eine Pause. Komm später wieder, oder vielleicht besser nicht!",
 | |
|                 "Ich habe gerade genug von all den Anfragen von Leuten, die keinen Sinn ergeben. Ich brauche eine Auszeit. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich bin gerade von Anfragen überhäuft, die keinen Sinn ergeben. Ich brauche eine Pause. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich bin gerade von Leuten überwältigt, die einfach nicht wissen, was sie tun. Ich brauche eine Auszeit. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade überfordert von all den Anfragen von Leuten, die einfach keinen Plan haben. Ich brauche eine Pause. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich habe gerade genug von all den nutzlosen Anfragen. Ich brauche einen Moment für mich. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich bin gerade von Menschen überwältigt, die einfach nicht wissen, was sie tun. Ich brauche eine Auszeit. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade mit sinnlosen Anfragen überhäuft. Ich brauche eine Pause. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich habe gerade genug von all den Ahnungslosen, die mich belästigen. Ich brauche eine Pause. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade überfordert von all den Anfragen von Leuten, die nichts kapieren. Ich brauche eine Auszeit. Komm später wieder, oder vielleicht besser nicht!",
 | |
|                 "Ich habe gerade genug von all den Anfragen von Leuten, die keine Ahnung haben. Ich brauche eine Pause. Versuch es später nochmal, oder besser noch, gar nicht!",
 | |
|                 "Ich bin gerade von den Anfragen von Menschen, die nicht wissen, was sie tun, überschwemmt. Ich brauche eine Pause. Komm später wieder, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade von nutzlosen Anfragen überhäuft. Ich brauche eine Auszeit. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade überfordert von all den Anfragen von Leuten, die einfach keinen Plan haben. Ich brauche eine Pause. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich habe gerade genug von all den Leuten, die mich belästigen. Ich brauche eine Pause. Versuch es später nochmal, oder am besten gar nicht!",
 | |
|                 "Ich bin gerade von all den Anfragen überwältigt, die ich bekomme. Ich brauche eine Auszeit. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich bin gerade von all den Anfragen von Leuten, die nichts verstehen, überwältigt. Ich brauche eine Pause. Komm später wieder, oder vielleicht besser nicht!",
 | |
|                 "Ich habe gerade genug von all den Anfragen von Leuten, die keinen Sinn ergeben. Ich brauche eine Auszeit. Komm später wieder, oder vielleicht auch nicht!",
 | |
|                 "Ich bin gerade von Anfragen überhäuft, die keinen Sinn ergeben. Ich brauche eine Pause. Komm später wieder, oder vielleicht auch nicht!"
 | |
|             ];
 | |
|             const randomIndex = Math.floor(Math.random() * errorMessages.length);
 | |
|             const errorMessage = errorMessages[randomIndex];
 | |
|             messages.push({ role: "assistant", content: errorMessage });
 | |
|             return errorMessage;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function showChatGPTLoadingAnimation() {
 | |
|         const loadingElement = document.createElement('div');
 | |
|         loadingElement.className = 'loading-animation';
 | |
|         chatGPTContainer.appendChild(loadingElement);
 | |
|         chatGPTContainer.scrollTop = chatGPTContainer.scrollHeight;
 | |
|     }
 | |
| 
 | |
|     function hideChatGPTLoadingAnimation() {
 | |
|         const loadingElement = document.querySelector('.loading-animation');
 | |
|         if (loadingElement) {
 | |
|             loadingElement.remove();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function showServerOverloadedMessage() {
 | |
|         const messageDiv = document.createElement('div');
 | |
|         messageDiv.className = 'message bot-exit-message';
 | |
|         messageDiv.textContent = 'Unsere Server sind gerade überlastet, bitte versuche es später noch einmal!';
 | |
|         chatGPTContainer.appendChild(messageDiv);
 | |
|     }
 | |
| 
 | |
|     function showExitMessage() {
 | |
|         const messageDiv = document.createElement('div');
 | |
|         messageDiv.className = 'message bot-exit-message';
 | |
|         messageDiv.textContent = 'FunGPT hat den Chat verlassen.';
 | |
|         chatGPTContainer.appendChild(messageDiv);
 | |
|     }
 | |
| 
 | |
|     function toggleLoading(isLoading) {
 | |
|         const buttonText = document.getElementById("buttonText");
 | |
|         const ellipsis = document.getElementById("ellipsis");
 | |
| 
 | |
|         if (isLoading) {
 | |
|             buttonText.style.display = 'none';
 | |
|             ellipsis.style.display = 'block';
 | |
|         } else {
 | |
|             buttonText.style.display = 'block';
 | |
|             ellipsis.style.display = 'none';
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function isGreeting(sentence) {
 | |
|         const greetingKeywords = ['hallo', 'hi', 'guten tag', 'grüß dich', 'moin', 'servus', 'hey', 'huhu', 'grüezi', 'sers', 'salut', 'willkommen', 'tach', 'tschüss', 'ahoi', 'na', 'tagchen', 'griaß di', 'griaß enk', 'juten tach', 'hallöchen', 'hallöle', 'grüssle', 'grüß gott', 'mahoin'];
 | |
|         return greetingKeywords.some(word => sentence.toLowerCase().startsWith(word));
 | |
|     }
 | |
| 
 | |
|     function isQuestion(sentence) {
 | |
|         sentence = sentence.trim();
 | |
|         if (sentence.endsWith('?')) return true;
 | |
| 
 | |
|         const questionWords = ['wer', 'wen', 'wem', 'wessen', 'was', 'wann', 'wo', 'warum', 'wie'];
 | |
|         return questionWords.some(word => sentence.toLowerCase().startsWith(word));
 | |
|     }
 | |
| 
 | |
|     function getRandomInt(min, max) {
 | |
|         return Math.floor(Math.random() * (max - min + 1)) + min;
 | |
|     }
 | |
| 
 | |
|     // Save Button Functionality
 | |
|     document.getElementById('save-button').addEventListener('click', function () {
 | |
|         var chatWindow = document.querySelector('.chat-messages');
 | |
|         
 | |
|         // Speichere aktuelle Scroll-Position
 | |
|         const originalScrollTop = chatWindow.scrollTop;
 | |
|         
 | |
|         // Speichere ursprüngliche Höhe und Style
 | |
|         const originalHeight = chatWindow.style.height;
 | |
|         const originalOverflow = chatWindow.style.overflow;
 | |
|         
 | |
|         // Setze temporär die Höhe auf die ScrollHeight und deaktiviere Scrolling
 | |
|         chatWindow.style.height = 'auto';
 | |
|         chatWindow.style.overflow = 'visible';
 | |
|         
 | |
|         html2canvas(chatWindow, {
 | |
|             height: chatWindow.scrollHeight,
 | |
|             windowHeight: chatWindow.scrollHeight
 | |
|         }).then(canvas => {
 | |
|             const link = document.createElement('a');
 | |
|             const date = new Date();
 | |
|             const filename = `DeppGPT_CHAT_${date.getFullYear()}${('0' + (date.getMonth() + 1)).slice(-2)}${('0' + date.getDate()).slice(-2)}_${('0' + date.getHours()).slice(-2)}${('0' + date.getMinutes()).slice(-2)}${('0' + date.getSeconds()).slice(-2)}.png`;
 | |
|             link.download = filename;
 | |
|             link.href = canvas.toDataURL();
 | |
|             link.click();
 | |
|             
 | |
|             // Stelle ursprüngliche Höhe und Style wieder her
 | |
|             chatWindow.style.height = originalHeight;
 | |
|             chatWindow.style.overflow = originalOverflow;
 | |
|             chatWindow.scrollTop = originalScrollTop;
 | |
|         });
 | |
|     });
 | |
| 
 | |
|     function createLoadingAnimation() {
 | |
|         const loadingAnimation = $('<div id="loading-animation"></div>');
 | |
|         loadingAnimation.css({
 | |
|             'border': '16px solid #f3f3f3',
 | |
|             'border-top': '16px solid #3498db',
 | |
|             'border-radius': '50%',
 | |
|             'width': '120px',
 | |
|             'height': '120px',
 | |
|             'animation': 'spin 2s linear infinite',
 | |
|         });
 | |
| 
 | |
|         const style = $('<style>@keyframes spin {0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); }}</style>');
 | |
|         $('html > head').append(style);
 | |
| 
 | |
|         return loadingAnimation;
 | |
|     }
 | |
| 
 | |
|     // Theme Functionality
 | |
|     const themeToggle = document.getElementById('theme-toggle');
 | |
|     const root = document.documentElement;
 | |
| 
 | |
|     // Check system preference
 | |
|     if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
 | |
|         root.setAttribute('data-theme', 'dark');
 | |
|         themeToggle.textContent = '🌞';
 | |
|     }
 | |
| 
 | |
|     // Listen for system theme changes
 | |
|     window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
 | |
|         const newTheme = e.matches ? 'dark' : 'light';
 | |
|         root.setAttribute('data-theme', newTheme);
 | |
|         themeToggle.textContent = newTheme === 'dark' ? '🌞' : '🌑';
 | |
|     });
 | |
| 
 | |
|     // Manual theme toggle
 | |
|     themeToggle.addEventListener('click', () => {
 | |
|         const currentTheme = root.getAttribute('data-theme');
 | |
|         const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
 | |
|         root.setAttribute('data-theme', newTheme);
 | |
|         themeToggle.textContent = newTheme === 'dark' ? '🌞' : '🌑';
 | |
|     });
 | |
| </script>
 | |
| </body>
 | |
| </html>
 | |
| <!--DeppGPT Ende-->
 |