Skip to content

Persist across Browser sessions #58

@billiemead

Description

@billiemead

I set up a Flipdown countdown timer to calculate how much time between when the CMS page is published and Midnight EST (when a callback changes a CSS class that removes an overlay).

    var now = new Date();
    var night = new Date(
        now.getFullYear(),
        now.getMonth(),
        now.getDate() + 1, // the next day, ...
        0, 0, 0 // ...at 00:00:00 hours
    );
    var timeUntilMidnight = night.getTime() - now.getTime();

Now, I'd like to use localStorage to make sure the countdown persists and keeps on ticking!

    // get timer offset (if not found, set to today)
        var now = new Date( localStorage.getItem('countdown-offset') || new Date() );

        // store the offset
        localStorage.setItem('countdown-offset', offset);

But when the count actually starts, wouldn't I want to use something like onUpdate ? Im actually not sure!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions