update.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var hwver = '';
  2. function reven() {
  3. dis = !getelem('unlock').checked || !hwver;
  4. getelem('setrev').disabled = dis;
  5. }
  6. function brev(ver,dover = true) {
  7. const bsel = getelem('boardrevs');
  8. const other = bsel.querySelector('option.other').value;
  9. hwver = ver && ver.match(/^MAX80 v(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*( [a-zA-Z0-9]+)?$/) ? ver : '';
  10. if (dover)
  11. getelem('ver').value = ver == other ? ver : hwver;
  12. bsel.value = hwver;
  13. if (bsel.selectedOptions.length == 0)
  14. bsel.value = other;
  15. reven();
  16. }
  17. function brn() { brev(event.target.selectedOptions[0].value); }
  18. function brt() { brev(event.target.value,false); }
  19. function bropen(ul) {
  20. ulchk = getelem('unlock');
  21. ulchk.checked = ul = (ul == undefined) ? ulchk.checked : ul;
  22. getelem('boardrevs').disabled = !ul;
  23. getelem('ver').disabled = !ul;
  24. getelem('warnrev').classList.toggle('hidden',!ul);
  25. reven();
  26. }
  27. fetchconfig('sys/getstatus')
  28. .then(map => brev(map.get('max80.hw.ver')))
  29. .catch(err => brev(undefined))
  30. .finally(() => {
  31. norev = !hwver;
  32. bropen(norev);
  33. getelem('norev').classList.toggle('hidden',!norev);
  34. getelem('upload.start').disabled = norev;
  35. });