cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              .container#app
  p.lead
    | delayが32bitを超えているとすぐ実行されてしまう。

  .card-deck
    .card(v-for="item in items")
      .card-header
        | {{ item.support }}
        br
        small.text-muted
          span.mr-1 delay:
          | {{ item.delay | separate }}
      .card-body
        h4.card-title(v-show="item.rest > 0")
          small.mr-2 あと
          | {{ item.rest | formatMsec | separate }}
          small.ml-1 秒
        h4.card-title(v-show="item.rest <= 0")
          | 完了
        
        p.card-text
          | {{ item.delay | formatTimestamp(startAt, "YYYY/M/D") }}
          | {{ item.delay | formatTimestamp(startAt, "HH:mm:ss") }}
          
        p.card-text
          | timeout: 
          span(v-show="item.isTimeoutDone", v-bind:class="{ 'badge-success': item.rest <= 0, 'badge-danger': item.rest > 0 }").ml-1.badge.badge-pill
            | Complete
            
          span(v-show="!item.isTimeoutDone").ml-1.badge.badge-pill.badge-secondary
            | Progress
        
        
            
          
!
            
              body {
  margin: 20px;
}

.text-white {
  .text-muted {
    color: rgba(#fff, .8) !important;
  }
}
            
          
!
            
              const value = {
  startAt: 0,  // 計測開始日時
  progressTime: 0,  // 経過ミリ秒
  items: [
    {
      delay: 5 * 1000, // 5秒
      rest: 0,
      isTimeoutDone: false,
      support: '5秒'
    },
    {
      delay: 60 * 1000, // 1分
      rest: 0,
      isTimeoutDone: false,
      support: '1分'
    },
    {
      delay: 2147483647,  // 32bit上限
      rest: 0,
      isTimeoutDone: false,
      support: '32ビットの最大値'
    },
    {
      delay: 2147483648,  // 32bit超える
      rest: 0,
      isTimeoutDone: false,
      support: '32ビットを超える値'
    }
  ]
};


const app = new Vue({
  el: '#app',
  data: value,
  
  mounted: function() {
    // 計測開始
    this.startAt = new Date().getTime();
    
    this.progress();

    setInterval(() => {
      this.progress();
    }, 1000);
    
    // setTimeoutを設定する
    this.items.forEach(function (value, index) {
      setTimeout(function () {
        value.isTimeoutDone = true;
      }, value.delay);
    });
  },
                    
  methods: {
    progress: function() {
      const progressTime = new Date().getTime() - this.startAt;
      this.progressTime = progressTime;
      
      // 計算し直す
      this.items.forEach(function (value, index) {
        value.rest = Math.max(value.delay - progressTime, 0); // 0を下回らないように
      });
    }
  },
  
  filters: {
    /**
     * 3桁ごとにカンマ
     *
     * @param num {number} 数値
     * @return {string} 3桁区切り
     */
    separate: function (num) {
      return String(num).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
    },
    
    /**
     * ミリ秒をフォーマットする
     *
     * @param msec {number} ミリ秒
     * @return {number} フォーマットした秒
     */
    formatMsec: function(msec) {
      // 小数点を省略
      return Math.round(msec / 1000);
    },
    
    /**
     * タイムスタンプをフォーマットする
     *
     * @param timestamp {number} タイムスタンプ
     * @param startAt {number} 基準時間
     * @param format {string} フォーマット
     * @return {string} フォーマットしたタイムスタンプ
     */
    formatTimestamp: function (timestamp, startAt, format = '') {
      return moment(startAt, 'x').add(timestamp, 'ms').format(format);
    }
  }
});


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console