Programación Orientada a Objetos en Java usando la notación JSON.
JSON: JavaScript Object Notation.
La intensión del Script mostrar como definir una Clase en JavaScript. esta clase es parte del F.js, se utiliza para un servicio de mensajeria embedido en la aplicación de tipo chat.
/*Class 'popupMessage'*/function popupMessage(){/*Properties*/this.step = 5;
this.messageobject;
this.timeout =100;
this.readtime = 0;
this.timetoread = 5;
this.messagewidth = 205;
this.messageheight = 120;
this.minopacity = 25;
this.maxopacity = 95;
this.IsVisible = true;
/*SetMessageObject Method definition*/
this.SetMessageObject=function(obj){
try{
this.messageobject = obj;
}
catch(ex){
alert('SetMessageObject(): ' +ex.message);
}
}/*Show Method Definition*/
this.Show=function(){
try{
if (this.IsVisible){
this.messageobject.style.display = 'block';
this.messageobject.filters.alpha.opacity = 25;
this.step = 5;
this.PlaceMessage();
this.OpenMessage();
} else {
this.messageobject.style.display = 'none';
}
}
catch(ex){
alert('Show(): ' +ex.message);
}
} /*MoveMessage method definition*/
this.MoveMessage=function(offsetW, offsetH){
try{
this.messageobject.style.left=document.body.clientWidth - offsetW;
this.messageobject.style.top=document.body.clientHeight - offsetH;
}
catch(ex){
alert('MoveMessage(): ' +ex.message);
}
} /*PlaceMessage Method*/
this.PlaceMessage=function(){
try{
this.MoveMessage( this.messagewidth, this.messageheight);
}
catch(ex){
alert('PlaceMessage(): ' +ex.message);
}
}/*TimeToRead Method*/
this.TimeToRead=function(){
try{
if (this.readtime<this.timetoread){
this.readtime ++;
setTimeout('TimeToRead()',1000);
}
else
{
this.step = 1;
this.HideMessage();
}
}
catch(ex){
alert('TimeToRead(): ' +ex.message);
}
}/*OpenMessage Method*/
this.OpenMessage=function(){
try{
if (this.IsVisible){
if (this.messageobject.filters.alpha.opacity<this.maxopacity) {
this.messageobject.filters.alpha.opacity+=this.step;
setTimeout('OpenMessage()',this.timeout);
}
else{
this.readtime = 0;
this.TimeToRead();
}
} else {
this.messageobject.style.display = 'none';
}
}
catch(ex){
alert('OpenMessage(): ' + ex.message);
}
} /*HideMessage method*/
this.HideMessage=function(){
try{
if (this.messageobject.filters.alpha.opacity>this.minopacity) {
this.messageobject.filters.alpha.opacity-=this.step;
setTimeout('HideMessage()', this.timeout);
}
else
this.messageobject.style.display = 'none';
}
catch(ex){
alert('HideMessage(): ' +ex.message);
}
}
}//Para usar la clase solo hay que hacer lo siguiente.var objx=new popupMessage();objx.HideMessage();