Spaces:
Running
Running
Update index.html
Browse files- index.html +88 -92
index.html
CHANGED
|
@@ -1,118 +1,114 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Dynamic
|
| 7 |
-
<link
|
| 8 |
<style>
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
padding: 15px;
|
| 19 |
-
margin-bottom: 10px;
|
| 20 |
-
background-color: #fff;
|
| 21 |
-
border-radius: 5px;
|
| 22 |
-
}
|
| 23 |
-
.box-title {
|
| 24 |
-
font-weight: bold;
|
| 25 |
}
|
| 26 |
-
.
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
background-color:
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
</style>
|
| 34 |
</head>
|
| 35 |
-
<body>
|
| 36 |
|
| 37 |
-
<
|
| 38 |
-
<div class="
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
<
|
|
|
|
| 44 |
</div>
|
| 45 |
-
<div class="form-group">
|
| 46 |
-
<label for="givenFacet">Given Facet:</label>
|
| 47 |
-
<input type="text" id="givenFacet" class="form-control" placeholder="Enter your facet in Python dictionary format">
|
| 48 |
-
</div>
|
| 49 |
-
<button class="btn btn-primary" id="submitBtn">Submit</button>
|
| 50 |
</div>
|
| 51 |
-
</div>
|
| 52 |
|
| 53 |
-
|
| 54 |
-
<div class="
|
| 55 |
-
<
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
<
|
|
|
|
| 59 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
</div>
|
| 61 |
-
</div>
|
| 62 |
-
|
| 63 |
-
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
| 64 |
-
<script>
|
| 65 |
-
$(document).ready(function() {
|
| 66 |
-
$('#submitBtn').click(function() {
|
| 67 |
-
const query = $('#query').val();
|
| 68 |
-
let givenFacet = $('#givenFacet').val();
|
| 69 |
-
const outputSection = $('#outputSection');
|
| 70 |
-
const facetBoxes = $('#facetBoxes');
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
const
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
});
|
| 87 |
-
|
| 88 |
-
|
|
|
|
| 89 |
});
|
| 90 |
-
|
| 91 |
-
outputSection.show();
|
| 92 |
-
} catch (e) {
|
| 93 |
-
alert('Invalid JSON format');
|
| 94 |
}
|
| 95 |
-
});
|
| 96 |
-
|
| 97 |
-
$('#getListBtn').click(function() {
|
| 98 |
-
const checkboxes = $('.facet-checkbox');
|
| 99 |
-
const selectedKeys = [];
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
| 106 |
});
|
| 107 |
-
|
| 108 |
-
const resultSection = $('#resultSection');
|
| 109 |
-
resultSection.empty();
|
| 110 |
-
const resultBox = $('<div class="result-box"></div>');
|
| 111 |
-
resultBox.text(`Selected keys: [${selectedKeys.join(', ')}]`);
|
| 112 |
-
resultSection.append(resultBox);
|
| 113 |
});
|
| 114 |
-
|
| 115 |
-
</script>
|
| 116 |
-
|
| 117 |
</body>
|
| 118 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
+
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<title>Dynamic Facet Explorer</title>
|
| 8 |
+
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
| 9 |
<style>
|
| 10 |
+
@keyframes zoomIn {
|
| 11 |
+
0% {
|
| 12 |
+
transform: translateY(0);
|
| 13 |
+
font-size: 1rem;
|
| 14 |
+
}
|
| 15 |
+
100% {
|
| 16 |
+
transform: translateY(-50px);
|
| 17 |
+
font-size: 2rem;
|
| 18 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|
| 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);
|
| 27 |
+
animation: zoomIn 0.5s ease-out;
|
| 28 |
}
|
| 29 |
</style>
|
| 30 |
</head>
|
|
|
|
| 31 |
|
| 32 |
+
<body class="bg-gray-50 min-h-screen font-sans text-gray-800">
|
| 33 |
+
<div class="container mx-auto px-4 py-12">
|
| 34 |
+
|
| 35 |
+
<!-- Query Input -->
|
| 36 |
+
<div class="sticky-query bg-white rounded-lg shadow-lg p-8 mb-12">
|
| 37 |
+
<div class="mb-6">
|
| 38 |
+
<label for="query" class="block text-lg font-medium text-gray-700 mb-2">Query</label>
|
| 39 |
+
<input type="text" id="query" placeholder="Enter your query" class="w-full px-4 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 40 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
</div>
|
|
|
|
| 42 |
|
| 43 |
+
<!-- Section 1: Input -->
|
| 44 |
+
<div class="bg-white rounded-lg shadow-lg p-8 mb-12">
|
| 45 |
+
<div class="mb-6">
|
| 46 |
+
<label for="given_facet" class="block text-lg font-medium text-gray-700 mb-2">Given Facet</label>
|
| 47 |
+
<input type="text" id="given_facet" placeholder="Enter your facet in Python dictionary format" class="w-full px-4 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 48 |
+
</div>
|
| 49 |
+
<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>
|
| 50 |
</div>
|
| 51 |
+
|
| 52 |
+
<!-- Section 2: Dynamic Boxes -->
|
| 53 |
+
<div id="dynamicBoxes" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"></div>
|
| 54 |
+
|
| 55 |
+
<!-- Get List Button -->
|
| 56 |
+
<div class="mt-12 text-center">
|
| 57 |
+
<button id="getList" class="bg-green-600 text-white py-3 px-8 rounded-md hover:bg-green-700 transition duration-300 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2">Get List</button>
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
<!-- Result Display -->
|
| 61 |
+
<div id="result" class="mt-12 text-center text-2xl font-semibold"></div>
|
| 62 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
| 65 |
+
<script>
|
| 66 |
+
$(document).ready(function() {
|
| 67 |
+
$('#submit').click(function() {
|
| 68 |
+
const query = $('#query').val();
|
| 69 |
+
const givenFacet = $('#given_facet').val();
|
| 70 |
+
|
| 71 |
+
try {
|
| 72 |
+
const facetObj = eval('(' + givenFacet + ')');
|
| 73 |
+
generateBoxes(facetObj);
|
| 74 |
+
} catch (error) {
|
| 75 |
+
alert('Invalid facet format. Please enter a valid Python dictionary.');
|
| 76 |
+
}
|
| 77 |
+
});
|
| 78 |
|
| 79 |
+
function generateBoxes(facetObj) {
|
| 80 |
+
const $dynamicBoxes = $('#dynamicBoxes').empty();
|
| 81 |
+
|
| 82 |
+
Object.entries(facetObj).forEach(([key, values]) => {
|
| 83 |
+
const $box = $('<div>').addClass('bg-white rounded-lg shadow-md p-6 fade-in');
|
| 84 |
+
|
| 85 |
+
const $title = $('<div>').addClass('flex items-center justify-between mb-4')
|
| 86 |
+
.append($('<h2>').addClass('text-xl font-semibold').text(`'${key}'`))
|
| 87 |
+
.append($('<input>').attr({
|
| 88 |
+
type: 'checkbox',
|
| 89 |
+
name: key,
|
| 90 |
+
class: 'form-checkbox h-5 w-5 text-blue-600'
|
| 91 |
+
}));
|
| 92 |
+
|
| 93 |
+
const $content = $('<div>').addClass('space-y-2');
|
| 94 |
+
values.forEach(value => {
|
| 95 |
+
$content.append($('<p>').addClass('text-gray-600').text(value));
|
| 96 |
});
|
| 97 |
+
|
| 98 |
+
$box.append($title).append($content);
|
| 99 |
+
$dynamicBoxes.append($box);
|
| 100 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
+
$('#getList').click(function() {
|
| 104 |
+
const checkedBoxes = $('input[type="checkbox"]:checked').map(function() {
|
| 105 |
+
return `'${this.name}'`;
|
| 106 |
+
}).get();
|
| 107 |
+
|
| 108 |
+
const result = `[${checkedBoxes.join(', ')}]`;
|
| 109 |
+
$('#result').text(result).addClass('fade-in');
|
| 110 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
});
|
| 112 |
+
</script>
|
|
|
|
|
|
|
| 113 |
</body>
|
| 114 |
</html>
|