{{- $format := splitList "\n" (trim .Data.format) -}}
{{- $randID := randAlphaNum 10 -}}
<div class="card-header">
<a class="card-header-title" href="{{.URL}}">
{{if ne .Icon ""}}
{{template "icon" .Icon}}
{{end}}
{{.Title}}
</a>
</div>
<div class="card-content">
<p id="APILoadingText_{{$randID}}">Loading...</p>
{{range $index, $fmtStr := $format}}
<div id="{{printf `APIElement%d_%s` $index $randID}}"></div>
{{if .Data.footer}}
<div class="card-footer" style="margin-top: auto">
<p class="card-footer-item">{{.Data.footer}}</p>
<script>
var request = new XMLHttpRequest()
request.open('GET', "{{proxy .URL}}", true)
request.onload = function () {
const data = JSON.parse(this.response)
document.getElementById("APILoadingText_{{$randID}}").classList.add("is-hidden")
document.getElementById("{{printf `APIElement%d_%s` $index $randID}}").innerHTML = `{{unescJS (trim $fmtStr)}}`
}
request.send()
</script>