ASP. NET Atlas extensions to JavaScript

Source: Internet
Author: User

JavaScript is a very powerful Object-Based language, but there are still some shortcomings in support of object-oriented Object Oriented. At the same time, the built-in JavaScript class libraries are also relatively simple, it even lacks all the common functions. ASP. NET Atlas extends JavaScript at runtime, greatly enhances its object-oriented support capability, and extends some common operations for development.

I have referenced the Atlas. js file and concluded that Atlas has the following extensions for JavaScript. Some omissions or errors may occur. Please forgive me and correct me.

String object extension

1. String. ltrim ()
Removes all spaces starting with the original String and returns a New String object.

2. String. rtrim ()
Remove all spaces at the end of the original String and return a New String object.

3. String. trim ()
Removes all spaces starting and ending with the original String and returns a New String object.

4. Boolean String. endsWidth (strEnd)
Whether the String ends with the input String.

5. Boolean String. startsWith (strStart)
Whether the String starts with the input String.

6. String. format (args1, args2 ,.)
Similar to String. Format () in C #, {n} in the operated String is replaced with the corresponding nth parameter, and a new String object is returned.

7. String. removeSpaces ()
Remove all spaces from the original String and return a New String object.

8. String. removeExtraSpaces ()
Replace consecutive spaces in the original String with a single space, including carriage return), and return a New String object.

9. String. removeSpaceDelimitedString (str)
Remove the specified word segment separated by spaces in the original String, and return a New String object. This method can be used to delete a class name that contains multiple class names DOM elements.

Array object extension

1. void Array. queue (objValue) and void Array. add (objValue)
Insert the specified objValue to the end of the Array.

2. void Array. addRange (rangeArray)
Adds the specified rangeArray to the end of the Array.

3. Boolean Array. contains (objValue) and Boolean Array. exists (objValue)
Returns a Boolean value indicating whether the Array contains the objValue project.

4. Array. clone ()
Returns a shortest copy of the Array.

5. void Array. insert (index, objValue)
Insert the specified objValue to the index position of the Array.

6. Object Array. dequeue ()
Remove and return the first entry in the Array.

7. Object Array. removeAt (index)
Remove and return the specified index entries in the Array.

8. Boolean Array. remove (objValue)
Removes the specified objValue entry from the Array. The returned Boolean value indicates whether the entry exists and is successfully removed.

9. Array. parse (string)
Parses the input Array in string format into an Array.

10. void Array. clear ()
Clear all entries in the Array.

11. Integer Array. get_length ()
Returns the number of entries in the Array, which is equivalent to Array. length.

12. Object Array. getItem (index)
Returns the entry of the specified index in the Array.

Date object extension

1. String Date. toFormattedString (stringFormat)
Format and output the Date object according to the input stringFormat. There are too many format strings ...... If you are too lazy to write the code, you can directly check lines 748-871 in Atlas. js ).

Number object extension

1. Number. parse (string)
Try to parse the input stirng as Number.

2. String Number. toFormattedString (stringFormat)
Format and output the Number object according to the input stringFormat. The format string is too large ...... If you are too lazy to write it, you need to directly read the 935-1024 lines in Atlas. js ).

Sys. StringBuilder class

Similar to StringBuilder in C:

Var sb = new Sys. StringBuilder ();
Sb. append ("<div> ");
Sb. appendLine ("a line of text ");
Sb. append ("</div> ");
SomeDOMElem. innerHTML = sb. toString ();

Object-oriented support

Define a base class that can be inherited

BaseClass = function ()
{
// Object
}
BaseClass. registerClass ("BaseClass ");

Inheritance class

DerivedClass = function ()
{
// Call base constructors
// The 2nd argument is an array you can use to pass arguments
DerivedClass. intializeBase (this, arguments );
}
DerivedClass. registerClass ("DerivedClass", "BaseClass ");

Multi-Inheritance

MultipleInherit = function ()
{
MultipleInherit. intializeBase (this, arguments); // bootstrap
// Object
}
MultipleInherit. registerClass ("MultipleInherit", ["BaseClass", "DerivedClass"]);

Define override methods)

BaseClass = function ()
{
// Object
This. initialize = function ()
{}
BaseClass. registerBaseMethod (this, "initialize ");
}
BaseClass. registerClass ("BaseClass ");

Call the base class override method

DerivedClass = function ()
{
DerivedClass. initializeBase (this, arguments); // bootstrap
This. initialize = function ()
{
DerivedClass. getBaseMethod (this, "BaseClass", "initialize"). call (this );
// To pass arguments to base class:
//. Call (this, args1, args2, args3)
}
}
DerivedClass. registerClass ("DerivedClass", ["Atlas. Bindings. Base", "BaseClass"]);

Namespace

RegisterNamespace ("Web. Utility ");
// Implement Web Utility
RegisterNamespace ("Web. Performance ");
// Implement Performance

Define the Enum type

Var theEnum = Type. createEnum ("name1", "name2 ");
For (var strItems in theEnum. getValues ())
{}

Define the Flag type

Var theFlags = Type. createFlags ("name1", value1, "name2", value2 ,);
(

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.