/**/ /*
Patterns Mode
Public
Function Constructor ()
{
This. membername = value;
}
Constructor. Prototype. membername = value;
Private
Function Constructor ()
{
VaR self = this;
VaR membername = value;
Function membername (){}
}
Note: The function statement
Function membername (){}
Is shorthand
VaR membername = function membername (){};
Privileged privilege a privileged method can access private variables and methods while being visible to public domains. You can also delete or replace a privileged method, but cannot change it.
The privileged method is assigned in the constructor using this.
Function Constructor ()
{
This. membername = function ()
{
Self. membername;
};
}
Static
Constructor. method = function ()
{
This. member;
}
Add public method;
This technique is generally used to add public methods. When a member is retrieved and not found in the object, it obtains it from the prototype member of the object constructor.
This prototype mechanism can be used to implement inheritance. It also saves the memory. To add a method to all objects generated by a constructor, add the function to the prototype of the constructor:
Container. Prototype. mymethod = function ()
{
This. member;
}
*/
// Class mystring
Function Mystring (STRs)
{
VaR _ STR = STRs; // Private field;
This . Str = _ STR; // Public Field
// Public Method
This . Lefttrim = Function (Start)
{
RET=Lefttrim (This. STR, start); // This = new mystring (STRs );
ReturnRET;
}
// Private Method
Function Lefttrim (STR, start)
{
If (Str. Length > 0 && Str. indexof (start) = 0 )
{
Str=Str. substring (start. length, str. Length );
Str=Lefttrim (STR, start );
}
Return STR;
}
This . Righttrim = Function (End)
{
RET=Righttrim (_ STR, end );
Return ret;
}
Function Righttrim (STR, end)
{
If (Str. Length > 0 && Str. lastindexof (end) = Str. Length - End. length)
{
Str=Str. substring (0, Str. Length-End. Length );
Str=Righttrim (STR, end );
}
Return STR;
}
VaR Self = This ;
This . Trim = Function ()
{
Str=Righttrim (self. lefttrim (" "),"");
Return Str;
}
}
// Static Method
Mystring. lefttrim = Function (STR, start)
{
If (Str. Length > 0 && Str. indexof (start) = 0 )
{
Str=Str. substring (start. length, str. Length );
Str= This. Lefttrim (STR, start );
}
Return STR;
}
Mystring. righttrim = Function (STR, end)
{
If (Str. Length > 0 && Str. lastindexof (end) = Str. Length - End. length)
{
Str=Str. substring (0, Str. Length-End. Length );
Str= This. Righttrim (STR, end );
}
Return STR;
}
// End Class mystring
Mystring. Prototype = new string ();
Function Vr3d ()
{
// This. vr3d () = function (){}
This . Name;
This . Changename = Function (Name)
{
This. Name=Name;
}
This . Url;
This . Seturl = Function (URL)
{
This. Url=URL;
}
This . Geturl = Function ()
{
If(This. Url)
Return This. Url;
Else
Return "";
}
}