Spaces:
Running
Running
Update index.html
Browse files- index.html +17 -16
index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
.sticky-query {
|
| 21 |
position: sticky;
|
| 22 |
top: 0;
|
| 23 |
-
z-
|
| 24 |
background-color: white;
|
| 25 |
padding: 1rem;
|
| 26 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
@@ -28,13 +28,13 @@
|
|
| 28 |
}
|
| 29 |
.fade-in {
|
| 30 |
animation: fadeIn 0.5s ease-out;
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
}
|
| 39 |
}
|
| 40 |
</style>
|
|
@@ -55,7 +55,7 @@
|
|
| 55 |
<div class="bg-white rounded-lg shadow-lg p-8 mb-12">
|
| 56 |
<div class="mb-6">
|
| 57 |
<label for="given_facet" class="block text-lg font-medium text-gray-700 mb-2">Given Facet</label>
|
| 58 |
-
<
|
| 59 |
</div>
|
| 60 |
<button id="submit" class="w-full bg-blue-600 text-white py-3 px-6 rounded-md hover:bg-blue-700 transition duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">Submit</button>
|
| 61 |
</div>
|
|
@@ -81,19 +81,20 @@
|
|
| 81 |
const query = $('#query').val();
|
| 82 |
const givenFacet = $('#given_facet').val();
|
| 83 |
try {
|
| 84 |
-
const facetObj =
|
| 85 |
generateBoxes(facetObj);
|
| 86 |
resetResult();
|
| 87 |
} catch (error) {
|
| 88 |
-
alert('Invalid facet format. Please enter a valid
|
| 89 |
}
|
| 90 |
});
|
| 91 |
-
function generateBoxes(
|
| 92 |
const $dynamicBoxes = $('#dynamicBoxes').empty();
|
| 93 |
-
|
|
|
|
| 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(
|
| 97 |
.append($('<input>').attr({
|
| 98 |
type: 'checkbox',
|
| 99 |
name: key,
|
|
@@ -109,7 +110,7 @@
|
|
| 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');
|
|
@@ -129,4 +130,4 @@
|
|
| 129 |
});
|
| 130 |
</script>
|
| 131 |
</body>
|
| 132 |
-
</html>
|
|
|
|
| 20 |
.sticky-query {
|
| 21 |
position: sticky;
|
| 22 |
top: 0;
|
| 23 |
+
z-index: 1;
|
| 24 |
background-color: white;
|
| 25 |
padding: 1rem;
|
| 26 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
|
|
| 28 |
}
|
| 29 |
.fade-in {
|
| 30 |
animation: fadeIn 0.5s ease-out;
|
| 31 |
+
}
|
| 32 |
+
@keyframes fadeIn {
|
| 33 |
+
0% {
|
| 34 |
+
opacity: 0;
|
| 35 |
+
}
|
| 36 |
+
100% {
|
| 37 |
+
opacity: 1;
|
| 38 |
}
|
| 39 |
}
|
| 40 |
</style>
|
|
|
|
| 55 |
<div class="bg-white rounded-lg shadow-lg p-8 mb-12">
|
| 56 |
<div class="mb-6">
|
| 57 |
<label for="given_facet" class="block text-lg font-medium text-gray-700 mb-2">Given Facet</label>
|
| 58 |
+
<textarea id="given_facet" placeholder="Enter your facet in the specified format" class="w-full px-4 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" rows="6"></textarea>
|
| 59 |
</div>
|
| 60 |
<button id="submit" class="w-full bg-blue-600 text-white py-3 px-6 rounded-md hover:bg-blue-700 transition duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">Submit</button>
|
| 61 |
</div>
|
|
|
|
| 81 |
const query = $('#query').val();
|
| 82 |
const givenFacet = $('#given_facet').val();
|
| 83 |
try {
|
| 84 |
+
const facetObj = JSON.parse(givenFacet.replace(/'/g, '"'));
|
| 85 |
generateBoxes(facetObj);
|
| 86 |
resetResult();
|
| 87 |
} catch (error) {
|
| 88 |
+
alert('Invalid facet format. Please enter a valid JSON array of objects.');
|
| 89 |
}
|
| 90 |
});
|
| 91 |
+
function generateBoxes(facetArray) {
|
| 92 |
const $dynamicBoxes = $('#dynamicBoxes').empty();
|
| 93 |
+
facetArray.forEach(facetObj => {
|
| 94 |
+
const [key, values] = Object.entries(facetObj)[0];
|
| 95 |
const $box = $('<div>').addClass('bg-white rounded-lg shadow-md p-6 fade-in');
|
| 96 |
const $title = $('<div>').addClass('flex items-center justify-between mb-4')
|
| 97 |
+
.append($('<h2>').addClass('text-xl font-semibold').text(key))
|
| 98 |
.append($('<input>').attr({
|
| 99 |
type: 'checkbox',
|
| 100 |
name: key,
|
|
|
|
| 110 |
}
|
| 111 |
$('#getList').click(function() {
|
| 112 |
const checkedBoxes = $('input[type="checkbox"]:checked').map(function() {
|
| 113 |
+
return `{'${this.name}': []}`;
|
| 114 |
}).get();
|
| 115 |
const result = `[${checkedBoxes.join(', ')}]`;
|
| 116 |
$('#result').text(result).addClass('fade-in');
|
|
|
|
| 130 |
});
|
| 131 |
</script>
|
| 132 |
</body>
|
| 133 |
+
</html>
|