-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.html
117 lines (107 loc) · 3.34 KB
/
ui.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PDF Summarizer</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
#drop-area, #url-input-area {
border: 2px dashed #ccc;
border-radius: 20px;
width: 480px;
padding: 20px;
margin-bottom: 20px;
}
#drop-area.highlight {
border-color: purple;
}
#summaries {
margin-top: 20px;
}
.summary {
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 10px;
}
#url-input {
width: 100%;
padding: 8px;
margin-bottom: 10px;
}
.input-group {
margin-bottom: 20px;
}
button {
padding: 8px 16px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>PDF Summarizer</h1>
<div class="input-group">
<div id="url-input-area">
<h3>Enter PDF URL</h3>
<input type="url" id="url-input" placeholder="https://example.com/document.pdf">
<button onclick="handleUrl()">Process URL</button>
</div>
</div>
<div class="input-group">
<div id="drop-area">
<h3>Or Drop PDF Files</h3>
<p>Drag and drop PDF files here or click to select files</p>
<input type="file" id="fileElem" multiple accept="application/pdf">
</div>
</div>
<div id="summaries"></div>
<script>
let dropArea = document.getElementById('drop-area');
let fileElem = document.getElementById('fileElem');
let summariesDiv = document.getElementById('summaries');
async function handleUrl() {
const urlInput = document.getElementById('url-input');
const url = urlInput.value.trim();
if (!url) {
alert('Please enter a valid URL');
return;
}
try {
const response = await fetch('/process-url', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ url }),
});
const summary = await response.json();
displaySummaries([summary]);
} catch (error) {
alert('Error processing URL: ' + error.message);
}
}
function displaySummaries(summaries) {
summariesDiv.innerHTML = '';
summaries.forEach((summary, index) => {
let div = document.createElement('div');
div.className = 'summary';
div.innerHTML = `<h3>${index + 1}. Summary</h3><p>${summary}</p>`;
summariesDiv.appendChild(div);
});
}
// ... (rest of the existing drop handling code remains the same)
</script>
</body>
</html>