Does the spinning wheel have a timeout?

im looking to add this wheel to my website, does this have a timeout for a day etc once someone has spun it once?

1 Like

Hey there and welcome to the Community, @Jay_Parkes :waving_hand:

This option is currently not supported in our app, but the idea is already on the Wishlist. Feel free to upvote it here - Reset the prize

In the meantime, we’ve got a custom solution that will reset the wheel every 24 hours:

const WIDGET_ID = 'YOUR_WIDGET_ID';
const LOCAL_STORAGE_SELECTOR = `SpinningWheel.winningRewardId.${WIDGET_ID}`;
const SESSION_STORAGE_SELECTOR = `elfsight-spinning-wheel-${WIDGET_ID}`;
const RESET_AFTER_HOURS = 24;

const waitForElement = (selector, root = document) =>
  new Promise((res) => {
    let i = 0;

    const check = () => {
      const component = root.querySelector(selector);

      if (component) {
        res(component);
      } else if (i !== 50) {
        setTimeout(check, 100);
        i++;
      }
    };

    check();
  });

waitForElement(`.elfsight-app-${WIDGET_ID}`).then(() => {
  const lsValue = localStorage.getItem(LOCAL_STORAGE_SELECTOR);

  if (!lsValue) {
    return;
  }

  try {
    const parsedValue = JSON.parse(lsValue);

    if (
      parsedValue &&
      typeof parsedValue === 'object' &&
      typeof parsedValue.value === 'string' &&
      typeof parsedValue.timestamp === 'number'
    ) {
      const currentTimestamp = Math.floor(Date.now() / 1000);
      const timestamp = parsedValue.timestamp;
      const resetThreshold = RESET_AFTER_HOURS * 60 * 60;

      if (currentTimestamp - timestamp >= resetThreshold) {
        localStorage.removeItem(LOCAL_STORAGE_SELECTOR);
        sessionStorage.removeItem(SESSION_STORAGE_SELECTOR);
      }
    }
  } catch (e) {
    console.error('Error parsing localStorage value:', e);
  }
});

Replace YOUR_WIDGET_ID in the 1st line of the code with the ID of your widget and add the resulted code to the Custom JS field on the Settings tab of your widget’s settings:


Give it a try and let us know if it worked for you :slightly_smiling_face:

1 Like