PragmaLens-AI / index.html
jamalinu's picture
Update index.html
52f858a verified
Raw
History Blame Contribute Delete
5.05 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PragmaLens AI</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body { background-color: #0f172a; }
</style>
</head>
<body class="min-h-screen flex items-center justify-center p-6 text-slate-200">
<div class="max-w-xl w-full bg-slate-800 p-8 rounded-2xl shadow-2xl border border-slate-700 text-center">
<!-- Header -->
<h1 class="text-4xl font-extrabold text-white mb-3">PragmaLens AI</h1>
<p class="text-slate-400 mb-8 px-4">
Expert discourse analysis: Grice's Maxims, pragmatics, ambiguity, and logical fallacies.
</p>
<!-- Input Area -->
<div class="space-y-4">
<textarea id="textInput" rows="5"
class="w-full p-4 bg-slate-900 border border-slate-600 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none text-white placeholder-slate-500"
placeholder="Paste your text here for analysis..."></textarea>
<!-- Custom File Upload (Fully English) -->
<div class="flex flex-col items-center gap-4">
<label class="cursor-pointer bg-slate-700 text-white px-6 py-2 rounded-full hover:bg-slate-600 transition text-sm">
<span id="fileName">Choose PDF File</span>
<input type="file" id="pdfInput" accept=".pdf" class="hidden" onchange="updateFileName(this)">
</label>
</div>
<button onclick="processData()"
class="w-full bg-blue-600 text-white font-bold py-3 rounded-xl hover:bg-blue-500 transition shadow-lg">
Analyze Discourse
</button>
</div>
<!-- Result Area -->
<div id="result" class="mt-6 p-6 bg-black/30 rounded-xl hidden text-left border border-slate-700">
</div>
</div>
<script>
function updateFileName(input) {
const fileName = input.files[0]?.name || "Choose PDF File";
document.getElementById('fileName').innerText = fileName;
}
async function processData() {
const text = document.getElementById('textInput').value;
const fileInput = document.getElementById('pdfInput');
const resDiv = document.getElementById('result');
resDiv.classList.remove('hidden');
resDiv.innerHTML = '<p class="text-center animate-pulse">Analyzing discourse... Please wait.</p>';
try {
let response;
if (fileInput.files.length > 0) {
const formData = new FormData();
formData.append('file', fileInput.files[0]);
response = await fetch('/analyze_pdf', { method: 'POST', body: formData });
} else if (text) {
response = await fetch('/analyze', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: text })
});
} else {
resDiv.innerText = "Please enter some text or upload a PDF.";
return;
}
const data = await response.json();
const output = `
<div class="space-y-6">
<section>
<h2 class="text-blue-400 font-bold uppercase tracking-widest text-sm mb-2 border-b border-slate-700 pb-1">Grice's Maxims</h2>
<p class="text-slate-200 text-base leading-relaxed">${data.grice_maxims}</p>
</section>
<section>
<h2 class="text-blue-400 font-bold uppercase tracking-widest text-sm mb-2 border-b border-slate-700 pb-1">Pragmatics</h2>
<p class="text-slate-200 text-base leading-relaxed">${data.pragmatics}</p>
</section>
<section>
<h2 class="text-blue-400 font-bold uppercase tracking-widest text-sm mb-2 border-b border-slate-700 pb-1">Ambiguity</h2>
<p class="text-slate-200 text-base leading-relaxed">${data.ambiguity}</p>
</section>
<section>
<h2 class="text-blue-400 font-bold uppercase tracking-widest text-sm mb-2 border-b border-slate-700 pb-1">Logical Fallacies</h2>
<p class="text-slate-200 text-base leading-relaxed">${data.fallacies}</p>
</section>
</div>`;
resDiv.innerHTML = output;
} catch (err) {
resDiv.innerText = "Error: Unable to connect to the analysis service.";
}
}
</script>
</body>
</html>