Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript MOOTOLS计数器倒计时不工作_Javascript_Mootools - Fatal编程技术网

Javascript MOOTOLS计数器倒计时不工作

Javascript MOOTOLS计数器倒计时不工作,javascript,mootools,Javascript,Mootools,我得到了一个倒计时,但它看起来不起作用 我收到一条错误消息Uncaught ReferenceError:PeriodicalExecuter未在CountDown.js第36行定义(this.timer=new PeriodicalExecuter(this.update.bind(this),(this.options.frequency | | 1000)/1000);) 类PeriodicalExecuter似乎未包含在mootools中。希望有人有PeriodicalExecuter的

我得到了一个倒计时,但它看起来不起作用
我收到一条错误消息
Uncaught ReferenceError:PeriodicalExecuter未在CountDown.js第36行定义
this.timer=new PeriodicalExecuter(this.update.bind(this),(this.options.frequency | | 1000)/1000);

PeriodicalExecuter
似乎未包含在mootools中。希望有人有
PeriodicalExecuter
的代码,或者知道在哪里可以找到它

PeriodicalExecuter
应至少包括函数
stop()
registerCallback()

这是CountDown.js的代码供您参考

/*
---
script: CountDown.js
license: MIT-style license.
description: CountDown - a mootools countdown implementation.
copyright: Copyright (c) 2008 Thierry Bela
authors: [Thierry Bela]

requires: 
  core:1.2.3: 
  - Events
  - Options
provides: [CountDown]
...
*/

var CountDown = new Class({

    /* 

        options: {

            onChange: $empty,
            onComplete: $empty,
            date: null,
            frequency: 1000 //define the update frequency (in ms), default to 1000
        },

        */
    Implements: [Options, Events],
    initialize: function (options) {

        this.setOptions(options);
        if(!this.options.date instanceof Date) this.options.date = new Date(this.options.date);

        this.timer = new PeriodicalExecuter(this.update.bind(this), (this.options.frequency || 1000) / 1000);
    },
    stop: function () {

        this.timer.stop();          
        return this
    },
    start: function () {

        this.timer.registerCallback();          
        return this
    },
    update: function () {

        var millis = Math.max(0, this.options.date.getTime() - new Date().getTime()),
        time = Math.floor(millis / 1000),
        stop = time == 0,
        countdown = {

            days: Math.floor(time / (60 * 60 * 24)), 
            time: time,
            millis: millis
        };

        time %= (60 * 60 * 24);

        countdown.hours = Math.floor(time / (60 * 60));
        time %= (60 * 60);
        countdown.minutes = Math.floor(time / 60);
        countdown.second = time % 60;

        this.fireEvent('onChange', countdown);

        if(stop) {

            this.timer.stop();
            this.fireEvent('onComplete');
        }
    }
});
编辑

我正在使用兼容的Mootools 1.4.5版

您可以将类代码更改为使用标准方法

看起来,
.registerCallback
只是一个启动计时器的函数,即
setInterval
。 显然
.stop
停止计时器,即
clearInterval

PeriodicalExecuter
类似乎唯一要做的事情就是每次都将实例化时提供给它的参数传递给
setInterval
调用

这些信息足以让您自己实现它:)


最后,我在上面的站点中找到了js文件

顺便说一句,谢谢@Reanimation.
源代码与您所说的类似