开发者

How I can Call Javascript prototype functions?

This is the Javascript code to call the Function Alerts it is from Stage6 that I will fully rebuild to bring it back to live :)

// Alerts (in the header)
    function Alerts(total) {
        this.current_page = 1;
        this.last_page = Math.ceil(total / 4);
        if (this.current_page == this.last_page) {
            $('alert-next-button').className = 'alert-next-inactive';
        }
    }

This is the Prototype Function it is from DivX Stage6:

Alerts.prototype.next = function () {
    if (this.current_page == this.last_page) {
        return;
    }
    new Effect.BlindUp('alerts-' + this.current_page, {
        scaleFrom:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    new Effect.BlindDown('alerts-' + (this.current_page + 1), {
        scaleTo:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    this.current_page++;
    if (this.current_page > 1) {
        $('alert-prev-button').className = 'alert-prev';
    }
    if (this.current_page == this.last_page) {
        $('alert-next-button').className = 'alert-next-inactive';
    }
}

The Second Prototype function:

Alerts.prototype.previous = function () {
    if (this.current_page == 1) {
        return;
    }
    new Effect.BlindUp('alerts-' + this.current_page, {
        scaleFrom:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    new Effect.BlindDown('alerts-' + (this.current_page - 1), {
        scaleTo:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    this.current_page--;
    if (this.current_page == 1) {
        $('alert-prev-button').className = 'alert-开发者_运维百科prev-inactive';
    }
    if (this.current_page < this.last_page) {
        $('alert-next-button').className = 'alert-next';
    }
}

I need the HTML Code for this functions. It is reverse engineering :=)

Here is the picture from Stage 6 http://img10.imageshack.us/img10/1733/83630697.png

I have all tested but I have no solution.

Hope someone can help me out.


Not sure if you are trying to define a prototype function, or call one:

To make a prototype function:

Alerts.prototype.nameYourFunction = function(total) {
    this.current_page = 1;
    this.last_page = Math.ceil(total / 4);
    if (this.current_page == this.last_page) {
        $('alert-next-button').className = 'alert-next-inactive';
    }

};

replace nameYourFunction to whatever you would like to call it

then you'll be able to call it like so:

Alerts.nameYourFunction(2);

OR to call the one you added to your question:

Alerts.next();


mmm... mmm.... var a = new Alerts(5); a.next()????

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜