Как я могу вызвать функции прототипа Javascript? - PullRequest
0 голосов
/ 24 сентября 2011

Это код Javascript для вызова Оповещения о функциях именно из Stage6 я полностью перестрою, чтобы вернуть к жизни :)

// 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';
        }
    }

Это функция прототипа из 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';
    }
}

Функция второго прототипа:

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';
    }
}

Мне нужен код HTML для этой функции. Это реверс-инжиниринг: =)

Вот картинка с 6 уровня http://img10.imageshack.us/img10/1733/83630697.png

Я все проверил, но у меня нет решения.

Надеюсь, кто-нибудь может мне помочь.

Ответы [ 2 ]

1 голос
/ 24 сентября 2011

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

1 голос
/ 24 сентября 2011

Не уверен, если вы пытаетесь определить функцию-прототип или вызываете одну из них:

Чтобы создать функцию-прототип:

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';
    }

};

замените nameYourFunction на то, что вы хотели бы назвать

тогда вы сможете назвать это так:

Alerts.nameYourFunction(2);

ИЛИ позвонить тому, кого вы добавили в свой вопрос:

Alerts.next();
...