common.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. $(() => {
  2. function loadHash(md5sum) {
  3. if (md5sum && md5sum.length)
  4. LoadingTasks.push(async () => displayMediaFullPage(await MediaStorage.Instance.getMedia(md5sum)));
  5. else
  6. document.getElementById("pch-fullPageMedia").classList.add("hidden");
  7. }
  8. window.addEventListener("hashchange", x => {
  9. x.preventDefault();
  10. loadHash(document.location?.hash?.substr(1))
  11. return true;
  12. });
  13. onScrollBottom = (function () {
  14. this.lastCall= null;
  15. this.fnc = () => {
  16. if (this.lastCall !== null)
  17. return;
  18. this.lastCall = setTimeout(() => {
  19. this.lastCall = null;
  20. }, 1000);
  21. window.displayMoreMedia();
  22. };
  23. return this;
  24. })();
  25. window.addEventListener("scroll", evt => {
  26. if (window.scrollY+window.innerHeight >= document.body.clientHeight)
  27. onScrollBottom.fnc();
  28. });
  29. AccessManager.RebuildAccess();
  30. loadHash(document.location?.hash?.substr(1));
  31. MediaStorage.Instance.downloadMetaList();
  32. });