load_list_items.js 744 B

1234567891011121314151617181920212223
  1. var ret = []
  2. document.querySelectorAll("{{.ListItemCss}}").forEach((v, i) => {
  3. let item = {}
  4. if ("{{.ListLinkCss}}" != "") {
  5. let link = v.querySelector("{{.ListLinkCss}}")
  6. if (link) {
  7. var href = link.href
  8. if (!href.startsWith("http")) href = window.location.origin + "/" + href
  9. let title = link.getAttribute("title") || link.innerText
  10. item = { "listTitle": title, "href": href, "no": i }
  11. } else {
  12. item = { "no": i }
  13. }
  14. }
  15. if ("{{.ListPubtimeCss}}" != "") {
  16. let pubtime = v.querySelector("{{.ListPubtimeCss}}")
  17. if (pubtime) {
  18. item["listPublishTime"] = pubtime.innerText
  19. }
  20. }
  21. ret.push(item)
  22. })
  23. ret