-
Notifications
You must be signed in to change notification settings - Fork 0
/
json.html
185 lines (185 loc) · 6.64 KB
/
json.html
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@300;400;500;600&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/a425097a26.js" crossorigin="anonymous"></script>
<style>
body {background:#fff;font-family: 'Roboto Slab', serif;}
#content{width:50%;margin:auto;}
a{text-decoration:none;color:#000;}
ul{--fa-li-margin:2em;--fa-li-width:2em;}
li{margin:0.5em;}
</style>
</head>
<body>
<div id="content">
<h1>Bibliography</h1>
<p>This code is also explorable on CodePen: <a href="https://codepen.io/joeeasterly/pen/eYVzBVg" target="_blank"><i class="fa-brands fa-codepen"></i> https://codepen.io/joeeasterly/pen/eYVzBVg</a></p>
<ul class="fa-ul" id="zoteroBiblio"></ul>
</div>
<script type="text/javascript">
async function get() {
let url = 'https://api.zotero.org/groups/4391561/collections/4I376PCC/items/top?direction=asc&format=json&sort=title'
let obj = await (await fetch(url)).json();
//console.log(obj);
return obj;
}
var zoteroJSON;
(async () => {
zoteroJSON = await get()
itemCount = zoteroJSON.length
const zoteroBiblio = document.getElementById("zoteroBiblio")
for (const item of zoteroJSON){
var title = item['data']['title']
var itemType = item['data']['itemType']
var itemUrl = item['data']['url']
const li = document.createElement('li')
const span = document.createElement('span')
const i = document.createElement('i')
switch (itemType) {
case "artwork":
li.setAttribute('class','artwork')
break;
case "audioRecording":
li.setAttribute('class','audioRecording')
break;
case "bill":
li.setAttribute('class','bill')
break;
case "blogPost":
i.setAttribute('class','fa-duotone fa-blog');
li.setAttribute('title','blogPost');
break;
case "book":
li.setAttribute('class','book')
i.setAttribute('class','fa-duotone fa-book');
li.setAttribute('title','Book');
break;
case "bookSection":
li.setAttribute('class','bookSection')
i.setAttribute('class','fa-duotone fa-book');
li.setAttribute('title','Book Section');
break;
case "case":
li.setAttribute('class','case')
break;
case "conferencePaper":
li.setAttribute('class','conferencePaper')
i.setAttribute('class','fa-duotone fa-presentation-screen');
li.setAttribute('title','Conference Paper');
break;
case "dictionaryEntry":
li.setAttribute('class','dictionaryEntry')
break;
case "document":
li.setAttribute('class','document')
i.setAttribute('class','fa-duotone fa-file');
li.setAttribute('title','blogPost');
break;
case "email":
li.setAttribute('class','email')
break;
case "encyclopediaArticle":
li.setAttribute('class','encyclopediaArticle')
break;
case "film":
li.setAttribute('class','film')
break;
case "forumPost":
li.setAttribute('class','forumPost')
break;
case "hearing":
li.setAttribute('class','hearing')
break;
case "instantMessage":
li.setAttribute('class','instantMessage')
break;
case "interview":
li.setAttribute('class','interview')
break;
case "journalArticle":
li.setAttribute('class','journalArticle')
i.setAttribute('class','fa-duotone fa-memo');
li.setAttribute('title','journal article');
break;
case "letter":
li.setAttribute('class','letter')
break;
case "magazineArticle":
li.setAttribute('class','magazineArticle')
break;
case "manuscript":
li.setAttribute('class','manuscript')
break;
case "map":
li.setAttribute('class','map')
break;
case "newspaperArticle":
li.setAttribute('class','newspaperArticle')
break;
case "patent":
li.setAttribute('class','patent')
break;
case "podcast":
li.setAttribute('class','podcast')
break;
case "presentation":
li.setAttribute('class','presentation')
i.setAttribute('class','fa-duotone fa-presentation-screen');
li.setAttribute('title','Presentation');
break;
case "radioBroadcast":
li.setAttribute('class','radioBroadcast')
break;
case "report":
li.setAttribute('class','report')
break;
case "software":
li.setAttribute('class','software')
break;
case "statute":
li.setAttribute('class','statute')
break;
case "thesis":
li.setAttribute('class','thesis')
break;
case "tvBroadcast":
li.setAttribute('class','tvBroadcast')
break;
case "videoRecording":
li.setAttribute('class','videoRecording')
i.setAttribute('class','fa-duotone fa-video');
li.setAttribute('title','Video Recording');
break;
case "webpage":
li.setAttribute('class','webpage')
i.setAttribute('class','fa-duotone fa-browser');
li.setAttribute('title','Web Page');
break;
case "attachment":
li.setAttribute('class','attachment')
break;
case "note":
li.setAttribute('class','note')
break;
default:
li.setAttribute('class','default');
i.setAttribute('class','fa-duotone fa-file');
li.setAttribute('title','Web Page');
}
const a = document.createElement('a')
a.setAttribute('href',itemUrl)
a.setAttribute('target','_blank')
a.textContent = title
span.setAttribute('class','fa-li')
zoteroBiblio.appendChild(li)
li.appendChild(span)
span.appendChild(i)
li.appendChild(a)
}
})()
</script>
</body>
</html>