RamAI123 commited on
Commit
8de5540
1 Parent(s): 8b83930

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +321 -0
templates/index.html ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>URL and Text Input App</title>
7
+ <script src="https://kit.fontawesome.com/4d86daed55.js" crossorigin="anonymous"></script>
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ margin: 0;
12
+ display: flex;
13
+ flex-direction: column;
14
+ align-items: center;
15
+ justify-content: flex-end;
16
+ min-height: 100vh;
17
+ background-image: url("https://ibb.co/K2rPsZ4");
18
+ background-image: linear-gradient(to right top, #d16ba5, #c777b9, #ba83ca, #aa8fd8, #9a9ae1, #8aa7ec, #79b3f4, #69bff8, #52cffe, #41dfff, #46eefa, #5ffbf1);
19
+ background-size: cover;
20
+
21
+ }
22
+
23
+ #header {
24
+ background-color: white;
25
+ padding: 10px;
26
+ width: 100%;
27
+ text-align: center;
28
+ position: fixed; /* Fixed position at the top */
29
+ top: 0;
30
+ color: black;
31
+ border: 2px solid #333; /* Border properties for title content */
32
+ padding: 0px;
33
+ border-radius: 8px;
34
+ box-sizing: content-box;
35
+ }
36
+
37
+ #interactionHistory {
38
+ width: 80%;
39
+ height:75vh;
40
+ text-align: left;
41
+ margin-top: 20px;
42
+ padding: 20px;
43
+ box-sizing: border-box;
44
+ border-radius: 8px;
45
+ background-image: linear-gradient(to right top, #9edd91, #b2d787, #c3d081, #d1ca7f, #dcc380, #e1bd7d, #e6b87b, #ebb27a, #efab72, #f3a46a, #f79c64, #fb945f);
46
+ overflow-y:auto;
47
+ }
48
+
49
+ #inputForm {
50
+ max-width: 80%;
51
+ width: 80%;
52
+ background-color: #34495e; /* Darker Blue for Input Form */
53
+ padding: 20px;
54
+ box-sizing: border-box;
55
+ border: 1px solid #2c3e50; /* Border Color */
56
+ border-radius: 8px;
57
+ display: flex;
58
+
59
+ margin-top: 20px;
60
+ margin-bottom: 30px;
61
+ }
62
+ #downloadPdfLink {
63
+ position: fixed;
64
+ top: 90px;
65
+ left: 10px;
66
+ background-color: #3498db;
67
+ color: white;
68
+ border: none;
69
+ padding: 5px 10px;
70
+ border-radius: 4px;
71
+ cursor: pointer;
72
+ text-decoration: none;
73
+ display: inline-block;
74
+ }
75
+
76
+ #shareLink {
77
+ position: fixed;
78
+ top: 90px;
79
+ right: 10px;
80
+ background-color: #3498db;
81
+ color: white;
82
+ border: none;
83
+ padding: 5px 10px;
84
+ border-radius: 4px;
85
+ cursor: pointer;
86
+ text-decoration: none;
87
+ display: inline-block;
88
+ margin-left: 5px;
89
+ }
90
+
91
+ #scrollButton {
92
+ position: absolute;
93
+ bottom: 20px;
94
+ right: 20px;
95
+ background-color: #3498db;
96
+ color: white;
97
+ border: none;
98
+ border-radius: 4px;
99
+ cursor: pointer;
100
+ padding: 10px;
101
+ }
102
+
103
+ #interactionHistory::-webkit-scrollbar {
104
+ width: 10px; /* For Chrome, Safari, and Opera */
105
+ }
106
+
107
+ #interactionHistory::-webkit-scrollbar-thumb {
108
+ background-color: #3498db; /* Color of the thumb */
109
+ }
110
+ #downloadPdfLink:hover,
111
+ #shareLink:hover {
112
+ background-color: #2980b9; /* Darker Blue on Hover */
113
+ }
114
+
115
+ .copy-button {
116
+ cursor: pointer;
117
+ background-color: #3498db;
118
+ color: white;
119
+ border: none;
120
+ padding: 5px 10px;
121
+ border-radius: 4px;
122
+ margin-left: 5px;
123
+ }
124
+
125
+ input[type="text"] {
126
+ width: 260%;
127
+ padding: 10px;
128
+ margin: 5px 0 0 0;
129
+ box-sizing: border-box;
130
+ display: inline-block;
131
+ border-radius:10px;
132
+ height:100%;
133
+ }
134
+
135
+ input[type="submit"] {
136
+ background-color: #3498db; /* Blue for Submit Button */
137
+ color: white;
138
+ border: solid;
139
+ border-radius: 10px;
140
+ cursor: pointer;
141
+ font-size: 13px;
142
+ }
143
+ #userForm{
144
+ display:flex;
145
+ justify-content:space-between;
146
+ width:100%;
147
+ }
148
+
149
+ input[type="submit"]:hover {
150
+ background-color: #2980b9; /* Darker Blue on Hover */
151
+ }
152
+ .fa-solid.fa-arrow-right{
153
+ margin-top: 10%;
154
+ font-size:25px;
155
+ background-color: #3498db;
156
+ color: white;
157
+ height: 70%;
158
+ padding:10px;
159
+ border-radius: 10px;
160
+ }
161
+ #scrollDownLink {
162
+ position: absolute;
163
+ top: 50%; /* Adjust the vertical position as needed */
164
+ right: 20px; /* Adjust the horizontal position as needed */
165
+ background-color: #3498db;
166
+ color: white;
167
+ border: none;
168
+ border-radius: 4px;
169
+ cursor: pointer;
170
+ padding: 10px;
171
+ }
172
+
173
+ #scrollDownLink:hover {
174
+ background-color: #2980b9; /* Darker Blue on Hover */
175
+ }
176
+
177
+ </style>
178
+ </head>
179
+ <body>
180
+
181
+ <div id="header" {% if input_submitted %} style="display: none;" {% endif %}>
182
+ <h1>Supply Chain Management</h1>
183
+ </div>
184
+
185
+ <!-- Updated HTML code with copy icon for specific keys -->
186
+
187
+ <div id="interactionHistory">
188
+ {% if chat_history %}
189
+ <div>
190
+ {% for message in chat_history %}
191
+ {% if 'Question' in message %}
192
+ <p><strong>{{ 'Question' }}:</strong> {{ message['Question'] }}</p>
193
+ {% endif %}
194
+ {% if 'Article content' in message %}
195
+ <p><strong>{{ 'Article Content' }}:</strong> {{ message['Article content'] }} <span class="copy-button" onclick="copyToClipboard('{{ message['Article content'] }}')"><i class="fas fa-copy"></i></span></p>
196
+ {% endif %}
197
+ {% if 'Short Article content' in message %}
198
+ <p><strong>{{ 'Short Article Content' }}:</strong> {{ message['Short Article content'] }} <span class="copy-button" onclick="copyToClipboard('{{ message['Short Article content'] }}')"><i class="fas fa-copy"></i></span></p>
199
+ {% endif %}
200
+ {% if 'Classification' in message %}
201
+ <p><strong>{{ 'Classification' }}:</strong> {{ message['Classification'] }}</p>
202
+ {% endif %}
203
+ {% if 'Summary risk' in message %}
204
+ <p><strong>{{ 'Summary Risk' }}:</strong> {{ message['Summary risk'] }} <span class="copy-button" onclick="copyToClipboard('{{ message['Summary risk'] }}')"><i class="fas fa-copy"></i></span></p>
205
+ {% endif %}
206
+ {% if 'Opportunity Summary' in message %}
207
+ <p><strong>{{ 'Opportunity Summary' }}:</strong> {{ message['Opportunity Summary'] }} <span class="copy-button" onclick="copyToClipboard('{{ message['Opportunity Summary'] }}')"><i class="fas fa-copy"></i></span></p>
208
+ {% endif %}
209
+ {% if message is mapping %}
210
+ {% for key, value in message.items() %}
211
+ {% if key not in ['Question','Article content','Summary risk','Opportunity Summary','Short Article content','Classification'] %}
212
+ <p><strong>{{ key }}:</strong> {{ value }}</p>
213
+ {% endif %}
214
+ {% endfor %}
215
+ {% else %}
216
+ <p>{{ message }}</p>
217
+ {% endif %}
218
+ {% endfor %}
219
+ </div>
220
+ {% endif %}
221
+ <button id="scrollButton" onclick="scrollToTop()"><i class="fa-solid fa-arrow-up"></i></button>
222
+ </div>
223
+ <a href="javascript:void(0);" onclick="scrollToInteractionHistory()" id="scrollDownLink"><i class="fa-solid fa-arrow-down"></i></a>
224
+
225
+ <div id="inputForm">
226
+ <!-- Updated form with standard form submission -->
227
+ <form action="/" method="post" id="userForm">
228
+ <input type="text" id="userInput" name="userInput" placeholder="Enter URL or Text" required>
229
+ <!-- Replace the input[type="submit"] button with a send icon -->
230
+ <button type="submit" onclick="sendQuestion()" style="background-color: #3498db; border: none; cursor: pointer; padding-top:6px; padding-bottom: 16px;">
231
+ <i class="fa-solid fa-arrow-right"></i>
232
+ </button>
233
+ </form>
234
+ <!-- Add this link in your HTML -->
235
+ </div>
236
+ <a href="{{ url_for('download_pdf') }}" id="downloadPdfLink" target="_blank"><i class="fa-solid fa-download"></i></a>
237
+
238
+ <a href="#" id="shareLink"><i class="fa-solid fa-share-from-square"></i></a>
239
+
240
+ <!-- JavaScript function to send a question asynchronously -->
241
+ <script>
242
+ function sendQuestion() {
243
+ // Get the user input
244
+ var userInput = $('#userInput').val();
245
+
246
+ // Send an asynchronous POST request to the server
247
+ $.ajax({
248
+ type: 'POST',
249
+ url: '/',
250
+ data: { userInput: userInput },
251
+ success: function(response) {
252
+ // Update the chat history div with the new content
253
+ $('#interactionHistory').html(response);
254
+ }
255
+ });
256
+ }
257
+
258
+ function scrollToTop() {
259
+ document.getElementById('interactionHistory').scrollTop = 0;
260
+ }
261
+ function checkScrollPosition() {
262
+ var interactionHistory = document.getElementById('interactionHistory');
263
+ var scrollButton = document.getElementById('scrollButton');
264
+
265
+ if (interactionHistory.scrollTop > 0) {
266
+ scrollButton.style.display = 'block';
267
+ } else {
268
+ scrollButton.style.display = 'none';
269
+ }
270
+ }
271
+ window.addEventListener('scroll', function () {
272
+ // Call the function when the body scrolls
273
+ checkScrollPosition();
274
+ });
275
+ function copyToClipboard(text) {
276
+ var textarea = document.createElement("textarea");
277
+ textarea.value = text;
278
+ document.body.appendChild(textarea);
279
+ textarea.select();
280
+ document.execCommand('copy');
281
+ document.body.removeChild(textarea);
282
+ alert('Copied to clipboard: ' + text);
283
+ }
284
+
285
+ function downloadPDF() {
286
+ // Trigger a request to the Flask route responsible for PDF generation
287
+ window.location.href = '/download_pdf';
288
+ }
289
+ function scrollToInteractionHistory() {
290
+ var interactionHistory = document.getElementById('interactionHistory');
291
+ interactionHistory.scrollTop = interactionHistory.scrollHeight;
292
+ }
293
+
294
+ document.addEventListener('DOMContentLoaded', function() {
295
+ // Get the share link element
296
+ var shareLink = document.getElementById('shareLink');
297
+
298
+ // Add a click event listener to trigger the share dialog
299
+ shareLink.addEventListener('click', function(event) {
300
+ event.preventDefault();
301
+
302
+ // Check if the Web Share API is supported
303
+ if (navigator.share) {
304
+ // Use the Web Share API to trigger the native sharing dialog
305
+ navigator.share({
306
+ title: document.title,
307
+ text: 'Check out this page!',
308
+ url: window.location.href
309
+ })
310
+ .then(() => console.log('Shared successfully'))
311
+ .catch((error) => console.error('Error sharing:', error));
312
+ } else {
313
+ // Fallback for browsers that do not support the Web Share API
314
+ alert('Sharing is not supported in your browser.');
315
+ }
316
+ });
317
+ });
318
+ </script>
319
+
320
+ </body>
321
+ </html>