chronology.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. $(() => {
  2. class Chronology
  3. {
  4. #min = null;
  5. #max = null;
  6. #onChronologyUpdated() {
  7. console.log("Chronology update with ", this.#min, this.#max);
  8. window.ReloadFilters(MediaStorage.Instance);
  9. }
  10. rebuildRange(_minTs, _maxTs) {
  11. let updated = false;
  12. if (!this.#min || this.#min.getTime() !== _minTs) {
  13. this.#min = new Date(_minTs);
  14. updated = true;
  15. }
  16. if (!this.#max || this.#max.getTime() !== _maxTs) {
  17. this.#max = new Date(_maxTs);
  18. updated = true;
  19. }
  20. if (updated)
  21. this.#onChronologyUpdated();
  22. }
  23. getRange() {
  24. return {
  25. min: new Date(this.#min),
  26. max: new Date(this.#max)
  27. };
  28. }
  29. isInitialized() {
  30. return this.#min && this.#max;
  31. }
  32. reset() {
  33. this.#min = this.#max = null;
  34. }
  35. }
  36. window.chronology = new Chronology();
  37. });