0

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.

3
  • What do you think is a prototype function here? Commented Sep 23, 2011 at 21:55
  • Please describe what you are trying to do. Are you trying to create a function or a persistent object with methods? Your use of this is normally associated with an object/methods, but I don't see any of that context. If you just want a function, then you can just change current_page and last_page to local variables and use it as a normal function. Commented Sep 23, 2011 at 21:55
  • Could it be that you are talking about Prototype.js and not prototype inheritance? Commented Sep 23, 2011 at 21:58

2 Answers 2

1

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();
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.