--- a/layouts/shortcodes/plugintable.html Mon Jan 14 18:57:59 2019 +0000
+++ b/layouts/shortcodes/plugintable.html Mon Jan 14 23:09:21 2019 +0000
@@ -1,21 +1,151 @@
+<div id="plugin-filters"> + <input type="text" id="plugin-filter-search" placeholder="Search plugins" /> + <div id="protocol-selector"></div> +<table id="protocol-table">
{{ range .Site.Data.plugins }}
- <td><img src="{{.logo}}" /></td>
- <td><b>{{.type}}</b> {{.info | markdownify }}</td>
- <a href="{{.repo}}">{{.maintainer}}</a>
+ <tr data-type="{{.type}}"> + <img src="{{.logo}}" /> + <td class="pulgin-heading"> + <td class="pulgin-info"> + <b>{{.type}}</b> {{.info | markdownify}} + <td class="pulgin-repo"> + <a href="{{.repo}}">{{.maintainer}}</a> + document.addEventListener("DOMContentLoaded", () => { + const selectorsContainer = document.getElementById("protocol-selector"); + const search = document.getElementById("plugin-filter-search"); + search.addEventListener("input", debounce(1000 * 0.5, filterRows)); + document.getElementById("protocol-table") + .getElementsByTagName("tr") + const typeFilter = new Set(); + const rowinfo = rows.map(elem => { + const type = elem.dataset.type; + if (!types[type]) types[type] = [] + types[type].push(elem); + head: getContents("pulgin-heading", elem), + info: getContents("pulgin-info", elem), + repo: getContents("pulgin-repo", elem), + Object.keys(types).forEach(type => { + const label = createAndAppend("label", selectorsContainer); + label.classList.add('pidgin-plugin-filter-checkbox') + const input = createAndAppend("input", label); + input.type = "checkbox"; + input.dataset.type = type + input.addEventListener("click", clickEvent); + label.appendChild(document.createTextNode(type)); + ///////////////////////// + function getContents(className, elem = document){ + elem.getElementsByClassName(className)[0] + .textContent.toLowerCase() + function clickEvent({target}) { + typeFilter[target.checked ? "add" : "delete"](target.dataset.type); + function filterRows() { + const str = (search.value || "").toLowerCase() + rowinfo.forEach((row) => { + if (shouldFilter(row, str)) + row.elem.classList.remove("filter-hide"); + row.elem.classList.add("filter-hide"); + function shouldFilter(row, str) { + (!typeFilter.size || typeFilter.has(row.elem.dataset.type)) + || row.head.includes(str) + || row.info.includes(str) + || row.repo.includes(str) + function debounce(t, fn) { + return function (...args) { + timer = setTimeout(() => fn(...args), t); + function createAndAppend(tag, elem = document) { + return elem.appendChild(document.createElement(tag)); + #plugin-filter-search { + #protocol-selector label { + #protocol-selector input { \ No newline at end of file