Skip to content

Instantly share code, notes, and snippets.

@peelman
Forked from roelentless/README.md
Created November 4, 2015 17:59
Show Gist options
  • Select an option

  • Save peelman/555e071be73d6ae5d9eb to your computer and use it in GitHub Desktop.

Select an option

Save peelman/555e071be73d6ae5d9eb to your computer and use it in GitHub Desktop.

Revisions

  1. @roelentless roelentless revised this gist Apr 15, 2013. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions countdown.coffee
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,12 @@ class Dashing.Countdown extends Dashing.Widget
    current_timestamp = Math.round(new Date().getTime()/1000)
    end_timestamp = Math.round( Date.parse($(@node).find(".more-info").html())/1000 )
    seconds_until_end = end_timestamp - current_timestamp
    if seconds_until_end < 0
    if seconds_until_end < 3600
    $(@node).parent().remove()
    else if seconds_until_end < 0
    @set('timeleft', "TIME UP!")
    for i in [0..100] by 1
    $(@node).fadeTo('fast', 0).fadeTo('fast', 1.0)
    return
    else
    d = Math.floor(seconds_until_end/86400)
    h = Math.floor((seconds_until_end-(d*86400))/3600)
  2. @roelentless roelentless revised this gist Apr 10, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -15,4 +15,4 @@ To include the widget in a dashboard, add the following snippet to the dashboard

    ##Preview

    TODO
    ![](http://s13.postimg.org/zc1c0wvbb/countdown.png)
  3. @roelentless roelentless created this gist Apr 10, 2013.
    18 changes: 18 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    ## Description

    Simple [Dashing](http://shopify.github.com/dashing) widget to countdown until a certain moment.
    Flashes the widget when finished.

    ##Usage

    To use this widget, copy `countdown.html`, `countdown.coffee`, and `countdown.scss` into the `/widgets/countdown` directory.

    To include the widget in a dashboard, add the following snippet to the dashboard layout file:

    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
    <div data-view="Countdown" data-title="GOAL_DISPLAY_NAME" data-end="26-Apr-2013 18:00:00"></div>
    </li>

    ##Preview

    TODO
    30 changes: 30 additions & 0 deletions countdown.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    class Dashing.Countdown extends Dashing.Widget

    ready: ->
    setInterval(@startCountdown, 500)

    startCountdown: =>
    current_timestamp = Math.round(new Date().getTime()/1000)
    end_timestamp = Math.round( Date.parse($(@node).find(".more-info").html())/1000 )
    seconds_until_end = end_timestamp - current_timestamp
    if seconds_until_end < 0
    @set('timeleft', "TIME UP!")
    for i in [0..100] by 1
    $(@node).fadeTo('fast', 0).fadeTo('fast', 1.0)
    return
    else
    d = Math.floor(seconds_until_end/86400)
    h = Math.floor((seconds_until_end-(d*86400))/3600)
    m = Math.floor((seconds_until_end-(d*86400)-(h*3600))/60)
    s = seconds_until_end-(d*86400)-(h*3600)-(m*60)
    if d >0
    dayname = 'day'
    if d > 1
    dayname = 'days'
    @set('timeleft', d + " "+dayname+" " + @formatTime(h) + ":" + @formatTime(m) + ":" + @formatTime(s))
    else
    @set('timeleft', @formatTime(h) + ":" + @formatTime(m) + ":" + @formatTime(s))


    formatTime: (i) ->
    if i < 10 then "0" + i else i
    6 changes: 6 additions & 0 deletions countdown.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    <h2 data-bind="title"></h2>

    <h1 data-bind="timeleft" class="countdown-time"></h1>

    <p class="before-more-info">ends on:</p>
    <p class="more-info" data-bind="end"></p>
    29 changes: 29 additions & 0 deletions countdown.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    // ----------------------------------------------------------------------------
    // Sass declarations
    // ----------------------------------------------------------------------------
    $background-color: #dc5945;

    // ----------------------------------------------------------------------------
    // Widget-clock styles
    // ----------------------------------------------------------------------------
    .widget-countdown {

    background-color: $background-color;

    h2 { font-size: 2em;}

    h1 { font-size: 2em;}

    .countdown-time {
    margin-top: 10px;
    color: gold;
    }

    .before-more-info {
    font-size: 15px;
    position: absolute;
    bottom: 52px;
    left: 0;
    right: 0;
    }
    }