Spaces:
Running
Running
Update index.html
Browse files- index.html +5 -10
index.html
CHANGED
|
@@ -77,25 +77,21 @@
|
|
| 77 |
<script>
|
| 78 |
$(document).ready(function() {
|
| 79 |
let isResultShown = false;
|
| 80 |
-
|
| 81 |
$('#submit').click(function() {
|
| 82 |
const query = $('#query').val();
|
| 83 |
const givenFacet = $('#given_facet').val();
|
| 84 |
-
|
| 85 |
try {
|
| 86 |
const facetObj = eval('(' + givenFacet + ')');
|
| 87 |
generateBoxes(facetObj);
|
|
|
|
| 88 |
} catch (error) {
|
| 89 |
alert('Invalid facet format. Please enter a valid Python dictionary.');
|
| 90 |
}
|
| 91 |
});
|
| 92 |
-
|
| 93 |
function generateBoxes(facetObj) {
|
| 94 |
const $dynamicBoxes = $('#dynamicBoxes').empty();
|
| 95 |
-
|
| 96 |
Object.entries(facetObj).forEach(([key, values]) => {
|
| 97 |
const $box = $('<div>').addClass('bg-white rounded-lg shadow-md p-6 fade-in');
|
| 98 |
-
|
| 99 |
const $title = $('<div>').addClass('flex items-center justify-between mb-4')
|
| 100 |
.append($('<h2>').addClass('text-xl font-semibold').text(`'${key}'`))
|
| 101 |
.append($('<input>').attr({
|
|
@@ -103,27 +99,22 @@
|
|
| 103 |
name: key,
|
| 104 |
class: 'form-checkbox h-5 w-5 text-blue-600'
|
| 105 |
}));
|
| 106 |
-
|
| 107 |
const $content = $('<div>').addClass('space-y-2');
|
| 108 |
values.forEach(value => {
|
| 109 |
$content.append($('<p>').addClass('text-gray-600').text(value));
|
| 110 |
});
|
| 111 |
-
|
| 112 |
$box.append($title).append($content);
|
| 113 |
$dynamicBoxes.append($box);
|
| 114 |
});
|
| 115 |
}
|
| 116 |
-
|
| 117 |
$('#getList').click(function() {
|
| 118 |
const checkedBoxes = $('input[type="checkbox"]:checked').map(function() {
|
| 119 |
return `'${this.name}'`;
|
| 120 |
}).get();
|
| 121 |
-
|
| 122 |
const result = `[${checkedBoxes.join(', ')}]`;
|
| 123 |
$('#result').text(result).addClass('fade-in');
|
| 124 |
isResultShown = true;
|
| 125 |
});
|
| 126 |
-
|
| 127 |
$('#reset').click(function() {
|
| 128 |
$('input[type="checkbox"]').prop('checked', false);
|
| 129 |
if (isResultShown) {
|
|
@@ -131,6 +122,10 @@
|
|
| 131 |
isResultShown = false;
|
| 132 |
}
|
| 133 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
});
|
| 135 |
</script>
|
| 136 |
</body>
|
|
|
|
| 77 |
<script>
|
| 78 |
$(document).ready(function() {
|
| 79 |
let isResultShown = false;
|
|
|
|
| 80 |
$('#submit').click(function() {
|
| 81 |
const query = $('#query').val();
|
| 82 |
const givenFacet = $('#given_facet').val();
|
|
|
|
| 83 |
try {
|
| 84 |
const facetObj = eval('(' + givenFacet + ')');
|
| 85 |
generateBoxes(facetObj);
|
| 86 |
+
resetResult();
|
| 87 |
} catch (error) {
|
| 88 |
alert('Invalid facet format. Please enter a valid Python dictionary.');
|
| 89 |
}
|
| 90 |
});
|
|
|
|
| 91 |
function generateBoxes(facetObj) {
|
| 92 |
const $dynamicBoxes = $('#dynamicBoxes').empty();
|
|
|
|
| 93 |
Object.entries(facetObj).forEach(([key, values]) => {
|
| 94 |
const $box = $('<div>').addClass('bg-white rounded-lg shadow-md p-6 fade-in');
|
|
|
|
| 95 |
const $title = $('<div>').addClass('flex items-center justify-between mb-4')
|
| 96 |
.append($('<h2>').addClass('text-xl font-semibold').text(`'${key}'`))
|
| 97 |
.append($('<input>').attr({
|
|
|
|
| 99 |
name: key,
|
| 100 |
class: 'form-checkbox h-5 w-5 text-blue-600'
|
| 101 |
}));
|
|
|
|
| 102 |
const $content = $('<div>').addClass('space-y-2');
|
| 103 |
values.forEach(value => {
|
| 104 |
$content.append($('<p>').addClass('text-gray-600').text(value));
|
| 105 |
});
|
|
|
|
| 106 |
$box.append($title).append($content);
|
| 107 |
$dynamicBoxes.append($box);
|
| 108 |
});
|
| 109 |
}
|
|
|
|
| 110 |
$('#getList').click(function() {
|
| 111 |
const checkedBoxes = $('input[type="checkbox"]:checked').map(function() {
|
| 112 |
return `'${this.name}'`;
|
| 113 |
}).get();
|
|
|
|
| 114 |
const result = `[${checkedBoxes.join(', ')}]`;
|
| 115 |
$('#result').text(result).addClass('fade-in');
|
| 116 |
isResultShown = true;
|
| 117 |
});
|
|
|
|
| 118 |
$('#reset').click(function() {
|
| 119 |
$('input[type="checkbox"]').prop('checked', false);
|
| 120 |
if (isResultShown) {
|
|
|
|
| 122 |
isResultShown = false;
|
| 123 |
}
|
| 124 |
});
|
| 125 |
+
function resetResult() {
|
| 126 |
+
$('#result').text('').removeClass('fade-in');
|
| 127 |
+
isResultShown = false;
|
| 128 |
+
}
|
| 129 |
});
|
| 130 |
</script>
|
| 131 |
</body>
|