-
Notifications
You must be signed in to change notification settings - Fork 5
/
monstersTab.qmd
130 lines (100 loc) · 3.29 KB
/
monstersTab.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
format:
html:
includes: include-after-body
---
```{=html}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script> -->
```
# Monsters Index
Select search field(s). Hold `shift` or drag mouse to select multiple.
Monster name is always part of the search field.
```{ojs}
data = {
const d = await FileAttachment("monsters.json").json()
return d
}
```
```{ojs}
cols = Object.keys(data[0])
cols2 = cols.slice(1)
```
```{ojs}
viewof theseCols = Inputs.select(cols2, {multiple:true, value:cols2})
```
<br>
```{ojs}
viewof search = {
let n = Inputs.search(data,{
columns:[cols[0]].concat(theseCols)
});
return n
}
```
<br>
<!-- ::: {.column-screen}
```{ojs}
viewof theseStats = Inputs.checkbox(["Armor Class", "Hit Dice", "Attacks", "Damage","Movement","No. Appearing","Save","Morale","Treasure Type","XP"])
```
::: -->
::: {.column-screen .table-responsive}
```{ojs}
// import { jQuery as $ } from "@ddspog/useful-libs"
Inputs.table(search, {width:"auto",
format:{
Name: id => htl.html`<a href=#\ onclick="test('${id}')">${id}</a>`
}})
```
:::
```{=html}
<script>
function my_modal(name){
$(document).ready(function() {
$.get("monstersAll.html", function(data) {
var content = $(data).find("[data-tag='" + name + "']").html();
$("#my").html(content);
});
});}
</script>
<div id="my"> </div>
```
```{=html}
<script>
function getMonsterContent(tag) {
var monsters = document.querySelectorAll('.monster[data-tag*="' + tag + '"], .monster[data-tag2*="' + tag + '"]');
var content = "";
for (var i = 0; i < monsters.length; i++) {
content += monsters[i].innerHTML;
}
return content;
}
function test(name){
$(document).ready(function() {
$.get('monstersAll.html', function(data) {
var content = $(data).find("[data-tag='" + name + "'], [data-tag2='" + name + "'], [data-tag3='" + name + "']").html();// $(data).find("[data-tag='" + name + "']", "[data-tag2='" + name + "']").html();
$('#myModal .modal-body').html(content);
$('#myModal').modal('show');
});
}
);}
</script>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"> </h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="modal-text">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
```