-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vendor dropdown and put in seperate file
- Loading branch information
Showing
3 changed files
with
56 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,8 @@ | ||
{{ define "main" }} | ||
<main aria-role="main"> | ||
{{ partial "banner.html" (dict "title" "Device Repository for LoRaWAN®" "description" .Description) }} | ||
<select id="tagDropdown"> | ||
<option value="" selected disabled>Select a Tag</option> | ||
{{ $tags := slice }} | ||
{{ range .Site.RegularPages }} | ||
{{ $pageTags := .Params.tags }} | ||
{{ range $pageTags }} | ||
{{ if not (in $tags .) }} | ||
{{ $tags = $tags | append . }} | ||
{{ end }} | ||
{{ end }} | ||
{{ end }} | ||
{{ $sortedTags := $tags | sort }} | ||
{{ range $sortedTags }} | ||
<option value="{{ . | urlize }}">{{ . }}</option> | ||
{{ end }} | ||
</select> | ||
<script> | ||
document.getElementById("tagDropdown").addEventListener("change", function() { | ||
var selectedTag = this.value; | ||
if (selectedTag) { | ||
window.location.href = "{{ .Site.BaseURL }}tags/" + selectedTag + "/"; | ||
} | ||
}); | ||
</script> | ||
{{ partial "tagdropdown.html" . }} | ||
{{ partial "vendordropdown.html" . }} | ||
{{ partial "device-list.html" (dict "devices" ( where site.RegularPages "Section" "devices" ) ) }} | ||
</main> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<select id="tagDropdown"> | ||
<option value="" selected disabled>Select a Tag</option> | ||
{{ $tags := slice }} | ||
{{ range .Site.RegularPages }} | ||
{{ $pageTags := .Params.tags }} | ||
{{ range $pageTags }} | ||
{{ if not (in $tags .) }} | ||
{{ $tags = $tags | append . }} | ||
{{ end }} | ||
{{ end }} | ||
{{ end }} | ||
{{ $sortedTags := $tags | sort }} | ||
{{ range $sortedTags }} | ||
<option value="{{ . | urlize }}">{{ . }}</option> | ||
{{ end }} | ||
</select> | ||
<script> | ||
document.getElementById("tagDropdown").addEventListener("change", function() { | ||
var selectedTag = this.value; | ||
if (selectedTag) { | ||
window.location.href = "{{ .Site.BaseURL }}tags/" + selectedTag + "/"; | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<select id="vendorDropdown"> | ||
<option value="" selected disabled>Select a Vendor</option> | ||
{{ $uniqueVendors := dict }} | ||
{{ $sortedVendors := slice }} | ||
{{ range .Site.RegularPages }} | ||
{{ with .Params.vendor }} | ||
{{ $vendorID := .id | urlize }} | ||
{{ $vendorName := .name }} | ||
{{ with index $uniqueVendors $vendorID }} | ||
{{/* Vendor already encountered, do nothing */}} | ||
{{ else }} | ||
{{ $uniqueVendors = $uniqueVendors | merge (dict $vendorID $vendorName) }} | ||
{{ $sortedVendors = $sortedVendors | append $vendorID }} | ||
{{ end }} | ||
{{ end }} | ||
{{ end }} | ||
{{ $sortedVendors = sort $sortedVendors }} | ||
{{ range $sortedVendors }} | ||
<option value="{{ . }}">{{ index $uniqueVendors . }}</option> | ||
{{ end }} | ||
</select> | ||
<script> | ||
document.getElementById("vendorDropdown").addEventListener("change", function() { | ||
var selectedVendor = this.value; | ||
if (selectedVendor) { | ||
// Redirect to the URL for the selected vendor | ||
window.location.href = "{{ .Site.BaseURL }}devices/" + selectedVendor + "/"; | ||
} | ||
}); | ||
</script> |