state.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. ArozOS Desktop - Desktop state
  3. Global variables shared by every desktop script: wallpaper, icons,
  4. float windows, selection, key state, list menu, upload limits and the
  5. browser / device detection flags.
  6. Part of desktop.html, see README.md in this folder for the load order.
  7. */
  8. /*
  9. ArOZ Online Desktop Interface
  10. This script maintain the usability of the desktop environment.
  11. This is not identical to the previous Desktop environment used in ArOZ Online BETA.
  12. */
  13. //System environment variables
  14. var isDesktopMode = true;
  15. var loggingOut = false;
  16. //Desktop background related
  17. var desktopThemeList = []; //Storing the list of background installed
  18. var currentBackgroundList = []; //Current list of background files
  19. var currentUserTheme = ""; //The theme for current user.
  20. var backgroundCrossfadeInterval = 30000; //Time between the crossfade of each background image
  21. var nextSlideshowIndex = 0; //The next background image index to be shown
  22. var backgroundIntervalCounter; //The interval object for background changer
  23. var desktopThemeColor = ""; //The current desktop theme color, which renders to the status bar and suchs
  24. //Module-registered extension icons (ext without dot → web-root-relative path)
  25. var extIconRegistry = {};
  26. //Desktop icon realted
  27. var desktopIconSize = "medium"; //Size of desktop icons. Allow {small / medium / big}
  28. var desktopIconPack = "default"; //Desktop icon pack to be used. Located under desktop/file_icon/{pack-name}
  29. var desktopGrids = []; //Reference virtual grid for icons on desktop
  30. var iconSize = []; //Defined the icon size for the desktop icons
  31. var desktopFileList = []; //Temperature storage of desktop filenames
  32. var startDragRelatuve = []; //Relative location of where the icon being start dragging
  33. var iconOffsetXY = [-10,-10]; //Pixel to offset for the icon location
  34. //Float window related
  35. var focusedWindow;
  36. const maxWindowCount = 100;
  37. var movingWindow = false;
  38. var resizingWindow = false;
  39. var resizingEdgeID = 0; //Resizing edge. {0, 1, 2, 3, 4, 5, 6} => None, Right, Right Bottom Corner, Bottom, Left Bottom Corner, Left, TOp
  40. var stackedFloatWindowListShown = false;
  41. //Laucnh icon related
  42. var multiSelecting = false;
  43. var multiSelectionStartPoint = [-1, -1];
  44. var clickDownOffset = [-1, -1];
  45. var renameMode = false;
  46. var operationTargetLaunchIcon;
  47. var currentMousePosition = [-1, -1];
  48. //Document key bindings
  49. var ctrlHold = false;
  50. var shiftHold = false;
  51. //ListMenu Related Paramters
  52. var moduleInstalled = [];
  53. var listMenuShown = false;
  54. //Module groups listed under each list menu category. Groups of retired
  55. //categories (Download, Files) and Internet still land somewhere sensible
  56. //for third party modules; any other group goes to Other.
  57. var listMenuCategories = {
  58. "Media": ["Media"],
  59. "Office": ["Office"],
  60. "Network": ["Network", "Internet", "Download"],
  61. "Engineering": ["Engineering"],
  62. "Development": ["Development"],
  63. "System": ["System Tools", "System Settings"],
  64. "Utilities": ["Utilities", "Files"]
  65. };
  66. //Context Menu variables
  67. var menuStartLocation = [0, 0];
  68. //Input Method Editor objects
  69. window.ime = {
  70. handler: null,
  71. focus: null
  72. };
  73. //Upload related
  74. let uploadFileChunkSize = 1024 * 512; //512KB per chunk in low memory upload
  75. let largeFileCutoffSize = 8192 * 1024 * 1024; //Any file larger than this size is consider "large file", default to 8GB
  76. let postUploadModeCutoff = 25 * 1048576; //25MB, files smaller than this will upload using POST Mode
  77. let uploadWindowSize = 8 * 1024 * 1024; //Bytes of chunks kept in flight per upload connection (see script/chunkupload.js)
  78. const CHUNK_TIMEOUT_MS = 30000; //30s without any server ack (once everything queued has been sent) before resending the oldest chunk
  79. const MAX_CHUNK_RETRIES = 3; //Maximum retries without any progress before marking the upload failed
  80. //Others
  81. var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  82. var daysNames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  83. var hostInfo = {};
  84. var userInfo = {};
  85. var powerman = false;
  86. var downloadMode = false;
  87. var lowMemoryMode = true;
  88. //Browser and device detection
  89. var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  90. var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  91. var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
  92. var isMacOS = (navigator.appVersion.indexOf("Mac")!=-1);
  93. if (isMacOS) document.documentElement.classList.add("isMacOS"); // dock.css: the backdrop blur fails on macOS browsers
  94. var isTouchScreen = window.matchMedia("(any-pointer: coarse)").matches;