Djacon commited on
Commit
4a46b4a
Β·
1 Parent(s): d98a217

Edit design | Add 2 logo's | Fix some bugs'

Browse files
.gitignore CHANGED
@@ -1 +1,2 @@
1
- __pycache__/
 
 
1
+ __pycache__/
2
+ copy.bat
static/404.html CHANGED
@@ -106,13 +106,8 @@
106
  <span class="mx-3 font-medium">Visit Main Website</span>
107
  </a>
108
 
109
- <button class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40"
110
- onclick="change_theme()">
111
- <svg class="w-6 h-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
112
- <path
113
- d="M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM19 3C20.1046 3 21 3.89543 21 5V19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V5C3 3.89543 3.89543 3 5 3H19Z"
114
- fill="currentColor"></path>
115
- </svg>
116
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
117
  </button>
118
  </div>
@@ -260,28 +255,6 @@
260
  </div>
261
  </div>
262
 
263
- <script>
264
- if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
265
- localStorage.theme = 'dark';
266
- document.documentElement.classList.add('dark');
267
- document.getElementById('theme-span').innerText = 'Set Light Theme';
268
- } else {
269
- localStorage.theme = 'light';
270
- document.documentElement.classList.remove('dark');
271
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
272
- }
273
-
274
- function change_theme() {
275
- if (localStorage.theme === 'dark') {
276
- localStorage.theme = 'light';
277
- document.documentElement.classList.remove('dark');
278
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
279
- } else {
280
- localStorage.theme = 'dark';
281
- document.documentElement.classList.add('dark');
282
- document.getElementById('theme-span').innerText = 'Set Light Theme';
283
- }
284
- }
285
- </script>
286
  </body>
287
  </html>
 
106
  <span class="mx-3 font-medium">Visit Main Website</span>
107
  </a>
108
 
109
+ <button id="theme-btn" class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40">
110
+ <img id="img-theme" src="images/sun.svg" width="24" height="24">
 
 
 
 
 
111
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
112
  </button>
113
  </div>
 
255
  </div>
256
  </div>
257
 
258
+ <script src="js/theme.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  </body>
260
  </html>
static/css/main.css CHANGED
@@ -2404,10 +2404,20 @@ select {
2404
  background-color: #282828;
2405
  } */
2406
 
 
 
 
 
 
 
 
 
 
 
2407
  .dark {
2408
- filter: invert(90%);
2409
  }
2410
 
2411
  .dark .no-invert {
2412
- filter: invert(90%);
2413
  }
 
2404
  background-color: #282828;
2405
  } */
2406
 
2407
+ #submit {
2408
+ background-color: #ffa116;
2409
+ }
2410
+ #submit:hover {
2411
+ background-color: #fcb140;
2412
+ }
2413
+ #submit:focus {
2414
+ box-shadow: 0 0 5px 2px rgb(255, 188, 87);
2415
+ }
2416
+
2417
  .dark {
2418
+ filter: invert(92%);
2419
  }
2420
 
2421
  .dark .no-invert {
2422
+ filter: invert(92%);
2423
  }
static/emotion_detection.html CHANGED
@@ -105,13 +105,8 @@
105
  <span class="mx-3 font-medium">Visit Main Website</span>
106
  </a>
107
 
108
- <button class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40"
109
- onclick="change_theme()">
110
- <svg class="w-6 h-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
111
- <path
112
- d="M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM19 3C20.1046 3 21 3.89543 21 5V19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V5C3 3.89543 3.89543 3 5 3H19Z"
113
- fill="currentColor"></path>
114
- </svg>
115
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
116
  </button>
117
  </div>
@@ -119,7 +114,7 @@
119
  </div>
120
 
121
  <div class="flex flex-col flex-1 overflow-hidden bg-gray-100">
122
- <header class="bg-white border-b border-gray-100">
123
  <div class="flex items-center justify-between px-4 py-4 sm:px-6">
124
  <div class="flex items-center">
125
  <button @click="sidebarOpen = !sidebarOpen" class="text-gray-500 lg:hidden focus:outline-none">
@@ -234,60 +229,28 @@
234
  <h1 class="text-lg font-medium text-gray-700 capitalize sm:text-xl md:text-2xl">Upload text</h1>
235
 
236
  <form id='sum-form' class="mt-6 space-y-5" onsubmit="return false;">
237
- <div>
238
- <label for="sum-type" class="block text-sm text-gray-700 capitalize">Select Type</label>
239
- <select id="sum-type"
240
- class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40">
241
- <option value="sum-text">Identify Text</option>
242
- <option value="sum-file">Identify File</option>
243
- </select>
244
- </div>
245
-
246
  <div id="sum-text-div">
247
- <label for="description"
248
- class="block text-sm text-gray-700 capitalize">description</label>
249
  <textarea id="sum-text-input" required class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
250
- style="min-height: 300px;"></textarea>
251
  </div>
252
 
253
- <div id="sum-file-div" class="hidden">
254
- <label for="image" class="block text-sm text-gray-700 capitalize">file</label>
255
- <label
256
- class="flex flex-col items-center justify-center w-full h-32 mt-2 text-gray-500 border-2 border-dashed rounded-md cursor-pointer hover:text-gray-600">
257
- <svg class="w-8 h-8" fill="currentColor" xmlns="http://www.w3.org/2000/svg"
 
258
  viewBox="0 0 20 20">
259
  <path
260
  d="M16.88 9.1A4 4 0 0 1 16 17H5a5 5 0 0 1-1-9.9V7a3 3 0 0 1 4.52-2.59A4.98 4.98 0 0 1 17 8c0 .38-.04.74-.12 1.1zM11 11h3l-4-4-4 4h3v3h2v-3z">
261
  </path>
262
  </svg>
263
- <span class="mt-4">Select File</span>
264
  <input id="sum-file-input" type="file" accept=".pdf, .txt" class="hidden">
265
  </label>
266
- </div>
267
-
268
- <p id='sum-err' class="hidden mt-2 text-sm text-red-500">Your password is too short.</p>
269
-
270
- <div class="flex justify-end">
271
- <style>
272
- #submit {
273
- background-color: #ffa116;
274
- }
275
- #submit:hover {
276
- background-color: #fcb140;
277
- }
278
- #submit:focus {
279
- box-shadow: 0 0 5px 2px rgb(255, 188, 87);
280
- }
281
- </style>
282
- <button id="submit" type="button" class="no-invert w-full flex items-center justify-center px-2 py-2 text-sm font-medium tracking-wide text-white capitalize transition-colors duration-200 transform rounded-md focus:outline-none">
283
- <svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
284
- <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
285
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
286
- <g id="SVGRepo_iconCarrier">
287
- <path d="M7 10L12 15L17 10" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
288
- </g>
289
- </svg>
290
- <span class="mx-1">Detect</span>
291
  </button>
292
  </div>
293
  </form>
@@ -297,12 +260,11 @@
297
  <h1 class="text-lg font-medium text-gray-700 capitalize sm:text-xl md:text-2xl">Result</h1>
298
 
299
  <div class="md:flex gap-8">
300
- <div class="w-full md:w-1/2 grid-cols-2 mt-6">
301
  <label for="description"
302
  class="block text-sm text-gray-700 capitalize">Extracted Text</label>
303
  <textarea id="extracted-text"
304
- class="minh-text block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
305
- style="min-height: 250px;"></textarea>
306
  </div>
307
 
308
  <div class="w-full md:w-1/2 grid-cols-2 mt-6">
@@ -320,30 +282,8 @@
320
  </div>
321
  </div>
322
 
323
- <script>
324
- if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
325
- localStorage.theme = 'dark';
326
- document.documentElement.classList.add('dark');
327
- document.getElementById('theme-span').innerText = 'Set Light Theme';
328
- } else {
329
- localStorage.theme = 'light';
330
- document.documentElement.classList.remove('dark');
331
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
332
- }
333
-
334
- function change_theme() {
335
- if (localStorage.theme === 'dark') {
336
- localStorage.theme = 'light';
337
- document.documentElement.classList.remove('dark');
338
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
339
- } else {
340
- localStorage.theme = 'dark';
341
- document.documentElement.classList.add('dark');
342
- document.getElementById('theme-span').innerText = 'Set Light Theme';
343
- }
344
- }
345
- </script>
346
 
 
347
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.min.js"></script>
348
  <script src="js/detection.js"></script>
349
  </body>
 
105
  <span class="mx-3 font-medium">Visit Main Website</span>
106
  </a>
107
 
108
+ <button id="theme-btn" class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40">
109
+ <img id="img-theme" src="images/sun.svg" width="24" height="24">
 
 
 
 
 
110
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
111
  </button>
112
  </div>
 
114
  </div>
115
 
116
  <div class="flex flex-col flex-1 overflow-hidden bg-gray-100">
117
+ <header class="static bg-white border-b border-gray-100">
118
  <div class="flex items-center justify-between px-4 py-4 sm:px-6">
119
  <div class="flex items-center">
120
  <button @click="sidebarOpen = !sidebarOpen" class="text-gray-500 lg:hidden focus:outline-none">
 
229
  <h1 class="text-lg font-medium text-gray-700 capitalize sm:text-xl md:text-2xl">Upload text</h1>
230
 
231
  <form id='sum-form' class="mt-6 space-y-5" onsubmit="return false;">
 
 
 
 
 
 
 
 
 
232
  <div id="sum-text-div">
 
 
233
  <textarea id="sum-text-input" required class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
234
+ style="min-height: 250px;" placeholder="Enter or upload your text and press &quot;Detect&quot;"></textarea>
235
  </div>
236
 
237
+ <p id='sum-err' class="no-invert hidden mt-2 text-sm text-red-500"></p>
238
+
239
+ <div class="flex justify-between no-invert">
240
+ <label id="word-counter" class="hidden flex items-center py-2 px-4 text-gray-500 rounded">Words:</label>
241
+ <label id="sum-file-div" class="flex items-center py-2 px-4 text-gray-500 rounded cursor-pointer hover:text-gray-700">
242
+ <svg class="w-6 h-6" fill="currentColor" xmlns="http://www.w3.org/2000/svg"
243
  viewBox="0 0 20 20">
244
  <path
245
  d="M16.88 9.1A4 4 0 0 1 16 17H5a5 5 0 0 1-1-9.9V7a3 3 0 0 1 4.52-2.59A4.98 4.98 0 0 1 17 8c0 .38-.04.74-.12 1.1zM11 11h3l-4-4-4 4h3v3h2v-3z">
246
  </path>
247
  </svg>
248
+ <span class="px-2">Upload</span>
249
  <input id="sum-file-input" type="file" accept=".pdf, .txt" class="hidden">
250
  </label>
251
+ <button id="submit" class="w-32 sm:w-80 flex items-center justify-center py-2 px-4 rounded font-medium text-white rounded-full"
252
+ style="max-height: 2.5rem;">
253
+ Detect
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  </button>
255
  </div>
256
  </form>
 
260
  <h1 class="text-lg font-medium text-gray-700 capitalize sm:text-xl md:text-2xl">Result</h1>
261
 
262
  <div class="md:flex gap-8">
263
+ <div class="hidden w-full md:w-1/2 grid-cols-2 mt-6">
264
  <label for="description"
265
  class="block text-sm text-gray-700 capitalize">Extracted Text</label>
266
  <textarea id="extracted-text"
267
+ class="minh-text block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"></textarea>
 
268
  </div>
269
 
270
  <div class="w-full md:w-1/2 grid-cols-2 mt-6">
 
282
  </div>
283
  </div>
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
 
286
+ <script src="js/theme.js"></script>
287
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.min.js"></script>
288
  <script src="js/detection.js"></script>
289
  </body>
static/images/moon.svg ADDED
static/images/sun.svg ADDED
static/index.html CHANGED
@@ -105,13 +105,8 @@
105
  <span class="mx-3 font-medium">Visit Main Website</span>
106
  </a>
107
 
108
- <button class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40"
109
- onclick="change_theme()">
110
- <svg class="w-6 h-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
111
- <path
112
- d="M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM19 3C20.1046 3 21 3.89543 21 5V19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V5C3 3.89543 3.89543 3 5 3H19Z"
113
- fill="currentColor"></path>
114
- </svg>
115
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
116
  </button>
117
  </div>
@@ -793,29 +788,7 @@
793
  </div>
794
  </div>
795
 
796
- <script>
797
- if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
798
- localStorage.theme = 'dark';
799
- document.documentElement.classList.add('dark');
800
- document.getElementById('theme-span').innerText = 'Set Light Theme';
801
- } else {
802
- localStorage.theme = 'light';
803
- document.documentElement.classList.remove('dark');
804
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
805
- }
806
-
807
- function change_theme() {
808
- if (localStorage.theme === 'dark') {
809
- localStorage.theme = 'light';
810
- document.documentElement.classList.remove('dark');
811
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
812
- } else {
813
- localStorage.theme = 'dark';
814
- document.documentElement.classList.add('dark');
815
- document.getElementById('theme-span').innerText = 'Set Light Theme';
816
- }
817
- }
818
- </script>
819
  </body>
820
 
821
  </html>
 
105
  <span class="mx-3 font-medium">Visit Main Website</span>
106
  </a>
107
 
108
+ <button id="theme-btn" class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40">
109
+ <img id="img-theme" src="images/sun.svg" width="24" height="24">
 
 
 
 
 
110
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
111
  </button>
112
  </div>
 
788
  </div>
789
  </div>
790
 
791
+ <script src="js/theme.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
792
  </body>
793
 
794
  </html>
static/js/detection.js CHANGED
@@ -1,35 +1,35 @@
1
  // Form Divs
2
- const form = document.getElementById("sum-form");
3
- const sumText = document.getElementById("sum-text-div");
4
- const sumFile = document.getElementById("sum-file-div");
5
- const sumVideo = document.getElementById("sum-video-div");
6
 
7
  // Form Data
8
- const selectOption = document.getElementById("sum-type");
9
- const sumTextInput = document.getElementById("sum-text-input");
10
- const sumFileInput = document.getElementById("sum-file-input");
11
- const sumVideoInput = document.getElementById("sum-video-input");
12
 
13
  // Error Output Section
14
- const sumError = document.getElementById("sum-err");
15
 
16
  // Result Section
17
- const extractText = document.getElementById("extracted-text");
18
- const summaryText = document.getElementById("summarized-text");
19
 
20
- const MAX_SIZE = 5000;
 
21
 
 
22
 
23
- function _summarize() {
 
24
  var xhr = new XMLHttpRequest();
25
- xhr.open("POST", "/predict_emotion", true);
26
- xhr.setRequestHeader("Content-Type", "application/json");
27
 
28
- var data = JSON.stringify({ "sum_type": selectOption.value, "text": extractText.value });
29
 
30
  xhr.onreadystatechange = function () {
31
  if (xhr.readyState === 4 && xhr.status === 200) {
32
- result = xhr.responseText.split("\\n").join("\n");
33
  summaryText.value = result.slice(1, -1);
34
  }
35
  };
@@ -43,12 +43,12 @@ function _extractFile() {
43
  if (file.type === 'text/plain') {
44
  const reader = new FileReader();
45
  reader.onload = function() {
46
- extractText.value = reader.result.slice(0, MAX_SIZE);
47
  };
48
  reader.readAsText(file, 'CP1251');
49
  return;
50
  } else if (file.type === 'application/pdf') {
51
- extractText.value = '';
52
  const reader = new FileReader();
53
  reader.onload = function (e) {
54
  const pdfData = e.target.result;
@@ -56,14 +56,14 @@ function _extractFile() {
56
  for (let pageNum = 1; pageNum <= pdfDocument.numPages; pageNum++) {
57
  pdfDocument.getPage(pageNum).then(function (pdfPage) {
58
  pdfPage.getTextContent().then(function (textContent) {
59
- let size = extractText.value.length;
60
  let pageText = [];
61
  for (const textItem of textContent.items) {
62
  pageText.push(textItem.str);
63
  size += textItem.str.length;
64
  if (size > MAX_SIZE) break;
65
  }
66
- extractText.value += pageText.join(' ');
67
  });
68
  });
69
  }
@@ -74,101 +74,63 @@ function _extractFile() {
74
  return;
75
  }
76
 
77
- // In progress...
78
- function _getCaptions(src) {
79
- return src;
80
- }
81
-
82
 
83
  async function summarize(event) {
84
  event.preventDefault();
85
 
86
- switch (selectOption.value) {
87
- case 'sum-text':
88
- let value = sumTextInput.value
89
- if (value === '') {
90
- sumError.innerText = `You need to input some text`;
91
- sumError.classList.remove('hidden');
92
- return;
93
- }
94
- break;
95
- case 'sum-file':
96
- const allowedTypes = ['application/pdf', 'text/plain'];
97
- const file = sumFileInput.files[0];
98
-
99
- if (!file) {
100
- sumError.innerText = 'There is no File';
101
- sumError.classList.remove('hidden');
102
- return;
103
- }
104
-
105
- if (!allowedTypes.includes(file.type)) {
106
- sumError.innerText = 'Not supported type (Only `.pdf` or `.txt`)';
107
- sumError.classList.remove('hidden');
108
- return;
109
- }
110
- case 'sum-video':
111
- regex = /^((((http)s?:\/\/)?((www\.)|(m\.))?youtube.com\/watch\?([^\?]*&)?v=.+)|(((http)s?:\/\/)?youtu.be\/([^\?=]+)(\?[^?]+)?))$/
112
- if (!sumVideoInput.value.match(regex)) {
113
- sumError.innerText = 'Invalid youtube link';
114
- sumError.classList.remove('hidden');
115
- return;
116
- }
117
  }
118
 
119
  sumError.classList.add('hidden');
120
 
121
  // Here we can finally summarize data
122
  summaryText.value = 'Please wait...';
123
- switch (selectOption.value) {
124
- case 'sum-text':
125
- extractText.value = sumTextInput.value.slice(0, MAX_SIZE);
126
- break;
127
- case 'sum-file':
128
- _extractFile();
129
- await (new Promise(resolve => setTimeout(resolve, 1000)));
130
- break;
131
- case 'sum-video':
132
- extractText.value = sumVideoInput.value.slice(0, MAX_SIZE);
133
- break;
134
  }
135
- _summarize();
 
 
 
136
  }
137
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
- document.addEventListener("DOMContentLoaded", function () {
140
- selectOption.addEventListener("change", function () {
141
- switch (selectOption.value) {
142
- case 'sum-text':
143
- sumText.classList.remove('hidden');
144
- sumFile.classList.add('hidden');
145
- sumVideo.classList.add('hidden');
146
-
147
- sumTextInput.setAttribute("required", "");
148
- sumVideoInput.removeAttribute("required");
149
- break;
150
- case 'sum-file':
151
- sumText.classList.add('hidden');
152
- sumFile.classList.remove('hidden');
153
- sumVideo.classList.add('hidden');
154
-
155
- sumTextInput.removeAttribute("required");
156
- sumVideoInput.removeAttribute("required");
157
- break;
158
- case 'sum-video':
159
- sumText.classList.add('hidden');
160
- sumFile.classList.add('hidden');
161
- sumVideo.classList.remove('hidden');
162
-
163
- sumTextInput.removeAttribute("required");
164
- sumVideoInput.setAttribute("required", "");
165
- break;
166
  }
 
 
 
 
 
167
  sumError.classList.add('hidden');
168
  });
169
- });
170
 
171
- document.addEventListener("DOMContentLoaded", function () {
172
- var submitButton = document.getElementById("submit");
173
- submitButton.addEventListener("click", summarize);
174
- });
 
1
  // Form Divs
2
+ const form = document.getElementById('sum-form');
3
+ const sumText = document.getElementById('sum-text-div');
4
+ const sumFile = document.getElementById('sum-file-div')
 
5
 
6
  // Form Data
7
+ const sumTextInput = document.getElementById('sum-text-input');
8
+ const sumFileInput = document.getElementById('sum-file-input');
 
 
9
 
10
  // Error Output Section
11
+ const sumError = document.getElementById('sum-err');
12
 
13
  // Result Section
14
+ const extractText = document.getElementById('extracted-text');
15
+ const summaryText = document.getElementById('summarized-text');
16
 
17
+ // Word Counter
18
+ const wordsCount = document.getElementById('word-counter');
19
 
20
+ const MAX_SIZE = 20000;
21
 
22
+
23
+ function _detect() {
24
  var xhr = new XMLHttpRequest();
25
+ xhr.open('POST', '/predict_emotion', true);
26
+ xhr.setRequestHeader('Content-Type', 'application/json');
27
 
28
+ var data = JSON.stringify({ 'sum_type': 'sum-text', 'text': extractText.value });
29
 
30
  xhr.onreadystatechange = function () {
31
  if (xhr.readyState === 4 && xhr.status === 200) {
32
+ result = xhr.responseText.split('\\n').join('\n');
33
  summaryText.value = result.slice(1, -1);
34
  }
35
  };
 
43
  if (file.type === 'text/plain') {
44
  const reader = new FileReader();
45
  reader.onload = function() {
46
+ sumTextInput.value = reader.result.slice(0, MAX_SIZE);
47
  };
48
  reader.readAsText(file, 'CP1251');
49
  return;
50
  } else if (file.type === 'application/pdf') {
51
+ sumTextInput.value = '';
52
  const reader = new FileReader();
53
  reader.onload = function (e) {
54
  const pdfData = e.target.result;
 
56
  for (let pageNum = 1; pageNum <= pdfDocument.numPages; pageNum++) {
57
  pdfDocument.getPage(pageNum).then(function (pdfPage) {
58
  pdfPage.getTextContent().then(function (textContent) {
59
+ let size = sumTextInput.value.length;
60
  let pageText = [];
61
  for (const textItem of textContent.items) {
62
  pageText.push(textItem.str);
63
  size += textItem.str.length;
64
  if (size > MAX_SIZE) break;
65
  }
66
+ sumTextInput.value += pageText.join(' ');
67
  });
68
  });
69
  }
 
74
  return;
75
  }
76
 
 
 
 
 
 
77
 
78
  async function summarize(event) {
79
  event.preventDefault();
80
 
81
+ let value = sumTextInput.value.trim()
82
+ if (value === '') {
83
+ sumError.innerText = `You need to input some text`;
84
+ sumError.classList.remove('hidden');
85
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
 
88
  sumError.classList.add('hidden');
89
 
90
  // Here we can finally summarize data
91
  summaryText.value = 'Please wait...';
92
+ extractText.value = sumTextInput.value.trim().slice(0, MAX_SIZE);
93
+ _detect();
94
+ }
95
+
96
+ function _update_counter() {
97
+ let text = sumTextInput.value.trim()
98
+ if (text === '') {
99
+ sumFile.classList.remove('hidden');
100
+ wordsCount.classList.add('hidden');
101
+ return;
 
102
  }
103
+
104
+ sumFile.classList.add('hidden');
105
+ wordsCount.classList.remove('hidden');
106
+ wordsCount.innerHTML = `Words: ${text.split(/\s+/).length} | Chars: ${text.length}`
107
  }
108
 
109
+ document.addEventListener('DOMContentLoaded', function () {
110
+ var submitButton = document.getElementById('submit');
111
+ submitButton.addEventListener('click', summarize);
112
+
113
+ sumFileInput.addEventListener('change', async function() {
114
+ const allowedTypes = ['application/pdf', 'text/plain'];
115
+ const file = sumFileInput.files[0];
116
+
117
+ if (!file) {
118
+ sumError.classList.remove('hidden');
119
+ return;
120
+ }
121
 
122
+ if (!allowedTypes.includes(file.type)) {
123
+ sumError.innerText = 'Not supported type (Only `.pdf` or `.txt`)';
124
+ sumError.classList.remove('hidden');
125
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }
127
+
128
+ _extractFile();
129
+
130
+ await (new Promise(resolve => setTimeout(resolve, 1000)));
131
+ _update_counter();
132
  sumError.classList.add('hidden');
133
  });
 
134
 
135
+ sumTextInput.addEventListener('input', _update_counter);
136
+ });
 
 
static/js/summarizer.js CHANGED
@@ -1,36 +1,38 @@
1
  // Form Divs
2
- const form = document.getElementById("sum-form");
3
- const sumText = document.getElementById("sum-text-div");
4
- const sumFile = document.getElementById("sum-file-div");
5
- const sumVideo = document.getElementById("sum-video-div");
6
 
7
  // Form Data
8
- const selectOption = document.getElementById("sum-type");
9
- const sumTextInput = document.getElementById("sum-text-input");
10
- const sumFileInput = document.getElementById("sum-file-input");
11
- const sumVideoInput = document.getElementById("sum-video-input");
12
 
13
  // Error Output Section
14
- const sumError = document.getElementById("sum-err");
15
 
16
  // Result Section
17
- const extractText = document.getElementById("extracted-text");
18
- const summaryText = document.getElementById("summarized-text");
 
 
 
19
 
20
  const MAX_SIZE = 20000;
21
 
22
 
23
- // In progress...
24
  function _summarize() {
25
  var xhr = new XMLHttpRequest();
26
- xhr.open("POST", "/predict_summarization", true);
27
- xhr.setRequestHeader("Content-Type", "application/json");
28
 
29
- var data = JSON.stringify({ "sum_type": selectOption.value, "text": extractText.value });
30
 
31
  xhr.onreadystatechange = function () {
32
  if (xhr.readyState === 4 && xhr.status === 200) {
33
- result = xhr.responseText.split("\\n").join("\n");
34
  summaryText.value = result.slice(1, -1);
35
  }
36
  };
@@ -44,11 +46,12 @@ function _extractFile() {
44
  if (file.type === 'text/plain') {
45
  const reader = new FileReader();
46
  reader.onload = function() {
47
- extractText.value = reader.result.slice(0, MAX_SIZE);
48
  };
49
  reader.readAsText(file, 'CP1251');
 
50
  } else if (file.type === 'application/pdf') {
51
- extractText.value = '';
52
  const reader = new FileReader();
53
  reader.onload = function (e) {
54
  const pdfData = e.target.result;
@@ -56,14 +59,14 @@ function _extractFile() {
56
  for (let pageNum = 1; pageNum <= pdfDocument.numPages; pageNum++) {
57
  pdfDocument.getPage(pageNum).then(function (pdfPage) {
58
  pdfPage.getTextContent().then(function (textContent) {
59
- let size = extractText.value.length;
60
  let pageText = [];
61
  for (const textItem of textContent.items) {
62
  pageText.push(textItem.str);
63
  size += textItem.str.length;
64
  if (size > MAX_SIZE) break;
65
  }
66
- extractText.value += pageText.join(' ');
67
  });
68
  });
69
  }
@@ -80,25 +83,9 @@ async function summarize(event) {
80
 
81
  switch (selectOption.value) {
82
  case 'sum-text':
83
- len = sumTextInput.value.length
84
  if (len < 250) {
85
- sumError.innerText = `The text size should be at least 100 characters (${len} < 250)`;
86
- sumError.classList.remove('hidden');
87
- return;
88
- }
89
- break;
90
- case 'sum-file':
91
- const allowedTypes = ['application/pdf', 'text/plain'];
92
- const file = sumFileInput.files[0];
93
-
94
- if (!file) {
95
- sumError.innerText = 'There is no File';
96
- sumError.classList.remove('hidden');
97
- return;
98
- }
99
-
100
- if (!allowedTypes.includes(file.type)) {
101
- sumError.innerText = 'Not supported type (Only `.pdf` or `.txt`)';
102
  sumError.classList.remove('hidden');
103
  return;
104
  }
@@ -119,11 +106,7 @@ async function summarize(event) {
119
  summaryText.value = 'Please wait...';
120
  switch (selectOption.value) {
121
  case 'sum-text':
122
- extractText.value = sumTextInput.value.slice(0, MAX_SIZE);
123
- break;
124
- case 'sum-file':
125
- _extractFile();
126
- await (new Promise(resolve => setTimeout(resolve, 1000)));
127
  break;
128
  case 'sum-video':
129
  extractText.value = sumVideoInput.value.slice(0, MAX_SIZE);
@@ -133,39 +116,70 @@ async function summarize(event) {
133
  }
134
 
135
 
136
- document.addEventListener("DOMContentLoaded", function () {
137
- selectOption.addEventListener("change", function () {
138
- switch (selectOption.value) {
139
- case 'sum-text':
140
- sumText.classList.remove('hidden');
141
- sumFile.classList.add('hidden');
142
- sumVideo.classList.add('hidden');
143
-
144
- sumTextInput.setAttribute("required", "");
145
- sumVideoInput.removeAttribute("required");
146
- break;
147
- case 'sum-file':
148
- sumText.classList.add('hidden');
149
- sumFile.classList.remove('hidden');
150
- sumVideo.classList.add('hidden');
151
-
152
- sumTextInput.removeAttribute("required");
153
- sumVideoInput.removeAttribute("required");
154
- break;
155
- case 'sum-video':
156
- sumText.classList.add('hidden');
157
- sumFile.classList.add('hidden');
158
- sumVideo.classList.remove('hidden');
159
-
160
- sumTextInput.removeAttribute("required");
161
- sumVideoInput.setAttribute("required", "");
162
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  sumError.classList.add('hidden');
165
  });
166
- });
167
 
168
- document.addEventListener("DOMContentLoaded", function () {
169
- var submitButton = document.getElementById("submit");
170
- submitButton.addEventListener("click", summarize);
171
- });
 
1
  // Form Divs
2
+ const form = document.getElementById('sum-form');
3
+ const sumText = document.getElementById('sum-text-div');
4
+ const sumFile = document.getElementById('sum-file-div')
5
+ const sumVideo = document.getElementById('sum-video-div');
6
 
7
  // Form Data
8
+ const selectOption = document.getElementById('sum-type');
9
+ const sumTextInput = document.getElementById('sum-text-input');
10
+ const sumFileInput = document.getElementById('sum-file-input');
11
+ const sumVideoInput = document.getElementById('sum-video-input');
12
 
13
  // Error Output Section
14
+ const sumError = document.getElementById('sum-err');
15
 
16
  // Result Section
17
+ const extractText = document.getElementById('extracted-text');
18
+ const summaryText = document.getElementById('summarized-text');
19
+
20
+ // Word Counter
21
+ const wordsCount = document.getElementById('word-counter');
22
 
23
  const MAX_SIZE = 20000;
24
 
25
 
 
26
  function _summarize() {
27
  var xhr = new XMLHttpRequest();
28
+ xhr.open('POST', '/predict_summarization', true);
29
+ xhr.setRequestHeader('Content-Type', 'application/json');
30
 
31
+ var data = JSON.stringify({ 'sum_type': selectOption.value, 'text': extractText.value });
32
 
33
  xhr.onreadystatechange = function () {
34
  if (xhr.readyState === 4 && xhr.status === 200) {
35
+ result = xhr.responseText.split('\\n').join('\n');
36
  summaryText.value = result.slice(1, -1);
37
  }
38
  };
 
46
  if (file.type === 'text/plain') {
47
  const reader = new FileReader();
48
  reader.onload = function() {
49
+ sumTextInput.value = reader.result.slice(0, MAX_SIZE);
50
  };
51
  reader.readAsText(file, 'CP1251');
52
+ return;
53
  } else if (file.type === 'application/pdf') {
54
+ sumTextInput.value = '';
55
  const reader = new FileReader();
56
  reader.onload = function (e) {
57
  const pdfData = e.target.result;
 
59
  for (let pageNum = 1; pageNum <= pdfDocument.numPages; pageNum++) {
60
  pdfDocument.getPage(pageNum).then(function (pdfPage) {
61
  pdfPage.getTextContent().then(function (textContent) {
62
+ let size = sumTextInput.value.length;
63
  let pageText = [];
64
  for (const textItem of textContent.items) {
65
  pageText.push(textItem.str);
66
  size += textItem.str.length;
67
  if (size > MAX_SIZE) break;
68
  }
69
+ sumTextInput.value += pageText.join(' ');
70
  });
71
  });
72
  }
 
83
 
84
  switch (selectOption.value) {
85
  case 'sum-text':
86
+ len = sumTextInput.value.trim().length
87
  if (len < 250) {
88
+ sumError.innerText = `The text size should be at least 250 characters (${len} < 250)`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  sumError.classList.remove('hidden');
90
  return;
91
  }
 
106
  summaryText.value = 'Please wait...';
107
  switch (selectOption.value) {
108
  case 'sum-text':
109
+ extractText.value = sumTextInput.value.trim().slice(0, MAX_SIZE);
 
 
 
 
110
  break;
111
  case 'sum-video':
112
  extractText.value = sumVideoInput.value.slice(0, MAX_SIZE);
 
116
  }
117
 
118
 
119
+ function _update_option() {
120
+ switch (selectOption.value) {
121
+ case 'sum-text':
122
+ sumText.classList.remove('hidden');
123
+ sumVideo.classList.add('hidden');
124
+
125
+ sumTextInput.setAttribute('required', '');
126
+ sumVideoInput.removeAttribute('required');
127
+ break;
128
+ case 'sum-video':
129
+ sumText.classList.add('hidden');
130
+ sumVideo.classList.remove('hidden');
131
+
132
+ sumTextInput.removeAttribute('required');
133
+ sumVideoInput.setAttribute('required', '');
134
+ break;
135
+ }
136
+ sumError.classList.add('hidden');
137
+ }
138
+
139
+ function _update_counter() {
140
+ let text = sumTextInput.value.trim()
141
+ if (text === '') {
142
+ sumFile.classList.remove('hidden');
143
+ wordsCount.classList.add('hidden');
144
+ return;
145
+ }
146
+
147
+ sumFile.classList.add('hidden');
148
+ wordsCount.classList.remove('hidden');
149
+ wordsCount.innerHTML = `Words: ${text.split(/\s+/).length} | Chars: ${text.length}`
150
+ }
151
+
152
+
153
+ document.addEventListener('DOMContentLoaded', function () {
154
+ selectOption.addEventListener('change', _update_option);
155
+
156
+ var submitButton = document.getElementById('submit');
157
+ submitButton.addEventListener('click', summarize);
158
+
159
+ sumFileInput.addEventListener('change', async function() {
160
+ const allowedTypes = ['application/pdf', 'text/plain'];
161
+ const file = sumFileInput.files[0];
162
+
163
+ if (!file) {
164
+ sumError.classList.remove('hidden');
165
+ return;
166
  }
167
+
168
+ if (!allowedTypes.includes(file.type)) {
169
+ sumError.innerText = 'Not supported type (Only `.pdf` or `.txt`)';
170
+ sumError.classList.remove('hidden');
171
+ return;
172
+ }
173
+
174
+ // Back to main option
175
+ selectOption.options[0].selected = true;
176
+ _update_option();
177
+ _extractFile();
178
+
179
+ await (new Promise(resolve => setTimeout(resolve, 1000)));
180
+ _update_counter();
181
  sumError.classList.add('hidden');
182
  });
 
183
 
184
+ sumTextInput.addEventListener('input', _update_counter);
185
+ });
 
 
static/js/theme.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
2
+ localStorage.theme = 'dark';
3
+ document.documentElement.classList.add('dark');
4
+ document.getElementById('img-theme').src = 'images/sun.svg'
5
+ document.getElementById('theme-span').innerText = 'Set Light Theme';
6
+ } else {
7
+ localStorage.theme = 'light';
8
+ document.documentElement.classList.remove('dark');
9
+ document.getElementById('img-theme').src = 'images/moon.svg'
10
+ document.getElementById('theme-span').innerText = 'Set Dark Theme';
11
+ }
12
+
13
+ const theme_btn = document.getElementById('theme-btn');
14
+ theme_btn.addEventListener('click', function() {
15
+ if (localStorage.theme === 'dark') {
16
+ localStorage.theme = 'light';
17
+ document.documentElement.classList.remove('dark');
18
+ document.getElementById('img-theme').src = 'images/moon.svg'
19
+ document.getElementById('theme-span').innerText = 'Set Dark Theme';
20
+ } else {
21
+ localStorage.theme = 'dark';
22
+ document.documentElement.classList.add('dark');
23
+ document.getElementById('img-theme').src = 'images/sun.svg'
24
+ document.getElementById('theme-span').innerText = 'Set Light Theme';
25
+ }
26
+ })
static/text_summarizer.html CHANGED
@@ -105,13 +105,8 @@
105
  <span class="mx-3 font-medium">Visit Main Website</span>
106
  </a>
107
 
108
- <button class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40"
109
- onclick="change_theme()">
110
- <svg class="w-6 h-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
111
- <path
112
- d="M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM19 3C20.1046 3 21 3.89543 21 5V19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V5C3 3.89543 3.89543 3 5 3H19Z"
113
- fill="currentColor"></path>
114
- </svg>
115
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
116
  </button>
117
  </div>
@@ -119,7 +114,7 @@
119
  </div>
120
 
121
  <div class="flex flex-col flex-1 overflow-hidden bg-gray-100">
122
- <header class="bg-white border-b border-gray-100">
123
  <div class="flex items-center justify-between px-4 py-4 sm:px-6">
124
  <div class="flex items-center">
125
  <button @click="sidebarOpen = !sidebarOpen" class="text-gray-500 lg:hidden focus:outline-none">
@@ -239,7 +234,6 @@
239
  <select id="sum-type"
240
  class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40">
241
  <option value="sum-text">Summarize Text</option>
242
- <option value="sum-file">Summarize File</option>
243
  <option value="sum-video">Summarize Youtube Video</option>
244
  </select>
245
  </div>
@@ -248,52 +242,32 @@
248
  <label for="description"
249
  class="block text-sm text-gray-700 capitalize">description</label>
250
  <textarea id="sum-text-input" required class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
251
- style="min-height: 300px;"></textarea>
 
 
 
 
 
 
252
  </div>
253
 
254
- <div id="sum-file-div" class="hidden">
255
- <label for="image" class="block text-sm text-gray-700 capitalize">file</label>
256
- <label
257
- class="flex flex-col items-center justify-center w-full h-32 mt-2 text-gray-500 border-2 border-dashed rounded-md cursor-pointer hover:text-gray-600">
258
- <svg class="w-8 h-8" fill="currentColor" xmlns="http://www.w3.org/2000/svg"
 
259
  viewBox="0 0 20 20">
260
  <path
261
  d="M16.88 9.1A4 4 0 0 1 16 17H5a5 5 0 0 1-1-9.9V7a3 3 0 0 1 4.52-2.59A4.98 4.98 0 0 1 17 8c0 .38-.04.74-.12 1.1zM11 11h3l-4-4-4 4h3v3h2v-3z">
262
  </path>
263
  </svg>
264
- <span class="mt-4">Select File</span>
265
  <input id="sum-file-input" type="file" accept=".pdf, .txt" class="hidden">
266
  </label>
267
- </div>
268
-
269
- <div id="sum-video-div" class="hidden">
270
- <label for="video" class="block text-sm text-gray-700 capitalize">Youtube link</label>
271
- <input id="sum-video-input" placeholder="https://www.youtube.com/watch?v=dQw4w9WgXcQ" type="url"
272
- class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40">
273
- </div>
274
- <p id='sum-err' class="hidden mt-2 text-sm text-red-500">Your password is too short.</p>
275
-
276
- <div class="flex justify-end">
277
- <style>
278
- #submit {
279
- background-color: #ffa116;
280
- }
281
- #submit:hover {
282
- background-color: #fcb140;
283
- }
284
- #submit:focus {
285
- box-shadow: 0 0 5px 2px rgb(255, 188, 87);
286
- }
287
- </style>
288
- <button id="submit" type="button" class="no-invert w-full flex items-center justify-center px-2 py-2 text-sm font-medium tracking-wide text-white capitalize transition-colors duration-200 transform rounded-md focus:outline-none">
289
- <svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
290
- <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
291
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
292
- <g id="SVGRepo_iconCarrier">
293
- <path d="M7 10L12 15L17 10" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
294
- </g>
295
- </svg>
296
- <span class="mx-1">Summarize</span>
297
  </button>
298
  </div>
299
  </form>
@@ -307,8 +281,7 @@
307
  <label for="description"
308
  class="block text-sm text-gray-700 capitalize">Extracted Text</label>
309
  <textarea id="extracted-text"
310
- class="minh-text block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
311
- style="min-height: 300px;"></textarea>
312
  </div>
313
 
314
  <div class="w-full md:w-1/2 grid-cols-2 mt-6">
@@ -316,7 +289,7 @@
316
  class="block text-sm text-gray-700 capitalize">Summarized Text</label>
317
  <textarea id="summarized-text"
318
  class="minh-text block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
319
- style="min-height: 300px;"></textarea>
320
  </div>
321
  </div>
322
  </div>
@@ -326,30 +299,7 @@
326
  </div>
327
  </div>
328
 
329
- <script>
330
- if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
331
- localStorage.theme = 'dark';
332
- document.documentElement.classList.add('dark');
333
- document.getElementById('theme-span').innerText = 'Set Light Theme';
334
- } else {
335
- localStorage.theme = 'light';
336
- document.documentElement.classList.remove('dark');
337
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
338
- }
339
-
340
- function change_theme() {
341
- if (localStorage.theme === 'dark') {
342
- localStorage.theme = 'light';
343
- document.documentElement.classList.remove('dark');
344
- document.getElementById('theme-span').innerText = 'Set Dark Theme';
345
- } else {
346
- localStorage.theme = 'dark';
347
- document.documentElement.classList.add('dark');
348
- document.getElementById('theme-span').innerText = 'Set Light Theme';
349
- }
350
- }
351
- </script>
352
-
353
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.min.js"></script>
354
  <script src="js/summarizer.js"></script>
355
  </body>
 
105
  <span class="mx-3 font-medium">Visit Main Website</span>
106
  </a>
107
 
108
+ <button id="theme-btn" class="flex items-center px-4 py-2 text-gray-500 transition-colors duration-300 transform rounded-lg hover:text-gray-600 hover:bg-gray-100 bg-opacity-40">
109
+ <img id="img-theme" src="images/sun.svg" width="24" height="24">
 
 
 
 
 
110
  <span id='theme-span' class="mx-3 font-medium">Set Light Theme</span>
111
  </button>
112
  </div>
 
114
  </div>
115
 
116
  <div class="flex flex-col flex-1 overflow-hidden bg-gray-100">
117
+ <header class="static bg-white border-b border-gray-100">
118
  <div class="flex items-center justify-between px-4 py-4 sm:px-6">
119
  <div class="flex items-center">
120
  <button @click="sidebarOpen = !sidebarOpen" class="text-gray-500 lg:hidden focus:outline-none">
 
234
  <select id="sum-type"
235
  class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40">
236
  <option value="sum-text">Summarize Text</option>
 
237
  <option value="sum-video">Summarize Youtube Video</option>
238
  </select>
239
  </div>
 
242
  <label for="description"
243
  class="block text-sm text-gray-700 capitalize">description</label>
244
  <textarea id="sum-text-input" required class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
245
+ style="min-height: 250px;" placeholder="Enter or upload your text and press &quot;Summarize&quot;"></textarea>
246
+ </div>
247
+
248
+ <div id="sum-video-div" class="hidden">
249
+ <label for="video" class="block text-sm text-gray-700 capitalize">Youtube link</label>
250
+ <input id="sum-video-input" placeholder="https://www.youtube.com/watch?v=dQw4w9WgXcQ" type="url"
251
+ class="block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40">
252
  </div>
253
 
254
+ <p id='sum-err' class="no-invert hidden mt-2 text-sm text-red-500"></p>
255
+
256
+ <div class="flex justify-between no-invert">
257
+ <label id="word-counter" class="hidden flex items-center py-2 px-4 text-gray-500 rounded">Words:</label>
258
+ <label id="sum-file-div" class="flex items-center py-2 px-4 text-gray-500 rounded cursor-pointer hover:text-gray-700">
259
+ <svg class="w-6 h-6" fill="currentColor" xmlns="http://www.w3.org/2000/svg"
260
  viewBox="0 0 20 20">
261
  <path
262
  d="M16.88 9.1A4 4 0 0 1 16 17H5a5 5 0 0 1-1-9.9V7a3 3 0 0 1 4.52-2.59A4.98 4.98 0 0 1 17 8c0 .38-.04.74-.12 1.1zM11 11h3l-4-4-4 4h3v3h2v-3z">
263
  </path>
264
  </svg>
265
+ <span class="px-2">Upload</span>
266
  <input id="sum-file-input" type="file" accept=".pdf, .txt" class="hidden">
267
  </label>
268
+ <button id="submit" class="w-32 sm:w-80 flex items-center justify-center py-2 px-4 rounded font-medium text-white rounded-full"
269
+ style="max-height: 2.5rem;">
270
+ Summarize
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  </button>
272
  </div>
273
  </form>
 
281
  <label for="description"
282
  class="block text-sm text-gray-700 capitalize">Extracted Text</label>
283
  <textarea id="extracted-text"
284
+ class="minh-text block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"></textarea>
 
285
  </div>
286
 
287
  <div class="w-full md:w-1/2 grid-cols-2 mt-6">
 
289
  class="block text-sm text-gray-700 capitalize">Summarized Text</label>
290
  <textarea id="summarized-text"
291
  class="minh-text block w-full px-4 py-2.5 mt-2 text-gray-600 placeholder-gray-400 bg-white border border-gray-200 rounded-md focus:border-indigo-400 focus:outline-none focus:ring focus:ring-indigo-300 focus:ring-opacity-40"
292
+ style="min-height: 250px;"></textarea>
293
  </div>
294
  </div>
295
  </div>
 
299
  </div>
300
  </div>
301
 
302
+ <script src="js/theme.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.min.js"></script>
304
  <script src="js/summarizer.js"></script>
305
  </body>