[英]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 :) 这是从Stage6调用功能警报的Javascript代码,我将对其进行完全重建以使其恢复活动:)
// 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: 这是来自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. 我需要此功能的HTML代码。 It is reverse engineering :=) 这是逆向工程:=)
Here is the picture from Stage 6 http://img10.imageshack.us/img10/1733/83630697.png 这是第六阶段的图片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 将nameYourFunction
替换为您要调用的nameYourFunction
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()
mmm ... mmm .... var a = new Alerts(5); a.next()
var a = new Alerts(5); a.next()
???? var a = new Alerts(5); a.next()
????
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.