ASP. NET Atlas extensions to Javascript

Source: Internet
Author: User

Author:Dflying Chen (Http://dflying.cnblogs.com/)

JavascriptIs a very powerful object-based (Object BasedBut for (Object Oriented).JavascriptThe built-in class libraries are also relatively simple, and even lack all common functions.ASP. NET AtlasExtended during runtimeJavascriptIt greatly enhances its object-oriented support capabilities and extends some common operations for development.

I have referencedAtlas. jsFile, summed upAtlasPairJavascriptThe following extensions are available. Some omissions or errors may occur. Please forgive me and correct me.

String object extension

  1. String string. ltrim ()
    Remove originalStringAll spaces at the beginning, and a newStringObject.
  2. String string. rtrim ()
    Remove originalStringAll spaces at the end, and a newStringObject.
  3. String string. Trim ()
    Remove originalStringAll spaces at the beginning and end, and a newStringObject.
  4. Boolean string. endswidth (strend)
    TheStringWhether to pass inStringEnd.
  5. Boolean string. startswith (strstart)
    TheStringWhether to pass inStringStart.
  6. String string. Format (args1, args2 ,.)
    SimilarC #InString. Format (), OperatedStringIn{N}Will be replaced by the correspondingNAnd return a newStringObject.
  7. String string. removespaces ()
    Remove originalStringAnd returns a newStringObject.
  8. String string. removeextraspaces ()
    Change the originalStringAnd returns a newStringObject.
  9. String string. removespacedelimitedstring (STR)
    Change the originalStringRemove the specified word (separated by spaces) in and return a newStringObject. This method can be used to delete multipleClassNameDomElementClassName.

Array object extension

  1. Void array. Queue (objvalue)AndVoid array. Add (objvalue)
    ObjvalueInsert to thisArray.
  2. Void array. addrange (rangearray)
    RangearrayJoin thisArray.
  3. Boolean array. Contains (objvalue)AndBoolean array. exists (objvalue)
    Returns a Boolean value representingArrayInclude or notObjvalueProject.
  4. Array array. Clone ()
    ReturnsArray.
  5. Void array. insert (index, objvalue)
    ObjvalueInsert to thisArrayOfIndexLocation.
  6. Object array. dequeue ()
    Remove and returnArrayThe first entry in.
  7. Object array. removeat (INDEX)
    Remove and returnArraySpecified inIndex.
  8. Boolean array. Remove (objvalue)
    Remove thisArraySpecified inObjvalueThe return Boolean value indicates whether the entry exists and is successfully removed.
  9. Array array. parse (string)
    TheStringRepresentsArrayResolvedArray.
  10. Void array. Clear ()
    ClearArrayAll entries in.
  11. Integer array. get_length ()
    ReturnsArrayNumber of entries, equivalentArray. Length.
  12. Object array. getitem (INDEX)
    ReturnsArraySpecified inIndex.

Date object extension

    1. String date. toformattedstring (stringformat)
      According to the inputStringformatFormat and outputDateObject (Format StringToo many ...... I am too lazy to write it. You need to read it directly.Atlas. jsMedium748-871All right ).

Number object extension

    1. Number number. parse (string)
      Try to parse the incomingStirngIsNumber.
    2. String number. toformattedstring (stringformat)
      According to the inputStringformatFormat and outputNumberObject (Format StringToo many ...... I am too lazy to write it. You need to read it directly.Atlas. jsMedium935-1024Rows ).

SYS. stringbuilder class

SimilarC #InStringbuilder:

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 writable (Override) Method

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

DefinitionEnumType

VaR Theenum = Type. createenum ( " Name1 " , " Name2 " );
For ( VaR Stritems In Theenum. getvalues ())
{
}

DefinitionFlagType

VaR Theflags = Type. createflags ( " Name1 " , Value1, " Name2 " , Value2 ,);

 

Related Article

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.