Spaces:
Sleeping

Login / Undex.html
Pezh's picture
Create Undex.html
c684ee1 verified
Raw History Blame Contribute Delete
1.99 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Checkbox List Flask App with Similarity Check</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<input type="text" id="inputItem"/>
<input type="text" id="similarityResult" readonly />
<button onclick="addItem()">Send</button>
<button onclick="listItems()">Check</button>
<button onclick="checkSimilarity()">Similarity</button>
<div id="checkboxList" style="display:none;"></div>
<script>
function addItem() {
const item = $('#inputItem').val();
$.ajax({
url: '/add_item',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ 'item': item }),
success: function(response) {
if (response.success) {
alert(`Added: ${response.item}`);
$('#inputItem').val(''); // Clear the input after adding the item
} else {
alert('Failed to add item.');
}
}
});
}
function listItems() {
// Only toggles visibility here, does not clear or repopulate the list
$('#checkboxList').toggle();
}
function checkSimilarity() {
const item = $('#inputItem').val();
$.ajax({
url: '/check_similarity',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ 'item': item }),
success: function(response) {
if (response.similar) {
$('#similarityResult').val('Yes!');
} else {
$('#similarityResult').val('No match found.');
}
}
});
}
</script>
</body>
</html>