tz.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. function tzn() {
  2. const tz = event.target.selectedOptions[0].dataset.tz;
  3. if (tz) sib(event.target,'input').value = tz;
  4. }
  5. function tzt() { sib(event.target,'select').value = ''; }
  6. fetchconfig('tzlist')
  7. .then(map => {
  8. function cln(z) {
  9. return ('tz/'+z).replaceAll('/','_ ')
  10. .replaceAll(/[^\w ]+/g,'-');
  11. }
  12. var elem = getelem('tzname');
  13. var grp = elem;
  14. map.set('',''); map.set('UTC','UTC0');
  15. var zones = Array.from(map.keys());
  16. zones = zones.filter(v => v && v != 'UTC').sort();
  17. zones.unshift('','UTC');
  18. for (const z of zones) {
  19. const zz = z.match(/^(?:(\S+?)\/)?(\S*)$/,z);
  20. if (!zz) { continue; }
  21. if (zz[1] && zz[1] != grp.label) {
  22. grp = document.createElement('OPTGROUP');
  23. grp.label = zz[1];
  24. grp.className = cln(zz[1]);
  25. elem.append(grp);
  26. } else if (!zz[1]) {
  27. grp = elem;
  28. }
  29. const pz = zz[2].replaceAll('_',' ').replaceAll('/',': ');
  30. var opt = new Option(pz, z);
  31. opt.className = cln(z);
  32. opt.dataset.tz = map.get(z);
  33. grp.append(opt);
  34. }
  35. translate(elem);
  36. })
  37. .finally(() => {loadform('setconfig','sys/getconfig');} );