Javascript function Summary

Source: Internet
Author: User
// Whether the format is currency ####
Function IsCurrencyData (s ){
Var reg =/^ \ d *\.? \ D {0, 2} $ /;
Var result = reg.exe c (s );
If (! Result)
Return false;
Return true;
}
// Precise data to the index of the decimal point
Function ToFixed (data, index ){
Var num = new Number (data );
Var ret = num. toFixed (index );
Return ret;
}
// (Jquery) obtain the selected value of a set of mutex-on lists
Function GetCheckedRadiosValue (name ){
Var value = $ ("input: radio [name = '" + name + "'] [checked]"). val ();
Return value;
}
// Set the cookie value
Function SetCookie (name, value, expiredays)
{
Var exdate = new Date ();
Exdate. setDate (exdate. getDate () + expiredays)
Document. cookie = name + "=" + escape (value) +
(Expiredays = null )? "": "; Path =/; expires =" + exdate. toGMTString ());
}
// Obtain the cookie value
Function GetCookiesValue (name)
{
If (document. cookie. length> 0)
{
Var c_start = document. cookie. indexOf (name + "= ")
If (c_start! =-1)
{
C_start = c_start + name. length + 1
C_end = document. cookie. indexOf (";", c_start)
If (c_end =-1) c_end = document. cookie. length
Return unescape (document. cookie. substring (c_start, c_end ))
}
}
Return ""
}
 
Function DoubleLinkedList (){
Function Node (){
This. Value;
This. Next;
This. Pre;
}
This. Head = new Node ();
This. Head. Next = null;
This. Head. Pre = null;
This. Count = 0;
This. CurrentNode = this. Head;
This. PNode = this. Head;
This. Add = function (v ){
Var nNode = new Node ();
NNode. Value = v;
NNode. Next = null;
NNode. Pre = this. CurrentNode;
This. CurrentNode. Next = nNode;
This. CurrentNode = nNode;
This. Count ++;
}
This. IsEmpty = function (){
Return this. Count> 0;
}
This. GoNext = function (){
If (this. PNode. Next! = Null ){
This. PNode = this. PNode. Next;
Return this. PNode;
} Else {
This. PNode = this. Head;
Return null;
}
}
This. IsGoToEnd = function (){
Return this. PNode. Next = null;
}
This. GoPre = function (){
If (this. PNode. Pre! = Null ){
This. PNode = this. PNode. Pre;
Return this. PNode;
}
Else {
This. PNode = this. Head;
Return null;
}
}
This. Remove = function (v ){
Var node;
While (node = list. GoNext ())! = Null ){
If (node. Value = v ){
Node. Pre. Next = node. Next;
Node. Next. Pre = node. Pre;
Node = null;
This. Count --;
This. PNode = this. Head;
Break;
}
}
}
}

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.