workflow.js 920 B

1234567891011121314151617181920212223242526272829
  1. var
  2. /** @const @type {string} */
  3. GRID_LIST_ENDPOINT = '/api/list'
  4. ;
  5. document.addEventListener('DOMContentLoaded', function() {
  6. doGet(GRID_LIST_ENDPOINT, function(st, resp) {
  7. if (resp) {
  8. resp.sort(function(a, b) {
  9. if (a["date"] !== b["date"])
  10. return b["date"] -a["date"];
  11. // Same date, sort by difficulty
  12. if (a["level"] !== b["level"])
  13. return a["level"] -b["level"];
  14. // Same date & difficulty, sort by provider name
  15. return a["provider"].localeCompare(b["provider"]);
  16. });
  17. var frag = dFrag();
  18. resp.forEach(function(i) {
  19. frag.appendChild(makeGridListItem(i));
  20. });
  21. var gridList = dGet(R.id.gridList);
  22. gridList.textContent = "";
  23. gridList.appendChild(frag);
  24. }
  25. });
  26. });