Subham9126 commited on
Commit
6d5721b
·
verified ·
1 Parent(s): b070f44

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +115 -18
index.html CHANGED
@@ -1,19 +1,116 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
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
+ const givenFacet = $('#givenFacet').val();
69
+ const outputSection = $('#outputSection');
70
+ const facetBoxes = $('#facetBoxes');
71
+
72
+ try {
73
+ const facets = JSON.parse(givenFacet.replace(/'/g, '"'));
74
+ facetBoxes.empty();
75
+
76
+ $.each(facets, function(key, values) {
77
+ const box = $('<div class="box"></div>');
78
+ const title = $(`<div class="box-title">'${key}' <input type="checkbox" class="facet-checkbox" data-key="${key}"></div>`);
79
+ box.append(title);
80
+
81
+ $.each(values, function(index, value) {
82
+ const valueItem = $('<div></div>').text(value);
83
+ box.append(valueItem);
84
+ });
85
+
86
+ facetBoxes.append(box);
87
+ });
88
+
89
+ outputSection.show();
90
+ } catch (e) {
91
+ alert('Invalid JSON format');
92
+ }
93
+ });
94
+
95
+ $('#getListBtn').click(function() {
96
+ const checkboxes = $('.facet-checkbox');
97
+ const selectedKeys = [];
98
+
99
+ checkboxes.each(function() {
100
+ if ($(this).is(':checked')) {
101
+ const key = $(this).data('key');
102
+ selectedKeys.push(`'${key}'`);
103
+ }
104
+ });
105
+
106
+ const resultSection = $('#resultSection');
107
+ resultSection.empty();
108
+ const resultBox = $('<div class="result-box"></div>');
109
+ resultBox.text(`Selected keys: [${selectedKeys.join(', ')}]`);
110
+ resultSection.append(resultBox);
111
+ });
112
+ });
113
+ </script>
114
+
115
+ </body>
116
  </html>