Spaces:
Running
Running
Update index.html
Browse files- index.html +7 -6
index.html
CHANGED
|
@@ -134,7 +134,7 @@
|
|
| 134 |
|
| 135 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
| 136 |
<script>
|
| 137 |
-
|
| 138 |
let isResultShown = false;
|
| 139 |
let facetData = [];
|
| 140 |
$('#submit').click(function() {
|
|
@@ -153,9 +153,10 @@
|
|
| 153 |
alert('Invalid facet format. Please check your input and try again.');
|
| 154 |
}
|
| 155 |
});
|
|
|
|
| 156 |
function generateBoxes(facetObj, method) {
|
| 157 |
const $dynamicBoxes = $('#dynamicBoxes').empty();
|
| 158 |
-
|
| 159 |
if (method === 'v1') {
|
| 160 |
Object.entries(facetObj).forEach(([key, values]) => {
|
| 161 |
createBox(key, values);
|
|
@@ -169,7 +170,7 @@
|
|
| 169 |
function createBox(key, values, index = null) {
|
| 170 |
const $box = $('<div>').addClass('bg-white rounded-lg shadow-md p-6 fade-in');
|
| 171 |
const $title = $('<div>').addClass('flex items-center justify-between mb-4')
|
| 172 |
-
.append($('<h2>').addClass('text-xl font-semibold').text(key))
|
| 173 |
.append($('<input>').attr({
|
| 174 |
type: 'checkbox',
|
| 175 |
name: key,
|
|
@@ -184,19 +185,20 @@
|
|
| 184 |
$dynamicBoxes.append($box);
|
| 185 |
}
|
| 186 |
}
|
|
|
|
| 187 |
$('#getList').click(function() {
|
| 188 |
const processingMethod = $('input[name="processingMethod"]:checked').val();
|
| 189 |
let result;
|
| 190 |
if (processingMethod === 'v1') {
|
| 191 |
result = $('input[type="checkbox"]:checked').map(function() {
|
| 192 |
-
return this.name;
|
| 193 |
}).get();
|
| 194 |
} else {
|
| 195 |
result = facetData.reduce((acc, facetObj, index) => {
|
| 196 |
const [key] = Object.keys(facetObj);
|
| 197 |
const $categoryCheckbox = $(`input[type="checkbox"][data-index="${index}"]`);
|
| 198 |
if ($categoryCheckbox.is(':checked')) {
|
| 199 |
-
acc.push(key);
|
| 200 |
}
|
| 201 |
return acc;
|
| 202 |
}, []);
|
|
@@ -217,7 +219,6 @@
|
|
| 217 |
isResultShown = false;
|
| 218 |
}
|
| 219 |
});
|
| 220 |
-
|
| 221 |
// Add input field
|
| 222 |
function addInput() {
|
| 223 |
const container = document.getElementById('inputContainer');
|
|
|
|
| 134 |
|
| 135 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
| 136 |
<script>
|
| 137 |
+
$(document).ready(function() {
|
| 138 |
let isResultShown = false;
|
| 139 |
let facetData = [];
|
| 140 |
$('#submit').click(function() {
|
|
|
|
| 153 |
alert('Invalid facet format. Please check your input and try again.');
|
| 154 |
}
|
| 155 |
});
|
| 156 |
+
|
| 157 |
function generateBoxes(facetObj, method) {
|
| 158 |
const $dynamicBoxes = $('#dynamicBoxes').empty();
|
| 159 |
+
|
| 160 |
if (method === 'v1') {
|
| 161 |
Object.entries(facetObj).forEach(([key, values]) => {
|
| 162 |
createBox(key, values);
|
|
|
|
| 170 |
function createBox(key, values, index = null) {
|
| 171 |
const $box = $('<div>').addClass('bg-white rounded-lg shadow-md p-6 fade-in');
|
| 172 |
const $title = $('<div>').addClass('flex items-center justify-between mb-4')
|
| 173 |
+
.append($('<h2>').addClass('text-xl font-semibold').text(`'${key}'`))
|
| 174 |
.append($('<input>').attr({
|
| 175 |
type: 'checkbox',
|
| 176 |
name: key,
|
|
|
|
| 185 |
$dynamicBoxes.append($box);
|
| 186 |
}
|
| 187 |
}
|
| 188 |
+
|
| 189 |
$('#getList').click(function() {
|
| 190 |
const processingMethod = $('input[name="processingMethod"]:checked').val();
|
| 191 |
let result;
|
| 192 |
if (processingMethod === 'v1') {
|
| 193 |
result = $('input[type="checkbox"]:checked').map(function() {
|
| 194 |
+
return `'${this.name}'`;
|
| 195 |
}).get();
|
| 196 |
} else {
|
| 197 |
result = facetData.reduce((acc, facetObj, index) => {
|
| 198 |
const [key] = Object.keys(facetObj);
|
| 199 |
const $categoryCheckbox = $(`input[type="checkbox"][data-index="${index}"]`);
|
| 200 |
if ($categoryCheckbox.is(':checked')) {
|
| 201 |
+
acc.push(`'${key}'`);
|
| 202 |
}
|
| 203 |
return acc;
|
| 204 |
}, []);
|
|
|
|
| 219 |
isResultShown = false;
|
| 220 |
}
|
| 221 |
});
|
|
|
|
| 222 |
// Add input field
|
| 223 |
function addInput() {
|
| 224 |
const container = document.getElementById('inputContainer');
|