* Ensure `updateChargeStatsDisplay` reliably updates charges and full charge display.
* Fix interval handling: clear previous intervals and reset variable to `null`.
* Inline full charge display logic, defaulting to `--:--:--` when not available.
Benefits:
* Charge stats now update consistently without missing ticks.
* Interval management is safer, preventing multiple overlapping timers.
Note:
* Full stats partial update logic is now fully integrated; previous issue of UI flicker or missed updates is resolved.
- Replace `currentCharges` with `displayCharges` for UI representation.
- Introduce `preciseCurrentCharges` to track fractional charge values.
- Update logic in `resetEdgeTracking`, `maybeNotifyChargesReached`, and related functions to use `displayCharges`.
- Modify `updateFullChargeDisplay` to calculate and use `preciseCurrentCharges` and `displayCharges`.
- Refactor `getRemainingMsToThreshold` into `getMsToTargetCharges` for clarity and precision.
- Replace `startChargesThresholdTicker` and `updateChargesThresholdUI` with a unified `updateChargesThresholdUI` function.
- Update HTML templates and dynamic UI updates to reflect `displayCharges`.
Benefits:
- Improves accuracy by distinguishing between displayed and precise charge values.
- Simplifies charge-related logic and reduces redundant calculations.
- Enhances readability and maintainability of charge tracking and UI updates.
Note:
- Ensure all dependent modules correctly handle the new `displayCharges` and `preciseCurrentCharges` fields.
- Introduce conditions to determine whether to call the API based on forced refresh, first check, or elapsed time.
- Add randomization for update intervals between 60s and 90s to stagger API requests.
- Preserve existing behavior of updating charges, cooldown, and max charges when API is called.
- Clear and reset the interval for `updateFullChargeDisplay` only when necessary.
Benefits:
- Reduces server load by avoiding frequent unnecessary API calls.
- Improves efficiency by introducing randomized update intervals.
- Maintains backward compatibility with existing functionality.
Note:
- Ensure `WPlaceService.getCharges()` continues to return valid data under new conditions.
- Replace `wplace-random-batch-input` and `wplace-block-size-input` classes with `wplace-settings-number-input`.
- Update CSS to consolidate styles under `wplace-settings-number-input`.
- Refactor theme variables for background and border colors to use explicit hex values, fixing visibility issue in light theme.
- Remove redundant `.wplace-block-size-input` styles.
Benefits:
- Number inputs are now correctly visible in all themes, including light.
- Reduces duplication in CSS by consolidating input styles.
- Improves consistency across input elements in the UI.
- Enhances clarity of theme variable usage with explicit naming.
Note:
- Ensure all components previously using `wplace-random-batch-input` or `wplace-block-size-input` are tested for visual consistency.
- Replace manual creation of multiple `<link>` elements with `appendLinkOnce` function.
- Add a utility function `appendLinkOnce` to ensure stylesheets are not added multiple times.
- Use `appendLinkOnce` for Font Awesome, Google Fonts, and external CSS links.
- Pass additional attributes (e.g., `data-*`) as an optional parameter to `appendLinkOnce`.
Benefits:
- Prevents potential issues caused by duplicate stylesheets.
- Reduces code duplication for creating and appending `<link>` elements.
- Improves maintainability and readability of the code.
Note:
- All future `<link>` additions should use `appendLinkOnce` to avoid similar bugs.
- Activate CSS variable settings for theming in `Auto-Image.js`.
- Update dropdown class from `wplace-selector` to `wplace-settings-select`.
- Remove inline styles from the "Apply Settings" button.
- Delete obsolete `.wplace-selector` CSS rules from `auto-image-styles.css`.
Benefits:
- Ensures consistent theming across components.
- Simplifies styling management.
- Improves maintainability by removing inline styles.
Note:
- Update dependent components to use the new `wplace-settings-select` class.