JavaScript is a very powerful Object Based language, but its support for Object Oriented still has some shortcomings. At the same time, JavaScript's built-in class library is relatively simple and even lacks all commonly used functions. ASP.NET Atlas extends JavaScript at runtime, greatly enhances its object-oriented support capabilities, and extends some commonly used operations during development.
I referred to the Atlas.js file and concluded that Atlas has the following extensions to JavaScript. There are some omissions or errors in some places, please forgive me and correct me.
Extension of String object
1. String String.ltrim()
Removes all spaces at the beginning of the original String and returns a new String object.
2. String String.rtrim()
Removes all spaces at the end of the original String and returns a new String object.
3. String String.trim()
Removes all spaces at the beginning and end of the original String and returns a new String object.
4. Boolean String.endsWidth(strEnd)
Whether this String ends with the passed in String.
5. Boolean String.startsWith(strStart)
Whether this String starts with the passed in String.
6. String String.format(args1,args2,.)
Similar to String.Format() in C#, {n} in the manipulated String will be replaced by the corresponding nth parameter and a new String object will be returned.
7. String String.removeSpaces()
Removes all spaces from the original String and returns a new String object.
8. String String.removeExtraSpaces()
Replace consecutive spaces in the original String with single spaces (including carriage returns) and return a new String object.
9. String String.removeSpaceDelimitedString(str)
Removes the specified words (text fragments separated by spaces) from the original String and returns a new String object. This method can be used when deleting a class name that contains DOM elements with multiple class names.
Extension of Array object
1. void Array.queue(objValue) and void Array.add(objValue)
Inserts the specified objValue into the end of this Array.
2. void Array.addRange(rangeArray)
Add the specified rangeArray to the end of the Array.
3. Boolean Array.contains(objValue) and Boolean Array.exists(objValue)
Returns a Boolean value representing whether the Array contains the objValue item.
4. Array Array.clone()
Returns a shallow copy of this Array.
5. void Array.insert(index, objValue)
Insert the specified objValue into the index position of the Array.
6. Object Array.dequeue()
Removes and returns the first entry in this Array.
7. Object Array.removeAt(index)
Removes and returns the entry at the specified index in this Array.
8.Boolean Array.remove(objValue)
Removes the specified objValue entry from the Array and returns a Boolean value indicating whether the entry exists and was successfully removed.
9. Array Array.parse(string)
Parse the incoming Array represented by string into an Array.
10. void Array.clear()
Clear all entries in this Array.
11. Integer Array.get_length()
Returns the number of entries in this Array, equivalent to Array.length.
12. Object Array.getItem(index)
Returns the entry at the specified index in this Array.
Extension of Date object
1. String Date.toFormattedString(stringFormat)
Format and output the Date object according to the input stringFormat (there are too many format strings... I am too lazy to write them. If you need them, just look at lines 748-871 in Atlas.js).
Extension of Number object
1. Number Number.parse(string)
Try to parse the incoming string as Number.
2. String Number.toFormattedString(stringFormat)
Format and output the Number object according to the input stringFormat (the format string is still too much... too lazy to write it, if you need it, just look at lines 935-1024 in Atlas.js).
The Sys.StringBuilder class
is 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
defines a base class that can be inherited
BaseClass = function()
{
// object
}
BaseClass.registerClass("BaseClass");
Inherited classDerivedClass
= function()
{
// Call base constructors
// The 2nd argument is an array you can use to pass arguments
DerivedClass.intializeBase(this,arguments);
}
DerivedClass.registerClass("DerivedClass","BaseClass");
Multiple
inheritanceMultipleInherit= function()
{
MultipleInherit.intializeBase(this,arguments); // bootstrap
// object
}
MultipleInherit.registerClass("MultipleInherit",["BaseClass", "DerivedClass"]);
Define methods that can be overridden
BaseClass = function()
{
// object
this.initialize = function()
{}
BaseClass.registerBaseMethod(this,"initialize");
}
BaseClass.registerClass("BaseClass");
Call the overridden method of the base class
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
defines the Enum type
var theEnum = Type.createEnum("name1","name2");
for (var strItems in theEnum.getValues())
{}
Define Flag type
var theFlags = Type.createFlags("name1",value1,"name2",value2,);