第一次申请个blog,在博客园安个家。希望大家常来窜门~~
这一段在编写DateEditor和配合使用的DatePicker的WebContorl,客户端使用htc实现。客户端的HTC组件通过 VimeJsFramework 实现强大的样式配制管理。
以下是 ClassTree:
-
以下是基本框架文件 VmSystem.js。
/*
Copyright (c) 2005 Vime. All rights reserved.
Version 1.0.1.18
对象基类支持。
*/
//支持 VimeJsFramework 类层次结构中的所有类,并为派生类提供低级别服务。
VmObject = function()
{
var hashCode = null;
this.GetHashCode = function VmObject_GetHashCode()
{
if(hashCode ==null)
hashCode = Math.round(Math.random()*10000);
return hashCode;
}
this.Equals = function VmObject_Equals(o)
{
if(VmObject.prototype.isPrototypeOf(o))
return o.GetHashCode() == this.GetHashCode();
new VmInterfaceException(this.GetType(),this.GetType()).Throw();
}
this.Dispose = function VmObject_Dispose()
{
}
this.GetType = function VmObject_GetType()
{
return "VmObject";
}
//Protected 获得调用方法的名称
this._GetFunctionName = function VmObject__GetFunctionName(s)
{
return s.substr(0,s.indexOf("{")).replace("function ","").replace("\r\n","").replace("\t","").replace(" ","").replace("_",".").replace("_","");
}
};
VmObject.prototype = new Object();
VmObject.Equals = function VmObject_Equals_(oa,ob)
{
if(!VmObject.prototype.isPrototypeOf(oa))
new VmInterfaceException("VmObject.Equals","VmObject").Throw();
if(!VmObject.prototype.isPrototypeOf(ob))
new VmInterfaceException("VmObject.Equals","VmObject").Throw();
return oa.GetHashCode() == ob.GetHashCode();
};
VmObject.prototype = new Object();
//VimeJsFrameWrok 信息
VmFrameWork = function()
{
this.GetType = function VmFrameWork_GetType()
{
return "VmFrameWork";
}
}
VmFrameWork.prototype = new VmObject();
VmFrameWork.Version = "1.00";
VmFrameWork.Author = "vme";
//有关浏览器的信息
VmBrowerInfo = function()
{
this.GetType = function VmBrowerInfo_GetType()
{
return "VmBrowerInfo";
}
var ua=navigator.userAgent;
this._IsIE= /msie/i.test(ua);
/MSIE\s+([^\);]+)(\)|;)/.test(ua);
this._IEVersion=RegExp.$1;
this._IsAboveVersion = function _VmBrowerInfo_IsAboveVersion(v)
{
var nv = parseFloat(this._IEVersion);
return nv>=v;
}
}
VmBrowerInfo.prototype = new VmObject();
var vmbi = new VmBrowerInfo();
VmBrowerInfo.IsIE = vmbi._IsIE;
VmBrowerInfo.IEVersion = vmbi._IEVersion;
VmBrowerInfo.IsAboveVersion = function(v)
{
return vmbi._IsAboveVersion(v);
}
//表示在程序执行期间发生的异常。
VmException = function(s,m)
{
this.GetType = function VmException_GetType()
{
return "VmException";
}
this.getSource = function VmException_getSource()
{
return s;
}
this.getMessage = function VmException_getMessage()
{
return m;
}
this._Throw = function VmException__Throw(e)
{
var invokeTrace = new Array();
var o=this.Throw.caller;
while(o!=null)
{
invokeTrace.push(this._GetFunctionName(o.toString()));
o=o.caller;
}
var deepthTab=" ";
var invokeString = "";
while(invokeTrace.length>0)
{
invokeString += deepthTab + ((deepthTab.length==4)?"":"┕") + invokeTrace.pop() + "\r\n";
deepthTab +=" ";
}
alert(e + "\r\n\r\n错误源: " + this.getSource() + "\r\n信息: " + this.getMessage() + "\r\n调用堆栈: \r\n" + invokeString);
throw this;
}
this.Throw = function VmException_Throw()
{
this._Throw(this.GetType());
}
};
VmException.prototype = new VmObject();
//不实现某类接口产生的异常。
VmInterfaceException = function(s,i)
{
this.GetType = function VmInterfaceException_GetType()
{
return "VmInterfaceException";
}
this.getSource = function VmInterfaceException_getSource()
{
return s;
}
this.getMessage = function VmInterfaceException_getMessage()
{
return "不实现某类接口产生的异常。" + "\r\n类接口: " + i;
}
this.Throw = function VmInterfaceException_Throw()
{
this._Throw(this.GetType());
}
};
VmInterfaceException.prototype = new VmException();
//在向方法提供的其中一个参数无效时引发的异常。
VmArgumentException = function(s,a)
{
this.GetType = function VmArgumentException_GetType()
{
return "VmArgumentException";
}
this.getSource = function VmArgumentException_getSource()
{
return s;
}
this.getMessage = function VmArgumentException_getMessage()
{
return "无效的参数。" + "\r\n参数名: " + a;
}
this.Throw = function VmArgumentException_Throw()
{
this._Throw(this.GetType());
}
}
VmArgumentException.prototype = new VmException();
//当参数值超出调用的方法所定义的允许取值范围时引发的异常。
VmArgumentOutOfRangeException = function(s,a)
{
this.GetType = function VmArgumentOutOfRangeException_GetType()
{
return "VmArgumentOutOfRangeException";
}
this.getSource = function VmArgumentOutOfRangeException_getSource()
{
return s;
}
this.getMessage = function VmArgumentOutOfRangeException_getMessage()
{
return "参数值超出调用的方法所定义的允许取值范围。" + "\r\n参数名: " + a;
}
this.Throw = function VmArgumentOutOfRangeException_Throw()
{
this._Throw(this.GetType());
}
}
VmArgumentOutOfRangeException.prototype = new VmException();
//表示可按照索引单独访问的一组对象。
VmCollectionBase = function()
{
this.GetType = function VmCollectionBase_GetType()
{
return "VmCollectionBase";
}
var c = new Array();
this.getCount = function VmCollectionBase_getCount()
{
return c.length;
}
this.getItem = function VmCollectionBase_getItem(index)
{
if(index<0 || index>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.getItem","index").Throw();
return c[index];
}
this.setItem = function VmCollectionBase_setItem(index,v)
{
if(index<0 || index>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.setItem","index").Throw();
c[index]=v;
}
this.Add = function VmCollectionBase_Add(v)
{
return c.push(v)-1;
}
this.Clear = function VmCollectionBase_Clear()
{
c.splice(0,c.length);
}
this.Contains = function VmCollectionBase_Contains(v)
{
return this.indexOf(v)!= -1;
}
this.IndexOf = function VmCollectionBase_IndexOf(v)
{
for(var j=0;j<c.length;j++)
{
if(c[j]==v)
return j;
}
return -1;
}
this.Insert = function VmCollectionBase_Insert(i,v)
{
if(i<0 || i>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.Insert","index").Throw();
c.splice(i,0,v);
}
this.Remove = function VmCollectionBase_Remove(v)
{
var i=this.IndexOf(v);
if(i!= -1)
c.splice(i,1);
}
this.RemoveAt = function VmCollectionBase_RemoveAt(i)
{
if(i<0 || i>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.RemoveAt","index").Throw();
c.splice(i,1);
}
}
VmCollectionBase.prototype = new VmObject();
//为枚举提供基类。
VmEnum = function()
{
this._Value = "";
this.GetType = function VmEnum_GetType()
{
return "VmEnum";
}
this.setValue = function VmEnum_setValue(name)
{
this._Value = this._GetValue(name);
}
this.getValue = function VmEnum_getValue()
{
return this._Value;
}
this._GetValue = function VmEnum__GetValue(name)
{
if(this[name]==null)
new VmArgumentOutOfRangeException("VmEnum._GetValue","name").Throw();
return this[name];
}
}
VmEnum.prototype = new VmObject();
////为位枚举提供基类。
VmFlagEnum = function()
{
this.GetType = function VmFlagEnum_GetType()
{
return "VmFlagEnum";
}
this._Value = 0;
this.And = function VmFlagEnum_Add(name)
{
this._Value &= parseInt(this._GetValue(name));
}
this.Or = function VmFlagEnum_Or(name)
{
this._Value |= parseInt(this._GetValue(name));
}
this.Xor = function VmFlagEnum_Xor(name)
{
this._Value ^= parseInt(this._GetValue(name));
}
}
VmFlagEnum.prototype = new VmEnum();
VmFlagEnum.And = function VmFlagEnum_And_(e1,e2)
{
if(!VmFlagEnum.prototype.isPrototypeOf(e1))
new VmInterfaceException("VmFlagEnum.And","VmFlagEnum").Throw();
if(!VmFlagEnum.prototype.isPrototypeOf(e2))
new VmInterfaceException("VmFlagEnum.And","VmFlagEnum").Throw();
return e1.getValue() & e2.getValue();
}
VmFlagEnum.Or = function VmFlagEnum_Or(e1,e2)
{
if(!VmFlagEnum.prototype.isPrototypeOf(e1))
new VmInterfaceException("VmFlagEnum.Or","VmFlagEnum").Throw();
if(!VmFlagEnum.prototype.isPrototypeOf(e2))
new VmInterfaceException("VmFlagEnum.Or","VmFlagEnum").Throw();
return e1.getValue() | e2.getValue();
}
VmFlagEnum.Xor = function VmFlagEnum_Xor_(e1,e2)
{
if(!VmFlagEnum.prototype.isPrototypeOf(e1))
new VmInterfaceException("VmFlagEnum.Xor","VmFlagEnum").Throw();
if(!VmFlagEnum.prototype.isPrototypeOf(e2))
new VmInterfaceException("VmFlagEnum.Xor","VmFlagEnum").Throw();
return e1.getValue() ^ e2.getValue();
}
//为事件的实现提供低级别服务。
VmEvent = function()
{
this.GetType = function VmEvent_GetType()
{
return "VmEvent";
}
var c = new VmCollectionBase();
this.AttachHandler = function VmEvent_AttachHandler(h)
{
c.Add(h);
}
this.RemoveHandler = function VmEvent_RemoveHandler(h)
{
c.Remove(h);
}
this.ActiveEvent = function VmEvent_ActiveEvent(args)
{
for(var i=0; i<c.getCount(); i++)
{
try
{
eval(c.getItem(i).toString() + "(args)");
}
catch(e)
{
new VmException("VmEvent",e.message).Throw();
}
}
}
}
VmCollectionBase.prototype = new VmObject();
//事件的数据类
VmEventArgs = function()
{
this.GetType = function VmEventArgs_GetType()
{
return "VmEventArgs";
}
}
VmEventArgs.prototype = new VmObject();
VmEventArgs.getEmpty = function VmEventArgs_getEmpty_()
{
return new VmEventArgs();
}
//将一个字符串类型数据转换为另一个基本数据类型。
VmConvert = function()
{
this.GetType = function VmConvert_GetType()
{
return "VmConvert";
}
}
VmConvert.prototype = new VmObject();
VmConvert.ToInt = function VmConvert_ToInt_(op)
{
var exp = /^\s*[-\+]?\d+\s*$/;
if (op.match(exp) == null)
return null;
var num = parseInt(op, 10);
return (isNaN(num) ? null : num);
}
VmConvert.ToDouble = function VmConvert_ToDouble_(op)
{
var exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\.(\\d+))?\\s*$");
var m = op.match(exp);
if (m == null)
return null;
var cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
var num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
}
VmConvert.ToCurrency = function VmConvert_ToCurrentcy_(op,digits)
{
var exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\,)*)(\\d+)"
+ ((digits > 0) ? "(\\.(\\d{1," + val.digits + "}))?" : "")
+ "\\s*$");
var m = op.match(exp);
if (m == null)
return null;
var intermed = m[2] + m[5] ;
var cleanInput = m[1] + intermed.replace(new RegExp("(\\,)", "g"), "") + ((digits > 0) ? "." + m[7] : 0);
var num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
}
VmConvert.ToDate = function VmConvert_ToConvert_(op,dateorder)
{
function GetFullYear(year) {
return (year + 1900);
}
var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$");
var m = op.match(yearFirstExp);
var day, month, year;
if (m != null && (m[2].length == 4 || dateorder == "ymd"))
{
day = m[6];
month = m[5];
year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10))
}
else
{
if (dateorder == "ymd")
{
return null;
}
var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");
m = op.match(yearLastExp);
if (m == null)
{
return null;
}
if (dateorder == "mdy")
{
day = m[3];
month = m[1];
}
else
{
day = m[1];
month = m[3];
}
year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10))
}
month -= 1;
var date = new Date(year, month, day);
return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null;
}
Copyright (c) 2005 Vime. All rights reserved.
Version 1.0.1.18
对象基类支持。
*/
//支持 VimeJsFramework 类层次结构中的所有类,并为派生类提供低级别服务。
VmObject = function()
{
var hashCode = null;
this.GetHashCode = function VmObject_GetHashCode()
{
if(hashCode ==null)
hashCode = Math.round(Math.random()*10000);
return hashCode;
}
this.Equals = function VmObject_Equals(o)
{
if(VmObject.prototype.isPrototypeOf(o))
return o.GetHashCode() == this.GetHashCode();
new VmInterfaceException(this.GetType(),this.GetType()).Throw();
}
this.Dispose = function VmObject_Dispose()
{
}
this.GetType = function VmObject_GetType()
{
return "VmObject";
}
//Protected 获得调用方法的名称
this._GetFunctionName = function VmObject__GetFunctionName(s)
{
return s.substr(0,s.indexOf("{")).replace("function ","").replace("\r\n","").replace("\t","").replace(" ","").replace("_",".").replace("_","");
}
};
VmObject.prototype = new Object();
VmObject.Equals = function VmObject_Equals_(oa,ob)
{
if(!VmObject.prototype.isPrototypeOf(oa))
new VmInterfaceException("VmObject.Equals","VmObject").Throw();
if(!VmObject.prototype.isPrototypeOf(ob))
new VmInterfaceException("VmObject.Equals","VmObject").Throw();
return oa.GetHashCode() == ob.GetHashCode();
};
VmObject.prototype = new Object();
//VimeJsFrameWrok 信息
VmFrameWork = function()
{
this.GetType = function VmFrameWork_GetType()
{
return "VmFrameWork";
}
}
VmFrameWork.prototype = new VmObject();
VmFrameWork.Version = "1.00";
VmFrameWork.Author = "vme";
//有关浏览器的信息
VmBrowerInfo = function()
{
this.GetType = function VmBrowerInfo_GetType()
{
return "VmBrowerInfo";
}
var ua=navigator.userAgent;
this._IsIE= /msie/i.test(ua);
/MSIE\s+([^\);]+)(\)|;)/.test(ua);
this._IEVersion=RegExp.$1;
this._IsAboveVersion = function _VmBrowerInfo_IsAboveVersion(v)
{
var nv = parseFloat(this._IEVersion);
return nv>=v;
}
}
VmBrowerInfo.prototype = new VmObject();
var vmbi = new VmBrowerInfo();
VmBrowerInfo.IsIE = vmbi._IsIE;
VmBrowerInfo.IEVersion = vmbi._IEVersion;
VmBrowerInfo.IsAboveVersion = function(v)
{
return vmbi._IsAboveVersion(v);
}
//表示在程序执行期间发生的异常。
VmException = function(s,m)
{
this.GetType = function VmException_GetType()
{
return "VmException";
}
this.getSource = function VmException_getSource()
{
return s;
}
this.getMessage = function VmException_getMessage()
{
return m;
}
this._Throw = function VmException__Throw(e)
{
var invokeTrace = new Array();
var o=this.Throw.caller;
while(o!=null)
{
invokeTrace.push(this._GetFunctionName(o.toString()));
o=o.caller;
}
var deepthTab=" ";
var invokeString = "";
while(invokeTrace.length>0)
{
invokeString += deepthTab + ((deepthTab.length==4)?"":"┕") + invokeTrace.pop() + "\r\n";
deepthTab +=" ";
}
alert(e + "\r\n\r\n错误源: " + this.getSource() + "\r\n信息: " + this.getMessage() + "\r\n调用堆栈: \r\n" + invokeString);
throw this;
}
this.Throw = function VmException_Throw()
{
this._Throw(this.GetType());
}
};
VmException.prototype = new VmObject();
//不实现某类接口产生的异常。
VmInterfaceException = function(s,i)
{
this.GetType = function VmInterfaceException_GetType()
{
return "VmInterfaceException";
}
this.getSource = function VmInterfaceException_getSource()
{
return s;
}
this.getMessage = function VmInterfaceException_getMessage()
{
return "不实现某类接口产生的异常。" + "\r\n类接口: " + i;
}
this.Throw = function VmInterfaceException_Throw()
{
this._Throw(this.GetType());
}
};
VmInterfaceException.prototype = new VmException();
//在向方法提供的其中一个参数无效时引发的异常。
VmArgumentException = function(s,a)
{
this.GetType = function VmArgumentException_GetType()
{
return "VmArgumentException";
}
this.getSource = function VmArgumentException_getSource()
{
return s;
}
this.getMessage = function VmArgumentException_getMessage()
{
return "无效的参数。" + "\r\n参数名: " + a;
}
this.Throw = function VmArgumentException_Throw()
{
this._Throw(this.GetType());
}
}
VmArgumentException.prototype = new VmException();
//当参数值超出调用的方法所定义的允许取值范围时引发的异常。
VmArgumentOutOfRangeException = function(s,a)
{
this.GetType = function VmArgumentOutOfRangeException_GetType()
{
return "VmArgumentOutOfRangeException";
}
this.getSource = function VmArgumentOutOfRangeException_getSource()
{
return s;
}
this.getMessage = function VmArgumentOutOfRangeException_getMessage()
{
return "参数值超出调用的方法所定义的允许取值范围。" + "\r\n参数名: " + a;
}
this.Throw = function VmArgumentOutOfRangeException_Throw()
{
this._Throw(this.GetType());
}
}
VmArgumentOutOfRangeException.prototype = new VmException();
//表示可按照索引单独访问的一组对象。
VmCollectionBase = function()
{
this.GetType = function VmCollectionBase_GetType()
{
return "VmCollectionBase";
}
var c = new Array();
this.getCount = function VmCollectionBase_getCount()
{
return c.length;
}
this.getItem = function VmCollectionBase_getItem(index)
{
if(index<0 || index>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.getItem","index").Throw();
return c[index];
}
this.setItem = function VmCollectionBase_setItem(index,v)
{
if(index<0 || index>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.setItem","index").Throw();
c[index]=v;
}
this.Add = function VmCollectionBase_Add(v)
{
return c.push(v)-1;
}
this.Clear = function VmCollectionBase_Clear()
{
c.splice(0,c.length);
}
this.Contains = function VmCollectionBase_Contains(v)
{
return this.indexOf(v)!= -1;
}
this.IndexOf = function VmCollectionBase_IndexOf(v)
{
for(var j=0;j<c.length;j++)
{
if(c[j]==v)
return j;
}
return -1;
}
this.Insert = function VmCollectionBase_Insert(i,v)
{
if(i<0 || i>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.Insert","index").Throw();
c.splice(i,0,v);
}
this.Remove = function VmCollectionBase_Remove(v)
{
var i=this.IndexOf(v);
if(i!= -1)
c.splice(i,1);
}
this.RemoveAt = function VmCollectionBase_RemoveAt(i)
{
if(i<0 || i>=c.length)
new VmArgumentOutOfRangeException("VmCollectionBase.RemoveAt","index").Throw();
c.splice(i,1);
}
}
VmCollectionBase.prototype = new VmObject();
//为枚举提供基类。
VmEnum = function()
{
this._Value = "";
this.GetType = function VmEnum_GetType()
{
return "VmEnum";
}
this.setValue = function VmEnum_setValue(name)
{
this._Value = this._GetValue(name);
}
this.getValue = function VmEnum_getValue()
{
return this._Value;
}
this._GetValue = function VmEnum__GetValue(name)
{
if(this[name]==null)
new VmArgumentOutOfRangeException("VmEnum._GetValue","name").Throw();
return this[name];
}
}
VmEnum.prototype = new VmObject();
////为位枚举提供基类。
VmFlagEnum = function()
{
this.GetType = function VmFlagEnum_GetType()
{
return "VmFlagEnum";
}
this._Value = 0;
this.And = function VmFlagEnum_Add(name)
{
this._Value &= parseInt(this._GetValue(name));
}
this.Or = function VmFlagEnum_Or(name)
{
this._Value |= parseInt(this._GetValue(name));
}
this.Xor = function VmFlagEnum_Xor(name)
{
this._Value ^= parseInt(this._GetValue(name));
}
}
VmFlagEnum.prototype = new VmEnum();
VmFlagEnum.And = function VmFlagEnum_And_(e1,e2)
{
if(!VmFlagEnum.prototype.isPrototypeOf(e1))
new VmInterfaceException("VmFlagEnum.And","VmFlagEnum").Throw();
if(!VmFlagEnum.prototype.isPrototypeOf(e2))
new VmInterfaceException("VmFlagEnum.And","VmFlagEnum").Throw();
return e1.getValue() & e2.getValue();
}
VmFlagEnum.Or = function VmFlagEnum_Or(e1,e2)
{
if(!VmFlagEnum.prototype.isPrototypeOf(e1))
new VmInterfaceException("VmFlagEnum.Or","VmFlagEnum").Throw();
if(!VmFlagEnum.prototype.isPrototypeOf(e2))
new VmInterfaceException("VmFlagEnum.Or","VmFlagEnum").Throw();
return e1.getValue() | e2.getValue();
}
VmFlagEnum.Xor = function VmFlagEnum_Xor_(e1,e2)
{
if(!VmFlagEnum.prototype.isPrototypeOf(e1))
new VmInterfaceException("VmFlagEnum.Xor","VmFlagEnum").Throw();
if(!VmFlagEnum.prototype.isPrototypeOf(e2))
new VmInterfaceException("VmFlagEnum.Xor","VmFlagEnum").Throw();
return e1.getValue() ^ e2.getValue();
}
//为事件的实现提供低级别服务。
VmEvent = function()
{
this.GetType = function VmEvent_GetType()
{
return "VmEvent";
}
var c = new VmCollectionBase();
this.AttachHandler = function VmEvent_AttachHandler(h)
{
c.Add(h);
}
this.RemoveHandler = function VmEvent_RemoveHandler(h)
{
c.Remove(h);
}
this.ActiveEvent = function VmEvent_ActiveEvent(args)
{
for(var i=0; i<c.getCount(); i++)
{
try
{
eval(c.getItem(i).toString() + "(args)");
}
catch(e)
{
new VmException("VmEvent",e.message).Throw();
}
}
}
}
VmCollectionBase.prototype = new VmObject();
//事件的数据类
VmEventArgs = function()
{
this.GetType = function VmEventArgs_GetType()
{
return "VmEventArgs";
}
}
VmEventArgs.prototype = new VmObject();
VmEventArgs.getEmpty = function VmEventArgs_getEmpty_()
{
return new VmEventArgs();
}
//将一个字符串类型数据转换为另一个基本数据类型。
VmConvert = function()
{
this.GetType = function VmConvert_GetType()
{
return "VmConvert";
}
}
VmConvert.prototype = new VmObject();
VmConvert.ToInt = function VmConvert_ToInt_(op)
{
var exp = /^\s*[-\+]?\d+\s*$/;
if (op.match(exp) == null)
return null;
var num = parseInt(op, 10);
return (isNaN(num) ? null : num);
}
VmConvert.ToDouble = function VmConvert_ToDouble_(op)
{
var exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\.(\\d+))?\\s*$");
var m = op.match(exp);
if (m == null)
return null;
var cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
var num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
}
VmConvert.ToCurrency = function VmConvert_ToCurrentcy_(op,digits)
{
var exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\,)*)(\\d+)"
+ ((digits > 0) ? "(\\.(\\d{1," + val.digits + "}))?" : "")
+ "\\s*$");
var m = op.match(exp);
if (m == null)
return null;
var intermed = m[2] + m[5] ;
var cleanInput = m[1] + intermed.replace(new RegExp("(\\,)", "g"), "") + ((digits > 0) ? "." + m[7] : 0);
var num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
}
VmConvert.ToDate = function VmConvert_ToConvert_(op,dateorder)
{
function GetFullYear(year) {
return (year + 1900);
}
var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$");
var m = op.match(yearFirstExp);
var day, month, year;
if (m != null && (m[2].length == 4 || dateorder == "ymd"))
{
day = m[6];
month = m[5];
year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10))
}
else
{
if (dateorder == "ymd")
{
return null;
}
var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");
m = op.match(yearLastExp);
if (m == null)
{
return null;
}
if (dateorder == "mdy")
{
day = m[3];
month = m[1];
}
else
{
day = m[1];
month = m[3];
}
year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10))
}
month -= 1;
var date = new Date(year, month, day);
return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null;
}