Subham9126 commited on
Commit
0ecb4b7
·
verified ·
1 Parent(s): 38fdf7d

Update index.html

Browse files
Files changed (1) hide show
  1. 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 Boxes with Facets</title>
7
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
8
  <style>
9
- body {
10
- font-family: Arial, sans-serif;
11
- background-color: #f8f9fa;
12
- }
13
- .container {
14
- margin-top: 50px;
15
- }
16
- .box {
17
- border: 1px solid #ddd;
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
- .result-box {
27
- border: 1px solid #28a745;
28
- padding: 15px;
29
- margin-top: 20px;
30
- background-color: #e8f5e9;
31
- border-radius: 5px;
 
 
32
  }
33
  </style>
34
  </head>
35
- <body>
36
 
37
- <div class="container">
38
- <div class="row mb-4">
39
- <div class="col-md-12">
40
- <h2>Input Section</h2>
41
- <div class="form-group">
42
- <label for="query">Query:</label>
43
- <input type="text" id="query" class="form-control" placeholder="Enter your query">
 
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
- <div class="row" id="outputSection" style="display: none;">
54
- <div class="col-md-12">
55
- <h2>Dynamic Boxes</h2>
56
- <div id="facetBoxes"></div>
57
- <button class="btn btn-success" id="getListBtn">Get List</button>
58
- <div id="resultSection"></div>
 
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
- try {
73
- // Replace single quotes with double quotes
74
- givenFacet = givenFacet.replace(/'/g, '"');
75
- const facets = JSON.parse(givenFacet);
76
- facetBoxes.empty();
77
-
78
- $.each(facets, function(key, values) {
79
- const box = $('<div class="box"></div>');
80
- const title = $(`<div class="box-title">'${key}' <input type="checkbox" class="facet-checkbox" data-key="${key}"></div>`);
81
- box.append(title);
 
 
 
 
82
 
83
- $.each(values, function(index, value) {
84
- const valueItem = $('<div></div>').text(value);
85
- box.append(valueItem);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  });
87
-
88
- facetBoxes.append(box);
 
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
- checkboxes.each(function() {
102
- if ($(this).is(':checked')) {
103
- const key = $(this).data('key');
104
- selectedKeys.push(`'${key}'`);
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>