)]}' {"version":3,"file":"project1.js","sources":["C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/rtl.js","C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/system.pas","C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/rtlconsts.pas","C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/types.pas","C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/js.pas","C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/sysutils.pas","C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/classes.pas","C:/fpc2js/pas2js-windows-0.9.25/packages/rtl/web.pas","C:/fpc2js/projects/projJ/lib/umutationobserver.pas","C:/fpc2js/projects/projJ/lib/jelement.pas","C:/fpc2js/projects/projJ/lib/jform.pas","C:/fpc2js/projects/projJ/lib/japplication.pas","C:/fpc2js/projects/projJ/lib/jglobals.pas","C:/fpc2js/projects/projJ/lib/jpanel.pas","C:/fpc2js/projects/projJ/lib/jlistbox.pas","C:/fpc2js/projects/projJ/lib/jbutton.pas","C:/fpc2js/projects/projJ/lib/jimage.pas","C:/fpc2js/projects/projJ/lib/jtoolbar.pas","C:/fpc2js/projects/projJ/lib/jprogressbar.pas","C:/fpc2js/projects/projJ/lib/jsplitter.pas","C:/fpc2js/projects/projJ/form1.pas","C:/fpc2js/projects/projJ/project1.lpr"],"sourcesContent":["var pas = {};\n\nvar rtl = {\n\n quiet: false,\n debug_load_units: false,\n debug_rtti: false,\n\n debug: function(){\n if (rtl.quiet || !console || !console.log) return;\n console.log(arguments);\n },\n\n error: function(s){\n rtl.debug('Error: ',s);\n throw s;\n },\n\n warn: function(s){\n rtl.debug('Warn: ',s);\n },\n\n hasString: function(s){\n return rtl.isString(s) && (s.length>0);\n },\n\n isArray: function(a) {\n return Array.isArray(a);\n },\n\n isFunction: function(f){\n return typeof(f)===\"function\";\n },\n\n isModule: function(m){\n return rtl.isObject(m) && rtl.hasString(m.$name) && (pas[m.$name]===m);\n },\n\n isImplementation: function(m){\n return rtl.isObject(m) && rtl.isModule(m.$module) && (m.$module.$impl===m);\n },\n\n isNumber: function(n){\n return typeof(n)===\"number\";\n },\n\n isObject: function(o){\n var s=typeof(o);\n return (typeof(o)===\"object\") && (o!=null);\n },\n\n isString: function(s){\n return typeof(s)===\"string\";\n },\n\n getNumber: function(n){\n return typeof(n)===\"number\"?n:NaN;\n },\n\n getChar: function(c){\n return ((typeof(c)===\"string\") && (c.length===1)) ? c : \"\";\n },\n\n getObject: function(o){\n return ((typeof(o)===\"object\") || (typeof(o)==='function')) ? o : null;\n },\n\n isPasClass: function(type){\n return (rtl.isObject(type) && type.hasOwnProperty('$classname') && rtl.isObject(type.$module));\n },\n\n isPasClassInstance: function(type){\n return (rtl.isObject(type) && rtl.isPasClass(type.$class));\n },\n\n hexStr: function(n,digits){\n return (\"000000000000000\"+n.toString(16).toUpperCase()).slice(-digits);\n },\n\n m_loading: 0,\n m_loading_intf: 1,\n m_intf_loaded: 2,\n m_loading_impl: 3, // loading all used unit\n m_initializing: 4, // running initialization\n m_initialized: 5,\n\n module: function(module_name, intfuseslist, intfcode, impluseslist, implcode){\n if (rtl.debug_load_units) rtl.debug('rtl.module name=\"'+module_name+'\" intfuses='+intfuseslist+' impluses='+impluseslist+' hasimplcode='+rtl.isFunction(implcode));\n if (!rtl.hasString(module_name)) rtl.error('invalid module name \"'+module_name+'\"');\n if (!rtl.isArray(intfuseslist)) rtl.error('invalid interface useslist of \"'+module_name+'\"');\n if (!rtl.isFunction(intfcode)) rtl.error('invalid interface code of \"'+module_name+'\"');\n if (!(impluseslist==undefined) && !rtl.isArray(impluseslist)) rtl.error('invalid implementation useslist of \"'+module_name+'\"');\n if (!(implcode==undefined) && !rtl.isFunction(implcode)) rtl.error('invalid implementation code of \"'+module_name+'\"');\n\n if (pas[module_name])\n rtl.error('module \"'+module_name+'\" is already registered');\n\n var module = pas[module_name] = {\n $name: module_name,\n $intfuseslist: intfuseslist,\n $impluseslist: impluseslist,\n $state: rtl.m_loading,\n $intfcode: intfcode,\n $implcode: implcode,\n $impl: null,\n $rtti: Object.create(rtl.tSectionRTTI)\n };\n module.$rtti.$module = module;\n if (implcode) module.$impl = {\n $module: module,\n $rtti: module.$rtti\n };\n },\n\n exitcode: 0,\n\n run: function(module_name){\n \n function doRun(){\n if (!rtl.hasString(module_name)) module_name='program';\n if (rtl.debug_load_units) rtl.debug('rtl.run module=\"'+module_name+'\"');\n rtl.initRTTI();\n var module = pas[module_name];\n if (!module) rtl.error('rtl.run module \"'+module_name+'\" missing');\n rtl.loadintf(module);\n rtl.loadimpl(module);\n if (module_name=='program'){\n if (rtl.debug_load_units) rtl.debug('running $main');\n var r = pas.program.$main();\n if (rtl.isNumber(r)) rtl.exitcode = r;\n }\n }\n \n if (rtl.showUncaughtExceptions) {\n try{\n doRun();\n } catch(re) {\n var errMsg = re.hasOwnProperty('$class') ? re.$class.$classname : '';\n\t errMsg += ((errMsg) ? ': ' : '') + (re.hasOwnProperty('fMessage') ? re.fMessage : re);\n alert('Uncaught Exception : '+errMsg);\n rtl.exitCode = 216;\n }\n } else {\n doRun();\n }\n return rtl.exitcode;\n },\n\n loadintf: function(module){\n if (module.$state>rtl.m_loading_intf) return; // already finished\n if (rtl.debug_load_units) rtl.debug('loadintf: \"'+module.$name+'\"');\n if (module.$state===rtl.m_loading_intf)\n rtl.error('unit cycle detected \"'+module.$name+'\"');\n module.$state=rtl.m_loading_intf;\n // load interfaces of interface useslist\n rtl.loaduseslist(module,module.$intfuseslist,rtl.loadintf);\n // run interface\n if (rtl.debug_load_units) rtl.debug('loadintf: run intf of \"'+module.$name+'\"');\n module.$intfcode(module.$intfuseslist);\n // success\n module.$state=rtl.m_intf_loaded;\n // Note: units only used in implementations are not yet loaded (not even their interfaces)\n },\n\n loaduseslist: function(module,useslist,f){\n if (useslist==undefined) return;\n for (var i in useslist){\n var unitname=useslist[i];\n if (rtl.debug_load_units) rtl.debug('loaduseslist of \"'+module.$name+'\" uses=\"'+unitname+'\"');\n if (pas[unitname]==undefined)\n rtl.error('module \"'+module.$name+'\" misses \"'+unitname+'\"');\n f(pas[unitname]);\n }\n },\n\n loadimpl: function(module){\n if (module.$state>=rtl.m_loading_impl) return; // already processing\n if (module.$state0){\n o = this[newinstancefnname](fnname,args);\n } else {\n o = Object.create(this);\n }\n o.$class = this; // Note: o.$class === Object.getPrototypeOf(o)\n o.$init();\n try{\n o[fnname].apply(o,args);\n if (o.AfterConstruction) o.AfterConstruction();\n } catch($e){\n o.$destroy;\n throw $e;\n }\n return o;\n };\n c.$destroy = function(fnname){\n if (this.BeforeDestruction) this.BeforeDestruction();\n this[fnname]();\n this.$final;\n };\n rtl.initClass(c,parent,name,initfn);\n },\n\n tObjectDestroy: \"Destroy\",\n\n free: function(obj,name){\n if (obj[name]==null) return;\n obj[name].$destroy(rtl.tObjectDestroy);\n obj[name]=null;\n },\n\n freeLoc: function(obj){\n if (obj==null) return;\n obj.$destroy(rtl.tObjectDestroy);\n return null;\n },\n\n is: function(instance,type){\n return type.isPrototypeOf(instance) || (instance===type);\n },\n\n isExt: function(instance,type,mode){\n // mode===1 means instance must be a Pascal class instance\n // mode===2 means instance must be a Pascal class\n // Notes:\n // isPrototypeOf and instanceof return false on equal\n // isPrototypeOf does not work for Date.isPrototypeOf(new Date())\n // so if isPrototypeOf is false test with instanceof\n // instanceof needs a function on right side\n if (instance == null) return false; // Note: ==null checks for undefined too\n if ((typeof(type) !== 'object') && (typeof(type) !== 'function')) return false;\n if (instance === type){\n if (mode===1) return false;\n if (mode===2) return rtl.isPasClass(instance);\n return true;\n }\n if (type.isPrototypeOf && type.isPrototypeOf(instance)){\n if (mode===1) return rtl.isPasClassInstance(instance);\n if (mode===2) return rtl.isPasClass(instance);\n return true;\n }\n if ((typeof type == 'function') && (instance instanceof type)) return true;\n return false;\n },\n\n Exception: null,\n EInvalidCast: null,\n EAbstractError: null,\n ERangeError: null,\n\n raiseE: function(typename){\n var t = rtl[typename];\n if (t==null){\n var mod = pas.SysUtils;\n if (!mod) mod = pas.sysutils;\n if (mod){\n t = mod[typename];\n if (!t) t = mod[typename.toLowerCase()];\n if (!t) t = mod['Exception'];\n if (!t) t = mod['exception'];\n }\n }\n if (t){\n if (t.Create){\n throw t.$create(\"Create\");\n } else if (t.create){\n throw t.$create(\"create\");\n }\n }\n if (typename === \"EInvalidCast\") throw \"invalid type cast\";\n if (typename === \"EAbstractError\") throw \"Abstract method called\";\n if (typename === \"ERangeError\") throw \"range error\";\n throw typename;\n },\n\n as: function(instance,type){\n if((instance === null) || rtl.is(instance,type)) return instance;\n rtl.raiseE(\"EInvalidCast\");\n },\n\n asExt: function(instance,type,mode){\n if((instance === null) || rtl.isExt(instance,type,mode)) return instance;\n rtl.raiseE(\"EInvalidCast\");\n },\n\n createInterface: function(module, name, guid, fnnames, ancestor, initfn){\n //console.log('createInterface name=\"'+name+'\" guid=\"'+guid+'\" names='+fnnames);\n var i = ancestor?Object.create(ancestor):{};\n module[name] = i;\n i.$module = module;\n i.$name = name;\n i.$fullname = module.$name+'.'+name;\n i.$guid = guid;\n i.$guidr = null;\n i.$names = fnnames?fnnames:[];\n if (rtl.isFunction(initfn)){\n // rtti\n if (rtl.debug_rtti) rtl.debug('createInterface '+i.$fullname);\n var t = i.$module.$rtti.$Interface(name,{ \"interface\": i, module: module });\n i.$rtti = t;\n if (ancestor) t.ancestor = ancestor.$rtti;\n if (!t.ancestor) t.ancestor = null;\n initfn.call(i);\n }\n return i;\n },\n\n strToGUIDR: function(s,g){\n var p = 0;\n function n(l){\n var h = s.substr(p,l);\n p+=l;\n return parseInt(h,16);\n }\n p+=1; // skip {\n g.D1 = n(8);\n p+=1; // skip -\n g.D2 = n(4);\n p+=1; // skip -\n g.D3 = n(4);\n p+=1; // skip -\n if (!g.D4) g.D4=[];\n g.D4[0] = n(2);\n g.D4[1] = n(2);\n p+=1; // skip -\n for(var i=2; i<8; i++) g.D4[i] = n(2);\n return g;\n },\n\n guidrToStr: function(g){\n if (g.$intf) return g.$intf.$guid;\n var h = rtl.hexStr;\n var s='{'+h(g.D1,8)+'-'+h(g.D2,4)+'-'+h(g.D3,4)+'-'+h(g.D4[0],2)+h(g.D4[1],2)+'-';\n for (var i=2; i<8; i++) s+=h(g.D4[i],2);\n s+='}';\n return s;\n },\n\n createTGUID: function(guid){\n var TGuid = (pas.System)?pas.System.TGuid:pas.system.tguid;\n var g = rtl.strToGUIDR(guid,new TGuid());\n return g;\n },\n\n getIntfGUIDR: function(intfTypeOrVar){\n if (!intfTypeOrVar) return null;\n if (!intfTypeOrVar.$guidr){\n var g = rtl.createTGUID(intfTypeOrVar.$guid);\n if (!intfTypeOrVar.hasOwnProperty('$guid')) intfTypeOrVar = Object.getPrototypeOf(intfTypeOrVar);\n g.$intf = intfTypeOrVar;\n intfTypeOrVar.$guidr = g;\n }\n return intfTypeOrVar.$guidr;\n },\n\n addIntf: function (aclass, intf, map){\n function jmp(fn){\n if (typeof(fn)===\"function\"){\n return function(){ return fn.apply(this.$o,arguments); };\n } else {\n return function(){ rtl.raiseE('EAbstractError'); };\n }\n }\n if(!map) map = {};\n var t = intf;\n var item = Object.create(t);\n aclass.$intfmaps[intf.$guid] = item;\n do{\n var names = t.$names;\n if (!names) break;\n for (var i=0; i=minval) && (i<=maxval)) return i;\n rtl.raiseE('ERangeError');\n },\n\n rcc: function(c,minval,maxval){\n // range check char\n if ((typeof(c)==='string') && (c.length===1)){\n var i = c.charCodeAt(0);\n if ((i>=minval) && (i<=maxval)) return c;\n }\n rtl.raiseE('ERangeError');\n },\n\n rcSetCharAt: function(s,index,c){\n // range check setCharAt\n if ((typeof(s)!=='string') || (index<0) || (index>=s.length)) rtl.raiseE('ERangeError');\n return rtl.setCharAt(s,index,c);\n },\n\n rcCharAt: function(s,index){\n // range check charAt\n if ((typeof(s)!=='string') || (index<0) || (index>=s.length)) rtl.raiseE('ERangeError');\n return s.charAt(index);\n },\n\n rcArrR: function(arr,index){\n // range check read array\n if (Array.isArray(arr) && (typeof(index)==='number') && (index>=0) && (index2){\n // arr,index1,index2,...\n arr=arr[index];\n for (var i=2; i=0) && (indexsrcarray.length) end = srcarray.length;\n if (index>=end) return [];\n if (type===0){\n return srcarray.slice(index,end);\n } else {\n var a = [];\n a.length = end-index;\n rtl.arrayClone(type,srcarray,index,end,a,0);\n return a;\n }\n },\n\n setCharAt: function(s,index,c){\n return s.substr(0,index)+c+s.substr(index+1);\n },\n\n getResStr: function(mod,name){\n var rs = mod.$resourcestrings[name];\n return rs.current?rs.current:rs.org;\n },\n\n createSet: function(){\n var s = {};\n for (var i=0; i newlen){\n return s.substring(0,newlen);\n } else if (s.repeat){\n // Note: repeat needs ECMAScript6!\n return s+' '.repeat(newlen-oldlen);\n } else {\n while (oldlen=width) return s;\n if (s.repeat){\n // Note: repeat needs ECMAScript6!\n return ' '.repeat(width-l) + s;\n } else {\n while (l2){\n return rtl.spaceLeft(d.toFixed(p),w);\n } else {\n\t // exponent width\n\t var pad = \"\";\n\t var ad = Math.abs(d);\n\t if (ad<1.0e+10) {\n\t\tpad='00';\n\t } else if (ad<1.0e+100) {\n\t\tpad='0';\n } \t\n\t if (arguments.length<2) {\n\t w=9;\t\t\n } else if (w<9) {\n\t\tw=9;\n }\t\t \n var p = w-8;\n var s=(d>0 ? \" \" : \"\" ) + d.toExponential(p);\n s=s.replace(/e(.)/,'E$1'+pad);\n return rtl.spaceLeft(s,w);\n }\n },\n\n initRTTI: function(){\n if (rtl.debug_rtti) rtl.debug('initRTTI');\n\n // base types\n rtl.tTypeInfo = { name: \"tTypeInfo\" };\n function newBaseTI(name,kind,ancestor){\n if (!ancestor) ancestor = rtl.tTypeInfo;\n if (rtl.debug_rtti) rtl.debug('initRTTI.newBaseTI \"'+name+'\" '+kind+' (\"'+ancestor.name+'\")');\n var t = Object.create(ancestor);\n t.name = name;\n t.kind = kind;\n rtl[name] = t;\n return t;\n };\n function newBaseInt(name,minvalue,maxvalue,ordtype){\n var t = newBaseTI(name,1 /* tkInteger */,rtl.tTypeInfoInteger);\n t.minvalue = minvalue;\n t.maxvalue = maxvalue;\n t.ordtype = ordtype;\n return t;\n };\n newBaseTI(\"tTypeInfoInteger\",1 /* tkInteger */);\n newBaseInt(\"shortint\",-0x80,0x7f,0);\n newBaseInt(\"byte\",0,0xff,1);\n newBaseInt(\"smallint\",-0x8000,0x7fff,2);\n newBaseInt(\"word\",0,0xffff,3);\n newBaseInt(\"longint\",-0x80000000,0x7fffffff,4);\n newBaseInt(\"longword\",0,0xffffffff,5);\n newBaseInt(\"nativeint\",-0x10000000000000,0xfffffffffffff,6);\n newBaseInt(\"nativeuint\",0,0xfffffffffffff,7);\n newBaseTI(\"char\",2 /* tkChar */);\n newBaseTI(\"string\",3 /* tkString */);\n newBaseTI(\"tTypeInfoEnum\",4 /* tkEnumeration */,rtl.tTypeInfoInteger);\n newBaseTI(\"tTypeInfoSet\",5 /* tkSet */);\n newBaseTI(\"double\",6 /* tkDouble */);\n newBaseTI(\"boolean\",7 /* tkBool */);\n newBaseTI(\"tTypeInfoProcVar\",8 /* tkProcVar */);\n newBaseTI(\"tTypeInfoMethodVar\",9 /* tkMethod */,rtl.tTypeInfoProcVar);\n newBaseTI(\"tTypeInfoArray\",10 /* tkArray */);\n newBaseTI(\"tTypeInfoDynArray\",11 /* tkDynArray */);\n newBaseTI(\"tTypeInfoPointer\",15 /* tkPointer */);\n var t = newBaseTI(\"pointer\",15 /* tkPointer */,rtl.tTypeInfoPointer);\n t.reftype = null;\n newBaseTI(\"jsvalue\",16 /* tkJSValue */);\n newBaseTI(\"tTypeInfoRefToProcVar\",17 /* tkRefToProcVar */,rtl.tTypeInfoProcVar);\n\n // member kinds\n rtl.tTypeMember = {};\n function newMember(name,kind){\n var m = Object.create(rtl.tTypeMember);\n m.name = name;\n m.kind = kind;\n rtl[name] = m;\n };\n newMember(\"tTypeMemberField\",1); // tmkField\n newMember(\"tTypeMemberMethod\",2); // tmkMethod\n newMember(\"tTypeMemberProperty\",3); // tmkProperty\n\n // base object for storing members: a simple object\n rtl.tTypeMembers = {};\n\n // tTypeInfoStruct - base object for tTypeInfoClass, tTypeInfoRecord, tTypeInfoInterface\n var tis = newBaseTI(\"tTypeInfoStruct\",0);\n tis.$addMember = function(name,ancestor,options){\n if (rtl.debug_rtti){\n if (!rtl.hasString(name) || (name.charAt()==='$')) throw 'invalid member \"'+name+'\", this=\"'+this.name+'\"';\n if (!rtl.is(ancestor,rtl.tTypeMember)) throw 'invalid ancestor \"'+ancestor+':'+ancestor.name+'\", \"'+this.name+'.'+name+'\"';\n if ((options!=undefined) && (typeof(options)!='object')) throw 'invalid options \"'+options+'\", \"'+this.name+'.'+name+'\"';\n };\n var t = Object.create(ancestor);\n t.name = name;\n this.members[name] = t;\n this.names.push(name);\n if (rtl.isObject(options)){\n for (var key in options) if (options.hasOwnProperty(key)) t[key] = options[key];\n };\n return t;\n };\n tis.addField = function(name,type,options){\n var t = this.$addMember(name,rtl.tTypeMemberField,options);\n if (rtl.debug_rtti){\n if (!rtl.is(type,rtl.tTypeInfo)) throw 'invalid type \"'+type+'\", \"'+this.name+'.'+name+'\"';\n };\n t.typeinfo = type;\n this.fields.push(name);\n return t;\n };\n tis.addFields = function(){\n var i=0;\n while(i0) ? S.substring(Index-1,Index+Size-1) : \"\";\r\nend;\r\n\r\nfunction Copy(const S: string; Index: Integer): String; assembler;\r\nasm\r\n if (Index<1) Index = 1;\r\n return S.substr(Index-1);\r\nend;\r\n\r\nprocedure Delete(var S: String; Index, Size: Integer);\r\nvar\r\n h: String;\r\nbegin\r\n if (Index<1) or (Index>length(S)) or (Size<=0) then exit;\r\n h:=S;\r\n S:=copy(h,1,Index-1)+copy(h,Index+Size);\r\nend;\r\n\r\nfunction Pos(const Search, InString: String): Integer; assembler;\r\nasm\r\n return InString.indexOf(Search)+1;\r\nend;\r\n\r\nfunction Pos(const Search, InString: String; StartAt : Integer): Integer; assembler; overload;\r\n\r\nasm\r\n return InString.indexOf(Search,StartAt-1)+1;\r\nend;\r\n\r\n\r\n\r\nprocedure Insert(const Insertion: String; var Target: String; Index: Integer);\r\nvar\r\n t: String;\r\nbegin\r\n if Insertion='' then exit;\r\n t:=Target;\r\n if Index<1 then\r\n Target:=Insertion+t\r\n else if Index>length(t) then\r\n Target:=t+Insertion\r\n else\r\n Target:=copy(t,1,Index-1)+Insertion+copy(t,Index,length(t));\r\nend;\r\n\r\nvar\r\n WriteBuf: String;\r\n JSArguments: array of JSValue; external name 'arguments';\r\n WriteCallBack : TConsoleHandler;\r\n\r\nFunction SetWriteCallBack(H : TConsoleHandler) : TConsoleHandler;\r\n\r\nbegin\r\n Result:=WriteCallBack;\r\n WriteCallBack:=H;\r\nend;\r\n\r\nprocedure Write;\r\nvar\r\n i: Integer;\r\nbegin\r\n for i:=0 to length(JSArguments)-1 do\r\n if Assigned(WriteCallBack) then\r\n WriteCallBack(JSArguments[i],False)\r\n else\r\n WriteBuf:=WriteBuf+String(JSArguments[i]);\r\nend;\r\n\r\nprocedure Writeln;\r\n\r\nvar\r\n i,l: Integer;\r\n s: String;\r\n\r\nbegin\r\n L:=length(JSArguments)-1;\r\n if Assigned(WriteCallBack) then\r\n begin\r\n for i:=0 to L do\r\n WriteCallBack(JSArguments[i],I=L);\r\n end\r\n else\r\n begin\r\n s:=WriteBuf;\r\n for i:=0 to L do\r\n s:=s+String(JSArguments[i]);\r\n asm\r\n console.log(s);\r\n end;\r\n WriteBuf:='';\r\n end;\r\nend;\r\n\r\nfunction Int(const A: Double): double;\r\n\r\n function FTrunc(const A: Double): double; overload; external name 'Math.trunc';\r\n\r\nbegin\r\n Result:=FTrunc(A);\r\nend;\r\n\r\nfunction Number(S: String): Double; external name 'Number';\r\n\r\nprocedure val(const S: String; out NI : NativeInt; out Code: Integer);\r\n\r\nvar\r\n x : double;\r\n\r\nbegin\r\n Code:=0;\r\n x:=Number(S);\r\n if isNaN(x) or (X<>Int(X)) then\r\n Code:=1\r\n else\r\n NI:=Trunc(x);\r\nend;\r\n\r\nprocedure val(const S: String; out SI : ShortInt; out Code: Integer);\r\n\r\nvar\r\n X:Double;\r\nbegin\r\n Code:=0;\r\n x:=Number(S);\r\n if isNaN(x) or (X<>Int(X)) then\r\n Code:=1\r\n else if (xMaxShortInt) then\r\n Code:=2\r\n else\r\n SI:=Trunc(x);\r\nend;\r\n\r\nprocedure val(const S: String; out SI: smallint; out Code: Integer);\r\n\r\nvar\r\n x: double;\r\nbegin\r\n Code:=0;\r\n x:=Number(S);\r\n if isNaN(x) or (X<>Int(X)) then\r\n Code:=1\r\n else if (xMaxSmallint) then\r\n Code:=2\r\n else\r\n SI:=Trunc(x);\r\nend;\r\n\r\nprocedure val(const S: String; out C: Cardinal; out Code: Integer);\r\n\r\nvar\r\n x: double;\r\nbegin\r\n Code:=0;\r\n x:=Number(S);\r\n if isNaN(x) or (X<>Int(X)) then\r\n Code:=1\r\n else if (x<0) or (x>MaxCardinal) then\r\n Code:=2\r\n else\r\n C:=trunc(x);\r\nend;\r\n\r\nprocedure val(const S: String; out B: Byte; out Code: Integer);\r\n\r\nvar\r\n x: double;\r\nbegin\r\n Code:=0;\r\n x:=Number(S);\r\n if isNaN(x) or (X<>Int(X)) then\r\n Code:=1\r\n else if (x<0) or (x>MaxByte) then\r\n Code:=2\r\n else\r\n B:=Trunc(x);\r\nend;\r\n\r\n\r\nprocedure val(const S: String; out W: word; out Code: Integer);\r\n\r\nvar\r\n x: double;\r\nbegin\r\n Code:=0;\r\n x:=Number(S);\r\n if isNaN(x) then\r\n Code:=1\r\n else if (x<0) or (x>MaxWord) then\r\n Code:=2\r\n else\r\n W:=Trunc(x);\r\nend;\r\n\r\nprocedure val(const S : String; out I : integer; out Code : Integer);\r\nvar\r\n x: double;\r\nbegin\r\n Code:=0;\r\n x:=Number(S);\r\n if isNaN(x) then\r\n Code:=1\r\n else if x>MaxInt then\r\n Code:=2\r\n else\r\n I:=Trunc(x);\r\nend;\r\n\r\nprocedure val(const S : String; out d : double; out Code : Integer);\r\n\r\nVar\r\n x: double;\r\nbegin\r\n x:=Number(S);\r\n if isNaN(x) then\r\n Code:=1\r\n else\r\n begin\r\n Code:=0;\r\n d:=x;\r\n end;\r\nend;\r\n\r\nfunction upcase(c : char) : char; assembler;\r\n\r\nasm\r\n return c.toUpperCase();\r\nend;\r\n\r\nfunction StringOfChar(c: Char; l: NativeInt): String;\r\nvar\r\n i: Integer;\r\nbegin\r\n Result:='';\r\n for i:=1 to l do Result:=Result+c;\r\nend;\r\n\r\nfunction Assigned(const V: JSValue): boolean; assembler;\r\nasm\r\n return (V!=undefined) && (V!=null) && (!rtl.isArray(V) || (V.length > 0));\r\nend;\r\n\r\nfunction StrictEqual(const A: JSValue; const B): boolean; assembler;\r\nasm\r\n return A === B;\r\nend;\r\n\r\nfunction StrictInequal(const A: JSValue; const B): boolean; assembler;\r\nasm\r\n return A !== B;\r\nend;\r\n\r\n{ TContainedObject }\r\n\r\nfunction TContainedObject.QueryInterface(const iid: TGuid; out obj): Integer;\r\nbegin\r\n if GetInterface(iid,obj) then\r\n Result:=S_OK\r\n else\r\n Result:=Integer(E_NOINTERFACE);\r\nend;\r\n\r\n{ TAggregatedObject }\r\n\r\nfunction TAggregatedObject.GetController: IUnknown;\r\nbegin\r\n Result := IUnknown(fController);\r\nend;\r\n\r\nfunction TAggregatedObject.QueryInterface(const iid: TGuid; out obj): Integer;\r\nbegin\r\n Result := IUnknown(fController).QueryInterface(iid, obj);\r\nend;\r\n\r\nfunction TAggregatedObject._AddRef: Integer;\r\nbegin\r\n Result := IUnknown(fController)._AddRef;\r\nend;\r\n\r\nfunction TAggregatedObject._Release: Integer;\r\nbegin\r\n Result := IUnknown(fController)._Release;\r\nend;\r\n\r\nconstructor TAggregatedObject.Create(const aController: IUnknown);\r\nbegin\r\n inherited Create;\r\n { do not keep a counted reference to the controller! }\r\n fController := Pointer(aController);\r\nend;\r\n\r\n{ TInterfacedObject }\r\n\r\nfunction TInterfacedObject.QueryInterface(const iid: TGuid; out obj): Integer;\r\nbegin\r\n if GetInterface(iid,obj) then\r\n Result:=S_OK\r\n else\r\n Result:=Integer(E_NOINTERFACE);\r\nend;\r\n\r\nfunction TInterfacedObject._AddRef: Integer;\r\nbegin\r\n inc(fRefCount);\r\n Result:=fRefCount;\r\nend;\r\n\r\nfunction TInterfacedObject._Release: Integer;\r\nbegin\r\n dec(fRefCount);\r\n Result:=fRefCount;\r\n if fRefCount=0 then\r\n Destroy;\r\nend;\r\n\r\nprocedure TInterfacedObject.BeforeDestruction;\r\nbegin\r\n if fRefCount<>0 then\r\n asm\r\n rtl.raiseE('EHeapMemoryError');\r\n end;\r\nend;\r\n\r\n{ TObject }\r\n\r\nconstructor TObject.Create;\r\nbegin\r\n\r\nend;\r\n\r\ndestructor TObject.Destroy;\r\nbegin\r\n\r\nend;\r\n\r\nprocedure TObject.Free;\r\nbegin\r\n Destroy;\r\nend;\r\n\r\nclass function TObject.ClassType: TClass; assembler;\r\nasm\r\n return this;\r\nend;\r\n\r\nclass function TObject.ClassNameIs(const Name: string): boolean;\r\nbegin\r\n Result:=SameText(Name,ClassName);\r\nend;\r\n\r\nclass function TObject.InheritsFrom(aClass: TClass): boolean; assembler;\r\nasm\r\n return (aClass!=null) && ((this==aClass) || aClass.isPrototypeOf(this));\r\nend;\r\n\r\nprocedure TObject.AfterConstruction;\r\nbegin\r\n\r\nend;\r\n\r\nprocedure TObject.BeforeDestruction;\r\nbegin\r\n\r\nend;\r\n\r\nfunction TObject.GetInterface(const iid: TGuid; out obj): boolean;\r\nbegin\r\n asm\r\n var i = iid.$intf;\r\n if (i){\r\n i = rtl.getIntfG(this,i.$guid,2);\r\n if (i){\r\n obj.set(i);\r\n return true;\r\n }\r\n }\r\n end;\r\n Result := GetInterfaceByStr(GUIDToString(iid),obj);\r\nend;\r\n\r\nfunction TObject.GetInterface(const iidstr: String; out obj): boolean;\r\nbegin\r\n Result := GetInterfaceByStr(iidstr,obj);\r\nend;\r\n\r\nfunction TObject.GetInterfaceByStr(const iidstr: String; out obj): boolean;\r\nbegin\r\n if (iidstr = IObjectInstance) then\r\n begin\r\n obj:=Self;\r\n exit(true);\r\n end;\r\n asm\r\n var i = rtl.getIntfG(this,iidstr,2);\r\n obj.set(i);\r\n return i!==null;\r\n end;\r\n Result:=false;\r\nend;\r\n\r\nfunction TObject.GetInterfaceWeak(const iid: TGuid; out obj): boolean;\r\nbegin\r\n Result:=GetInterface(iid,obj);\r\n asm\r\n if (Result){\r\n var o = obj.get();\r\n if (o.$kind==='com'){\r\n o._Release();\r\n }\r\n }\r\n end;\r\nend;\r\n\r\nfunction TObject.Equals(Obj: TObject): boolean;\r\nbegin\r\n Result:=Obj=Self;\r\nend;\r\n\r\nfunction TObject.ToString: String;\r\nbegin\r\n Result:=ClassName;\r\nend;\r\n\r\n\r\ninitialization\r\n ExitCode:=0; // set it here, so that WPO does not remove it\r\n\r\nend.\r\n\r\n","{\r\n This file is part of the Pas2JS run time library.\r\n Copyright (c) 2017 by Mattias Gaertner\r\n\r\n See the file COPYING.FPC, included in this distribution,\r\n for details about the copyright.\r\n\r\n This program is distributed in the hope that it will be useful,\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n **********************************************************************}\r\nunit RTLConsts;\r\n\r\ninterface\r\n\r\nconst\r\n SArgumentMissing = 'Missing argument in format \"%s\"';\r\n SInvalidFormat = 'Invalid format specifier : \"%s\"';\r\n SInvalidArgIndex = 'Invalid argument index in format: \"%s\"';\r\n SListCapacityError = 'List capacity (%s) exceeded.';\r\n SListCountError = 'List count (%s) out of bounds.';\r\n SListIndexError = 'List index (%s) out of bounds';\r\n SSortedListError = 'Operation not allowed on sorted list';\r\n SDuplicateString = 'String list does not allow duplicates'; \r\n SErrFindNeedsSortedList = 'Cannot use find on unsorted list';\r\n\r\n SInvalidName = 'Invalid component name: \"%s\"';\r\n SInvalidBoolean = '\"%s\" is not a valid boolean.';\r\n SDuplicateName = 'Duplicate component name: \"%s\"';\r\n\r\n SErrInvalidDate = 'Invalid date: \"%s\"';\r\n SErrInvalidTimeFormat = 'Invalid time format: \"%s\"';\r\n SInvalidDateFormat = 'Invalid date format: \"%s\"';\r\n\r\n SCantReadPropertyS = 'Cannot read property \"%s\"';\r\n SCantWritePropertyS = 'Cannot write property \"%s\"';\r\n SErrPropertyNotFound = 'Unknown property: \"%s\"';\r\n SIndexedPropertyNeedsParams = 'Indexed property \"%s\" needs parameters';\r\n\r\n SErrInvalidInteger = 'Invalid integer value: \"%s\"';\r\n SErrInvalidFloat = 'Invalid floating-point value: \"%s\"';\r\n SInvalidDateTime = 'Invalid date-time value: %s';\r\n SInvalidCurrency = 'Invalid currency value: %s';\r\n SErrInvalidDayOfWeek = '%d is not a valid day of the week';\r\n SErrInvalidTimeStamp = 'Invalid date/timestamp : \"%s\"';\r\n SErrInvalidDateWeek = '%d %d %d is not a valid dateweek';\r\n SErrInvalidDayOfYear = 'Year %d does not have a day number %d';\r\n SErrInvalidDateMonthWeek = 'Year %d, month %d, Week %d and day %d is not a valid date.';\r\n SErrInvalidDayOfWeekInMonth = 'Year %d Month %d NDow %d DOW %d is not a valid date';\r\n SInvalidJulianDate = '%f Julian cannot be represented as a DateTime';\r\n SErrInvalidHourMinuteSecMsec = '%d:%d:%d.%d is not a valid time specification';\r\n\r\n SInvalidGUID = '\"%s\" is not a valid GUID value';\r\n\r\nimplementation\r\n\r\nend.\r\n\r\n","{\r\n This file is part of the Pas2JS run time library.\r\n Copyright (c) 2018 by Mattias Gaertner\r\n\r\n See the file COPYING.FPC, included in this distribution,\r\n for details about the copyright.\r\n\r\n This program is distributed in the hope that it will be useful,\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n **********************************************************************}\r\nunit Types;\r\n\r\n{$mode objfpc}\r\n\r\ninterface\r\n\r\ntype\r\n TDirection = (FromBeginning, FromEnd);\r\n\r\n TBooleanDynArray = array of Boolean;\r\n TIntegerDynArray = array of Integer;\r\n TStringDynArray = array of String;\r\n TDoubleDynArray = array of Double;\r\n TJSValueDynArray = array of JSValue;\r\n\r\n TDuplicates = (dupIgnore, dupAccept, dupError);\r\n\r\n TListCallback = procedure(data, arg: JSValue) of object;\r\n TListStaticCallback = procedure(data, arg: JSValue);\r\n\r\n TSize = record\r\n cx, cy: integer;\r\n end;\r\n\r\n TPoint = record\r\n x, y: integer;\r\n end;\r\n\r\n TRect = record\r\n Left, Top, Right, Bottom: Integer;\r\n end;\r\n\r\nfunction EqualRect(const r1,r2 : TRect) : Boolean;\r\nfunction Rect(Left, Top, Right, Bottom : Integer) : TRect;\r\nfunction Bounds(ALeft, ATop, AWidth, AHeight : Integer) : TRect;\r\nfunction Point(x,y : Integer): TPoint; {$IFDEF Has_Inline}inline;{$ENDIF}\r\nfunction PtInRect(const aRect: TRect; const p: TPoint) : Boolean;\r\nfunction IntersectRect(out aRect: TRect; const R1,R2: TRect) : Boolean;\r\nfunction UnionRect(out aRect: TRect; const R1,R2: TRect) : Boolean;\r\nfunction IsRectEmpty(const aRect: TRect) : Boolean;\r\nfunction OffsetRect(var aRect: TRect; DX, DY: Integer) : Boolean;\r\nfunction CenterPoint(const aRect: TRect): TPoint;\r\nfunction InflateRect(var aRect: TRect; dx, dy: Integer): Boolean;\r\nfunction Size(AWidth, AHeight: Integer): TSize;\r\nfunction Size(const aRect: TRect): TSize;\r\n\r\nimplementation\r\n\r\nfunction EqualRect(const r1, r2: TRect): Boolean;\r\nbegin\r\n Result:=(r1.left=r2.left) and (r1.right=r2.right) and (r1.top=r2.top) and (r1.bottom=r2.bottom);\r\nend;\r\n\r\nfunction Rect(Left, Top, Right, Bottom: Integer): TRect;\r\nbegin\r\n Result.Left:=Left;\r\n Result.Top:=Top;\r\n Result.Right:=Right;\r\n Result.Bottom:=Bottom;\r\nend;\r\n\r\nfunction Bounds(ALeft, ATop, AWidth, AHeight: Integer): TRect;\r\nbegin\r\n Result.Left:=ALeft;\r\n Result.Top:=ATop;\r\n Result.Right:=ALeft+AWidth;\r\n Result.Bottom:=ATop+AHeight;\r\nend;\r\n\r\nfunction Point(x, y: Integer): TPoint;\r\nbegin\r\n Result.x:=x;\r\n Result.y:=y;\r\nend;\r\n\r\nfunction PtInRect(const aRect: TRect; const p: TPoint): Boolean;\r\nbegin\r\n Result:=(p.y>=aRect.Top) and\r\n (p.y=aRect.Left) and\r\n (p.x R1.Left then\r\n lRect.Left := R2.Left;\r\n if R2.Top > R1.Top then\r\n lRect.Top := R2.Top;\r\n if R2.Right < R1.Right then\r\n lRect.Right := R2.Right;\r\n if R2.Bottom < R1.Bottom then\r\n lRect.Bottom := R2.Bottom;\r\n\r\n // The var parameter is only assigned in the end to avoid problems\r\n // when passing the same rectangle in the var and const parameters.\r\n if IsRectEmpty(lRect) then\r\n begin\r\n aRect:=Rect(0,0,0,0);\r\n Result:=false;\r\n end\r\n else\r\n begin\r\n Result:=true;\r\n aRect := lRect;\r\n end;\r\nend;\r\n\r\nfunction UnionRect(out aRect: TRect; const R1, R2: TRect): Boolean;\r\nvar\r\n lRect: TRect;\r\nbegin\r\n lRect:=R1;\r\n if R2.LeftR1.Right then\r\n lRect.Right:=R2.Right;\r\n if R2.Bottom>R1.Bottom then\r\n lRect.Bottom:=R2.Bottom;\r\n\r\n if IsRectEmpty(lRect) then\r\n begin\r\n aRect:=Rect(0,0,0,0);\r\n Result:=false;\r\n end\r\n else\r\n begin\r\n aRect:=lRect;\r\n Result:=true;\r\n end;\r\nend;\r\n\r\nfunction IsRectEmpty(const aRect: TRect): Boolean;\r\nbegin\r\n Result:=(aRect.Right<=aRect.Left) or (aRect.Bottom<=aRect.Top);\r\nend;\r\n\r\nfunction OffsetRect(var aRect: TRect; DX, DY: Integer): Boolean;\r\nbegin\r\n with aRect do\r\n begin\r\n inc(Left,dx);\r\n inc(Top,dy);\r\n inc(Right,dx);\r\n inc(Bottom,dy);\r\n end;\r\n Result:=true;\r\nend;\r\n\r\nfunction CenterPoint(const aRect: TRect): TPoint;\r\n\r\n function Avg(a, b: Longint): Longint;\r\n begin\r\n if a < b then\r\n Result := a + ((b - a) shr 1)\r\n else\r\n Result := b + ((a - b) shr 1);\r\n end;\r\n\r\nbegin\r\n with aRect do\r\n begin\r\n Result.X := Avg(Left, Right);\r\n Result.Y := Avg(Top, Bottom);\r\n end;\r\nend;\r\n\r\nfunction InflateRect(var aRect: TRect; dx, dy: Integer): Boolean;\r\nbegin\r\n with aRect do\r\n begin\r\n dec(Left, dx);\r\n dec(Top, dy);\r\n inc(Right, dx);\r\n inc(Bottom, dy);\r\n end;\r\n Result := True;\r\nend;\r\n\r\nfunction Size(AWidth, AHeight: Integer): TSize;\r\nbegin\r\n Result.cx := AWidth;\r\n Result.cy := AHeight;\r\nend;\r\n\r\nfunction Size(const aRect: TRect): TSize;\r\nbegin\r\n Result.cx := aRect.Right - aRect.Left;\r\n Result.cy := aRect.Bottom - aRect.Top;\r\nend;\r\n\r\nend.\r\n\r\n","{\r\n This file is part of the Pas2JS run time library.\r\n Copyright (c) 2017 by Mattias Gaertner\r\n\r\n See the file COPYING.FPC, included in this distribution,\r\n for details about the copyright.\r\n\r\n This program is distributed in the hope that it will be useful,\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n **********************************************************************}\r\nunit JS;\r\n\r\n{$mode objfpc}\r\n{$modeswitch externalclass}\r\n\r\ninterface\r\n\r\nuses\r\n Types;\r\n\r\ntype\r\n // We cannot use EConvertError or Exception, this would result in a circular dependency.\r\n\r\n { EJS }\r\n\r\n EJS = class(TObject)\r\n private\r\n FMessage: string;\r\n Public\r\n constructor Create(const Msg: String); reintroduce;\r\n property Message : string Read FMessage Write FMessage;\r\n end;\r\n\r\n TJSObjectPropertyDescriptor = JSValue;\r\n Float32 = Double;\r\n Float64 = Double;\r\n\r\n { TJSObject }\r\n\r\n TJSObject = class external name 'Object'\r\n private\r\n function GetProperties(Name: String): JSValue; external name '[]';\r\n procedure SetProperties(Name: String; const AValue: JSValue); external name '[]';\r\n public\r\n constructor new;\r\n class function create(const proto: TJSObject): TJSObject;\r\n class function create(const proto, propertiesObject: TJSObject): TJSObject;\r\n class function assign(const Target, Source1: TJSObject): TJSObject; varargs;\r\n class procedure defineProperty(const obj: TJSObject; propname: String; const descriptor: TJSObjectPropertyDescriptor);\r\n //class procedure defineProperties\r\n class function freeze(const obj: TJSObject): TJSObject;\r\n class function getOwnPropertyDescriptor(const obj: TJSObject; propname: String): TJSObjectPropertyDescriptor;\r\n //class function getOwnPropertyDescriptors\r\n class function getOwnPropertyNames(const obj: TJSObject): TStringDynArray;\r\n {$IFDEF FIREFOX}\r\n class function getOwnPropertySymbols(const obj: TJSObject): TJSValueDynArray;\r\n {$ENDIF}\r\n class function getPrototypeOf(const obj: TJSObject): TJSObject;\r\n {$IFDEF FIREFOX}\r\n class function _is(const value1, value2: JSValue): boolean;\r\n {$ENDIF}\r\n class function isExtensible(const obj: TJSObject): boolean;\r\n class function isFrozen(const obj: TJSObject): boolean;\r\n class function isSealed(const obj: TJSObject): boolean;\r\n class function keys(const obj: TJSObject): TStringDynArray;\r\n class function preventExtensions(const obj: TJSObject): TJSObject;\r\n class function seal(const obj: TJSObject): TJSObject;\r\n class function setPrototypeOf(const obj, prototype: TJSObject): TJSObject;\r\n function hasOwnProperty(prop: String): boolean;\r\n function isPrototypeOf(const obj: TJSObject): boolean;\r\n function propertyIsEnumerable(propname: String): boolean;\r\n function toLocaleString: String;\r\n function toString: String;\r\n function valueOf: JSValue;\r\n property Properties[Name: String]: JSValue read GetProperties write SetProperties; default;\r\n end;\r\n\r\n TJSObjectDynArray = Array of TJSObject;\r\n TJSObjectDynArrayArray = Array of TJSObjectDynArray;\r\n TJSStringDynArray = Array of String;\r\n\r\n { TJSFunction }\r\n\r\n TJSFunction = class external name 'Function'(TJSObject)\r\n private\r\n Flength: NativeInt external name 'length';\r\n Fprototyp: TJSFunction external name 'prototyp';\r\n public\r\n name: String;\r\n property prototyp: TJSFunction read Fprototyp;\r\n property length: NativeInt read Flength;\r\n function apply(thisArg: TJSObject; const ArgArray: TJSValueDynArray): JSValue; varargs;\r\n function bind(thisArg: TJSObject): JSValue; varargs;\r\n function call(thisArg: TJSObject): JSValue; varargs;\r\n end;\r\n\r\n { TJSDate - wrapper for JavaScript Date }\r\n\r\n TJSDate = class external name 'Date'(TJSFunction)\r\n private\r\n function getDate: NativeInt;\r\n function getFullYear: NativeInt;\r\n function getHours: NativeInt;\r\n function getMilliseconds: NativeInt;\r\n function getMinutes: NativeInt;\r\n function getMonth: NativeInt;\r\n function getSeconds: NativeInt;\r\n function getYear: NativeInt;\r\n function getTime: NativeInt;\r\n function getUTCDate: NativeInt;\r\n function getUTCFullYear: NativeInt;\r\n function getUTCHours: NativeInt;\r\n function getUTCMilliseconds: NativeInt;\r\n function getUTCMinutes: NativeInt;\r\n function getUTCMonth: NativeInt;\r\n function getUTCSeconds: NativeInt;\r\n procedure setDate(const AValue: NativeInt);\r\n procedure setFullYear(const AValue: NativeInt);\r\n procedure setHours(const AValue: NativeInt);\r\n procedure setMilliseconds(const AValue: NativeInt);\r\n procedure setMinutes(const AValue: NativeInt);\r\n procedure setMonth(const AValue: NativeInt);\r\n procedure setSeconds(const AValue: NativeInt);\r\n procedure setYear(const AValue: NativeInt);\r\n procedure setTime(const AValue: NativeInt);\r\n procedure setUTCDate(const AValue: NativeInt);\r\n procedure setUTCFullYear(const AValue: NativeInt);\r\n procedure setUTCHours(const AValue: NativeInt);\r\n procedure setUTCMilliseconds(const AValue: NativeInt);\r\n procedure setUTCMinutes(const AValue: NativeInt);\r\n procedure setUTCMonth(const AValue: NativeInt);\r\n procedure setUTCSeconds(const AValue: NativeInt);\r\n public\r\n constructor New; reintroduce;\r\n constructor New(const MilliSecsSince1970: NativeInt); // milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored\r\n constructor New(const aDateString: String); // RFC 2822, ISO8601\r\n constructor New(aYear: NativeInt; aMonth: NativeInt; aDayOfMonth: NativeInt = 1;\r\n TheHours: NativeInt = 0; TheMinutes: NativeInt = 0; TheSeconds: NativeInt = 0;\r\n TheMilliseconds: NativeInt = 0);\r\n class function now: NativeInt; // current date and time in milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored\r\n class function parse(const aDateString: string): NativeInt; // format depends on browser\r\n class function UTC(aYear: NativeInt; aMonth: NativeInt = 0; aDayOfMonth: NativeInt = 1;\r\n TheHours: NativeInt = 0; TheMinutes: NativeInt = 0; TheSeconds: NativeInt = 0;\r\n TheMilliseconds: NativeInt = 0): NativeInt;\r\n function getDay: NativeInt;\r\n function getTimezoneOffset: NativeInt;\r\n function getUTCDay: NativeInt; // day of the week\r\n function toDateString: string; // human readable date, without time\r\n function toISOString: string; // ISO 8601 Extended Format\r\n function toJSON: string;\r\n function toGMTString: string; // in GMT timezone\r\n function toLocaleDateString: string; // date in locale timezone, no time\r\n function toLocaleString: string; reintroduce; // date and time in locale timezone\r\n function toLocaleTimeString: string; // time in locale timezone, no date\r\n function toTimeString: string; // time human readable, no date\r\n function toUTCString: string; // date and time using UTC timezone\r\n property Year: NativeInt read getYear write setYear;\r\n property Time: NativeInt read getTime write setTime; // milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored\r\n property FullYear: NativeInt read getFullYear write setFullYear;\r\n property UTCDate: NativeInt read getUTCDate write setUTCDate; // day of month\r\n property UTCFullYear: NativeInt read getUTCFullYear write setUTCFullYear;\r\n property UTCHours: NativeInt read getUTCHours write setUTCHours;\r\n property UTCMilliseconds: NativeInt read getUTCMilliseconds write setUTCMilliseconds;\r\n property UTCMinutes: NativeInt read getUTCMinutes write setUTCMinutes;\r\n property UTCMonth: NativeInt read getUTCMonth write setUTCMonth;\r\n property UTCSeconds: NativeInt read getUTCSeconds write setUTCSeconds;\r\n property Month: NativeInt read getMonth write setMonth;\r\n property Date: NativeInt read getDate write setDate; // day of the month, starting at 1\r\n property Hours: NativeInt read getHours write setHours;\r\n property Minutes: NativeInt read getMinutes write setMinutes;\r\n property Seconds: NativeInt read getSeconds write setSeconds;\r\n property Milliseconds: NativeInt read getMilliseconds write setMilliseconds;\r\n end;\r\n\r\n TLocaleCompareOptions = record\r\n localematched : string;\r\n usage: string;\r\n sensitivity : string;\r\n ignorePunctuation : Boolean;\r\n numeric : boolean;\r\n caseFirst : string;\r\n end;\r\n\r\n TJSRegexp = class external name 'RegExp'\r\n private\r\n {$IFDEF FIREFOX}\r\n // not on all browsers:\r\n FFlags : string; external name 'flags';\r\n FSticky : boolean; external name 'sticky';\r\n {$endif}\r\n fglobal: boolean; external name 'global';\r\n fignoreCase : boolean; external name 'ignoreCase';\r\n fmultiline : boolean; external name 'multiline';\r\n fsource : string; external name 'source';\r\n funicode : boolean; external name 'unicode';\r\n public\r\n Constructor New(Pattern : string);\r\n Constructor New(Pattern, Flags : string);\r\n lastIndex: NativeInt;\r\n function exec(aString : string): TStringDynArray;\r\n function test(aString : string) : boolean;\r\n function toString : String;\r\n property Global : boolean read fglobal;\r\n property IgnoreCase : Boolean read FIgnoreCase;\r\n property Multiline : Boolean Read FMultiLine;\r\n Property Source : string Read FSource;\r\n Property Unicode : boolean Read FUnicode;\r\n {$IFDEF FIREFOX}\r\n // not on all browsers:\r\n property Flags : string read FFlags;\r\n property Sticky : boolean read FSticky;\r\n {$endif}\r\n end;\r\n\r\n\r\n TReplaceCallBack = Function () : string; varargs;\r\n\r\n TJSString = class external name 'String'\r\n private\r\n flength : NativeInt; external name 'length';\r\n public \r\n constructor New(Const S : String);\r\n constructor New(Const I : NativeInt);\r\n constructor New(Const D : double);\r\n property length : NativeInt read flength; \r\n class function fromCharCode() : string; varargs;\r\n class function fromCodePoint() : string; varargs;\r\n function anchor(const aName : string) : string;\r\n function charAt(aIndex : NativeInt) : string;\r\n function charCodeAt(aIndex : NativeInt) : NativeInt;\r\n function codePointAt(aIndex : NativeInt) : NativeInt;\r\n function concat(s : string) : string; varargs;\r\n function endsWith(aSearchString : string; Pos : NativeInt = 0) : boolean;\r\n function includes(aSearchString : string; Pos : NativeInt = 0) : boolean;\r\n function indexOf(aSearchString : String; Pos : NativeInt = 0) : Integer;\r\n function lastIndexOf(aSearchString : String) : NativeInt;overload;\r\n function lastIndexOf(aSearchString : String; Pos : NativeInt) : Integer;overload;\r\n function link(aUrl : string) : String;\r\n function localeCompare(aCompareString : string) : NativeInt; overload;\r\n function localeCompare(aCompareString : string; aLocales: string) : integer; overload;\r\n function localeCompare(compareString : string; locales: string; Options : TlocaleCompareOptions) : integer; overload;\r\n function match(aRegexp : TJSRegexp) : TStringDynArray; overload;\r\n function match(aRegexp : String) : TStringDynArray;overload;\r\n {$IFDEF ECMAScript6}\r\n function normalize(aForm : string) : string;\r\n {$ENDIF}\r\n function _repeat(aCount : NativeInt) : Integer; external name 'repeat';\r\n function replace(aRegexp : String; NewString : String) : String; overload;\r\n function replace(aRegexp : TJSRegexp; NewString : String) : String; overload;\r\n function replace(Regexp : String; aCallback : TReplaceCallBack) : String; overload;\r\n function replace(Regexp : TJSRegexp; aCallback : TReplaceCallBack) : String; overload;\r\n function search(Regexp : TJSRegexp) : NativeInt; overload;\r\n function search(Regexp : JSValue) : NativeInt; overload;\r\n function slice(aBeginIndex : NativeInt) : String; overload;\r\n function slice(aBeginIndex, aEndIndex : NativeInt) : String; overload;\r\n function split : TStringDynArray; overload;\r\n function split(aSeparator : string) : TStringDynArray; overload;\r\n function split(aSeparator : string; aLimit : NativeInt) : TStringDynArray; overload;\r\n function startsWith(aSearchString : String) : Boolean; overload;\r\n function startsWith(aSearchString : String; aPosition : NativeInt) : Boolean; overload;\r\n function substr(aStartIndex : NativeInt) : String; overload;\r\n function substr(aStartIndex,aLength : NativeInt) : String; overload;\r\n function subString(aStartIndex : NativeInt) : String; overload;\r\n function subString(aStartIndex,aEndIndex : NativeInt) : String; overload;\r\n function toLocaleLowerCase : String;\r\n function toLocaleUpperCase : String;\r\n function toLowerCase : String;\r\n function toString : string;\r\n function toUpperCase : String;\r\n function trim : string;\r\n function valueOf : string;\r\n end;\r\n\r\n TJSArray = Class;\r\n \r\n TJSArrayEvent = reference to function (element : JSValue; index: NativeInt; anArray : TJSArray) : Boolean;\r\n TJSArrayMapEvent = reference to function (element : JSValue; index: NativeInt; anArray : TJSArray) : JSValue;\r\n TJSArrayReduceEvent = reference to function (accumulator, currentValue : JSValue; currentIndex : NativeInt; anArray : TJSArray) : JSValue;\r\n TJSArrayCompareEvent = reference to function (a,b : JSValue) : NativeInt;\r\n TJSArrayCallback = TJSArrayEvent;\r\n TJSArrayMapCallback = TJSArrayMapEvent;\r\n TJSArrayReduceCallBack = TJSArrayReduceEvent;\r\n TJSArrayCompareCallBack = TJSArrayCompareEvent;\r\n\r\n { TJSArray }\r\n\r\n TJSArray = Class external name 'Array'\r\n private\r\n function GetElements(Index: NativeInt): JSValue; external name '[]';\r\n procedure SetElements(Index: NativeInt; const AValue: JSValue); external name '[]';\r\n public\r\n FLength : NativeInt; external name 'length';\r\n constructor new; overload;\r\n constructor new(aLength : NativeInt); overload;\r\n constructor new(aElement1 : JSValue); varargs; overload;\r\n class function _of() : TJSArray; varargs; external name 'of'; \r\n class function isArray(a: JSValue) : Boolean;\r\n{$IFDEF JAVASCRIPT2015} \r\n class function from(a : JSValue) : TJSArray;\r\n{$ENDIF} \r\n function concat(el : JSValue) : TJSArray; varargs;\r\n function copyWithin(aTarget : NativeInt) : TJSarray;overload; // not in IE\r\n function copyWithin(aTarget, aStart : NativeInt) : TJSarray;overload; // not in IE\r\n function copyWithin(aTarget, aStart, aEnd : NativeInt) : TJSarray;overload; // not in IE\r\n Function every(const aCallback : TJSArrayCallBack) : boolean;overload;\r\n Function every(const aCallback : TJSArrayEvent; aThis : TObject) : boolean;overload;\r\n Function filter(const aCallBack : TJSArrayCallBack) : TJSArray; overload;\r\n Function filter(const aCallBack : TJSArrayEvent; aThis : TObject) : TJSArray;overload;\r\n Function fill(aValue : JSValue) : TJSArray; overload;\r\n Function fill(aValue : JSValue; aStartIndex : NativeInt) : TJSArray; overload;\r\n Function fill(aValue : JSValue; aStartIndex,aEndIndex : NativeInt) : TJSArray; overload;\r\n Function find(const aCallBack : TJSArrayCallBack) : JSValue; overload;\r\n Function find(const aCallBack : TJSArrayEvent; aThis : TObject) : JSValue; overload;\r\n Function findIndex(const aCallBack : TJSArrayCallBack) : NativeInt; overload;\r\n Function findIndex(const aCallBack : TJSArrayEvent; aThis : TObject) : NativeInt; overload;\r\n procedure forEach(const aCallBack : TJSArrayEvent); overload;\r\n procedure forEach(const aCallBack : TJSArrayEvent; aThis : TObject); overload;\r\n function includes(aElement : JSValue) : Boolean; overload;\r\n function includes(aElement : JSValue; FromIndex : NativeInt) : Boolean; overload;\r\n function indexOf(aElement : JSValue) : NativeInt; overload;\r\n function indexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;\r\n function join : String; overload;\r\n function join (aSeparator : string) : String; overload;\r\n function lastIndexOf(aElement : JSValue) : NativeInt; overload;\r\n function lastIndexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;\r\n Function map(const aCallBack : TJSArrayMapCallBack) : TJSArray; overload;\r\n Function map(const aCallBack : TJSArrayMapEvent; aThis : TObject) : TJSArray; overload;\r\n function pop : JSValue; \r\n function push(aElement : JSValue) : NativeInt; varargs;\r\n function reduce(const aCallBack : TJSArrayReduceCallBack) : JSValue; overload;\r\n function reduce(const aCallBack : TJSArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;\r\n function reduceRight(const aCallBack : TJSArrayReduceCallBack) : JSValue; overload;\r\n function reduceRight(const aCallBack : TJSArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;\r\n Function reverse : TJSArray;\r\n Function shift : JSValue;\r\n Function slice : TJSArray; overload;\r\n function slice(aBegin : NativeInt) : TJSArray; overload;\r\n function slice(aBegin,aEnd : NativeInt) : TJSArray; overload;\r\n Function some(const aCallback : TJSArrayCallBack) : boolean; overload;\r\n Function some(const aCallback : TJSArrayEvent; aThis : TObject) : boolean; overload;\r\n Function sort(const aCallback : TJSArrayCompareCallBack) : TJSArray; overload;\r\n Function sort() : TJSArray; overload;\r\n function splice(aStart : NativeInt) : TJSArray; overload;\r\n function splice(aStart,aDeleteCount : NativeInt) : TJSArray; varargs; overload;\r\n function toLocaleString: String; overload;\r\n function toLocaleString(locales : string) : String; overload;\r\n function toLocaleString(locales : string; const Options : TLocaleCompareOptions) : String; overload;\r\n function toString : String;\r\n function unshift : NativeInt; varargs; \r\n Property Length : NativeInt Read FLength Write FLength;\r\n property Elements[Index: NativeInt]: JSValue read GetElements write SetElements; default;\r\n end;\r\n\r\n TJSArrayBuffer = Class external name 'ArrayBuffer'\r\n private\r\n fLength : NativeInt; external name 'byteLength';\r\n public\r\n constructor new(aByteLength : NativeInt);\r\n class function isView(aValue : JSValue) : Boolean; \r\n function slice(aBegin : NativeInt) : TJSArrayBuffer; overload;\r\n function slice(aBegin,aEnd : NativeInt) : TJSArrayBuffer; overload;\r\n Property byteLength : NativeInt Read fLength;\r\n end;\r\n\r\n TJSBufferSource = class external name 'BufferSource'\r\n end;\r\n\r\n { TJSTypedArray }\r\n TJSTypedArray = Class;\r\n\r\n TJSTypedArrayCallBack = function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : Boolean;\r\n TJSTypedArrayEvent = function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : Boolean of object;\r\n TJSTypedArrayMapCallBack = function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : JSValue;\r\n TJSTypedArrayMapEvent = function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : JSValue of object;\r\n TJSTypedArrayReduceCallBack = function (accumulator, currentValue : JSValue; currentIndex : NativeInt; anArray : TJSTypedArray) : JSValue;\r\n TJSTypedArrayCompareCallBack = function (a,b : JSValue) : NativeInt;\r\n\r\n TJSTypedArray = class external name 'TypedArray' (TJSBufferSource)\r\n Private\r\n FBuffer: TJSArrayBuffer; external name 'buffer';\r\n FByteLength: NativeInt; external name 'byteLength';\r\n FLength: NativeInt; external name 'length';\r\n FByteOffset: NativeInt; external name 'byteOffset';\r\n function getValue(Index : NativeInt) : JSValue; external name '[]';\r\n procedure setValue(Index : NativeInt;AValue : JSValue); external name '[]';\r\n Public\r\n class var BYTES_PER_ELEMENT : NativeInt;\r\n class var name : string;\r\n class function from(aValue : jsValue) : TJSTypedArray;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSTypedArray;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSTypedArray;\r\n class function _of(aValue : jsValue) : TJSTypedArray; varargs; external name 'of';\r\n function copyWithin(aTarget : NativeInt) : TJSTypedArray;overload;\r\n function copyWithin(aTarget, aStart : NativeInt) : TJSTypedArray;overload;\r\n function copyWithin(aTarget, aStart, aEnd : NativeInt) : TJSTypedArray;overload;\r\n Function every(const aCallback : TJSTypedArrayCallBack) : boolean;overload;\r\n Function every(const aCallback : TJSTypedArrayEvent; aThis : TObject) : boolean;overload;\r\n Function fill(aValue : JSValue) : TJSTypedArray; overload;\r\n Function fill(aValue : JSValue; aStartIndex : NativeInt) : TJSTypedArray; overload;\r\n Function fill(aValue : JSValue; aStartIndex,aEndIndex : NativeInt) : TJSTypedArray; overload;\r\n Function filter(const aCallBack : TJSTypedArrayCallBack) : TJSTypedArray; overload;\r\n Function filter(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : TJSTypedArray;overload;\r\n Function find(const aCallBack : TJSTypedArrayCallBack) : JSValue; overload;\r\n Function find(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : JSValue; overload;\r\n Function findIndex(const aCallBack : TJSTypedArrayCallBack) : NativeInt; overload;\r\n Function findIndex(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : NativeInt; overload;\r\n procedure forEach(const aCallBack : TJSTypedArrayCallBack); overload;\r\n procedure forEach(const aCallBack : TJSTypedArrayEvent; aThis : TObject); overload;\r\n function includes(aElement : JSValue) : Boolean; overload;\r\n function includes(aElement : JSValue; FromIndex : NativeInt) : Boolean; overload;\r\n function indexOf(aElement : JSValue) : NativeInt; overload;\r\n function indexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;\r\n function join : String; overload;\r\n function join (aSeparator : string) : String; overload;\r\n function lastIndexOf(aElement : JSValue) : NativeInt; overload;\r\n function lastIndexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;\r\n Function map(const aCallBack : TJSTypedArrayCallBack) : TJSTypedArray; overload;\r\n Function map(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : TJSTypedArray; overload;\r\n function reduce(const aCallBack : TJSTypedArrayReduceCallBack) : JSValue; overload;\r\n function reduce(const aCallBack : TJSTypedArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;\r\n function reduceRight(const aCallBack : TJSTypedArrayReduceCallBack) : JSValue; overload;\r\n function reduceRight(const aCallBack : TJSTypedArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;\r\n Function reverse : TJSTypedArray;\r\n procedure _set(anArray : TJSArray); external name 'set';\r\n procedure _set(anArray : TJSArray; anOffset : NativeInt); external name 'set';\r\n procedure _set(anArray : TJSTypedArray); external name 'set';\r\n procedure _set(anArray : TJSTypedArray; anOffset : NativeInt); external name 'set';\r\n Function slice : TJSTypedArray; overload;\r\n function slice(aBegin : NativeInt) : TJSTypedArray; overload;\r\n function slice(aBegin,aEnd : NativeInt) : TJSTypedArray; overload;\r\n Function some(const aCallback : TJSTypedArrayCallBack) : boolean; overload;\r\n Function some(const aCallback : TJSTypedArrayEvent; aThis : TObject) : boolean; overload;\r\n Function sort(const aCallback : TJSTypedArrayCompareCallBack) : TJSTypedArray; overload;\r\n Function sort() : TJSTypedArray; overload;\r\n function splice(aStart : NativeInt) : TJSTypedArray; overload;\r\n function splice(aStart,aDeleteCount : NativeInt) : TJSTypedArray; varargs; overload;\r\n function toLocaleString: String; overload;\r\n function toLocaleString(locales : string) : String; overload;\r\n function toLocaleString(locales : string; const Options : TLocaleCompareOptions) : String; overload;\r\n function toString : String;\r\n function unshift : NativeInt; varargs;\r\n property buffer : TJSArrayBuffer read FBuffer;\r\n property byteLength : NativeInt Read FByteLength;\r\n property byteOffset : NativeInt Read FByteOffset;\r\n property length : NativeInt Read FLength;\r\n property values[Index : NativeInt] : JSValue Read getValue Write SetValue; default;\r\n end;\r\n\r\n { TJSInt8Array }\r\n\r\n TJSInt8Array = class external name 'Int8Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): Shortint; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: Shortint);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSInt8Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSInt8Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSInt8Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSInt8Array; varargs; external name 'of'; reintroduce;\r\n procedure _set(anArray : Array of ShortInt); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of ShortInt; anOffset : NativeInt); external name 'set';\r\n property values[Index : NativeInt] : Shortint Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSUint8Array = class external name 'Uint8Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): Byte; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: Byte);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSUInt8Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt8Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt8Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSUInt8Array; varargs; external name 'of'; reintroduce;\r\n procedure _set(anArray : Array of Byte); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of Byte; anOffset : NativeInt); external name 'set';\r\n Property values[Index : NativeInt] : Byte Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSUint8ClampedArray = class external name 'Uint8ClampedArray' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): Byte; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: Byte);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSUInt8ClampedArray; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt8ClampedArray; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt8ClampedArray; reintroduce;\r\n class function _of(aValue : jsValue) : TJSUInt8ClampedArray; varargs; external name 'of'; reintroduce;\r\n procedure _set(anArray : Array of Byte); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of Byte; anOffset : NativeInt); external name 'set';\r\n Property values[Index : NativeInt] : Byte Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSInt16Array = class external name 'Int16Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): smallint; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: Smallint);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSInt16Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSInt16Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSInt16Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSInt16Array; varargs; external name 'of'; reintroduce;\r\n procedure _set(anArray : Array of SmallInt); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of SmallInt; anOffset : NativeInt); external name 'set';\r\n Property values[Index : NativeInt] : SmallInt Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSUint16Array = class external name 'Uint16Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): Word; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: Word);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSUInt16Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt16Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt16Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSUInt16Array; varargs; external name 'of'; reintroduce;\r\n procedure _set(anArray : Array of Word); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of Word; anOffset : NativeInt); external name 'set';\r\n Property values[Index : NativeInt] : Word Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSInt32Array = class external name 'Int32Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): longint; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: longint);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSInt32Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSInt32Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSInt32Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSInt32Array; varargs;external name 'of'; reintroduce;\r\n procedure _set(anArray : Array of LongInt); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of LongInt; anOffset : NativeInt); external name 'set';\r\n Property values[Index : NativeInt] : longint Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSUint32Array = class external name 'Uint32Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): LongWord; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: LongWord);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSUInt32Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt32Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt32Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSUInt32Array; varargs; external name 'of'; reintroduce;\r\n procedure _set(anArray : Array of Cardinal); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of Cardinal; anOffset : NativeInt); external name 'set';\r\n Property values[Index : NativeInt] : LongWord Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSFloat32Array = class external name 'Float32Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): Float32; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: Float32);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSFloat32Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSFloat32Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSFloat32Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSFloat32Array; varargs; reintroduce;\r\n procedure _set(anArray : Array of Double); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of Double; anOffset : NativeInt); external name 'set'; reintroduce;\r\n Property values[Index : NativeInt] : Float32 Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSFloat64Array = class external name 'Float64Array' (TJSTypedArray)\r\n private\r\n function getTypedValue(Index : NativeInt): Float64; external name '[]';\r\n procedure setTypedValue(Index : NativeInt; AValue: Float64);external name '[]';\r\n public\r\n constructor new (length : NativeInt);\r\n constructor new (atypedArray : TJSTypedArray);\r\n constructor new (aObject : TJSObject);\r\n constructor new (buffer : TJSArrayBuffer);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset: NativeInt);\r\n constructor new (buffer : TJSArrayBuffer; aByteOffset, aLength: NativeInt);\r\n class function from(aValue : jsValue) : TJSFloat64Array; reintroduce;\r\n class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSFloat64Array; reintroduce;\r\n class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSFloat64Array; reintroduce;\r\n class function _of(aValue : jsValue) : TJSFloat64Array; varargs; reintroduce;\r\n procedure _set(anArray : Array of Double); external name 'set'; reintroduce;\r\n procedure _set(anArray : Array of Double; anOffset : NativeInt); external name 'set'; reintroduce;\r\n Property values[Index : NativeInt] : Float64 Read getTypedValue Write setTypedValue; default;\r\n end;\r\n\r\n TJSDataView = Class external name 'DataView' (TJSBufferSource)\r\n private\r\n fBuffer : TJSArrayBuffer; external name 'buffer';\r\n fLength : NativeInt; external name 'byteLength';\r\n fOffset : NativeInt; external name 'byteOffset';\r\n public\r\n constructor new(aBuffer : TJSArrayBuffer); overload;\r\n constructor new(aBuffer : TJSArrayBuffer; aOffset : NativeInt); overload;\r\n constructor new(aBuffer : TJSArrayBuffer; aOffset,aByteLength : NativeInt); overload;\r\n function getFloat32(aByteOffset : NativeInt) : double; overload;\r\n function getFloat32(aByteOffset : NativeInt; aLittleEndian: Boolean) : double; overload;\r\n function getFloat64(aByteOffset : NativeInt) : double; overload;\r\n function getFloat64(aByteOffset : NativeInt; aLittleEndian: Boolean) : double; overload;\r\n function getInt8(aByteOffset : NativeInt) : ShortInt; \r\n function getInt16(aByteOffset : NativeInt) : SmallInt; overload;\r\n function getInt16(aByteOffset : NativeInt; aLittleEndian : Boolean) : SmallInt; overload;\r\n function getInt32(aByteOffset : NativeInt) : Longint; overload;\r\n function getInt32(aByteOffset : NativeInt; aLittleEndian : Boolean) : Longint; overload;\r\n function getUint8(aByteOffset : NativeInt) : Byte; overload;\r\n function getUint16(aByteOffset : NativeInt) : Word; overload;\r\n function getUint16(aByteOffset : NativeInt; aLittleEndian : Boolean) : Word; overload;\r\n function getUint32(aByteOffset : NativeInt) : LongWord; overload;\r\n function getUint32(aByteOffset : NativeInt; aLittleEndian : Boolean) : LongWord; overload;\r\n\r\n procedure setFloat32(aByteOffset : NativeInt; aValue : double); overload;\r\n procedure setFloat32(aByteOffset : NativeInt; aValue : double; aLittleEndian: Boolean); overload;\r\n procedure setFloat64(aByteOffset : NativeInt; aValue : double); overload;\r\n procedure setFloat64(aByteOffset : NativeInt; aValue : double; aLittleEndian: Boolean); overload;\r\n procedure setInt8(aByteOffset : NativeInt; aValue : ShortInt); \r\n procedure setInt16(aByteOffset : NativeInt; aValue : SmallInt); overload;\r\n procedure setInt16(aByteOffset : NativeInt; aValue : SmallInt; aLittleEndian : Boolean); overload;\r\n procedure setInt32(aByteOffset : NativeInt; aValue : Longint); overload;\r\n procedure setInt32(aByteOffset : NativeInt; aValue : Longint; aLittleEndian : Boolean); overload;\r\n procedure setUint8(aByteOffset : NativeInt; aValue : Byte); overload;\r\n procedure setUint16(aByteOffset : NativeInt; aValue : Word); overload;\r\n procedure setUint16(aByteOffset : NativeInt; aValue : Word; aLittleEndian : Boolean); overload;\r\n procedure setUint32(aByteOffset : NativeInt; aValue : LongWord); overload;\r\n procedure setUint32(aByteOffset : NativeInt; aValue: LongWord; aLittleEndian : Boolean); overload;\r\n \r\n Property byteLength : NativeInt Read fLength;\r\n Property byteOffset : NativeInt read fOffset;\r\n property buffer : TJSArrayBuffer Read fBuffer;\r\n end;\r\n\r\n TJSJSON = class external name 'JSON' (TJSObject)\r\n Public\r\n class function parse(aJSON : String) : JSValue;\r\n // Use this only when you are sure you will get an object, no checking is done.\r\n class function parseObject(aJSON : String) : TJSObject; external name 'parse';\r\n class function stringify(aValue : JSValue) : string;\r\n class function stringify(aValue,aReplacer : JSValue) : string;\r\n class function stringify(aValue,aReplacer : JSValue; space: NativeInt) : string;\r\n class function stringify(aValue,aReplacer : JSValue; space: String) : string;\r\n end;\r\n\r\n { TJSError }\r\n\r\n TJSError = CLass external name 'Error'\r\n private\r\n FMessage: String; external name 'message';\r\n Public\r\n Constructor new;\r\n Constructor new(Const aMessage : string);\r\n Constructor new(Const aMessage,aFileName : string);\r\n Constructor new(Const aMessage,aFileName : string; aLineNumber : NativeInt);\r\n Property Message : String Read FMessage;\r\n end;\r\n\r\n\r\n TJSPromiseResolver = reference to function (aValue : JSValue) : JSValue;\r\n TJSPromiseExecutor = reference to procedure (resolve,reject : TJSPromiseResolver);\r\n TJSPromiseFinallyHandler = reference to procedure;\r\n TJSPromise = Class;\r\n TJSPromiseArray = array of TJSPromise;\r\n\r\n TJSPromise = class external name 'Promise'\r\n constructor new(Executor : TJSPromiseExecutor);\r\n class function all(arg : Array of JSValue) : TJSPromise; overload;\r\n class function all(arg : JSValue) : TJSPromise; overload;\r\n class function all(arg : TJSPromiseArray) : TJSPromise; overload;\r\n class function race(arg : Array of JSValue) : TJSPromise; overload;\r\n class function race(arg : JSValue) : TJSPromise; overload;\r\n class function race(arg : TJSPromiseArray) : TJSPromise; overload;\r\n class function reject(reason : JSValue) : TJSPromise;\r\n class function resolve(value : JSValue): TJSPromise; overload;\r\n class function resolve : TJSPromise; overload;\r\n function _then (onAccepted : TJSPromiseResolver) : TJSPromise; external name 'then';\r\n function catch (onRejected : TJSPromiseResolver) : TJSPromise;\r\n function _finally(value : TJSPromiseFinallyHandler): TJSPromise;\r\n end;\r\n\r\n\r\nvar\r\n // This can be used in procedures/functions to provide access to the 'arguments' array.\r\n JSArguments: TJSValueDynArray; external name 'arguments';\r\n // This can be used in all code to access the javascript 'this' object.\r\n JSThis: TJSObject; external name 'this';\r\n // This can be used in catch blocks to access the JS throw value\r\n JSExceptValue: JSValue; external name '$e';\r\n\r\nFunction new(aElements: TJSValueDynArray) : TJSObject; overload;\r\n\r\nfunction decodeURIComponent(encodedURI : String) : String; external name 'decodeURIComponent';\r\nfunction encodeURIComponent(str : String) : String; external name 'encodeURIComponent';\r\n\r\nfunction parseInt(s: String; Radix: NativeInt): NativeInt; overload; external name 'parseInt'; // may result NaN\r\nfunction parseInt(s: String): NativeInt; overload; external name 'parseInt'; // may result NaN\r\nfunction parseFloat(s: String): double; overload; external name 'parseFloat'; // may result NaN\r\n\r\nfunction hasString(const v: JSValue): boolean; external name 'rtl.hasString';// isString(v) and v<>''\r\nfunction hasValue(const v: JSValue): boolean; assembler; // returns the JS definition of if(v): v is not false, undefined, null, 0, NaN, or the empty string. Note: JS if(new Boolean(false)) returns true.\r\nfunction isArray(const v: JSValue): boolean; external name 'rtl.isArray';\r\nfunction isBoolean(const v: JSValue): boolean; assembler;\r\nfunction isCallback(const v: JSValue): boolean; assembler;\r\nfunction isChar(const v: JSValue): boolean; assembler;\r\nfunction isClass(const v: JSValue): boolean; assembler; // is a Pascal class, e.g. a TClass\r\nfunction isClassInstance(const v: JSValue): boolean; assembler;// is a Pascal class instance, e.g. a TObject\r\nfunction isFunction(const v: JSValue): boolean; external name 'rtl.isFunction';\r\nfunction isInteger(const v: JSValue): boolean; assembler;\r\nfunction isModule(const v: JSValue): boolean; external name 'rtl.isModule';\r\nfunction isNull(const v: JSValue): boolean; assembler;\r\nfunction isNumber(const v: JSValue): boolean; external name 'rtl.isNumber';\r\nfunction isObject(const v: JSValue): boolean; external name 'rtl.isObject'; // true if not null and a JS Object\r\nfunction isRecord(const v: JSValue): boolean; assembler;\r\nfunction isString(const v: JSValue): boolean; external name 'rtl.isString';\r\nfunction isUndefined(const v: JSValue): boolean; assembler;\r\nfunction isDefined(const v: JSValue): boolean; assembler;\r\nfunction isUTF16Char(const v: JSValue): boolean; assembler;\r\nfunction isExt(const InstanceOrClass, aClass: JSValue): boolean; external name 'rtl.isExt'; // aClass can be a JS object or function\r\nfunction jsInstanceOf(const aFunction, aFunctionWithPrototype: JSValue): String; assembler;\r\nfunction jsTypeOf(const v: JSValue): String; external name 'typeof';\r\nfunction jsIsNaN(const v: JSValue): boolean; external name 'isNaN';// true if value cannot be converted to a number. e.g. True on NaN, undefined, {}, '123'. False on true, null, '', ' ', '1A'\r\nfunction toNumber(const v: JSValue): double; assembler; // if not possible, returns NaN\r\nfunction toInteger(const v: JSValue): NativeInt; // if v is not an integer, returns 0\r\nfunction toObject(Value: JSValue): TJSObject; // If Value is not a Javascript object, returns Nil\r\nfunction toArray(Value: JSValue): TJSArray; // If Value is not a Javascript array, returns Nil\r\nfunction toBoolean(Value: JSValue): Boolean; // If Value is not a Boolean, returns False\r\nfunction toString(Value: JSValue): String; // If Value is not a string, returns ''\r\n\r\nType\r\n TJSValueType = (jvtNull,jvtBoolean,jvtInteger,jvtFloat,jvtString,jvtObject,jvtArray);\r\n\r\nFunction GetValueType(JS : JSValue) : TJSValueType;\r\n\r\nVar\r\n Null : JSValue; external name 'null';\r\n Undefined : JSValue; external name 'undefined';\r\n\r\nimplementation\r\n\r\nFunction new(aElements: TJSValueDynArray) : TJSObject;\r\n\r\n function toString(I : Integer): string; external name 'String';\r\n\r\nVar\r\n L,I : integer;\r\n S : String;\r\n\r\nbegin\r\n L:=length(aElements);\r\n if (L mod 2)=1 then\r\n raise EJS.Create('Number of arguments must be even');\r\n I:=0;\r\n // Check all arguments;\r\n While (i2)) return false;\r\n var code = v.charCodeAt(0);\r\n if (code < 0xD800){\r\n if (v.length == 1) return true;\r\n } else if (code <= 0xDBFF){\r\n if (v.length==2){\r\n code = v.charCodeAt(1);\r\n if (code >= 0xDC00 && code <= 0xDFFF) return true;\r\n };\r\n };\r\n return false;\r\nend;\r\n\r\nfunction jsInstanceOf(const aFunction, aFunctionWithPrototype: JSValue\r\n ): String; assembler;\r\nasm\r\n return aFunction instanceof aFunctionWithPrototype;\r\nend;\r\n\r\nfunction toNumber(const v: JSValue): double; assembler;\r\nasm\r\n return v-0;\r\nend;\r\n\r\nfunction toInteger(const v: JSValue): NativeInt;\r\nbegin\r\n if IsInteger(v) then\r\n Result:=NativeInt(v)\r\n else\r\n Result:=0;\r\nend;\r\n\r\nfunction toObject(Value: JSValue): TJSObject;\r\n\r\nbegin\r\n if IsObject(Value) then\r\n Result:=TJSObject(Value)\r\n else\r\n Result:=Nil;\r\nend;\r\n\r\nfunction toArray(Value: JSValue): TJSArray; // If not possible, returns Nil\r\n\r\nbegin\r\n if IsArray(Value) then\r\n Result:=TJSArray(Value)\r\n else\r\n Result:=Nil;\r\nend;\r\n\r\nfunction toBoolean(Value: JSValue): Boolean; // If not possible, returns False\r\n\r\nbegin\r\n if isBoolean(Value) then\r\n Result:=Boolean(Value)\r\n else\r\n Result:=False;\r\nend;\r\n\r\nfunction toString(Value: JSValue): String; // If not possible, returns ''\r\n\r\nbegin\r\n if IsString(Value) then\r\n Result:=String(Value)\r\n else\r\n Result:='';\r\nend;\r\n\r\n{ EJS }\r\n\r\nconstructor EJS.Create(const Msg: String);\r\nbegin\r\n FMessage:=Msg;\r\nend;\r\n\r\n\r\nFunction GetValueType(JS : JSValue) : TJSValueType;\r\n\r\nVar\r\n t : string;\r\n\r\nbegin\r\n if isNull(js) then // null reported as object\r\n result:=jvtNull\r\n else\r\n begin\r\n t:=jsTypeOf(js);\r\n if (t='string') then\r\n Result:=jvtString\r\n else if (t='boolean') then\r\n Result:=jvtBoolean\r\n else if (t='object') then\r\n begin\r\n if IsArray(JS) then\r\n Result:=jvtArray\r\n else\r\n Result:=jvtObject;\r\n end\r\n else if (t='number') then\r\n if isInteger(JS) then\r\n result:=jvtInteger\r\n else\r\n result:=jvtFloat\r\n end;\r\nend;\r\n\r\nend.\r\n\r\n","{\r\n This file is part of the Pas2JS run time library.\r\n Copyright (c) 2017 by Mattias Gaertner\r\n\r\n See the file COPYING.FPC, included in this distribution,\r\n for details about the copyright.\r\n\r\n This program is distributed in the hope that it will be useful,\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n **********************************************************************}\r\nunit SysUtils;\r\n\r\n{$mode objfpc}\r\n\r\ninterface\r\n\r\nuses\r\n RTLConsts, js;\r\n\r\nprocedure FreeAndNil(var Obj);\r\n\r\ntype\r\n TProcedure = procedure;\r\n\r\n {*****************************************************************************\r\n Various types\r\n *****************************************************************************}\r\n\r\ntype\r\n { TFloatRec }\r\n TFloatRec = Record\r\n Exponent: Integer;\r\n Negative: Boolean;\r\n Digits: Array Of Char;\r\n End;\r\n TEndian = (Little,Big);\r\n TFileName = String;\r\n TByteArray = array [0..32767] of Byte;\r\n TWordArray = array [0..16383] of Word;\r\n TBytes = Array of byte;\r\n TStringArray = array of string;\r\n\r\n TMonthNameArray = array [1..12] of string;\r\n TDayTable = array [1..12] of Word;\r\n TWeekNameArray = array [1..7] of string;\r\n TMonthNames = TMonthNameArray;\r\n TDayNames = array[0..6] of string;\r\n\r\n{*****************************************************************************\r\n Exception handling\r\n*****************************************************************************}\r\n\r\n { Exception }\r\n\r\n Exception = class(TObject)\r\n private\r\n fMessage: String;\r\n fHelpContext: Integer;\r\n public\r\n constructor Create(const Msg: String); reintroduce;\r\n constructor CreateFmt(const Msg: string; const Args: array of jsvalue);\r\n constructor CreateHelp(const Msg: String; AHelpContext: Integer);\r\n constructor CreateFmtHelp(const Msg: string; const Args: array of jsvalue; AHelpContext: Integer);\r\n function ToString: String; override;\r\n property HelpContext: Integer read fHelpContext write fHelpContext;\r\n property Message: String read fMessage write fMessage;\r\n end;\r\n\r\n ExceptClass = class of Exception;\r\n\r\n EExternal = class(Exception);\r\n\r\n { General math errors }\r\n EMathError = class(EExternal);\r\n EInvalidOp = class(EMathError);\r\n EZeroDivide = class(EMathError);\r\n EOverflow = class(EMathError);\r\n EUnderflow = class(EMathError);\r\n\r\n EAbort = class(Exception);\r\n EInvalidCast = class(Exception);\r\n EAssertionFailed = class(Exception);\r\n EObjectCheck = class(Exception);\r\n\r\n { String conversion errors }\r\n EConvertError = class(Exception);\r\n EFormatError = class(Exception);\r\n\r\n\r\n { integer math exceptions }\r\n EIntError = Class(EExternal);\r\n EDivByZero = Class(EIntError);\r\n ERangeError = Class(EIntError);\r\n EIntOverflow = Class(EIntError);\r\n\r\n { General math errors }\r\n\r\n { Run-time and I/O Errors }\r\n EInOutError = class(Exception)\r\n public\r\n ErrorCode : Integer;\r\n end;\r\n\r\n EHeapMemoryError = class(Exception);\r\n EHeapException = EHeapMemoryError;\r\n\r\n EExternalException = class(EExternal);\r\n EInvalidPointer = Class(EHeapMemoryError);\r\n EOutOfMemory = Class(EHeapMemoryError);\r\n\r\n { EVariantError }\r\n\r\n EVariantError = Class(Exception)\r\n ErrCode : longint;\r\n Constructor CreateCode(Code : Longint);\r\n end;\r\n\r\n EAccessViolation = Class(EExternal);\r\n EBusError = Class(EAccessViolation);\r\n EPrivilege = class(EExternal);\r\n EStackOverflow = class(EExternal);\r\n EControlC = class(EExternal);\r\n\r\n { String conversion errors }\r\n\r\n { Other errors }\r\n EAbstractError = Class(Exception);\r\n\r\n EPropReadOnly = class(Exception);\r\n EPropWriteOnly = class(Exception);\r\n\r\n EIntfCastError = class(Exception);\r\n EInvalidContainer = class(Exception);\r\n EInvalidInsert = class(Exception);\r\n\r\n EPackageError = class(Exception);\r\n\r\n EOSError = class(Exception)\r\n public\r\n ErrorCode: Longint;\r\n end;\r\n\r\n ESafecallException = class(Exception);\r\n ENoThreadSupport = Class(Exception);\r\n ENoWideStringSupport = Class(Exception);\r\n ENotImplemented = class(Exception);\r\n\r\n EArgumentException = class(Exception);\r\n EArgumentOutOfRangeException = class(EArgumentException);\r\n EArgumentNilException = class(EArgumentException);\r\n\r\n EPathTooLongException = class(Exception);\r\n ENotSupportedException = class(Exception);\r\n EDirectoryNotFoundException = class(Exception);\r\n EFileNotFoundException = class(Exception);\r\n EPathNotFoundException = class(Exception);\r\n\r\n ENoConstructException = class(Exception);\r\n\r\n\r\n//function GetTickCount: Integer;\r\n\r\n\r\n{*****************************************************************************\r\n String function\r\n*****************************************************************************}\r\n\r\nConst\r\n EmptyStr = '';\r\n EmptyWideStr = ''; // No difference here.\r\n HexDisplayPrefix: string = '$';\r\n LeadBytes = [] unimplemented;\r\n\r\nFunction CharInSet(Ch: Char;Const CSet : array of char) : Boolean;\r\n\r\nfunction LeftStr(const S: string; Count: Integer): String; assembler;\r\nfunction RightStr(const S: string; Count: Integer): String; assembler;\r\n\r\nfunction Trim(const S: String): String; assembler;\r\nfunction TrimLeft(const S: String): String; assembler;\r\nfunction TrimRight(const S: String): String; assembler;\r\n\r\nfunction UpperCase(const s: String): String; assembler; overload;\r\nfunction LowerCase(const s: String): String; assembler; overload;\r\n\r\nfunction CompareStr(const s1, s2: String): Integer; assembler;\r\nfunction SameStr(const s1, s2: String): Boolean; assembler;\r\nfunction CompareText(const s1, s2: String): Integer; assembler;\r\nfunction SameText(const s1, s2: String): Boolean; assembler;\r\nfunction AnsiCompareText(const s1, s2: String): Integer; assembler;\r\nfunction AnsiSameText(const s1, s2: String): Boolean; assembler;\r\nfunction AnsiCompareStr(const s1, s2: String): Integer;\r\nprocedure AppendStr(var Dest: String; const S: string);\r\n\r\nfunction Format(const Fmt: String; const Args: array of JSValue): String;\r\n\r\n// JavaScript built-in functions\r\nfunction LocaleCompare(const s1, s2, locales: String): Boolean; assembler; overload;\r\nfunction NormalizeStr(const S: String; const Norm: String = 'NFC'): String; assembler; overload; // not in IE\r\n\r\nfunction IsValidIdent(const Ident: string; AllowDots: Boolean = False; StrictDots: Boolean = False): Boolean;\r\n\r\nType\r\n TStringReplaceFlag = (rfReplaceAll, rfIgnoreCase);\r\n TReplaceFlag = TStringReplaceFlag;\r\n TStringReplaceFlags = set of TStringReplaceFlag;\r\n TReplaceFlags = TStringReplaceFlags;\r\n\r\nfunction StringReplace(aOriginal, aSearch, aReplace : string; Flags : TStringReplaceFlags) : String;\r\nfunction QuoteString(aOriginal : String; AQuote : Char) : String;\r\nfunction IsDelimiter(const Delimiters, S: string; Index: Integer): Boolean;\r\nfunction AdjustLineBreaks(const S: string): string;\r\nfunction AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string;\r\nfunction WrapText(const Line, BreakStr: string; const BreakChars: Array of char; MaxCol: Integer): string;\r\nfunction WrapText(const Line: string; MaxCol: Integer): string;\r\n\r\n{ *****************************************************************************\r\n Integer conversions\r\n *****************************************************************************}\r\n\r\nfunction IntToStr(const Value: Integer): string;\r\nFunction TryStrToInt(const S : String; Out res : Integer) : Boolean;\r\nFunction TryStrToInt(const S : String; Out res : NativeInt) : Boolean;\r\nFunction StrToIntDef(const S : String; Const aDef : Integer) : Integer;\r\nFunction StrToIntDef(const S : String; Const aDef : NativeInt) : NativeInt;\r\nFunction StrToInt(const S : String) : Integer;\r\nFunction StrToNativeInt(const S : String) : NativeInt;\r\n// For compatibility\r\nFunction StrToInt64(const S : String) : NativeLargeInt;\r\nFunction StrToInt64Def(const S : String; ADefault : NativeLargeInt) : NativeLargeInt;\r\nFunction TryStrToInt64(const S : String; Out res : NativeLargeInt) : Boolean;\r\nFunction StrToQWord(const S : String) : NativeLargeUInt;\r\nFunction StrToQWordDef(const S : String; ADefault : NativeLargeUInt) : NativeLargeUInt;\r\nFunction TryStrToQWord(const S : String; Out res : NativeLargeUInt) : Boolean;\r\nFunction StrToUInt64(const S : String) : NativeLargeUInt;\r\nFunction StrToUInt64Def(const S : String; ADefault : NativeLargeUInt) : NativeLargeUInt;\r\nFunction TryStrToUInt64(const S : String; Out res : NativeLargeUInt) : Boolean;\r\nFunction StrToDWord(const S : String) : DWord;\r\nFunction StrToDWordDef(const S : String; ADefault : DWord) : DWord;\r\nFunction TryStrToDWord(const S : String; Out res : DWord) : Boolean;\r\n\r\nfunction IntToHex(Value: NativeInt; Digits: integer): string;\r\n\r\n{ *****************************************************************************\r\n Float conversions\r\n *****************************************************************************}\r\n\r\nconst\r\n // Note: Currency is internally a double, multiplied by 10000 and truncated.\r\n // The below values are the safe limits, within every step exists.\r\n // Since currency is a double it can take much larger values, but the result\r\n // may differ from Delphi/FPC\r\n MaxCurrency: Currency = 450359962737.0495; // fpc: 922337203685477.5807;\r\n MinCurrency: Currency = -450359962737.0496; // fpc: -922337203685477.5808;\r\n\r\nType\r\n TFloatFormat = (ffFixed,ffGeneral,ffExponent,ffNumber,ffCurrency);\r\n\r\nFunction FloatToDecimal(Value : double; Precision, Decimals : integer) : TFloatRec;\r\nFunction FloatToStr(Value: Double): String;\r\nFunction FloatToStrF(const Value : double; format: TFloatFormat; Precision, Digits: Integer): String;\r\nFunction TryStrToFloat(const S : String; Out res : Double) : Boolean;\r\nFunction StrToFloatDef(const S : String; Const aDef : Double) : Double;\r\nFunction StrToFloat(const S : String) : Double;\r\nFunction FormatFloat (Fmt : String; aValue : Double) : String;\r\n\r\n{ *****************************************************************************\r\n Boolean conversions\r\n *****************************************************************************}\r\n\r\nVar\r\n TrueBoolStrs, FalseBoolStrs : Array of String;\r\n\r\nfunction StrToBool(const S: String): Boolean;\r\nfunction BoolToStr(B: Boolean; UseBoolStrs:Boolean=False): string;\r\nfunction BoolToStr(B: Boolean; const TrueS, FalseS: String): string;\r\nfunction StrToBoolDef(const S: String; Default: Boolean): Boolean;\r\nfunction TryStrToBool(const S: String; out Value: Boolean): Boolean;\r\n\r\n\r\n{*****************************************************************************\r\n OS/Environment\r\n*****************************************************************************}\r\n\r\nConst\r\n ConfigExtension : String = '.cfg';\r\n SysConfigDir : String = '';\r\n\r\ntype\r\n TOnGetEnvironmentVariable = function(Const EnvVar: String): String;\r\n TOnGetEnvironmentString = function(Index: Integer): String;\r\n TOnGetEnvironmentVariableCount = function: Integer;\r\nvar\r\n OnGetEnvironmentVariable: TOnGetEnvironmentVariable;\r\n OnGetEnvironmentString: TOnGetEnvironmentString;\r\n OnGetEnvironmentVariableCount: TOnGetEnvironmentVariableCount;\r\n\r\nfunction GetEnvironmentVariable(Const EnvVar: String): String;\r\nfunction GetEnvironmentVariableCount: Integer;\r\nfunction GetEnvironmentString(Index: Integer): String;\r\n\r\nprocedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);\r\nProcedure Abort;\r\n\r\n{*****************************************************************************\r\n Events\r\n*****************************************************************************}\r\nType\r\n TEventType = (etCustom,etInfo,etWarning,etError,etDebug);\r\n TEventTypes = Set of TEventType;\r\n\r\n{*****************************************************************************\r\n Date and time\r\n*****************************************************************************}\r\nType\r\n \r\n TDateTime = double;\r\n \r\n TTime = TDateTime;\r\n TDate = TDateTime;\r\n \r\n TSystemTime = record\r\n Year, Month, Day, DayOfWeek: word;\r\n Hour, Minute, Second, MilliSecond: word;\r\n end ;\r\n TTimeStamp = record\r\n Time: longint; { Number of milliseconds since midnight }\r\n Date: longint; { One plus number of days since 1/1/0001 }\r\n end ;\r\n\r\n\r\nVar\r\n TimeSeparator : char = ':';\r\n DateSeparator : char = '-';\r\n ShortDateFormat : string = 'yyyy-mm-dd';\r\n LongDateFormat : string = 'ddd, yyyy-mm-dd';\r\n ShortTimeFormat : string = 'hh:nn';\r\n LongTimeFormat : string = 'hh:nn:ss';\r\n DecimalSeparator : string = '.';\r\n ThousandSeparator : string;\r\n TimeAMString : string = 'AM';\r\n TimePMString : string = 'PM';\r\n\r\nconst\r\n\r\n HoursPerDay = 24;\r\n MinsPerHour = 60;\r\n SecsPerMin = 60;\r\n MSecsPerSec = 1000;\r\n MinsPerDay = HoursPerDay * MinsPerHour;\r\n SecsPerDay = MinsPerDay * SecsPerMin;\r\n MSecsPerDay = SecsPerDay * MSecsPerSec;\r\n MaxDateTime: TDateTime = 2958465.99999999;\r\n MinDateTime: TDateTime = -693593.99999999;\r\n\r\n JulianEpoch = TDateTime(-2415018.5);\r\n UnixEpoch = JulianEpoch + TDateTime(2440587.5);\r\n\r\n DateDelta = 693594; // Days between 1/1/0001 and 12/31/1899\r\n UnixDateDelta = 25569;\r\n\r\n { True=Leapyear }\r\n\r\nVar\r\n MonthDays : array [Boolean] of TDayTable =\r\n ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),\r\n (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));\r\n ShortMonthNames : TMonthNames = (\r\n 'Jan',\r\n 'Feb',\r\n 'Mar',\r\n 'Apr',\r\n 'May',\r\n 'Jun',\r\n 'Jul',\r\n 'Aug',\r\n 'Sep',\r\n 'Oct',\r\n 'Nov',\r\n 'Dec');\r\n LongMonthNames : TMonthNames = (\r\n 'January',\r\n 'February',\r\n 'March',\r\n 'April',\r\n 'May',\r\n 'June',\r\n 'July',\r\n 'August',\r\n 'September',\r\n 'October',\r\n 'November',\r\n 'December');\r\n ShortDayNames : TDayNames = (\r\n 'Sun',\r\n 'Mon',\r\n 'Tue',\r\n 'Wed',\r\n 'Thu',\r\n 'Fri',\r\n 'Sat');\r\n\r\n LongDayNames : TDayNames = (\r\n 'Sunday',\r\n 'Monday',\r\n 'Tuesday',\r\n 'Wednesday',\r\n 'Thursday',\r\n 'Friday',\r\n 'Saturday');\r\n\r\ntype\r\n // Stub, for easier porting of FPC/Delphi code.\r\n // Reading/Writing the properties will actually set the global variables\r\n\r\n { TFormatSettings }\r\n\r\n TFormatSettings = class(TObject)\r\n private\r\n function GetCurrencyDecimals: Byte;\r\n function GetCurrencyFormat: Byte;\r\n function GetCurrencyString: String;\r\n function GetDateSeparator: char;\r\n function GetDecimalSeparator: string;\r\n function GetLongDateFormat: string;\r\n function GetLongDayNames: TDayNames;\r\n function GetLongMonthNames: TMonthNames;\r\n function GetLongTimeFormat: string;\r\n function GetNegCurrFormat: Byte;\r\n function GetShortDateFormat: string;\r\n function GetShortDayNames: TDayNames;\r\n function GetShortMonthNames: TMonthNames;\r\n function GetShortTimeFormat: string;\r\n function GetThousandSeparator: string;\r\n function GetTimeAMString: string;\r\n function GetTimePMString: string;\r\n function GetTimeSeparator: char;\r\n procedure SetCurrencyFormat(AValue: Byte);\r\n procedure SetCurrencyString(AValue: String);\r\n procedure SetDateSeparator(const Value: char);\r\n procedure SetDecimalSeparator(const Value: string);\r\n procedure SetLongDateFormat(const Value: string);\r\n procedure SetLongDayNames(AValue: TDayNames);\r\n procedure SetLongMonthNames(AValue: TMonthNames);\r\n procedure SetLongTimeFormat(const Value: string);\r\n procedure SetNegCurrFormat(AValue: Byte);\r\n procedure SetShortDateFormat(const Value: string);\r\n procedure SetShortDayNames(AValue: TDayNames);\r\n procedure SetShortMonthNames(AValue: TMonthNames);\r\n procedure SetShortTimeFormat(const Value: string);\r\n procedure SetCurrencyDecimals(AValue: Byte);\r\n procedure SetThousandSeparator(const Value: string);\r\n procedure SetTimeAMString(const Value: string);\r\n procedure SetTimePMString(const Value: string);\r\n procedure SetTimeSeparator(const Value: char);\r\n public\r\n Property ShortMonthNames : TMonthNames Read GetShortMonthNames Write SetShortMonthNames;\r\n Property LongMonthNames : TMonthNames Read GetLongMonthNames Write SetLongMonthNames;\r\n Property ShortDayNames : TDayNames Read GetShortDayNames Write SetShortDayNames;\r\n Property LongDayNames : TDayNames Read GetLongDayNames Write SetLongDayNames;\r\n property TimeSeparator : char read GetTimeSeparator write SetTimeSeparator;\r\n property DateSeparator : char read GetDateSeparator write SetDateSeparator;\r\n property ShortDateFormat : string read GetShortDateFormat write SetShortDateFormat;\r\n property LongDateFormat : string read GetLongDateFormat write SetLongDateFormat;\r\n property ShortTimeFormat : string read GetShortTimeFormat write SetShortTimeFormat;\r\n property LongTimeFormat : string read GetLongTimeFormat write SetLongTimeFormat;\r\n property DecimalSeparator : string read GetDecimalSeparator write SetDecimalSeparator;\r\n property ThousandSeparator : string read GetThousandSeparator write SetThousandSeparator;\r\n property TimeAMString : string read GetTimeAMString write SetTimeAMString;\r\n property TimePMString : string read GetTimePMString write SetTimePMString;\r\n Property CurrencyFormat : Byte read GetCurrencyFormat Write SetCurrencyFormat;\r\n Property NegCurrFormat : Byte read GetNegCurrFormat Write SetNegCurrFormat;\r\n Property CurrencyDecimals : Byte Read GetCurrencyDecimals Write SetCurrencyDecimals;\r\n Property CurrencyString : String Read GetCurrencyString Write SetCurrencyString;\r\n end;\r\n\r\nVar\r\n FormatSettings: TFormatSettings;\r\n TwoDigitYearCenturyWindow : word = 50;\r\n { Threshold to be subtracted from year before age-detection.}\r\n\r\n\r\nfunction DateTimeToJSDate(aDateTime : TDateTime) : TJSDate;\r\nfunction JSDateToDateTime(aDate : TJSDate) : TDateTime;\r\n\r\nfunction DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;\r\nfunction TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;\r\nfunction MSecsToTimeStamp(MSecs: NativeInt): TTimeStamp;\r\nfunction TimeStampToMSecs(const TimeStamp: TTimeStamp): NativeInt;\r\nfunction TryEncodeDate(Year, Month, Day: Word; out Date: TDateTime): Boolean;\r\nfunction TryEncodeTime(Hour, Min, Sec, MSec: Word; out Time: TDateTime): Boolean;\r\nfunction EncodeDate(Year, Month, Day :word): TDateTime;\r\nfunction EncodeTime(Hour, Minute, Second, MilliSecond:word): TDateTime;\r\nfunction ComposeDateTime(Date,Time : TDateTime) : TDateTime;\r\nprocedure DecodeDate(Date: TDateTime; out Year, Month, Day: word);\r\nfunction DecodeDateFully(const DateTime: TDateTime; out Year, Month, Day, DOW: Word): Boolean;\r\nprocedure DecodeTime(Time: TDateTime; out Hour, Minute, Second, MilliSecond: word);\r\nprocedure DateTimeToSystemTime(DateTime: TDateTime; out SystemTime: TSystemTime);\r\nfunction SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;\r\nfunction DayOfWeek(DateTime: TDateTime): integer;\r\nfunction Date: TDateTime;\r\nfunction Time: TDateTime;\r\nfunction Now: TDateTime;\r\nfunction IncMonth(const DateTime: TDateTime; NumberOfMonths: integer = 1 ): TDateTime;\r\nprocedure IncAMonth(var Year, Month, Day: Word; NumberOfMonths: Integer = 1);\r\nfunction IsLeapYear(Year: Word): boolean;\r\nfunction DateToStr(Date: TDateTime): string;\r\n// function DateToStr(Date: TDateTime; const FormatSettings: TFormatSettings): string;\r\nfunction TimeToStr(Time: TDateTime): string;\r\n// function TimeToStr(Time: TDateTime; const FormatSettings: TFormatSettings): string;\r\nfunction DateTimeToStr(DateTime: TDateTime; ForceTimeIfZero : Boolean = False): string;\r\n// function DateTimeToStr(DateTime: TDateTime; const FormatSettings: TFormatSettings; ForceTimeIfZero : Boolean = False): string;\r\nfunction StrToDate(const S: String): TDateTime;\r\nfunction StrToDate(const S: String; separator : char): TDateTime;\r\nfunction StrToDate(const S: String; const useformat : string; separator : char): TDateTime;\r\n//function StrToDate(const S: string; FormatSettings : TFormatSettings): TDateTime;\r\nfunction StrToTime(const S: String): TDateTime;\r\nfunction StrToTime(const S: String; separator : char): TDateTime;\r\n// function StrToTime(const S: string; FormatSettings : TFormatSettings): TDateTime;\r\nfunction StrToDateTime(const S: String): TDateTime;\r\n//function StrToDateTime(const s: ShortString; const FormatSettings : TFormatSettings): TDateTime;\r\nfunction FormatDateTime(const FormatStr: string; const DateTime: TDateTime): string;\r\n// function FormatDateTime(const FormatStr: string; DateTime: TDateTime; const FormatSettings: TFormatSettings; Options : TFormatDateTimeOptions = []): string;\r\nfunction TryStrToDate(const S: String; out Value: TDateTime): Boolean;\r\nfunction TryStrToDate(const S: String; out Value: TDateTime; separator : char): Boolean;\r\nfunction TryStrToDate(const S: String; out Value: TDateTime; const useformat : string; separator : char): Boolean;\r\n// function TryStrToDate(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean;\r\nfunction TryStrToTime(const S: String; out Value: TDateTime): Boolean;\r\nfunction TryStrToTime(const S: String; out Value: TDateTime; separator : char): Boolean;\r\nfunction TryStrToDateTime(const S: String; out Value: TDateTime): Boolean;\r\n// function TryStrToTime(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean;\r\n// function TryStrToDateTime(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean;\r\nfunction StrToDateDef(const S: String; const Defvalue : TDateTime): TDateTime;\r\nfunction StrToDateDef(const S: String; const Defvalue : TDateTime; separator : char): TDateTime;\r\nfunction StrToTimeDef(const S: String; const Defvalue : TDateTime): TDateTime;\r\nfunction StrToTimeDef(const S: String; const Defvalue : TDateTime; separator : char): TDateTime;\r\nfunction StrToDateTimeDef(const S: String; const Defvalue : TDateTime): TDateTime;\r\nfunction CurrentYear:Word;\r\nprocedure ReplaceTime(var dati: TDateTime; NewTime : TDateTime);\r\nprocedure ReplaceDate(var DateTime: TDateTime; const NewDate: TDateTime);\r\nFunction FloatToDateTime (Const Value : Extended) : TDateTime;\r\n\r\n{ *****************************************************************************\r\n Currency support\r\n *****************************************************************************}\r\n\r\nVar\r\n CurrencyFormat : Byte = 0;\r\n NegCurrFormat : Byte = 0;\r\n CurrencyDecimals : Byte = 2;\r\n CurrencyString : String = '$';\r\n\r\nFunction FloattoCurr (Const Value : Extended) : Currency;\r\nfunction TryFloatToCurr(const Value: Extended; var AResult: Currency): Boolean;\r\nFunction CurrToStr(Value: Currency): string;\r\n//Function CurrToStr(Value: Currency; Const FormatSettings: TFormatSettings): string;\r\nfunction StrToCurr(const S: string): Currency;\r\n//function StrToCurr(const S: string; Const FormatSettings: TFormatSettings): Currency;\r\nfunction TryStrToCurr(const S: string;Out Value : Currency): Boolean;\r\n//function TryStrToCurr(const S: string;Out Value : Currency; Const FormatSettings: TFormatSettings): Boolean;\r\nfunction StrToCurrDef(const S: string; Default : Currency): Currency;\r\n//function StrToCurrDef(const S: string; Default : Currency; Const FormatSettings: TFormatSettings): Currency;\r\n\r\n{*****************************************************************************\r\n File Paths\r\n*****************************************************************************}\r\ntype\r\n PathStr = String;\r\n//function ExtractFilePath(const FileName: PathStr): PathStr;\r\n\r\n{*****************************************************************************\r\n Interfaces\r\n*****************************************************************************}\r\n\r\nconst\r\n GUID_NULL: TGuid = '{00000000-0000-0000-0000-000000000000}';\r\n\r\nfunction Supports(const Instance: IInterface; const AClass: TClass; out Obj): Boolean; overload;\r\nfunction Supports(const Instance: IInterface; const IID: TGuid; out Intf): Boolean; overload;\r\nfunction Supports(const Instance: TObject; const IID: TGuid; out Intf): Boolean; overload;\r\nfunction Supports(const Instance: TObject; const IID: TGuidString; out Intf): Boolean; overload;\r\n\r\nfunction Supports(const Instance: IInterface; const AClass: TClass): Boolean; overload;\r\nfunction Supports(const Instance: IInterface; const IID: TGuid): Boolean; overload;\r\nfunction Supports(const Instance: TObject; const IID: TGuid): Boolean; overload;\r\nfunction Supports(const Instance: TObject; const IID: TGuidString): Boolean; overload;\r\n\r\nfunction Supports(const AClass: TClass; const IID: TGuid): Boolean; overload;\r\nfunction Supports(const AClass: TClass; const IID: TGuidString): Boolean; overload;\r\n\r\nfunction TryStringToGUID(const s: string; out Guid: TGuid): Boolean;\r\nfunction StringToGUID(const S: string): TGuid;\r\nfunction GUIDToString(const guid: TGuid): string;\r\nfunction IsEqualGUID(const guid1, guid2: TGuid): Boolean;\r\nfunction GuidCase(const guid: TGuid; const List: array of TGuid): Integer;\r\n\r\nimplementation\r\n\r\nprocedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);\r\n\r\nVar\r\n S : String;\r\n\r\nbegin\r\n S:='Application raised an exception '+ExceptObject.ClassName;\r\n if ExceptObject is Exception then\r\n S:=S+' : '+Exception(ExceptObject).Message;\r\n{$IFDEF BROWSER}\r\n asm\r\n window.alert(S);\r\n end;\r\n{$ENDIF}\r\n{$IFDEF NODEJS}\r\n Writeln(S);\r\n{$ENDIF}\r\n if ExceptAddr=nil then;\r\nend;\r\n\r\nConst\r\n SAbortError = 'Operation aborted';\r\n\r\nprocedure Abort;\r\nbegin\r\n Raise EAbort.Create(SAbortError);\r\nend;\r\n\r\n\r\nFunction CharInSet(Ch: Char;Const CSet : array of char) : Boolean;\r\n\r\nVar\r\n I : integer;\r\n\r\nbegin\r\n Result:=False;\r\n I:=Length(CSet)-1;\r\n While (Not Result) and (I>=0) do\r\n begin\r\n Result:=(Ch=CSet[i]);\r\n Dec(I);\r\n end;\r\nend;\r\n\r\nfunction LeftStr(const S: string; Count: Integer): String; assembler;\r\nasm\r\n return (Count>0) ? S.substr(0,Count) : \"\";\r\nend;\r\n\r\nfunction RightStr(const S: string; Count: Integer): String; assembler;\r\nasm\r\n var l = S.length;\r\n return (Count<1) ? \"\" : ( Count>=l ? S : S.substr(l-Count));\r\nend;\r\n\r\nfunction Trim(const S: String): String; assembler;\r\nasm\r\n return S.trim();\r\nend;\r\n\r\nfunction TrimLeft(const S: String): String; assembler;\r\nasm\r\n return S.replace(/^[\\s\\uFEFF\\xA0\\x00-\\x1f]+/,'');\r\nend;\r\n\r\nfunction TrimRight(const S: String): String; assembler;\r\nasm\r\n return S.replace(/[\\s\\uFEFF\\xA0\\x00-\\x1f]+$/,'');\r\nend;\r\n\r\nfunction IntToStr(const Value: Integer): string;\r\nbegin\r\n Result:=str(Value);\r\nend;\r\n\r\nFunction FloatToDecimal(Value : double; Precision, Decimals : integer) : TFloatRec;\r\n\r\nConst\r\n Rounds = '234567890';\r\n\r\nvar\r\n Buffer: String; //Though str func returns only 25 chars, this might change in the future\r\n InfNan: string;\r\n Error, N, L, Start, C: Integer;\r\n GotNonZeroBeforeDot, BeforeDot : boolean;\r\n\r\nbegin\r\n if Value=0 then ;\r\n SetLength(Result.Digits,19);\r\n asm\r\n Buffer=Value.toPrecision(21); // Double precision\r\n end;\r\n N := 1;\r\n L := Length(Buffer);\r\n while Buffer[N]=' ' do\r\n Inc(N);\r\n Result.Negative := (Buffer[N] = '-');\r\n if Result.Negative then\r\n Inc(N)\r\n else if (Buffer[N] = '+') then\r\n inc(N);\r\n { special cases for Inf and Nan }\r\n if (L>=N+2) then\r\n begin\r\n InfNan:=copy(Buffer,N,3);\r\n if (InfNan='Inf') then\r\n begin\r\n Result.Digits[0]:=#0;\r\n Result.Exponent:=32767;\r\n exit\r\n end;\r\n if (InfNan='Nan') then\r\n begin\r\n Result.Digits[0]:=#0;\r\n Result.Exponent:=-32768;\r\n exit\r\n end;\r\n end;\r\n Start := N; //Start of digits\r\n Result.Exponent := 0; BeforeDot := true;\r\n GotNonZeroBeforeDot := false;\r\n while (L>=N) and (Buffer[N]<>'E') do\r\n begin\r\n if Buffer[N]='.' then\r\n BeforeDot := false\r\n else\r\n begin\r\n if BeforeDot then\r\n begin // Currently this is always 1 char\r\n Inc(Result.Exponent);\r\n Result.Digits[N-Start] := Buffer[N];\r\n if Buffer[N] <> '0' then\r\n GotNonZeroBeforeDot := true;\r\n end\r\n else\r\n Result.Digits[N-Start-1] := Buffer[N]\r\n end;\r\n Inc(N);\r\n end;\r\n Inc(N); // Pass through 'E'\r\n if N<=L then\r\n begin\r\n Val(Copy(Buffer, N, L-N+1), C, Error); // Get exponent after 'E'\r\n Inc(Result.Exponent, C);\r\n end;\r\n // Calculate number of digits we have from str\r\n if BeforeDot then\r\n N := N - Start - 1\r\n else\r\n N := N - Start - 2;\r\n L := Length(Result.Digits);\r\n if N= L Then\r\n N := L-1;\r\n if N = 0 Then\r\n begin\r\n if Result.Digits[0] >= '5' Then\r\n begin\r\n Result.Digits[0] := '1';\r\n Result.Digits[1] := #0;\r\n Inc(Result.Exponent);\r\n end\r\n Else\r\n Result.Digits[0] := #0;\r\n end //N=0\r\n Else if N > 0 Then\r\n begin\r\n if Result.Digits[N] >= '5' Then\r\n begin\r\n Repeat\r\n Result.Digits[N] := #0;\r\n Dec(N);\r\n // Writeln(N,': ',Result.Digits[N],', Rounding to : ',Rounds[StrToInt(Result.Digits[N])]);\r\n Result.Digits[N]:=Rounds[StrToInt(Result.Digits[N])];\r\n Until (N = 0) Or (Result.Digits[N] < ':');\r\n If Result.Digits[0] = ':' Then\r\n begin\r\n Result.Digits[0] := '1';\r\n Inc(Result.Exponent);\r\n end;\r\n end\r\n Else\r\n begin\r\n Result.Digits[N] := '0';\r\n While (N > -1) And (Result.Digits[N] = '0') Do\r\n begin\r\n Result.Digits[N] := #0;\r\n Dec(N);\r\n end;\r\n end;\r\n end //N>0\r\n Else\r\n Result.Digits[0] := #0;\r\n if (Result.Digits[0] = #0) and\r\n not GotNonZeroBeforeDot then\r\n begin\r\n Result.Exponent := 0;\r\n Result.Negative := False;\r\n end;\r\nend;\r\n\r\n\r\nfunction FloatToStr(Value: Double): String;\r\nbegin\r\n Result:=FloatToStrF(Value,ffGeneral,15,0);\r\nend;\r\n\r\nFunction TryStrToFloat(const S : String; Out res : Double) : Boolean;\r\n\r\nVar\r\n J : JSValue;\r\n N : String;\r\n\r\nbegin\r\n N:=S;\r\n // Delocalize\r\n if (ThousandSeparator <>'') then\r\n N:=StringReplace(N,ThousandSeparator,'',[rfReplaceAll]);\r\n if (DecimalSeparator<>'.') then\r\n N:=StringReplace(N,DecimalSeparator,'.',[]);\r\n J:=parseFloat(N);\r\n Result:=Not jsIsNaN(J);\r\n if Result then\r\n Res:=Double(J);\r\nend;\r\n\r\nFunction StrToFloatDef(const S : String; Const aDef : Double) : Double;\r\n\r\nbegin\r\n if not TryStrToFloat(S,Result) then\r\n Result:=aDef;\r\nend;\r\n\r\nFunction StrToFloat(const S : String) : Double;\r\nbegin\r\n if not TryStrToFloat(S,Result) then\r\n Raise EConvertError.CreateFmt(SErrInvalidFloat,[S]);\r\nend;\r\n\r\nfunction FormatFloat(Fmt: String; aValue: Double): String;\r\n\r\nType\r\n TPosArray = Array of Integer;\r\n\r\nconst\r\n MaxPrecision = 18; // Extended precision\r\n\r\nvar\r\n // Input in usable format\r\n E : Extended; // Value as extended.\r\n FV: TFloatRec; // Value as floatrec.\r\n Section : String; // Format can contain 3 sections, semicolon separated: Pos;Neg;Zero. This is the one to use.\r\n SectionLength : Integer; // Length of section.\r\n // Calculated based on section. Static during output\r\n ThousandSep: Boolean; // Thousands separator detected in format ?\r\n IsScientific: Boolean; // Use Scientific notation ? (E detected in format)\r\n DecimalPos: Integer; // Position of decimal point in pattern.\r\n FirstDigit: Integer; // First actual digit in input (# or 0), relative to decimal point\r\n LastDigit: Integer; // Last required (0) digit, relative to decimal point\r\n RequestedDigits: Integer; // Number of requested digits, # and 0 alike\r\n ExpSize : Integer; // Number of digits in exponent\r\n Available: Integer; // Available digits in FV.\r\n // These change during output loop\r\n Current: Integer; // Current digit in available digits\r\n PadZeroes: Integer; // Difference in requested digits before comma and exponent, needs to be padded with zeroes.\r\n DistToDecimal: Integer; // Place of current digit, relative to decimal point taking in account PadZeroes!\r\n\r\n Procedure InitVars;\r\n\r\n begin\r\n E:=aValue;\r\n Section:='';\r\n SectionLength:=0;\r\n ThousandSep:=false;\r\n IsScientific:=false;\r\n DecimalPos:=0;\r\n FirstDigit:=MaxInt;\r\n LastDigit:=0;\r\n RequestedDigits:=0;\r\n ExpSize:=0;\r\n Available:=-1;\r\n end;\r\n\r\n procedure ToResult(const AChar: Char);\r\n begin\r\n Result:=Result+AChar;\r\n end;\r\n\r\n procedure AddToResult(const AStr: String);\r\n\r\n begin\r\n Result:=Result+AStr;\r\n end;\r\n\r\n procedure WriteDigit(ADigit: Char);\r\n\r\n // Write a digit to result, prepend with decimalseparator or append with 1000 separator\r\n\r\n begin\r\n if ADigit=#0 then exit;\r\n // Writeln('WriteDigit: ',ADigit,', DistToDecimal: ',DistToDecimal);\r\n Dec(DistToDecimal);\r\n // -1 -> we've arrived behind the decimal\r\n if (DistToDecimal=-1) then\r\n begin\r\n AddToResult(DecimalSeparator);\r\n ToResult(ADigit);\r\n end\r\n else\r\n begin\r\n // We're still before the decimal.\r\n ToResult(ADigit);\r\n if ThousandSep and ((DistToDecimal mod 3)=0) and (DistToDecimal>1) then\r\n AddToResult(ThousandSeparator);\r\n end;\r\n end;\r\n\r\n Function GetDigit : Char;\r\n\r\n // Return next digit from available digits.\r\n // May return #0 if none available.\r\n // Will return '0' if applicable.\r\n\r\n begin\r\n // Writeln(' DistToDecimal <= LastDigit : ',DistToDecimal,' < ',LastDigit,' have digit: ',Current<=Available, '(',Current,')');\r\n Result:=#0;\r\n if (Current<=Available) then\r\n begin\r\n Result:=FV.Digits[Current];\r\n Inc(Current);\r\n end\r\n else if (DistToDecimal <= LastDigit) then\r\n Dec(DistToDecimal)\r\n else\r\n Result:='0';\r\n // Writeln('GetDigit ->: ',Result);\r\n end;\r\n\r\n procedure CopyDigit;\r\n\r\n // Copy a digit (#, 0) to the output with the correct value\r\n\r\n begin\r\n // Writeln('CopyDigit ');\r\n if (PadZeroes=0) then\r\n WriteDigit(GetDigit) // No shift needed, just copy what is available.\r\n else if (PadZeroes<0) then\r\n begin\r\n // We must prepend zeroes\r\n Inc(PadZeroes);\r\n if (DistToDecimal<=FirstDigit) then\r\n WriteDigit('0')\r\n else\r\n Dec(DistToDecimal);\r\n end\r\n else\r\n begin\r\n // We must append zeroes\r\n while PadZeroes > 0 do\r\n begin\r\n WriteDigit(GetDigit);\r\n Dec(PadZeroes);\r\n end;\r\n WriteDigit(GetDigit);\r\n end;\r\n end;\r\n\r\n Function GetSections(Var SP : TPosArray) : Integer;\r\n\r\n var\r\n FL : Integer;\r\n i : Integer;\r\n C,Q : Char;\r\n inQuote : Boolean;\r\n\r\n begin\r\n Result:=1;\r\n SP[1]:=-1;\r\n SP[2]:=-1;\r\n SP[3]:=-1;\r\n inQuote:=False;\r\n Q:=#0;\r\n I:=1;\r\n FL:=Length(Fmt);\r\n while (I<=FL) do\r\n begin\r\n C:=Fmt[I];\r\n case C of\r\n ';':\r\n begin\r\n if not InQuote then\r\n begin\r\n if Result>3 then\r\n Raise Exception.Create('Invalid float format');\r\n SP[Result]:=I+1;\r\n Inc(Result);\r\n end;\r\n end;\r\n '\"','''':\r\n begin\r\n if InQuote then\r\n InQuote:=C<>Q\r\n else\r\n begin\r\n InQuote:=True;\r\n Q:=C;\r\n end;\r\n end;\r\n end;\r\n Inc(I);\r\n end;\r\n if SP[Result]=-1 then\r\n SP[Result]:=FL+1;\r\n end;\r\n\r\n Procedure AnalyzeFormat;\r\n\r\n var\r\n I,Len: Integer;\r\n Q,C: Char;\r\n InQuote : Boolean;\r\n\r\n begin\r\n Len:=Length(Section);\r\n I:=1;\r\n InQuote:=False;\r\n Q:=#0;\r\n while (I<=Len) do\r\n begin\r\n C:=Section[i];\r\n if C in ['\"',''''] then\r\n begin\r\n if InQuote then\r\n InQuote:=C<>Q\r\n else\r\n begin\r\n InQuote:=True;\r\n Q:=C;\r\n end;\r\n end\r\n else if not InQuote then\r\n case C of\r\n '.':\r\n if (DecimalPos=0) then\r\n DecimalPos:=RequestedDigits+1;\r\n ',':\r\n ThousandSep:=ThousandSeparator<>#0;\r\n 'e', 'E':\r\n begin\r\n Inc(I);\r\n if (I4 then\r\n ExpSize:=4;\r\n end;\r\n end;\r\n '#':\r\n Inc(RequestedDigits);\r\n '0':\r\n begin\r\n if RequestedDigits0 then\r\n LastDigit:=0;\r\n // Writeln('FirstDigit: ',DecimalPos,'-',FirstDigit);\r\n FirstDigit:=DecimalPos-FirstDigit;\r\n if FirstDigit<0 then\r\n FirstDigit:=0;\r\n end;\r\n\r\n Function ValueOutSideScope : Boolean;\r\n begin\r\n With FV do\r\n Result:=((Exponent >= 18) and (not IsScientific)) or (Exponent = $7FF) or (Exponent = $800)\r\n end;\r\n\r\n Procedure CalcRunVars;\r\n\r\n Var\r\n D,P: Integer;\r\n\r\n begin\r\n if IsScientific then\r\n begin\r\n P:=RequestedDigits;\r\n D:=9999;\r\n end\r\n else\r\n begin\r\n P:=MaxPrecision;\r\n D:=RequestedDigits-DecimalPos+1;\r\n end;\r\n FV:=FloatToDecimal(aValue,P,D);\r\n DistToDecimal:=DecimalPos-1;\r\n if IsScientific then\r\n PadZeroes:=0 // No padding.\r\n else\r\n begin\r\n PadZeroes:=FV.Exponent-(DecimalPos-1);\r\n if (PadZeroes>=0) then\r\n DistToDecimal:=FV.Exponent\r\n end;\r\n // Writeln('PadZeroes : ',PadZeroes, ', DistToDecimal : ',DistToDecimal);\r\n Available:=-1;\r\n while (Available#0) do\r\n Inc(Available);\r\n // Writeln('Available: ',Available);\r\n end;\r\n\r\n Function FormatExponent(ASign: Char; aExponent: Integer) : String;\r\n\r\n begin\r\n Result:=IntToStr(aExponent);\r\n Result:=StringOfChar('0',ExpSize-Length(Result))+Result;\r\n if (aExponent<0) then\r\n Result:='-'+Result\r\n else if (aExponent>0) and (aSign='+') then\r\n Result:=aSign+Result;\r\n end;\r\n\r\nvar\r\n I,S : Integer;\r\n C,Q : Char;\r\n PA : TPosArray;\r\n InLiteral : Boolean;\r\n\r\nbegin\r\n SetLength(PA,4);\r\n Result:='';\r\n Initvars;\r\n // What section to use ?\r\n if (E>0) then\r\n S:=1\r\n else if (E<0) then\r\n S:=2\r\n else\r\n S:=3;\r\n PA[0]:=0;\r\n I:=GetSections(PA);\r\n if (IQ\r\n else\r\n begin\r\n inLiteral:=True;\r\n Q:=C;\r\n end;\r\n end\r\n else if InLiteral then\r\n ToResult(C)\r\n else\r\n case C of\r\n '0', '#':\r\n CopyDigit;\r\n '.', ',':\r\n ; // Do nothing, handled by CopyDigit\r\n 'e', 'E':\r\n begin\r\n ToResult(C); // Always needed\r\n Inc(I);\r\n if I<=Length(Section) then\r\n begin\r\n C:=Section[I];\r\n if (C in ['+','-']) then\r\n begin\r\n AddToResult(FormatExponent(C,FV.Exponent-DecimalPos+1));\r\n // Skip rest\r\n while (I0.0)\r\n else\r\n begin\r\n CheckBoolStrs;\r\n for I:=low(TrueBoolStrs) to High(TrueBoolStrs) do\r\n if Temp=uppercase(TrueBoolStrs[I]) then\r\n begin\r\n Value:=true;\r\n exit;\r\n end;\r\n for I:=low(FalseBoolStrs) to High(FalseBoolStrs) do\r\n if Temp=uppercase(FalseBoolStrs[I]) then\r\n begin\r\n Value:=false;\r\n exit;\r\n end;\r\n Result:=false;\r\n end;\r\nend;\r\n\r\nfunction UpperCase(const s: String): String; assembler;\r\nasm\r\n return s.toUpperCase();\r\nend;\r\n\r\nfunction LowerCase(const s: String): String; assembler;\r\nasm\r\n return s.toLowerCase();\r\nend;\r\n\r\nfunction CompareStr(const s1, s2: String): Integer; assembler;\r\nasm\r\n var l1 = s1.length;\r\n var l2 = s2.length;\r\n if (l1<=l2){\r\n var s = s2.substr(0,l1);\r\n if (s1s){ return 1;\r\n } else { return l1l2){ return 1;\r\n } else if (l10 then\r\n Result:=Copy(S,1,P-1)+DS+Copy(S,P+1,Length(S)-P)\r\n else\r\n Result:=S;\r\nend;\r\n\r\nfunction FormatGeneralFloat(Value : double; Precision : Integer; DS : String) : string;\r\n\r\nVar\r\n P, PE, Q, Exponent: Integer;\r\n\r\nBegin\r\n If (Precision = -1) Or (Precision > maxdigits) Then\r\n Precision := maxdigits;\r\n { First convert to scientific format, with correct precision }\r\n Str(Value:precision+7, Result);\r\n { Delete leading spaces }\r\n Result:=TrimLeft(Result);\r\n P:=Pos('.',Result);\r\n if P=0 then\r\n exit;\r\n { Consider removing exponent }\r\n PE:=Pos('E',Result);\r\n if PE=0 then\r\n begin\r\n Result:=ReplaceDecimalSep(Result,DS);\r\n exit;\r\n end;\r\n { Read exponent }\r\n Q:=PE+2;\r\n Exponent := 0;\r\n while (Q <= Length(Result)) do\r\n begin\r\n Exponent := Exponent*10 + Ord(Result[Q])-Ord('0');\r\n Inc(Q);\r\n end;\r\n if Result[PE+1] = '-' then\r\n Exponent := -Exponent;\r\n if (P+Exponent < PE) and (Exponent > -6) then\r\n begin\r\n { OK to remove exponent }\r\n SetLength(Result,PE-1); { Trim exponent }\r\n if Exponent >= 0 then\r\n begin\r\n { Shift point to right }\r\n for Q := 0 to Exponent-1 do\r\n begin\r\n Result[P] := Result[P+1];\r\n Inc(P);\r\n end;\r\n Result[P] := '.';\r\n P := 1;\r\n if Result[P] = '-' then\r\n Inc(P);\r\n while (Result[P] = '0') and (P < Length(Result)) and (Copy(Result,P+1,Length(DS))<>DS) do\r\n { Trim leading zeros; conversion above should not give any, but occasionally does\r\n because of rounding }\r\n System.Delete(Result,P,1);\r\n end\r\n else\r\n begin\r\n { Add zeros at start }\r\n Insert(Copy('00000',1,-Exponent),Result,P-1);\r\n Result[P-Exponent] := Result[P-Exponent-1]; { Copy leading digit }\r\n Result[P] := '.';\r\n if Exponent <> -1 then\r\n Result[P-Exponent-1] := '0';\r\n end;\r\n { Remove trailing zeros }\r\n Q := Length(Result);\r\n while (Q > 0) and (Result[Q] = '0') do\r\n Dec(Q);\r\n if Result[Q] = '.' then\r\n Dec(Q); { Remove trailing decimal point }\r\n if (Q = 0) or ((Q=1) and (Result[1] = '-')) then\r\n Result := '0'\r\n else\r\n SetLength(Result,Q);\r\n end\r\n else\r\n begin\r\n { Need exponent, but remove superfluous characters }\r\n { Delete trailing zeros }\r\n while Result[PE-1] = '0' do\r\n begin\r\n System.Delete(Result,PE-1,1);\r\n Dec(PE);\r\n end;\r\n { If number ends in decimal point, remove it }\r\n if Result[PE-1] = DS then\r\n begin\r\n System.Delete(Result,PE-1,1);\r\n Dec(PE);\r\n end;\r\n { delete superfluous + in exponent }\r\n if Result[PE+1]='+' then\r\n System.Delete(Result,PE+1,1)\r\n else\r\n Inc(PE);\r\n while Result[PE+1] = '0' do\r\n { Delete leading zeros in exponent }\r\n System.Delete(Result,PE+1,1)\r\n end;\r\n Result:=ReplaceDecimalSep(Result,DS)\r\nend;\r\n\r\nfunction FormatExponentFloat(Value : double; Precision,Digits : Integer;DS : String) : string;\r\n\r\nVar\r\n P: Integer;\r\nBegin\r\n DS:=DecimalSeparator;\r\n If (Precision = -1) Or (Precision > maxdigits) Then\r\n Precision := maxdigits;\r\n Str(Value:Precision+7, Result);\r\n { Delete leading spaces }\r\n while Result[1] = ' ' do\r\n System.Delete(Result, 1, 1);\r\n P:=Pos('E',Result);\r\n if P=0 then\r\n begin\r\n Result:=ReplaceDecimalSep(Result,DS);\r\n exit;\r\n end;\r\n Inc(P, 2);\r\n if Digits > 4 then\r\n Digits:=4;\r\n Digits:=Length(Result) - P - Digits + 1;\r\n if Digits < 0 then\r\n insert(copy('0000',1,-Digits),Result,P)\r\n else\r\n while (Digits > 0) and (Result[P] = '0') do\r\n begin\r\n System.Delete(Result, P, 1);\r\n if P > Length(Result) then\r\n begin\r\n System.Delete(Result, P - 2, 2);\r\n break;\r\n end;\r\n Dec(Digits);\r\n end;\r\n Result:=ReplaceDecimalSep(Result,DS);\r\nEnd;\r\n\r\nfunction FormatFixedFloat(Value : double; Digits : Integer; DS : String) : string;\r\n\r\nBegin\r\n If Digits = -1 Then\r\n Digits := 2\r\n Else If Digits > 18 Then\r\n Digits := 18;\r\n Str(Value:0:Digits, Result);\r\n if (Result<>'') and (Result[1]=' ') then\r\n Delete(Result,1,1);\r\n Result:=ReplaceDecimalSep(Result,DS);\r\nend;\r\n\r\n\r\nfunction FormatNumberFloat(Value : double; Digits : Integer; DS,TS : String) : string;\r\n\r\nVar\r\n P : integer;\r\n\r\nBegin\r\n If Digits = -1 Then\r\n Digits := 2\r\n else If Digits > maxdigits Then\r\n Digits := maxdigits;\r\n Str(Value:0:Digits, Result);\r\n if (Result<>'') and (Result[1]=' ') then\r\n Delete(Result,1,1);\r\n P:=Pos('.',Result);\r\n Result:=ReplaceDecimalSep(Result,DS);\r\n Dec(P,3);\r\n if (TS<>'') and (TS<>#0) then\r\n While (P>1) Do\r\n Begin\r\n If (Result[P-1] <> '-') Then\r\n Insert(TS, Result, P);\r\n Dec(P, 3);\r\n End;\r\nEnd;\r\n\r\nfunction RemoveLeadingNegativeSign(var AValue: String; DS : String): Boolean;\r\n\r\n// removes negative sign in case when result is zero eg. -0.00\r\n\r\nvar\r\n i: PtrInt;\r\n TS: String;\r\n StartPos: PtrInt;\r\n\r\nbegin\r\n Result:=False;\r\n StartPos := 2;\r\n TS := ThousandSeparator;\r\n for i :=StartPos to length(AValue) do\r\n begin\r\n Result := (AValue[i] in ['0', DS, 'E', '+']) or (aValue=TS);\r\n if not Result then\r\n break;\r\n end;\r\n if (Result) then\r\n Delete(AValue, 1, 1);\r\nend;\r\n\r\nFunction FormatNumberCurrency(const Value : Currency; Digits : Integer; DS,TS : String) : string;\r\n\r\nVar\r\n Negative: Boolean;\r\n P : Integer;\r\n\r\nBegin\r\n If Digits = -1 Then\r\n Digits := CurrencyDecimals\r\n Else If Digits > 18 Then\r\n Digits := 18;\r\n Str(Value:0:Digits, Result);\r\n Negative:=Result[1] = '-';\r\n if Negative then\r\n System.Delete(Result, 1, 1);\r\n P := Pos('.', Result);\r\n If P <> 0 Then\r\n Result:=ReplaceDecimalSep(Result,DS)\r\n else\r\n P := Length(Result)+1;\r\n Dec(P, 3);\r\n While (P > 1) Do\r\n Begin\r\n If ThousandSeparator<>#0 Then\r\n Insert(FormatSettings.ThousandSeparator, Result, P);\r\n Dec(P, 3);\r\n End;\r\n if (length(Result) > 1) and Negative then\r\n Negative := not RemoveLeadingNegativeSign(Result,DS);\r\n If Not Negative Then\r\n Case CurrencyFormat Of\r\n 0: Result := CurrencyString + Result;\r\n 1: Result := Result + CurrencyString;\r\n 2: Result := CurrencyString + ' ' + Result;\r\n 3: Result := Result + ' ' + CurrencyString;\r\n end\r\n else\r\n Case NegCurrFormat Of\r\n 0: Result := '(' + CurrencyString + Result + ')';\r\n 1: Result := '-' + CurrencyString + Result;\r\n 2: Result := CurrencyString + '-' + Result;\r\n 3: Result := CurrencyString + Result + '-';\r\n 4: Result := '(' + Result + CurrencyString + ')';\r\n 5: Result := '-' + Result + CurrencyString;\r\n 6: Result := Result + '-' + CurrencyString;\r\n 7: Result := Result + CurrencyString + '-';\r\n 8: Result := '-' + Result + ' ' + CurrencyString;\r\n 9: Result := '-' + CurrencyString + ' ' + Result;\r\n 10: Result := Result + ' ' + CurrencyString + '-';\r\n 11: Result := CurrencyString + ' ' + Result + '-';\r\n 12: Result := CurrencyString + ' ' + '-' + Result;\r\n 13: Result := Result + '-' + ' ' + CurrencyString;\r\n 14: Result := '(' + CurrencyString + ' ' + Result + ')';\r\n 15: Result := '(' + Result + ' ' + CurrencyString + ')';\r\n end;\r\n if TS='' then ;\r\nend;\r\n\r\nFunction FloatToStrF(const Value : double; format: TFloatFormat; Precision, Digits: Integer): String;\r\n\r\nVar\r\n DS: string;\r\n\r\nBegin\r\n DS:=DecimalSeparator;\r\n Case format Of\r\n ffGeneral:\r\n Result:=FormatGeneralFloat(Value,Precision,DS);\r\n ffExponent:\r\n Result:=FormatExponentFloat(Value,Precision,Digits,DS);\r\n ffFixed:\r\n Result:=FormatFixedFloat(Value,Digits,DS);\r\n ffNumber:\r\n Result:=FormatNumberFloat(Value,Digits,DS,ThousandSeparator);\r\n ffCurrency:\r\n Result:=FormatNumberCurrency(Value,Digits,DS,ThousandSeparator);\r\n end;\r\n if (Format<>ffCurrency) and (length(Result)>1) and (Result[1]='-') then\r\n RemoveLeadingNegativeSign(Result,DS);\r\nend;\r\n\r\nfunction Format (const Fmt: String; const Args: array of jsvalue): String;\r\n\r\nVar ChPos,OldPos,ArgPos,DoArg,Len : SizeInt;\r\n Hs,ToAdd : String;\r\n Index : SizeInt;\r\n Width,Prec : Longint;\r\n Left : Boolean;\r\n Fchar : char;\r\n vq : nativeint;\r\n\r\n {\r\n ReadFormat reads the format string. It returns the type character in\r\n uppercase, and sets index, Width, Prec to their correct values,\r\n or -1 if not set. It sets Left to true if left alignment was requested.\r\n In case of an error, DoFormatError is called.\r\n }\r\n\r\n Function ReadFormat : Char;\r\n\r\n Var Value : NativeInt;\r\n\r\n Procedure ReadInteger;\r\n\r\n var\r\n Code: integer;\r\n ArgN: SizeInt;\r\n begin\r\n If Value<>-1 then exit; // Was already read.\r\n OldPos:=ChPos;\r\n While (ChPos<=Len) and\r\n (Fmt[ChPos]<='9') and (Fmt[ChPos]>='0') do inc(ChPos);\r\n If ChPos>len then\r\n DoFormatError(feInvalidFormat,Fmt);\r\n If Fmt[ChPos]='*' then\r\n begin\r\n\r\n if Index=-1 then\r\n ArgN:=Argpos\r\n else\r\n begin\r\n ArgN:=Index;\r\n Inc(Index);\r\n end;\r\n\r\n If (ChPos>OldPos) or (ArgN>High(Args)) then\r\n DoFormatError(feInvalidFormat,Fmt);\r\n\r\n ArgPos:=ArgN+1;\r\n\r\n if IsNumber(Args[ArgN]) and IsInteger(Args[ArgN]) then\r\n Value:=Integer(Args[ArgN])\r\n else\r\n DoFormatError(feInvalidFormat,Fmt);\r\n Inc(ChPos);\r\n end\r\n else\r\n begin\r\n If (OldPos0 then DoFormatError (feInvalidFormat,Fmt);\r\n end\r\n else\r\n Value:=-1;\r\n end;\r\n end;\r\n\r\n Procedure ReadIndex;\r\n\r\n begin\r\n If Fmt[ChPos]<>':' then\r\n ReadInteger\r\n else\r\n value:=0; // Delphi undocumented behaviour, assume 0, #11099\r\n If Fmt[ChPos]=':' then\r\n begin\r\n If Value=-1 then DoFormatError(feMissingArgument,Fmt);\r\n Index:=Value;\r\n Value:=-1;\r\n Inc(ChPos);\r\n end;\r\n end;\r\n\r\n Procedure ReadLeft;\r\n\r\n begin\r\n If Fmt[ChPos]='-' then\r\n begin\r\n left:=True;\r\n Inc(ChPos);\r\n end\r\n else\r\n Left:=False;\r\n end;\r\n\r\n Procedure ReadWidth;\r\n\r\n begin\r\n ReadInteger;\r\n If Value<>-1 then\r\n begin\r\n Width:=Value;\r\n Value:=-1;\r\n end;\r\n end;\r\n\r\n Procedure ReadPrec;\r\n\r\n begin\r\n If Fmt[ChPos]='.' then\r\n begin\r\n inc(ChPos);\r\n ReadInteger;\r\n If Value=-1 then\r\n Value:=0;\r\n prec:=Value;\r\n end;\r\n end;\r\n\r\n\r\n begin\r\n Index:=-1;\r\n Width:=-1;\r\n Prec:=-1;\r\n Value:=-1;\r\n inc(ChPos);\r\n If Fmt[ChPos]='%' then\r\n begin\r\n Result:='%';\r\n exit; // VP fix\r\n end;\r\n ReadIndex;\r\n ReadLeft;\r\n ReadWidth;\r\n ReadPrec;\r\n Result:=Upcase(Fmt[ChPos]);\r\n end;\r\n\r\n\r\n function Checkarg (AT : TJSValueType; err:boolean):boolean;\r\n {\r\n Check if argument INDEX is of correct type (AT)\r\n If Index=-1, ArgPos is used, and argpos is augmented with 1\r\n DoArg is set to the argument that must be used.\r\n }\r\n begin\r\n result:=false;\r\n if Index=-1 then\r\n DoArg:=Argpos\r\n else\r\n DoArg:=Index;\r\n ArgPos:=DoArg+1;\r\n If (Doarg>High(Args)) or (GetValueTYpe(Args[Doarg])<>AT) then\r\n begin\r\n if err then\r\n DoFormatError(feInvalidArgindex,Fmt);\r\n dec(ArgPos);\r\n exit;\r\n end;\r\n result:=true;\r\n end;\r\n\r\nbegin\r\n Result:='';\r\n Len:=Length(Fmt);\r\n ChPos:=1;\r\n OldPos:=1;\r\n ArgPos:=0;\r\n While ChPos<=len do\r\n begin\r\n While (ChPos<=Len) and (Fmt[ChPos]<>'%') do\r\n inc(ChPos);\r\n If ChPos>OldPos Then\r\n Result:=Result+Copy(Fmt,OldPos,ChPos-Oldpos);\r\n If ChPos'-' then\r\n ToAdd:=StringOfChar('0',Index)+ToAdd\r\n else\r\n // + 1 to accomodate for - sign in length !!\r\n Insert(StringOfChar('0',Index+1),toadd,2);\r\n end;\r\n 'U' : begin\r\n Checkarg(jvtinteger,True);\r\n if NativeInt(Args[Doarg])<0 then\r\n DoFormatError(feInvalidArgindex,Fmt);\r\n Toadd:=IntToStr(NativeInt(Args[Doarg]));\r\n Width:=Abs(width);\r\n Index:=Prec-Length(ToAdd);\r\n ToAdd:=StringOfChar('0',Index)+ToAdd\r\n end;\r\n 'E' : begin\r\n if CheckArg(jvtFloat,false) or CheckArg(jvtInteger,True) then\r\n ToAdd:=FloatToStrF(Double(Args[doarg]),ffFixed,9999,Prec);\r\n end;\r\n 'F' : begin\r\n if CheckArg(jvtFloat,false) or CheckArg(jvtInteger,True) then\r\n ToAdd:=FloatToStrF(Double(Args[doarg]),ffFixed,9999,Prec);\r\n end;\r\n 'G' : begin\r\n if CheckArg(jvtFloat,false) or CheckArg(jvtInteger,True) then\r\n ToAdd:=FloatToStrF(Double(Args[doarg]),ffGeneral,Prec,3);\r\n end;\r\n 'N' : begin\r\n if CheckArg(jvtFloat,false) or CheckArg(jvtInteger,True) then\r\n ToAdd:=FloatToStrF(Double(Args[doarg]),ffNumber,9999,Prec);\r\n end;\r\n 'M' : begin\r\n if CheckArg(jvtFloat,false) or CheckArg(jvtInteger,True) then\r\n ToAdd:=FloatToStrF(Double(Args[doarg]),ffCurrency,9999,Prec);\r\n end;\r\n 'S' : begin\r\n CheckArg(jvtString,true);\r\n hs:=String(Args[doarg]);\r\n Index:=Length(hs);\r\n If (Prec<>-1) and (Index>Prec) then\r\n Index:=Prec;\r\n ToAdd:=Copy(hs,1,Index);\r\n end;\r\n 'P' : Begin\r\n CheckArg(jvtInteger,true);\r\n ToAdd:=IntToHex(NativeInt(Args[DoArg]),31);\r\n end;\r\n 'X' : begin\r\n Checkarg(jvtinteger,true);\r\n vq:=nativeInt(Args[Doarg]);\r\n index:=31; // May need to adjust to NativeInt\r\n If Prec>index then\r\n ToAdd:=IntToHex(vq,index)\r\n else\r\n begin\r\n // determine minimum needed number of hex digits.\r\n Index:=1;\r\n While (NativeInt(1) shl (Index*4)<=vq) and (index<16) do\r\n inc(Index);\r\n If Index>Prec then\r\n Prec:=Index;\r\n ToAdd:=IntToHex(vq,Prec);\r\n end;\r\n end;\r\n '%': ToAdd:='%';\r\n end;\r\n If Width<>-1 then\r\n If Length(ToAdd)= Len then exit;\r\n First := True;\r\n end;\r\n end\r\n else\r\n if not (Ident[I] in AlphaNum) then exit;\r\n I:=I+1;\r\n end;\r\n Result:=true;\r\nend;\r\n\r\nprocedure FreeAndNil(var Obj);\r\nvar\r\n o: TObject;\r\nbegin\r\n o:=TObject(Obj);\r\n if o=nil then exit;\r\n TObject(Obj):=nil;\r\n o.Destroy;\r\nend;\r\n\r\n{ EVariantError }\r\n\r\nconstructor EVariantError.CreateCode(Code: Longint);\r\nbegin\r\n ErrCode:=Code;\r\nend;\r\n\r\n{ Exception }\r\n\r\nconstructor Exception.Create(const Msg: String);\r\nbegin\r\n fMessage:=Msg;\r\nend;\r\n\r\nconstructor Exception.CreateFmt(const Msg: string; const Args: array of JSValue);\r\nbegin\r\n //writeln('Exception.CreateFmt START ',ClassName,' \"',Msg,'\" Args=',Args);\r\n fMessage:=Format(Msg,Args);\r\n //writeln('Exception.CreateFmt END ',ClassName,' \"',Msg,'\" fMessage=',fMessage);\r\nend;\r\n\r\nconstructor Exception.CreateHelp(const Msg: String; AHelpContext: Integer);\r\nbegin\r\n fMessage:=Msg;\r\n fHelpContext:=AHelpContext;\r\nend;\r\n\r\nconstructor Exception.CreateFmtHelp(const Msg: string;\r\n const Args: array of JSValue; AHelpContext: Integer);\r\nbegin\r\n fMessage:=Format(Msg,Args);\r\n fHelpContext:=AHelpContext;\r\nend;\r\n\r\nfunction Exception.ToString: String;\r\nbegin\r\n Result:=ClassName+': '+Message;\r\nend;\r\n\r\nConst\r\n RESpecials = '([\\[\\]\\(\\)\\\\\\.\\*])';\r\n\r\nFunction StringReplace(aOriginal, aSearch, aReplace : string; Flags : TStringReplaceFlags) : String;\r\n\r\nVar\r\n REFlags : String;\r\n REString : String;\r\n\r\nbegin\r\n REFlags:='';\r\n if rfReplaceAll in flags then\r\n ReFlags:='g';\r\n if rfIgnoreCase in flags then\r\n ReFlags:=ReFlags+'i';\r\n REString:=TJSString(aSearch).replace(TJSRegexp.new(RESpecials,'g'),'\\$1');\r\n Result:=TJSString(aOriginal).replace(TJSRegexp.new(REString,REFlags),aReplace);\r\nend;\r\n\r\nFunction QuoteString(aOriginal : String; AQuote : Char) : String;\r\n\r\nVar\r\n REString : String;\r\n\r\nbegin\r\n REString:=TJSString(aQuote).replace(TJSRegexp.new(aOriginal,'g'),'\\\\$1');\r\n Result:=AQuote+TJSString(aOriginal).replace(TJSRegexp.new(REString,'g'),'$1\\$1')+AQuote;\r\nend;\r\n\r\nfunction IsDelimiter(const Delimiters, S: string; Index: Integer): Boolean;\r\nbegin\r\n Result:=False;\r\n if (Index>0) and (Index<=Length(S)) then\r\n Result:=Pos(S[Index],Delimiters)<>0; // Note we don't do MBCS yet\r\nend;\r\n\r\nfunction AdjustLineBreaks(const S: string): string;\r\n\r\nbegin\r\n Result:=AdjustLineBreaks(S,DefaultTextLineBreakStyle);\r\nend;\r\n\r\nfunction AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string;\r\n\r\nvar\r\n I,L: Longint;\r\n Res : String;\r\n\r\n Procedure Add(C : Char);\r\n begin\r\n Res:=Res+C;\r\n end;\r\n\r\nbegin\r\n I:=0;\r\n L:=Length(S);\r\n Result:='';\r\n While (I<=L) do\r\n case S[I] of\r\n #10: begin\r\n if Style in [tlbsCRLF,tlbsCR] then\r\n Add(#13);\r\n if Style=tlbsCRLF then\r\n Add(#10);\r\n Inc(I);\r\n end;\r\n #13: begin\r\n if Style=tlbsCRLF then\r\n Add(#13);\r\n Add(#10);\r\n Inc(I);\r\n if S[I]=#10 then\r\n Inc(I);\r\n end;\r\n else\r\n Add(S[i]);\r\n Inc(I);\r\n end;\r\n Result:=Res;\r\nend;\r\n\r\nfunction WrapText(const Line, BreakStr: string; const BreakChars: Array of char; MaxCol: Integer): string;\r\n\r\nconst\r\n Quotes = ['''', '\"'];\r\n\r\nVar\r\n L : String;\r\n C,LQ,BC : Char;\r\n P,BLen,Len : Integer;\r\n HB,IBC : Boolean;\r\n\r\nbegin\r\n Result:='';\r\n L:=Line;\r\n Blen:=Length(BreakStr);\r\n If (BLen>0) then\r\n BC:=BreakStr[1]\r\n else\r\n BC:=#0;\r\n Len:=Length(L);\r\n While (Len>0) do\r\n begin\r\n P:=1;\r\n LQ:=#0;\r\n HB:=False;\r\n IBC:=False;\r\n While ((P<=Len) and ((P<=MaxCol) or not IBC)) and ((LQ<>#0) or Not HB) do\r\n begin\r\n C:=L[P];\r\n If (C=LQ) then\r\n LQ:=#0\r\n else If (C in Quotes) then\r\n LQ:=C;\r\n If (LQ<>#0) then\r\n Inc(P)\r\n else\r\n begin\r\n HB:=((C=BC) and (BreakStr=Copy(L,P,BLen)));\r\n If HB then\r\n Inc(P,Blen)\r\n else\r\n begin\r\n If (P>=MaxCol) then\r\n IBC:=CharInSet(C,BreakChars);\r\n Inc(P);\r\n end;\r\n end;\r\n// Writeln('\"',C,'\" : IBC : ',IBC,' HB : ',HB,' LQ : ',LQ,' P>MaxCol : ',P>MaxCol);\r\n end;\r\n Result:=Result+Copy(L,1,P-1);\r\n Delete(L,1,P-1);\r\n Len:=Length(L);\r\n If (Len>0) and Not HB then\r\n Result:=Result+BreakStr;\r\n end;\r\nend;\r\n\r\nfunction WrapText(const Line: string; MaxCol: Integer): string;\r\n\r\nbegin\r\n Result:=WrapText(Line,sLineBreak, [' ', '-', #9], MaxCol);\r\nend;\r\n\r\n\r\nfunction GetEnvironmentVariable(const EnvVar: String): String;\r\nbegin\r\n if Assigned(OnGetEnvironmentVariable) then\r\n Result:=OnGetEnvironmentVariable(EnvVar)\r\n else\r\n Result:='';\r\nend;\r\n\r\nfunction GetEnvironmentVariableCount: Integer;\r\nbegin\r\n if Assigned(OnGetEnvironmentVariableCount) then\r\n Result:=OnGetEnvironmentVariableCount()\r\n else\r\n Result:=0;\r\nend;\r\n\r\nfunction GetEnvironmentString(Index: Integer): String;\r\nbegin\r\n if Assigned(OnGetEnvironmentString) then\r\n Result:=OnGetEnvironmentString(Index)\r\n else\r\n Result:='';\r\nend;\r\n\r\n{ Date/Time routines}\r\n\r\nFunction DoEncodeDate(Year, Month, Day: Word): longint;\r\n\r\nVar\r\n D : TDateTime;\r\n\r\nbegin\r\n If TryEncodeDate(Year,Month,Day,D) then\r\n Result:=Trunc(D)\r\n else\r\n Result:=0;\r\nend;\r\n\r\nfunction DoEncodeTime(Hour, Minute, Second, MilliSecond: word): TDateTime;\r\n\r\nbegin\r\n If not TryEncodeTime(Hour,Minute,Second,MilliSecond,Result) then\r\n Result:=0;\r\nend;\r\n\r\nFunction DateTimeToJSDate(aDateTime : TDateTime) : TJSDate;\r\n\r\nVar\r\n Y,M,D,h,n,s,z : Word;\r\n\r\nbegin\r\n DecodeDate(Trunc(aDateTime),Y,M,D);\r\n DecodeTime(Frac(aDateTime),H,N,S,Z);\r\n Result:=TJSDate.New(Y,M,D,h,n,s,z);\r\nend;\r\n\r\nFunction JSDatetoDateTime(ADate: TJSDate) : TDateTime;\r\n\r\nbegin\r\n Result:=EncodeDate(ADate.FullYear,ADate.Month+1,ADate.Date) +\r\n EncodeTime(ADate.Hours,ADate.Minutes,ADate.Seconds,ADate.Milliseconds);\r\nend;\r\n\r\n\r\n{ ComposeDateTime converts a Date and a Time into one TDateTime }\r\nfunction ComposeDateTime(Date,Time : TDateTime) : TDateTime;\r\n\r\nbegin\r\n if Date < 0 then\r\n Result := trunc(Date) - Abs(frac(Time))\r\n else\r\n Result := trunc(Date) + Abs(frac(Time));\r\nend;\r\n\r\nFunction TryEncodeDate(Year,Month,Day : Word; Out Date : TDateTime) : Boolean;\r\n\r\nvar\r\n c, ya: LongWord;\r\nbegin\r\n Result:=(Year>0) and (Year<10000) and\r\n (Month >= 1) and (Month<=12) and\r\n (Day>0) and (Day<=MonthDays[IsleapYear(Year),Month]);\r\n If Result then\r\n begin\r\n if month > 2 then\r\n Dec(Month,3)\r\n else\r\n begin\r\n Inc(Month,9);\r\n Dec(Year);\r\n end;\r\n c:= Year DIV 100;\r\n ya:= Year - 100*c;\r\n Date := (146097*c) SHR 2 + (1461*ya) SHR 2 + (153*LongWord(Month)+2) DIV 5 + LongWord(Day);\r\n // Note that this line can't be part of the line above, since TDateTime is\r\n // signed and c and ya are not\r\n Date := Date - 693900;\r\n end\r\nend;\r\n\r\nfunction TryEncodeTime(Hour, Min, Sec, MSec:word; Out Time : TDateTime) : boolean;\r\n\r\nbegin\r\n Result:=(Hour<24) and (Min<60) and (Sec<60) and (MSec<1000);\r\n If Result then\r\n Time:=TDateTime(LongWord(Hour)*3600000+LongWord(Min)*60000+LongWord(Sec)*1000+MSec)/MSecsPerDay;\r\nend;\r\n\r\n{ EncodeDate packs three variables Year, Month and Day into a\r\n TDateTime value the result is the number of days since 12/30/1899 }\r\n\r\nfunction EncodeDate(Year, Month, Day: word): TDateTime;\r\n\r\nbegin\r\n If Not TryEncodeDate(Year,Month,Day,Result) then\r\n Raise EConvertError.CreateFmt('%s-%s-%s is not a valid date specification',\r\n [IntToStr(Year),IntToStr(Month),IntToStr(Day)]);\r\nend;\r\n\r\n{ EncodeTime packs four variables Hour, Minute, Second and MilliSecond into\r\n a TDateTime value }\r\n\r\nfunction EncodeTime(Hour, Minute, Second, MilliSecond:word):TDateTime;\r\n\r\nbegin\r\n If not TryEncodeTime(Hour,Minute,Second,MilliSecond,Result) then\r\n Raise EConvertError.CreateFmt('%s:%s:%s.%s is not a valid time specification',\r\n [IntToStr(Hour),IntToStr(Minute),IntToStr(Second),IntToStr(MilliSecond)]);\r\nend;\r\n\r\n\r\n{ DecodeDate unpacks the value Date into three values:\r\n Year, Month and Day }\r\n\r\nprocedure DecodeDate(Date: TDateTime; out Year, Month, Day: word);\r\nvar\r\n ly,ld,lm,j : LongWord;\r\nbegin\r\n if Date <= -datedelta then // If Date is before 1-1-1 then return 0-0-0\r\n begin\r\n Year := 0;\r\n Month := 0;\r\n Day := 0;\r\n end\r\n else\r\n begin\r\n if Date>0 then\r\n Date:=(Date+(1/(msecsperday*2)))\r\n else\r\n Date:=Date-(1/(msecsperday*2));\r\n if Date>MaxDateTime then\r\n Date:=MaxDateTime;\r\n// Raise EConvertError.CreateFmt('%f is not a valid TDatetime encoding, maximum value is %f.',[Date,MaxDateTime]);\r\n j := ((Trunc(Date) + 693900) SHL 2)-1;\r\n ly:= j DIV 146097;\r\n j:= j - 146097 * LongWord(ly);\r\n ld := j SHR 2;\r\n j:=(ld SHL 2 + 3) DIV 1461;\r\n ld:= ((ld SHL 2) + 7 - 1461*j) SHR 2;\r\n lm:=(5 * ld-3) DIV 153;\r\n ld:= (5 * ld +2 - 153*lm) DIV 5;\r\n ly:= 100 * LongWord(ly) + j;\r\n if lm < 10 then\r\n inc(lm,3)\r\n else\r\n begin\r\n dec(lm,9);\r\n inc(ly);\r\n end;\r\n year:=ly;\r\n month:=lm;\r\n day:=ld;\r\n end;\r\nend;\r\n\r\n\r\nfunction DecodeDateFully(const DateTime: TDateTime; out Year, Month, Day, DOW: Word): Boolean;\r\nbegin\r\n DecodeDate(DateTime,Year,Month,Day);\r\n DOW:=DayOfWeek(DateTime);\r\n Result:=IsLeapYear(Year);\r\nend;\r\n { DateTimeToTimeStamp converts DateTime to a TTimeStamp }\r\n\r\nfunction DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;\r\n\r\nVar\r\n D : Double;\r\nbegin\r\n D:=DateTime * Double(MSecsPerDay);\r\n if D<0 then\r\n D:=D-0.5\r\n else\r\n D:=D+0.5;\r\n result.Time := Trunc(Abs(Trunc(D)) Mod MSecsPerDay);\r\n result.Date := DateDelta + (Trunc(D) div MSecsPerDay);\r\nend;\r\n\r\n{ TimeStampToDateTime converts TimeStamp to a TDateTime value }\r\n\r\nfunction TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;\r\nbegin\r\n Result := ComposeDateTime(TimeStamp.Date - DateDelta,TimeStamp.Time/MSecsPerDay)\r\nend;\r\n\r\n{ MSecsToTimeStamp }\r\n\r\nfunction MSecsToTimeStamp(MSecs: NativeInt): TTimeStamp;\r\nbegin\r\n result.Date := Trunc(msecs/msecsperday);\r\n msecs:= msecs-NativeInt(result.date)*msecsperday;\r\n result.Time := Round(MSecs);\r\nend;\r\n\r\nfunction TimeStampToMSecs(const TimeStamp: TTimeStamp): NativeInt;\r\nbegin\r\n result := TimeStamp.Time + (timestamp.date*msecsperday);\r\nend ;\r\n\r\n\r\n\r\n{ DecodeTime unpacks Time into four values:\r\n Hour, Minute, Second and MilliSecond }\r\n\r\nprocedure DecodeTime(Time: TDateTime; out Hour, Minute, Second, MilliSecond: word);\r\nVar\r\n l : LongWord;\r\nbegin\r\n l := DateTimeToTimeStamp(Time).Time;\r\n Hour := l div 3600000;\r\n l := l mod 3600000;\r\n Minute := l div 60000;\r\n l := l mod 60000;\r\n Second := l div 1000;\r\n l := l mod 1000;\r\n MilliSecond := l;\r\nend;\r\n\r\n{ DateTimeToSystemTime converts DateTime value to SystemTime }\r\n\r\nprocedure DateTimeToSystemTime(DateTime: TDateTime; out SystemTime: TSystemTime);\r\nbegin\r\n DecodeDateFully(DateTime, SystemTime.Year, SystemTime.Month, SystemTime.Day,SystemTime.DayOfWeek);\r\n DecodeTime(DateTime, SystemTime.Hour, SystemTime.Minute, SystemTime.Second, SystemTime.MilliSecond);\r\n Dec(SystemTime.DayOfWeek);\r\nend ;\r\n\r\n{ SystemTimeToDateTime converts SystemTime to a TDateTime value }\r\n\r\nfunction SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;\r\nbegin\r\n result := ComposeDateTime(DoEncodeDate(SystemTime.Year, SystemTime.Month, SystemTime.Day),\r\n DoEncodeTime(SystemTime.Hour, SystemTime.Minute, SystemTime.Second, SystemTime.MilliSecond));\r\nend ;\r\n\r\nfunction DayOfWeek(DateTime: TDateTime): integer;\r\nbegin\r\n Result := 1 + ((Trunc(DateTime) - 1) mod 7);\r\n If (Result<=0) then\r\n Inc(Result,7);\r\nend;\r\n\r\n\r\n\r\nfunction Now: TDateTime;\r\nbegin\r\n Result:=JSDateToDateTime(TJSDate.New());\r\nend;\r\n\r\nfunction Date: TDateTime;\r\n\r\nbegin\r\n Result:=Trunc(Now);\r\nend;\r\n\r\nfunction Time: TDateTime;\r\nbegin\r\n Result:=Now-Date;\r\nend ;\r\n\r\n{ IncMonth increments DateTime with NumberOfMonths months,\r\n NumberOfMonths can be less than zero }\r\n\r\nfunction IncMonth(const DateTime: TDateTime; NumberOfMonths: integer = 1 ): TDateTime;\r\nvar\r\n Year, Month, Day : word;\r\nbegin\r\n DecodeDate(DateTime, Year, Month, Day);\r\n IncAMonth(Year, Month, Day, NumberOfMonths);\r\n result := ComposeDateTime(DoEncodeDate(Year, Month, Day), DateTime);\r\nend ;\r\n\r\n{ IncAMonth is the same as IncMonth, but operates on decoded date }\r\n\r\nprocedure IncAMonth(var Year, Month, Day: Word; NumberOfMonths: Integer = 1);\r\nvar\r\n TempMonth, S: Integer;\r\nbegin\r\n If NumberOfMonths>=0 then\r\n s:=1\r\n else\r\n s:=-1;\r\n inc(Year,(NumberOfMonths div 12));\r\n TempMonth:=Month+(NumberOfMonths mod 12)-1;\r\n if (TempMonth>11) or\r\n (TempMonth<0) then\r\n begin\r\n Dec(TempMonth, S*12);\r\n Inc(Year, S);\r\n end;\r\n Month:=TempMonth+1; { Months from 1 to 12 }\r\n If (Day>MonthDays[IsLeapYear(Year)][Month]) then\r\n Day:=MonthDays[IsLeapYear(Year)][Month];\r\nend;\r\n\r\n{ IsLeapYear returns true if Year is a leap year }\r\n\r\nfunction IsLeapYear(Year: Word): boolean;\r\nbegin\r\n Result := (Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0));\r\nend;\r\n\r\n{ DateToStr returns a string representation of Date using ShortDateFormat }\r\n\r\nfunction DateToStr(Date: TDateTime): string;\r\nbegin\r\n Result:=FormatDateTime('ddddd', Date);\r\nend ;\r\n\r\n{ TimeToStr returns a string representation of Time using LongTimeFormat }\r\n\r\nfunction TimeToStr(Time: TDateTime): string;\r\nbegin\r\n Result:=FormatDateTime('tt',Time);\r\nend ;\r\n\r\n{ DateTimeToStr returns a string representation of DateTime using LongDateTimeFormat }\r\n\r\nVar\r\n DateTimeToStrFormat : Array[Boolean] of string = ('c','f');\r\n\r\nfunction DateTimeToStr(DateTime: TDateTime; ForceTimeIfZero : Boolean = False): string;\r\nbegin\r\n Result:=FormatDateTime(DateTimeToStrFormat[ForceTimeIfZero], DateTime)\r\nend ;\r\n\r\n\r\n{ StrToDate converts the string S to a TDateTime value\r\n if S does not represent a valid date value\r\n an EConvertError will be raised }\r\n\r\nfunction IntStrToDate(Out ErrorMsg : String; const S: String; const useformat : string; separator : char): TDateTime;\r\n\r\nConst\r\n WhiteSpace = ' '#8#9#10#12#13;\r\n Digits = '0123456789';\r\n\r\n procedure FixErrorMsg(const errmarg : String);\r\n\r\n begin\r\n ErrorMsg:=Format(SInvalidDateFormat,[errmarg]);\r\n end;\r\n\r\nvar\r\n df:string;\r\n d,m,y,ly,ld,lm:word;\r\n n,i,len:longint;\r\n c: integer;\r\n dp,mp,yp,which : Byte;\r\n s1:string;\r\n values: array of integer;\r\n YearMoreThenTwoDigits : boolean;\r\n\r\nbegin\r\n SetLength(values,4);\r\n Result:=0;\r\n Len:=Length(S);\r\n ErrorMsg:='';\r\n While (Len>0) and (Pos(S[Len],WhiteSpace)>0) do\r\n Dec(len);\r\n if (Len=0) then\r\n begin\r\n FixErrorMsg(S);\r\n exit;\r\n end;\r\n YearMoreThenTwoDigits := False;\r\n if separator = #0 then\r\n if (DateSeparator<>#0) then\r\n separator := DateSeparator\r\n else\r\n separator:='-';\r\n // Writeln('Separator: ',Separator);\r\n df := UpperCase(useFormat);\r\n { Determine order of D,M,Y }\r\n yp:=0;\r\n mp:=0;\r\n dp:=0;\r\n Which:=0;\r\n i:=0;\r\n while (i0 then\r\n s1 := s1 + s[i];\r\n { space can be part of the shortdateformat, and is defaultly in slovak\r\n windows, therefor it shouldn't be taken as separator (unless so specified)\r\n and ignored }\r\n if (Separator <> ' ') and (s[i] = ' ') then\r\n Continue;\r\n if (s[i] = separator) or ((i = len) and (Pos(s[i],Digits)>0)) then\r\n begin\r\n inc(n);\r\n if n>3 then\r\n begin\r\n// Writeln('More than 3 separators');\r\n FixErrorMsg(S);\r\n exit;\r\n end;\r\n // Check if the year has more then two digits (if n=yp, then we are evaluating the year.)\r\n if (n=yp) and (length(s1)>2) then YearMoreThenTwoDigits := True;\r\n val(s1, values[n], c);\r\n if c<>0 then\r\n begin\r\n// Writeln('S1 not a number ',S1);\r\n FixErrorMsg(s);\r\n Exit;\r\n end;\r\n s1 := '';\r\n end\r\n else if (Pos(s[i],Digits)=0) then\r\n begin\r\n// Writeln('Not a number at pos ',I,' ',S[i]);\r\n FixErrorMsg(s);\r\n Exit;\r\n end;\r\n end ;\r\n// Writeln('Which : ',Which,' N : ',N);\r\n if (Which<3) and (N>Which) then\r\n begin\r\n FixErrorMsg(s);\r\n Exit;\r\n end;\r\n // Fill in values.\r\n DecodeDate(Date,Ly,LM,LD);\r\n If N=3 then\r\n begin\r\n y:=values[yp];\r\n m:=values[mp];\r\n d:=values[dp];\r\n end\r\n Else\r\n begin\r\n Y:=ly;\r\n If n<2 then\r\n begin\r\n d:=values[1];\r\n m := LM;\r\n end\r\n else\r\n If dp= 0) and (y < 100) and not YearMoreThenTwoDigits then\r\n begin\r\n ly := ly - TwoDigitYearCenturyWindow;\r\n Inc(Y, ly div 100 * 100);\r\n if (TwoDigitYearCenturyWindow > 0) and (Y < ly) then\r\n Inc(Y, 100);\r\n end;\r\n if not TryEncodeDate(y, m, d, result) then\r\n errormsg:=SErrInvalidDate;\r\nend;\r\n\r\nfunction StrToDate(const S: String; const useformat : string; separator : char): TDateTime;\r\nVar\r\n MSg : String;\r\nbegin\r\n Result:=IntStrToDate(Msg,S,useFormat,Separator);\r\n If (Msg<>'') then\r\n Raise EConvertError.Create(Msg);\r\nend;\r\n\r\nfunction StrToDate(const S: String; separator : char): TDateTime;\r\nbegin\r\n result := StrToDate(S,ShortDateFormat,separator)\r\nend;\r\n\r\nfunction StrToDate(const S: String): TDateTime;\r\nbegin\r\n result := StrToDate(S,ShortDateFormat,#0);\r\nend;\r\n\r\n{ StrToTime converts the string S to a TDateTime value\r\n if S does not represent a valid time value an\r\n EConvertError will be raised }\r\n\r\n\r\nfunction IntStrToTime(Out ErrorMsg : String; const S: String; Len : integer; separator : char): TDateTime;\r\n\r\nconst\r\n AMPM_None = 0;\r\n AMPM_AM = 1;\r\n AMPM_PM = 2;\r\n tiHour = 0;\r\n tiMin = 1;\r\n tiSec = 2;\r\n tiMSec = 3;\r\n\r\ntype\r\n TTimeValues = array of Word;\r\n\r\nvar\r\n AmPm: integer;\r\n TimeValues: TTimeValues;\r\n\r\n\r\n function SplitElements(out TimeValues: TTimeValues; out AmPm: Integer): Boolean;\r\n //Strict version. It does not allow #32 as Separator, it will treat it as whitespace always\r\n const\r\n Digits = '0123456789';\r\n var\r\n Cur, Offset, ElemLen, Err, TimeIndex, FirstSignificantDigit: Integer;\r\n Value: Integer;\r\n DigitPending, MSecPending: Boolean;\r\n AmPmStr: String;\r\n CurChar: Char;\r\n I : Integer;\r\n allowedchars : string;\r\n\r\n begin\r\n Result := False;\r\n AmPm := AMPM_None; //No Am or PM in string found yet\r\n MSecPending := False;\r\n TimeIndex := 0; //indicating which TTimeValue must be filled next\r\n For I:=tiHour to tiMSec do\r\n TimeValues[i]:=0;\r\n Cur := 1;\r\n //skip leading blanks\r\n While (Cur < Len) and (S[Cur] =#32) do Inc(Cur);\r\n Offset := Cur;\r\n //First non-blank cannot be Separator or DecimalSeparator\r\n if (Cur > Len - 1) or (S[Cur] = Separator) or (S[Cur] = Decimalseparator) then\r\n begin\r\n // Writeln('Error in sep S[Cur]',S[Cur],' ',separator,' ',GetDecimalSeparator);\r\n Exit;\r\n end;\r\n DigitPending := (Pos(S[Cur],Digits)>0);\r\n While (Cur <= Len) do\r\n begin\r\n //writeln;\r\n // writeln('Main While loop: Cur = ',Cur,' S[Cur] = \"',S[Cur],'\" Len = ',Len,' separator : ',Separator);\r\n CurChar := S[Cur];\r\n if Pos(CurChar,Digits)>0 then\r\n begin//Digits\r\n //HH, MM, SS, or Msec?\r\n // writeln('Digit: ', CurChar);\r\n //Digits are only allowed after starting Am/PM or at beginning of string or after Separator\r\n //and TimeIndex must be <= tiMSec\r\n //Uncomment \"or (#32 = Separator)\" and it will allllow #32 as separator\r\n if (not (DigitPending {or (#32 = Separator)})) or (TimeIndex > tiMSec) then\r\n begin\r\n // Writeln('DigitPending',ElemLen);\r\n Exit;\r\n end;\r\n OffSet := Cur;\r\n if (CurChar <> '0') then FirstSignificantDigit := OffSet else FirstSignificantDigit := -1;\r\n while (Cur < Len) and (Pos(S[Cur + 1],Digits)>0) do\r\n begin\r\n //Mark first Digit that is not '0'\r\n if (FirstSignificantDigit = -1) and (S[Cur] <> '0') then FirstSignificantDigit := Cur;\r\n Inc(Cur);\r\n end;\r\n if (FirstSignificantDigit = -1) then FirstSignificantDigit := Cur;\r\n ElemLen := 1+ Cur - FirstSignificantDigit;\r\n // writeln(' S[FirstSignificantDigit] = ',S[FirstSignificantDigit], ' S[Cur] = ',S[Cur],' ElemLen = ',ElemLen,' -> ', S[Offset], ElemLen);\r\n // writeln(' Cur = ',Cur);\r\n //this way we know that Val() will never overflow Value !\r\n if (ElemLen <= 2) or ((ElemLen <= 3) and (TimeIndex = tiMSec) ) then\r\n begin\r\n Val(Copy(S,FirstSignificantDigit, ElemLen), Value, Err);\r\n // writeln(' Value = ',Value,' HH = ',TimeValues[0],' MM = ',TimeValues[1],' SS = ',TimeValues[2],' MSec = ',Timevalues[3]);\r\n //This is safe now, because we know Value < High(Word)\r\n TimeValues[TimeIndex] := Value;\r\n Inc(TimeIndex);\r\n DigitPending := False;\r\n end\r\n else\r\n begin\r\n // Writeln('Wrong elemlen: ',ElemLen, ' timeIndex: ',timeindex);\r\n Exit; //Value to big, so it must be a wrong timestring\r\n end;\r\n end//Digits\r\n else if (CurChar = #32) then\r\n begin\r\n //writeln('#32');\r\n //just skip, but we must adress this, or it will be parsed by either AM/PM or Separator\r\n end\r\n else if (CurChar = Separator) then\r\n begin\r\n // writeln('Separator ',Separator);\r\n if DigitPending or (TimeIndex > tiSec) then\r\n begin\r\n // Writeln ('DigitPending ',DigitPending,' or (TimeIndex',Timeindex,' > tiSec,', tiSec,')');\r\n Exit;\r\n end;\r\n DigitPending := True;\r\n MSecPending := False;\r\n end\r\n else if (CurChar = DecimalSeparator) then\r\n begin\r\n //writeln('DecimalSeparator');\r\n if DigitPending or MSecPending or (TimeIndex <> tiMSec) then\r\n begin\r\n // Writeln('DigitPending ',DigitPending,' or MSecPending ',MSecPending,' (',TimeIndex,',Timeindex, >', tiMSec,' tiSec)');\r\n Exit;\r\n end;\r\n DigitPending := True;\r\n MSecPending := True;\r\n end\r\n else\r\n begin//AM/PM?\r\n //None of the above, so this char _must_ be the start of AM/PM string\r\n //If we already have found AM/PM or we expect a digit then then timestring must be wrong at this point\r\n //writeln('AM/PM?');\r\n if (AmPm <> AMPM_None) or DigitPending then\r\n begin\r\n // Writeln('AmPm <> AMPM_None) or DigitPending');\r\n Exit;\r\n end;\r\n OffSet := Cur;\r\n allowedchars:=DecimalSeparator+' ';\r\n if Separator<>#0 then\r\n allowedchars:=allowedchars+Separator;\r\n while (Cur < Len -1) and (Pos(S[Cur + 1],AllowedChars)=0)\r\n and (Pos(S[Cur + 1],Digits)=0) do Inc(Cur);\r\n ElemLen := 1 + Cur - OffSet;\r\n // writeln(' S[Offset] = ',S[1+Offset], ' S[Cur] = ',S[Cur],' ElemLen = ',ElemLen,' -> ', S[1+Offset], ElemLen);\r\n // writeln(' Cur = ',Cur, 'S =',S);\r\n AmPmStr := Copy(S,1+OffSet, ElemLen);\r\n\r\n // writeln('AmPmStr = ',ampmstr,' (',length(ampmstr),')');\r\n //We must compare to TimeAMString before hardcoded 'AM' for delphi compatibility\r\n //Also it is perfectly legal, though insane to have TimeAMString = 'PM' and vice versa\r\n if (CompareText(AmPmStr, TimeAMString) = 0) then AmPm := AMPM_AM\r\n else if (CompareText(AmPmStr, TimePMString) = 0) then AmPm := AMPM_PM\r\n else if (CompareText(AmPmStr, 'AM') = 0) then AmPm := AMPM_AM\r\n else if (CompareText(AmPmStr, 'PM') = 0) then AmPm := AMPM_PM\r\n else\r\n begin\r\n // Writeln('No timestring ',AmPmStr);\r\n Exit; //If text does not match any of these, timestring must be wrong;\r\n end;\r\n //if AM/PM is at beginning of string, then a digit is mandatory after it\r\n if (TimeIndex = tiHour) then\r\n begin\r\n DigitPending := True;\r\n end\r\n //otherwise, no more TimeValues allowed after this\r\n else\r\n begin\r\n TimeIndex := tiMSec + 1;\r\n DigitPending := False;\r\n end;\r\n end;//AM/PM\r\n Inc(Cur)\r\n end;//while\r\n\r\n //If we arrive here, parsing the elements has been successfull\r\n //if not at least Hours specified then input is not valid\r\n //when am/pm is specified Hour must be <= 12 and not 0\r\n if (TimeIndex = tiHour) or ((AmPm <> AMPM_None) and ((TimeValues[tiHour] > 12) or (TimeValues[tiHour] = 0))) or DigitPending then\r\n Exit;\r\n Result := True;\r\n end;\r\n\r\nbegin\r\n setlength(timevalues,4);\r\n if separator = #0 then\r\n if (TimeSeparator<>#0) then\r\n separator := TimeSeparator\r\n else\r\n separator:=':';\r\n AmPm := AMPM_None;\r\n if not SplitElements(TimeValues, AmPm) then\r\n begin\r\n ErrorMsg:=Format(SErrInvalidTimeFormat,[S]);\r\n Exit;\r\n end;\r\n if (AmPm=AMPM_PM) and (TimeValues[tiHour]<>12) then Inc(TimeValues[tiHour], 12)\r\n else if (AmPm=AMPM_AM) and (TimeValues[tiHour]=12) then TimeValues[tiHour]:=0;\r\n // Writeln( TimeValues[tiHour], TimeValues[tiMin], TimeValues[tiSec], TimeValues[tiMSec]);\r\n if not TryEncodeTime(TimeValues[tiHour], TimeValues[tiMin], TimeValues[tiSec], TimeValues[tiMSec], result) Then\r\n\r\n ErrorMsg:=Format(SErrInvalidTimeFormat,[S]);\r\nend ;\r\n\r\nfunction StrToTime(const s: String; separator : char): TDateTime;\r\n\r\nVar\r\n Msg : String;\r\n\r\nbegin\r\n Result:=IntStrToTime(Msg,S,Length(S),Separator);\r\n If (Msg<>'') then\r\n Raise EConvertError.Create(Msg);\r\nend;\r\n\r\nfunction StrToTime(const s: String): TDateTime;\r\nbegin\r\n result:= StrToTime(s, TimeSeparator);\r\nend;\r\n\r\n{ StrToDateTime converts the string S to a TDateTime value\r\n if S does not represent a valid date and/or time value\r\n an EConvertError will be raised }\r\n\r\nfunction SplitDateTimeStr(DateTimeStr: String; out DateStr, TimeStr: String): Integer;\r\n\r\n{ Helper function for StrToDateTime\r\n Pre-condition\r\n Date is before Time\r\n If either Date or Time is omitted then see what fits best, a time or a date (issue #0020522)\r\n Date and Time are separated by whitespace (space Tab, Linefeed or carriage return)\r\n FS.DateSeparator can be the same as FS.TimeSeparator (issue #0020522)\r\n If they are both #32 and TrimWhite(DateTimeStr) contains a #32 a date is assumed.\r\n Post-condition\r\n DateStr holds date as string or is empty\r\n TimeStr holds time as string or is empty\r\n Result = number of strings returned, 0 = error\r\n}\r\nconst\r\n WhiteSpace = #9#10#13#32;\r\n\r\nvar\r\n p: Integer;\r\n DummyDT: TDateTime;\r\nbegin\r\n Result := 0;\r\n DateStr := '';\r\n TimeStr := '';\r\n DateTimeStr := Trim(DateTimeStr);\r\n if Length(DateTimeStr) = 0 then exit;\r\n if (DateSeparator = #32) and (TimeSeparator = #32) and (Pos(#32, DateTimeStr) > 0) then\r\n begin\r\n DateStr:=DateTimeStr;\r\n {\r\n Assume a date: dd [mm [yy]].\r\n Really fancy would be counting the number of whitespace occurrences and decide\r\n and split accordingly\r\n }\r\n Exit(1);\r\n end;\r\n p:=1;\r\n //find separator\r\n if (DateSeparator<>#32) then\r\n begin\r\n while (p0)) do\r\n Inc(p);\r\n end\r\n else\r\n begin\r\n p:=Pos(TimeSeparator, DateTimeStr);\r\n if (p<>0) then\r\n repeat\r\n Dec(p);\r\n until (p=0) or (Pos(DateTimeStr[p],WhiteSpace)>0);\r\n end;\r\n //Always fill DateStr, it eases the algorithm later\r\n if (p=0) then\r\n p:=Length(DateTimeStr);\r\n DateStr:=Copy(DateTimeStr,1,p);\r\n TimeStr:=Trim(Copy(DateTimeStr,p+1,100));\r\n if (Length(TimeStr)<>0) then\r\n Result:=2\r\n else\r\n begin\r\n Result:=1; //found 1 string\r\n // 2 cases when DateTimeStr only contains a time:\r\n // Date/time separator differ, and string contains a timeseparator\r\n // Date/time separators are equal, but transformation to date fails.\r\n if ((DateSeparator<>TimeSeparator) and (Pos(TimeSeparator,DateStr) > 0))\r\n or ((DateSeparator=TimeSeparator) and (not TryStrToDate(DateStr, DummyDT))) then\r\n begin\r\n TimeStr := DateStr;\r\n DateStr := '';\r\n end;\r\n end;\r\nend;\r\n\r\nfunction StrToDateTime(const s: String): TDateTime;\r\n\r\nvar\r\n TimeStr, DateStr: String;\r\n PartsFound: Integer;\r\nbegin\r\n PartsFound := SplitDateTimeStr(S, DateStr, TimeStr);\r\n case PartsFound of\r\n 0: Result:=StrToDate('');\r\n 1: if (Length(DateStr) > 0) then\r\n Result := StrToDate(DateStr,ShortDateFormat,DateSeparator)\r\n else\r\n Result := StrToTime(TimeStr);\r\n 2: Result := ComposeDateTime(StrTodate(DateStr,ShortDateFormat,DateSeparator),\r\n StrToTime(TimeStr));\r\n end;\r\nend;\r\n\r\nFunction FormatDateTime(const FormatStr: string; const DateTime: TDateTime) : String;\r\n\r\n procedure StoreStr(APos,Len: Integer);\r\n begin\r\n// Writeln('StoreStr: ',Result,'+',Copy(FormatStr,APos,Len));\r\n Result:=Result+Copy(FormatStr,APos,Len);\r\n end;\r\n\r\n procedure StoreString(const AStr: string);\r\n\r\n begin\r\n// Writeln('StoreString: ',Result,'+',AStr);\r\n Result:=Result+AStr;\r\n end;\r\n\r\n procedure StoreInt(Value, Digits: Integer);\r\n var\r\n S: string;\r\n\r\n begin\r\n S:=IntToStr(Value);\r\n While (Length(S) 1 then // 0 is original string, 1 is included FormatString\r\n Exit;\r\n FormatCurrent := 1;\r\n FormatEnd := Length(FormatStr);\r\n Clock12 := false;\r\n isInterval := false;\r\n // look for unquoted 12-hour clock token\r\n P:=1;\r\n while P<=FormatEnd do\r\n begin\r\n Token := FormatStr[P];\r\n case Token of\r\n '''', '\"':\r\n begin\r\n Inc(P);\r\n while (P < FormatEnd) and (FormatStr[P]<>Token) do\r\n Inc(P);\r\n end;\r\n 'A', 'a':\r\n begin\r\n if (CompareText(Copy(FormatStr,P,3),'A/P')=0) or\r\n (CompareText(Copy(FormatStr,P,4),'AMPM')=0) or\r\n (CompareText(Copy(FormatStr,P,5),'AM/PM')=0) then\r\n begin\r\n Clock12 := true;\r\n break;\r\n end;\r\n end;\r\n end; // case\r\n Inc(P);\r\n end ;\r\n token := #255;\r\n lastformattoken := ' ';\r\n prevlasttoken := 'H';\r\n while FormatCurrent <= FormatEnd do\r\n begin\r\n Token := UpperCase(FormatStr[FormatCurrent])[1];\r\n // Writeln('Treating token at pos ',FormatCurrent,', : ',Token,' (',FormatStr,')');\r\n Count := 1;\r\n P := FormatCurrent + 1;\r\n case Token of\r\n '''', '\"':\r\n begin\r\n while (P < FormatEnd) and (FormatStr[P]<>Token) do\r\n Inc(P);\r\n Inc(P);\r\n Count := P - FormatCurrent;\r\n StoreStr(FormatCurrent + 1, Count - 2);\r\n end ;\r\n 'A':\r\n begin\r\n if CompareText(Copy(FormatStr,FormatCurrent,4), 'AMPM') = 0 then\r\n begin\r\n Count := 4;\r\n if Hour < 12 then\r\n StoreString(TimeAMString)\r\n else\r\n StoreString(TimePMString);\r\n end\r\n else if CompareText(Copy(FormatStr,FormatCurrent,5), 'AM/PM') = 0 then\r\n begin\r\n Count := 5;\r\n if Hour < 12 then StoreStr(FormatCurrent, 2)\r\n else StoreStr(FormatCurrent+3, 2);\r\n end\r\n else if CompareText(Copy(FormatStr,FormatCurrent,3), 'A/P') = 0 then\r\n begin\r\n Count := 3;\r\n if Hour < 12 then StoreStr(FormatCurrent, 1)\r\n else StoreStr(FormatCurrent+2, 1);\r\n end\r\n else\r\n raise EConvertError.Create('Illegal character in format string');\r\n end ;\r\n '/':\r\n begin\r\n // Writeln('Detected date separator');\r\n StoreString(DateSeparator);\r\n end;\r\n ':': StoreString(TimeSeparator);\r\n ' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y', 'Z', 'F' :\r\n begin\r\n // Writeln(FormatCurrent,' Special Token: ',Token,', Count: ',Count,', P: ',P);\r\n while (P <= FormatEnd) and (UpperCase(FormatStr[P]) = Token) do\r\n Inc(P);\r\n Count := P - FormatCurrent;\r\n // Writeln(FormatCurrent,' Special Token: ',Token,', Count: ',Count,', P: ',P);\r\n case Token of\r\n ' ': StoreStr(FormatCurrent, Count);\r\n 'Y': begin\r\n if Count > 2 then\r\n StoreInt(Year, 4)\r\n else\r\n StoreInt(Year mod 100, 2);\r\n end;\r\n 'M': begin\r\n\t if isInterval and ((prevlasttoken = 'H') or TimeFlag) then\r\n\t StoreInt(Minute + (Hour + trunc(abs(DateTime))*24)*60, 0)\r\n\t else\r\n if (lastformattoken = 'H') or TimeFlag then\r\n begin\r\n if Count = 1 then\r\n StoreInt(Minute, 0)\r\n else\r\n StoreInt(Minute, 2);\r\n end\r\n else\r\n begin\r\n case Count of\r\n 1: StoreInt(Month, 0);\r\n 2: StoreInt(Month, 2);\r\n 3: StoreString(ShortMonthNames[Month]);\r\n else\r\n StoreString(LongMonthNames[Month]);\r\n end;\r\n end;\r\n end;\r\n 'D': begin\r\n case Count of\r\n 1: StoreInt(Day, 0);\r\n 2: StoreInt(Day, 2);\r\n 3: StoreString(ShortDayNames[DayOfWeek]);\r\n 4: StoreString(LongDayNames[DayOfWeek]);\r\n 5: StoreFormat(ShortDateFormat, Nesting+1, False);\r\n else\r\n StoreFormat(LongDateFormat, Nesting+1, False);\r\n end ;\r\n end ;\r\n 'H':\r\n\t if isInterval then\r\n\t StoreInt(Hour + trunc(abs(DateTime))*24, 0)\r\n\t else\r\n\t if Clock12 then\r\n begin\r\n tmp := hour mod 12;\r\n if tmp=0 then tmp:=12;\r\n if Count = 1 then\r\n StoreInt(tmp, 0)\r\n else\r\n StoreInt(tmp, 2);\r\n end\r\n else begin\r\n if Count = 1 then\r\n\t\t StoreInt(Hour, 0)\r\n else\r\n StoreInt(Hour, 2);\r\n end;\r\n 'N': if isInterval then\r\n\t StoreInt(Minute + (Hour + trunc(abs(DateTime))*24)*60, 0)\r\n\t\t else\r\n\t\t if Count = 1 then\r\n StoreInt(Minute, 0)\r\n else\r\n StoreInt(Minute, 2);\r\n 'S': if isInterval then\r\n\t StoreInt(Second + (Minute + (Hour + trunc(abs(DateTime))*24)*60)*60, 0)\r\n\t else\r\n\t if Count = 1 then\r\n StoreInt(Second, 0)\r\n else\r\n StoreInt(Second, 2);\r\n 'Z': if Count = 1 then\r\n StoreInt(MilliSecond, 0)\r\n else\r\n\t\t StoreInt(MilliSecond, 3);\r\n 'T': if Count = 1 then\r\n\t\t StoreFormat(ShortTimeFormat, Nesting+1, True)\r\n else\r\n\t StoreFormat(LongTimeFormat, Nesting+1, True);\r\n 'C': begin\r\n StoreFormat(ShortDateFormat, Nesting+1, False);\r\n if (Hour<>0) or (Minute<>0) or (Second<>0) then\r\n begin\r\n StoreString(' ');\r\n StoreFormat(LongTimeFormat, Nesting+1, True);\r\n end;\r\n end;\r\n 'F': begin\r\n StoreFormat(ShortDateFormat, Nesting+1, False);\r\n StoreString(' ');\r\n StoreFormat(LongTimeFormat, Nesting+1, True);\r\n end;\r\n end;\r\n\t prevlasttoken := lastformattoken;\r\n lastformattoken := token;\r\n end;\r\n else\r\n StoreString(Token);\r\n end ;\r\n Inc(FormatCurrent, Count);\r\n end;\r\n end;\r\n\r\nbegin\r\n DecodeDateFully(DateTime, Year, Month, Day, DayOfWeek);\r\n DecodeTime(DateTime, Hour, Minute, Second, MilliSecond);\r\n // Writeln(DateTime,'->',Year,',', Month, ',',Day, ',',DayOfWeek,',',Hour, ',',Minute, ',',Second, ',',MilliSecond);\r\n if FormatStr <> '' then\r\n StoreFormat(FormatStr, 0, False)\r\n else\r\n StoreFormat('C', 0, False);\r\nend ;\r\n\r\n\r\n\r\nfunction CurrentYear: Word;\r\n\r\nbegin\r\n Result:=TJSDate.New().FullYear;\r\nend;\r\n\r\nfunction TryStrToDate(const S: String; out Value: TDateTime): Boolean;\r\nbegin\r\n Result:=TryStrToDate(S,Value,ShortDateFormat,#0);\r\nend;\r\n\r\nfunction TryStrToDate(const S: String; out Value: TDateTime; separator : char): Boolean;\r\n\r\nbegin\r\n Result:=TryStrToDate(S,Value,ShortDateFormat,Separator);\r\nend;\r\n\r\nfunction TryStrToDate(const S: String; out Value: TDateTime;\r\n const useformat : string; separator : char = #0): Boolean;\r\n\r\nVar\r\n Msg : String;\r\n\r\nbegin\r\n Result:=Length(S)<>0;\r\n If Result then\r\n begin\r\n Value:=IntStrToDate(Msg,S,useformat,Separator);\r\n Result:=(Msg='');\r\n end;\r\nend;\r\n\r\n\r\n\r\n\r\nfunction TryStrToTime(const S: String; out Value: TDateTime; separator : char): Boolean;\r\nVar\r\n Msg : String;\r\nbegin\r\n Result:=Length(S)<>0;\r\n If Result then\r\n begin\r\n Value:=IntStrToTime(Msg,S,Length(S),Separator);\r\n Result:=(Msg='');\r\n end;\r\nend;\r\n\r\nfunction TryStrToTime(const S: String; out Value: TDateTime): Boolean;\r\nbegin\r\n result:=TryStrToTime(S,Value,#0);\r\nend;\r\n\r\nfunction TryStrToDateTime(const S: String; out Value: TDateTime): Boolean;\r\n\r\nvar\r\n I: integer;\r\n dtdate, dttime :TDateTime;\r\nbegin\r\n result:=false;\r\n I:=Pos(TimeSeparator,S);\r\n If (I>0) then\r\n begin\r\n While (I>0) and (S[I]<>' ') do\r\n Dec(I);\r\n If I>0 then\r\n begin\r\n if not TryStrToDate(Copy(S,1,I-1),dtdate) then\r\n exit;\r\n if not TryStrToTime(Copy(S,i+1, Length(S)-i),dttime) then\r\n exit;\r\n Value:=ComposeDateTime(dtdate,dttime);\r\n result:=true;\r\n end\r\n else\r\n result:=TryStrToTime(s,Value);\r\n end\r\n else\r\n result:=TryStrToDate(s,Value);\r\nend;\r\n\r\n\r\n\r\nfunction StrToDateDef(const S: String; const Defvalue : TDateTime): TDateTime;\r\nbegin\r\n result := StrToDateDef(S,DefValue,#0);\r\nend;\r\n\r\nfunction StrToTimeDef(const S: String; const Defvalue : TDateTime): TDateTime;\r\nbegin\r\n result := StrToTimeDef(S,DefValue,#0);\r\nend;\r\n\r\nfunction StrToDateTimeDef(const S: String; const Defvalue : TDateTime): TDateTime;\r\nbegin\r\n if not TryStrToDateTime(s,Result) Then\r\n result:=defvalue;\r\nend;\r\n\r\nfunction StrToDateDef(const S: String; const Defvalue : TDateTime; separator : char): TDateTime;\r\nbegin\r\n if not TryStrToDate(s,Result, separator) Then\r\n result:=defvalue;\r\nend;\r\n\r\nfunction StrToTimeDef(const S: String; const Defvalue : TDateTime; separator : char): TDateTime;\r\nbegin\r\n if not TryStrToTime(s,Result, separator) Then\r\n result:=defvalue;\r\nend;\r\n\r\nprocedure ReplaceTime(var dati:TDateTime; NewTime : TDateTime);\r\nbegin\r\n dati:= ComposeDateTime(dati, newtime);\r\nend;\r\n\r\nprocedure ReplaceDate(var DateTime: TDateTime; const NewDate: TDateTime);\r\nvar\r\n tmp : TDateTime;\r\nbegin\r\n tmp:=NewDate;\r\n ReplaceTime(tmp,DateTime);\r\n DateTime:=tmp;\r\nend;\r\n\r\nFunction FloatToDateTime (Const Value : Extended) : TDateTime;\r\nbegin\r\n If (ValueMaxDateTime) then\r\n Raise EConvertError.CreateFmt (SInvalidDateTime,[FloatToStr(Value)]);\r\n Result:=Value;\r\nend;\r\n\r\nfunction FloattoCurr(const Value: Extended): Currency;\r\nbegin\r\n if not TryFloatToCurr(Value, Result) then\r\n Raise EConvertError.CreateFmt(SInvalidCurrency, [FloatToStr(Value)]);\r\nend;\r\n\r\nfunction TryFloatToCurr(const Value: Extended; var AResult: Currency): Boolean;\r\nbegin\r\n Result:=(Value>=MinCurrency) and (Value<=MaxCurrency);\r\n if Result then\r\n AResult := Value;\r\nend;\r\n\r\nfunction CurrToStr(Value: Currency): string;\r\nbegin\r\n Result:=FloatToStrF(Value,ffGeneral,-1,0);\r\nend;\r\n\r\n(*\r\nfunction CurrToStr(Value: Currency; const FormatSettings: TFormatSettings): string;\r\nbegin\r\n\r\nend;\r\n*)\r\n\r\nfunction StrToCurr(const S: string): Currency;\r\n\r\nbegin\r\n if not TryStrToCurr(S,Result) then\r\n Raise EConvertError.createfmt(SInvalidCurrency,[S]);\r\nend;\r\n\r\n(*\r\nfunction StrToCurr(const S: string; const FormatSettings: TFormatSettings): Currency;\r\nbegin\r\n\r\nend;\r\n*)\r\n\r\nfunction TryStrToCurr(const S: string; out Value: Currency): Boolean;\r\n\r\nVar\r\n D : Double;\r\n\r\nbegin\r\n Result:=TryStrToFloat(S,D);\r\n if Result then\r\n Value:=D;\r\nend;\r\n\r\n(*\r\nfunction TryStrToCurr(const S: string; out Value: Currency; const FormatSettings: TFormatSettings): Boolean;\r\nbegin\r\n\r\nend;\r\n*)\r\n\r\nfunction StrToCurrDef(const S: string; Default: Currency): Currency;\r\n\r\nVar\r\n R : Currency;\r\n\r\nbegin\r\n if TryStrToCurr(S,R) then\r\n Result:=R\r\n else\r\n Result:=Default;\r\nend;\r\n\r\n(*\r\nfunction StrToCurrDef(const S: string; Default: Currency; const FormatSettings: TFormatSettings): Currency;\r\nbegin\r\n\r\nend;\r\n*)\r\n\r\n{ ---------------------------------------------------------------------\r\n Interface related\r\n ---------------------------------------------------------------------}\r\nfunction Supports(const Instance: IInterface; const AClass: TClass; out Obj\r\n ): Boolean;\r\nbegin\r\n Result := (Instance<>nil) and (Instance.QueryInterface(IObjectInstance,Obj)=S_OK)\r\n and (TObject(Obj).InheritsFrom(AClass));\r\nend;\r\n\r\nfunction Supports(const Instance: IInterface; const IID: TGUID; out Intf\r\n ): Boolean;\r\nbegin\r\n Result:=(Instance<>nil) and (Instance.QueryInterface(IID,Intf)=S_OK);\r\nend;\r\n\r\nfunction Supports(const Instance: TObject; const IID: TGUID; out Intf\r\n ): Boolean;\r\nbegin\r\n Result:=(Instance<>nil) and Instance.GetInterface(IID,Intf);\r\nend;\r\n\r\nfunction Supports(const Instance: TObject; const IID: TGuidString; out Intf\r\n ): Boolean;\r\nbegin\r\n Result:=(Instance<>nil) and Instance.GetInterfaceByStr(IID,Intf);\r\nend;\r\n\r\nfunction Supports(const Instance: IInterface; const AClass: TClass): Boolean;\r\nvar\r\n Temp: TObject;\r\nbegin\r\n Result:=Supports(Instance,AClass,Temp);\r\nend;\r\n\r\nfunction Supports(const Instance: IInterface; const IID: TGUID): Boolean;\r\nvar\r\n Temp: IInterface;\r\nbegin\r\n Result:=Supports(Instance,IID,Temp);\r\nend;\r\n\r\nfunction Supports(const Instance: TObject; const IID: TGUID): Boolean;\r\nvar\r\n Temp: TJSObject;\r\nbegin\r\n Result:=Supports(Instance,IID,Temp);\r\n asm\r\n if (Temp && Temp.$kind==='com') Temp._Release();\r\n end;\r\nend;\r\n\r\nfunction Supports(const Instance: TObject; const IID: TGuidString): Boolean;\r\nvar\r\n Temp: TJSObject;\r\nbegin\r\n Result:=Supports(Instance,IID,Temp);\r\n asm\r\n if (Temp && Temp.$kind==='com') Temp._Release();\r\n end;\r\nend;\r\n\r\nfunction Supports(const AClass: TClass; const IID: TGUID): Boolean;\r\nvar\r\n maps: JSValue;\r\nbegin\r\n if AClass=nil then exit(false);\r\n maps := TJSObject(AClass)['$intfmaps'];\r\n if not maps then exit(false);\r\n if TJSObject(maps)[GUIDToString(IID)] then exit(true);\r\n Result:=false;\r\nend;\r\n\r\nfunction Supports(const AClass: TClass; const IID: TGuidString): Boolean;\r\nvar\r\n maps: JSValue;\r\nbegin\r\n if AClass=nil then exit(false);\r\n maps := TJSObject(AClass)['$intfmaps'];\r\n if not maps then exit(false);\r\n if TJSObject(maps)[uppercase(IID)] then exit(true);\r\n Result:=false;\r\nend;\r\n\r\nfunction TryStringToGUID(const s: string; out Guid: TGUID): Boolean;\r\nvar\r\n re: TJSRegexp;\r\nbegin\r\n if Length(s)<>38 then Exit(False);\r\n re:=TJSRegexp.new('^\\{[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\}$');\r\n Result:=re.test(s);\r\n if not Result then\r\n begin\r\n Guid.D1:=0;\r\n exit;\r\n end;\r\n asm\r\n rtl.strToGUIDR(s,Guid.get());\r\n end;\r\n Result:=true;\r\nend;\r\n\r\nfunction StringToGUID(const S: string): TGUID;\r\nbegin\r\n if not TryStringToGUID(S, Result) then\r\n raise EConvertError.CreateFmt(SInvalidGUID, [S]);\r\nend;\r\n\r\nfunction GUIDToString(const guid: TGUID): string;\r\nbegin\r\n Result:=System.GUIDToString(guid);\r\nend;\r\n\r\nfunction IsEqualGUID(const guid1, guid2: TGUID): Boolean;\r\nvar\r\n i: integer;\r\nbegin\r\n if (guid1.D1<>guid2.D1) or (guid1.D2<>guid2.D2) or (guid1.D3<>guid2.D3) then\r\n exit(false);\r\n for i:=0 to 7 do if guid1.D4[i]<>guid2.D4[i] then exit(false);\r\n Result:=true;\r\nend;\r\n\r\nfunction GuidCase(const guid: TGUID; const List: array of TGuid): Integer;\r\nbegin\r\n for Result := High(List) downto 0 do\r\n if IsEqualGUID(guid, List[Result]) then\r\n Exit;\r\n Result := -1;\r\nend;\r\n\r\n{ ---------------------------------------------------------------------\r\n Integer/Ordinal related\r\n ---------------------------------------------------------------------}\r\n\r\nFunction TryStrToInt(const S : String; Out res : Integer) : Boolean;\r\n\r\nVar\r\n NI : NativeInt;\r\n\r\nbegin\r\n Result:=TryStrToInt(S,NI);\r\n if Result then\r\n res:=NI;\r\nend;\r\n\r\nFunction TryStrToInt(const S : String; Out res : NativeInt) : Boolean;\r\n\r\nVar\r\n Radix : Integer = 10;\r\n F,N : String;\r\n J : JSValue;\r\n\r\nbegin\r\n N:=S;\r\n F:=Copy(N,1,1);\r\n if (F='$') then\r\n Radix:=16\r\n else if (F='&') then\r\n Radix:=8\r\n else if (F='%') then\r\n Radix:=2;\r\n If Radix<>10 then\r\n Delete(N,1,1);\r\n J:=parseInt(N,Radix);\r\n Result:=Not jsIsNan(j);\r\n if Result then\r\n res:=NativeInt(J);\r\nend;\r\n\r\nFunction StrToIntDef(const S : String; Const aDef : Integer) : Integer;\r\n\r\nVar\r\n R : NativeInt;\r\n\r\nbegin\r\n if TryStrToInt(S,R) then\r\n Result:=R\r\n else\r\n Result:=aDef;\r\nend;\r\n\r\nFunction StrToIntDef(const S : String; Const aDef : NativeInt) : NativeInt;\r\n\r\nVar\r\n R : NativeInt;\r\n\r\nbegin\r\n if TryStrToInt(S,R) then\r\n Result:=R\r\n else\r\n Result:=aDef;\r\nend;\r\n\r\nFunction StrToInt(const S : String) : Integer;\r\n\r\nVar\r\n R : NativeInt;\r\n\r\nbegin\r\n if not TryStrToInt(S,R) then\r\n Raise EConvertError.CreateFmt(SErrInvalidInteger,[S]);\r\n Result:=R;\r\nend;\r\n\r\nFunction StrToNativeInt(const S : String) : NativeInt;\r\n\r\nbegin\r\n if not TryStrToInt(S,Result) then\r\n Raise EConvertError.CreateFmt(SErrInvalidInteger,[S]);\r\nend;\r\n\r\nFunction StrToInt64(const S : String) : NativeLargeInt;\r\n\r\nVar\r\n N : NativeInt;\r\n\r\nbegin\r\n if not TryStrToInt(S,N) then\r\n Raise EConvertError.CreateFmt(SErrInvalidInteger,[S]);\r\n Result:=N;\r\nend;\r\n\r\nFunction TryStrToInt64(const S : String; Out res : NativeLargeInt) : Boolean;\r\n\r\nVar\r\n R : nativeint;\r\n\r\nbegin\r\n Result:=TryStrToInt(S,R);\r\n If Result then\r\n Res:=R;\r\nend;\r\n\r\nFunction StrToInt64Def(const S : String; ADefault : NativeLargeInt) : NativeLargeInt;\r\n\r\n\r\nbegin\r\n if TryStrToInt64(S,Result) then\r\n Result:=ADefault;\r\nend;\r\n\r\nFunction StrToQWord(const S : String) : NativeLargeUInt;\r\n\r\nVar\r\n N : NativeInt;\r\n\r\nbegin\r\n if (not TryStrToInt(S,N)) or (N<0) then\r\n Raise EConvertError.CreateFmt(SErrInvalidInteger,[S]);\r\n Result:=N;\r\nend;\r\n\r\nFunction TryStrToQWord(const S : String; Out res : NativeLargeUInt) : Boolean;\r\n\r\nVar\r\n R : nativeint;\r\n\r\nbegin\r\n Result:=TryStrToInt(S,R) and (R>=0);\r\n If Result then\r\n Res:=R;\r\nend;\r\n\r\nFunction StrToQWordDef(const S : String; ADefault : NativeLargeUInt) : NativeLargeUInt;\r\n\r\nbegin\r\n if Not TryStrToQword(S,Result) then\r\n Result:=ADefault;\r\nend;\r\n\r\n\r\nFunction StrToUInt64(const S : String) : NativeLargeUInt;\r\n\r\nVar\r\n N : NativeInt;\r\n\r\nbegin\r\n if (not TryStrToInt(S,N)) or (N<0) then\r\n Raise EConvertError.CreateFmt(SErrInvalidInteger,[S]);\r\n Result:=N;\r\nend;\r\n\r\nFunction TryStrToUInt64(const S : String; Out res : NativeLargeUInt) : Boolean;\r\n\r\nVar\r\n R : nativeint;\r\n\r\nbegin\r\n Result:=TryStrToInt(S,R) and (R>=0);\r\n If Result then\r\n Res:=R;\r\nend;\r\n\r\nFunction StrToUInt64Def(const S : String; ADefault : NativeLargeUInt) : NativeLargeUInt;\r\n\r\n\r\nbegin\r\n if Not TryStrToUInt64(S,Result) then\r\n Result:=ADefault;\r\nend;\r\n\r\nFunction TryStrToDWord(const S : String; Out res : DWord) : Boolean;\r\n\r\nVar\r\n R : nativeint;\r\n\r\nbegin\r\n Result:=TryStrToInt(S,R) and (R>=0) and (R<=DWord($FFFFFFFF));\r\n If Result then\r\n Res:=R;\r\nend;\r\n\r\nFunction StrToDWord(const S : String) : DWord;\r\n\r\nbegin\r\n if not TryStrToDWord(S,Result) then\r\n Raise EConvertError.CreateFmt(SErrInvalidInteger,[S]);\r\nend;\r\n\r\n\r\nFunction StrToDWordDef(const S : String; ADefault : DWord) : DWord;\r\n\r\nbegin\r\n if Not TryStrToDWord(S,Result) then\r\n Result:=ADefault;\r\nend;\r\n\r\n\r\nfunction IntToHex(Value: NativeInt; Digits: integer): string;\r\nconst\r\n HexDigits = '0123456789ABCDEF';\r\nbegin\r\n If Digits=0 then\r\n Digits:=1;\r\n Result:='';\r\n While Value>0 do\r\n begin\r\n result:=HexDigits[(value and 15)+1]+Result;\r\n value := value shr 4;\r\n end ;\r\n while (Length(Result)nil) then\r\n GetOwner.GetInterface(IInterface, FOwnerInterface);\r\nend;\r\n\r\n{ TComponentEnumerator }\r\n\r\nconstructor TComponentEnumerator.Create(AComponent: TComponent);\r\nbegin\r\n inherited Create;\r\n FComponent := AComponent;\r\n FPosition := -1;\r\nend;\r\n\r\nfunction TComponentEnumerator.GetCurrent: TComponent;\r\nbegin\r\n Result := FComponent.Components[FPosition];\r\nend;\r\n\r\nfunction TComponentEnumerator.MoveNext: Boolean;\r\nbegin\r\n Inc(FPosition);\r\n Result := FPosition < FComponent.ComponentCount;\r\nend;\r\n\r\n{ TListEnumerator }\r\n\r\nconstructor TListEnumerator.Create(AList: TList);\r\nbegin\r\n inherited Create;\r\n FList := AList;\r\n FPosition := -1;\r\nend;\r\n\r\nfunction TListEnumerator.GetCurrent: JSValue;\r\nbegin\r\n Result := FList[FPosition];\r\nend;\r\n\r\nfunction TListEnumerator.MoveNext: Boolean;\r\nbegin\r\n Inc(FPosition);\r\n Result := FPosition < FList.Count;\r\nend;\r\n\r\n{ TFPListEnumerator }\r\n\r\nconstructor TFPListEnumerator.Create(AList: TFPList);\r\nbegin\r\n inherited Create;\r\n FList := AList;\r\n FPosition := -1;\r\nend;\r\n\r\nfunction TFPListEnumerator.GetCurrent: JSValue;\r\nbegin\r\n Result := FList[FPosition];\r\nend;\r\n\r\nfunction TFPListEnumerator.MoveNext: Boolean;\r\nbegin\r\n Inc(FPosition);\r\n Result := FPosition < FList.Count;\r\nend;\r\n\r\n{ TFPList }\r\n\r\nprocedure TFPList.CopyMove(aList: TFPList);\r\nvar r : integer;\r\nbegin\r\n Clear;\r\n for r := 0 to aList.count-1 do\r\n Add(aList[r]);\r\nend;\r\n\r\nprocedure TFPList.MergeMove(aList: TFPList);\r\nvar r : integer;\r\nbegin\r\n For r := 0 to aList.count-1 do\r\n if IndexOf(aList[r]) < 0 then\r\n Add(aList[r]);\r\nend;\r\n\r\nprocedure TFPList.DoCopy(ListA, ListB: TFPList);\r\nbegin\r\n if Assigned(ListB) then\r\n CopyMove(ListB)\r\n else\r\n CopyMove(ListA);\r\nend;\r\n\r\nprocedure TFPList.DoSrcUnique(ListA, ListB: TFPList);\r\nvar r : integer;\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n Clear;\r\n for r := 0 to ListA.Count-1 do\r\n if ListB.IndexOf(ListA[r]) < 0 then\r\n Add(ListA[r]);\r\n end\r\n else\r\n begin\r\n for r := Count-1 downto 0 do\r\n if ListA.IndexOf(Self[r]) >= 0 then\r\n Delete(r);\r\n end;\r\nend;\r\n\r\nprocedure TFPList.DoAnd(ListA, ListB: TFPList);\r\nvar r : integer;\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n Clear;\r\n for r := 0 to ListA.count-1 do\r\n if ListB.IndexOf(ListA[r]) >= 0 then\r\n Add(ListA[r]);\r\n end\r\n else\r\n begin\r\n for r := Count-1 downto 0 do\r\n if ListA.IndexOf(Self[r]) < 0 then\r\n Delete(r);\r\n end;\r\nend;\r\n\r\nprocedure TFPList.DoDestUnique(ListA, ListB: TFPList);\r\n\r\n procedure MoveElements(Src, Dest: TFPList);\r\n var r : integer;\r\n begin\r\n Clear;\r\n for r := 0 to Src.count-1 do\r\n if Dest.IndexOf(Src[r]) < 0 then\r\n self.Add(Src[r]);\r\n end;\r\n\r\nvar Dest : TFPList;\r\nbegin\r\n if Assigned(ListB) then\r\n MoveElements(ListB, ListA)\r\n else\r\n Dest := TFPList.Create;\r\n try\r\n Dest.CopyMove(Self);\r\n MoveElements(ListA, Dest)\r\n finally\r\n Dest.Destroy;\r\n end;\r\nend;\r\n\r\nprocedure TFPList.DoOr(ListA, ListB: TFPList);\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n CopyMove(ListA);\r\n MergeMove(ListB);\r\n end\r\n else\r\n MergeMove(ListA);\r\nend;\r\n\r\nprocedure TFPList.DoXOr(ListA, ListB: TFPList);\r\nvar\r\n r : integer;\r\n l : TFPList;\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n Clear;\r\n for r := 0 to ListA.Count-1 do\r\n if ListB.IndexOf(ListA[r]) < 0 then\r\n Add(ListA[r]);\r\n for r := 0 to ListB.Count-1 do\r\n if ListA.IndexOf(ListB[r]) < 0 then\r\n Add(ListB[r]);\r\n end\r\n else\r\n begin\r\n l := TFPList.Create;\r\n try\r\n l.CopyMove(Self);\r\n for r := Count-1 downto 0 do\r\n if listA.IndexOf(Self[r]) >= 0 then\r\n Delete(r);\r\n for r := 0 to ListA.Count-1 do\r\n if l.IndexOf(ListA[r]) < 0 then\r\n Add(ListA[r]);\r\n finally\r\n l.Destroy;\r\n end;\r\n end;\r\nend;\r\n\r\nfunction TFPList.Get(Index: Integer): JSValue;\r\nbegin\r\n If (Index < 0) or (Index >= FCount) then\r\n RaiseIndexError(Index);\r\n Result:=FList[Index];\r\nend;\r\n\r\nprocedure TFPList.Put(Index: Integer; Item: JSValue);\r\nbegin\r\n if (Index < 0) or (Index >= FCount) then\r\n RaiseIndexError(Index);\r\n FList[Index] := Item;\r\nend;\r\n\r\nprocedure TFPList.SetCapacity(NewCapacity: Integer);\r\nbegin\r\n If (NewCapacity < FCount) then\r\n Error (SListCapacityError, str(NewCapacity));\r\n if NewCapacity = FCapacity then\r\n exit;\r\n SetLength(FList,NewCapacity);\r\n FCapacity := NewCapacity;\r\nend;\r\n\r\nprocedure TFPList.SetCount(NewCount: Integer);\r\nbegin\r\n if (NewCount < 0) then\r\n Error(SListCountError, str(NewCount));\r\n If NewCount > FCount then\r\n begin\r\n If NewCount > FCapacity then\r\n SetCapacity(NewCount);\r\n end;\r\n FCount := NewCount;\r\nend;\r\n\r\nprocedure TFPList.RaiseIndexError(Index: Integer);\r\nbegin\r\n Error(SListIndexError, str(Index));\r\nend;\r\n\r\ndestructor TFPList.Destroy;\r\nbegin\r\n Clear;\r\n inherited Destroy;\r\nend;\r\n\r\nprocedure TFPList.AddList(AList: TFPList);\r\n\r\nVar\r\n I : Integer;\r\n\r\nbegin\r\n If (Capacity=FCount) then\r\n Error (SListIndexError, str(Index));\r\n FCount := FCount-1;\r\n System.Delete(FList,Index,1);\r\n Dec(FCapacity);\r\nend;\r\n\r\nclass procedure TFPList.Error(const Msg: string; const Data: String);\r\nbegin\r\n Raise EListError.CreateFmt(Msg,[Data]);\r\nend;\r\n\r\nprocedure TFPList.Exchange(Index1, Index2: Integer);\r\nvar\r\n Temp : JSValue;\r\nbegin\r\n If (Index1 >= FCount) or (Index1 < 0) then\r\n Error(SListIndexError, str(Index1));\r\n If (Index2 >= FCount) or (Index2 < 0) then\r\n Error(SListIndexError, str(Index2));\r\n Temp := FList[Index1];\r\n FList[Index1] := FList[Index2];\r\n FList[Index2] := Temp;\r\nend;\r\n\r\nfunction TFPList.Expand: TFPList;\r\nvar\r\n IncSize : Integer;\r\nbegin\r\n if FCount < FCapacity then exit(self);\r\n IncSize := 4;\r\n if FCapacity > 3 then IncSize := IncSize + 4;\r\n if FCapacity > 8 then IncSize := IncSize+8;\r\n if FCapacity > 127 then Inc(IncSize, FCapacity shr 2);\r\n SetCapacity(FCapacity + IncSize);\r\n Result := Self;\r\nend;\r\n\r\nfunction TFPList.Extract(Item: JSValue): JSValue;\r\nvar\r\n i : Integer;\r\nbegin\r\n i := IndexOf(Item);\r\n if i >= 0 then\r\n begin\r\n Result := Item;\r\n Delete(i);\r\n end\r\n else\r\n Result := nil;\r\nend;\r\n\r\nfunction TFPList.First: JSValue;\r\nbegin\r\n If FCount = 0 then\r\n Result := Nil\r\n else\r\n Result := Items[0];\r\nend;\r\n\r\nfunction TFPList.GetEnumerator: TFPListEnumerator;\r\nbegin\r\n Result:=TFPListEnumerator.Create(Self);\r\nend;\r\n\r\nfunction TFPList.IndexOf(Item: JSValue): Integer;\r\n\r\nVar\r\n C : Integer;\r\n\r\nbegin\r\n Result:=0;\r\n C:=Count;\r\n while (ResultItem) do\r\n Inc(Result);\r\n If Result>=C then\r\n Result:=-1;\r\n\r\nend;\r\n\r\nfunction TFPList.IndexOfItem(Item: JSValue; Direction: TDirection): Integer;\r\n\r\nbegin\r\n if Direction=fromBeginning then\r\n Result:=IndexOf(Item)\r\n else\r\n begin\r\n Result:=Count-1;\r\n while (Result >=0) and (Flist[Result]<>Item) do\r\n Result:=Result - 1;\r\n end;\r\nend;\r\n\r\n\r\nprocedure TFPList.Insert(Index: Integer; Item: JSValue);\r\nbegin\r\n if (Index < 0) or (Index > FCount )then\r\n Error(SlistIndexError, str(Index));\r\n TJSArray(FList).splice(Index, 0, Item);\r\n inc(FCapacity);\r\n inc(FCount);\r\nend;\r\n\r\nfunction TFPList.Last: JSValue;\r\nbegin\r\n If FCount = 0 then\r\n Result := nil\r\n else\r\n Result := Items[FCount - 1];\r\nend;\r\n\r\nprocedure TFPList.Move(CurIndex, NewIndex: Integer);\r\nvar\r\n Temp: JSValue;\r\nbegin\r\n if (CurIndex < 0) or (CurIndex > Count - 1) then\r\n Error(SListIndexError, str(CurIndex));\r\n if (NewIndex < 0) or (NewIndex > Count -1) then\r\n Error(SlistIndexError, str(NewIndex));\r\n if CurIndex=NewIndex then exit;\r\n Temp:=FList[CurIndex];\r\n // ToDo: use TJSArray.copyWithin if available\r\n TJSArray(FList).splice(CurIndex,1);\r\n TJSArray(FList).splice(NewIndex,0,Temp);\r\nend;\r\n\r\nprocedure TFPList.Assign(ListA: TFPList; AOperator: TListAssignOp;\r\n ListB: TFPList);\r\nbegin\r\n case AOperator of\r\n laCopy : DoCopy (ListA, ListB); // replace dest with src\r\n laSrcUnique : DoSrcUnique (ListA, ListB); // replace dest with src that are not in dest\r\n laAnd : DoAnd (ListA, ListB); // remove from dest that are not in src\r\n laDestUnique: DoDestUnique (ListA, ListB);// remove from dest that are in src\r\n laOr : DoOr (ListA, ListB); // add to dest from src and not in dest\r\n laXOr : DoXOr (ListA, ListB); // add to dest from src and not in dest, remove from dest that are in src\r\n end;\r\nend;\r\n\r\nfunction TFPList.Remove(Item: JSValue): Integer;\r\nbegin\r\n Result := IndexOf(Item);\r\n If Result <> -1 then\r\n Delete(Result);\r\nend;\r\n\r\nprocedure TFPList.Pack;\r\nvar\r\n Dst, i: Integer;\r\n V: JSValue;\r\nbegin\r\n Dst:=0;\r\n for i:=0 to Count-1 do\r\n begin\r\n V:=FList[i];\r\n if not Assigned(V) then continue;\r\n FList[Dst]:=V;\r\n inc(Dst);\r\n end;\r\nend;\r\n\r\n// Needed by Sort method.\r\n\r\nProcedure QuickSort(aList: TJSValueDynArray; L, R : Longint;\r\n const Compare: TListSortCompare);\r\nvar\r\n I, J : Longint;\r\n P, Q : JSValue;\r\nbegin\r\n repeat\r\n I := L;\r\n J := R;\r\n P := aList[ (L + R) div 2 ];\r\n repeat\r\n while Compare(P, aList[i]) > 0 do\r\n I := I + 1;\r\n while Compare(P, aList[J]) < 0 do\r\n J := J - 1;\r\n If I <= J then\r\n begin\r\n Q := aList[I];\r\n aList[I] := aList[J];\r\n aList[J] := Q;\r\n I := I + 1;\r\n J := J - 1;\r\n end;\r\n until I > J;\r\n // sort the smaller range recursively\r\n // sort the bigger range via the loop\r\n // Reasons: memory usage is O(log(n)) instead of O(n) and loop is faster than recursion\r\n if J - L < R - I then\r\n begin\r\n if L < J then\r\n QuickSort(aList, L, J, Compare);\r\n L := I;\r\n end\r\n else\r\n begin\r\n if I < R then\r\n QuickSort(aList, I, R, Compare);\r\n R := J;\r\n end;\r\n until L >= R;\r\nend;\r\n\r\nprocedure TFPList.Sort(const Compare: TListSortCompare);\r\nbegin\r\n if Not Assigned(FList) or (FCount < 2) then exit;\r\n QuickSort(Flist, 0, FCount-1, Compare);\r\nend;\r\n\r\nprocedure TFPList.ForEachCall(const proc2call: TListCallback; const arg: JSValue\r\n );\r\nvar\r\n i : integer;\r\n v : JSValue;\r\nbegin\r\n For I:=0 To Count-1 Do\r\n begin\r\n v:=FList[i];\r\n if Assigned(v) then\r\n proc2call(v,arg);\r\n end;\r\nend;\r\n\r\nprocedure TFPList.ForEachCall(const proc2call: TListStaticCallback;\r\n const arg: JSValue);\r\nvar\r\n i : integer;\r\n v : JSValue;\r\nbegin\r\n For I:=0 To Count-1 Do\r\n begin\r\n v:=FList[i];\r\n if Assigned(v) then\r\n proc2call(v,arg);\r\n end;\r\nend;\r\n\r\n{ TList }\r\n\r\nprocedure TList.CopyMove(aList: TList);\r\nvar\r\n r : integer;\r\nbegin\r\n Clear;\r\n for r := 0 to aList.count-1 do\r\n Add(aList[r]);\r\nend;\r\n\r\nprocedure TList.MergeMove(aList: TList);\r\nvar r : integer;\r\nbegin\r\n For r := 0 to aList.count-1 do\r\n if IndexOf(aList[r]) < 0 then\r\n Add(aList[r]);\r\nend;\r\n\r\nprocedure TList.DoCopy(ListA, ListB: TList);\r\nbegin\r\n if Assigned(ListB) then\r\n CopyMove(ListB)\r\n else\r\n CopyMove(ListA);\r\nend;\r\n\r\nprocedure TList.DoSrcUnique(ListA, ListB: TList);\r\nvar r : integer;\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n Clear;\r\n for r := 0 to ListA.Count-1 do\r\n if ListB.IndexOf(ListA[r]) < 0 then\r\n Add(ListA[r]);\r\n end\r\n else\r\n begin\r\n for r := Count-1 downto 0 do\r\n if ListA.IndexOf(Self[r]) >= 0 then\r\n Delete(r);\r\n end;\r\nend;\r\n\r\nprocedure TList.DoAnd(ListA, ListB: TList);\r\nvar r : integer;\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n Clear;\r\n for r := 0 to ListA.Count-1 do\r\n if ListB.IndexOf(ListA[r]) >= 0 then\r\n Add(ListA[r]);\r\n end\r\n else\r\n begin\r\n for r := Count-1 downto 0 do\r\n if ListA.IndexOf(Self[r]) < 0 then\r\n Delete(r);\r\n end;\r\nend;\r\n\r\nprocedure TList.DoDestUnique(ListA, ListB: TList);\r\n\r\n procedure MoveElements(Src, Dest : TList);\r\n var r : integer;\r\n begin\r\n Clear;\r\n for r := 0 to Src.Count-1 do\r\n if Dest.IndexOf(Src[r]) < 0 then\r\n Add(Src[r]);\r\n end;\r\n\r\nvar Dest : TList;\r\nbegin\r\n if Assigned(ListB) then\r\n MoveElements(ListB, ListA)\r\n else\r\n try\r\n Dest := TList.Create;\r\n Dest.CopyMove(Self);\r\n MoveElements(ListA, Dest)\r\n finally\r\n Dest.Destroy;\r\n end;\r\nend;\r\n\r\nprocedure TList.DoOr(ListA, ListB: TList);\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n CopyMove(ListA);\r\n MergeMove(ListB);\r\n end\r\n else\r\n MergeMove(ListA);\r\nend;\r\n\r\nprocedure TList.DoXOr(ListA, ListB: TList);\r\nvar\r\n r : integer;\r\n l : TList;\r\nbegin\r\n if Assigned(ListB) then\r\n begin\r\n Clear;\r\n for r := 0 to ListA.Count-1 do\r\n if ListB.IndexOf(ListA[r]) < 0 then\r\n Add(ListA[r]);\r\n for r := 0 to ListB.Count-1 do\r\n if ListA.IndexOf(ListB[r]) < 0 then\r\n Add(ListB[r]);\r\n end\r\n else\r\n try\r\n l := TList.Create;\r\n l.CopyMove (Self);\r\n for r := Count-1 downto 0 do\r\n if listA.IndexOf(Self[r]) >= 0 then\r\n Delete(r);\r\n for r := 0 to ListA.Count-1 do\r\n if l.IndexOf(ListA[r]) < 0 then\r\n Add(ListA[r]);\r\n finally\r\n l.Destroy;\r\n end;\r\nend;\r\n\r\nfunction TList.Get(Index: Integer): JSValue;\r\nbegin\r\n Result := FList.Get(Index);\r\nend;\r\n\r\nprocedure TList.Put(Index: Integer; Item: JSValue);\r\nvar V : JSValue;\r\nbegin\r\n V := Get(Index);\r\n FList.Put(Index, Item);\r\n if Assigned(V) then\r\n Notify(V, lnDeleted);\r\n if Assigned(Item) then\r\n Notify(Item, lnAdded);\r\nend;\r\n\r\nprocedure TList.Notify(aValue: JSValue; Action: TListNotification);\r\nbegin\r\n if Assigned(aValue) then ;\r\n if Action=lnExtracted then ;\r\nend;\r\n\r\nprocedure TList.SetCapacity(NewCapacity: Integer);\r\nbegin\r\n FList.SetCapacity(NewCapacity);\r\nend;\r\n\r\nfunction TList.GetCapacity: integer;\r\nbegin\r\n Result := FList.Capacity;\r\nend;\r\n\r\nprocedure TList.SetCount(NewCount: Integer);\r\nbegin\r\n if NewCount < FList.Count then\r\n while FList.Count > NewCount do\r\n Delete(FList.Count - 1)\r\n else\r\n FList.SetCount(NewCount);\r\nend;\r\n\r\nfunction TList.GetCount: integer;\r\nbegin\r\n Result := FList.Count;\r\nend;\r\n\r\nfunction TList.GetList: TJSValueDynArray;\r\nbegin\r\n Result := FList.List;\r\nend;\r\n\r\nconstructor TList.Create;\r\nbegin\r\n inherited Create;\r\n FList := TFPList.Create;\r\nend;\r\n\r\ndestructor TList.Destroy;\r\nbegin\r\n if Assigned(FList) then\r\n Clear;\r\n FreeAndNil(FList);\r\nend;\r\n\r\nprocedure TList.AddList(AList: TList);\r\nvar\r\n I: Integer;\r\nbegin\r\n { this only does FList.AddList(AList.FList), avoiding notifications }\r\n FList.AddList(AList.FList);\r\n\r\n { make lnAdded notifications }\r\n for I := 0 to AList.Count - 1 do\r\n if Assigned(AList[I]) then\r\n Notify(AList[I], lnAdded);\r\nend;\r\n\r\nfunction TList.Add(Item: JSValue): Integer;\r\nbegin\r\n Result := FList.Add(Item);\r\n if Assigned(Item) then\r\n Notify(Item, lnAdded);\r\nend;\r\n\r\nprocedure TList.Clear;\r\nbegin\r\n While (FList.Count>0) do\r\n Delete(Count-1);\r\nend;\r\n\r\nprocedure TList.Delete(Index: Integer);\r\n\r\nvar V : JSValue;\r\n\r\nbegin\r\n V:=FList.Get(Index);\r\n FList.Delete(Index);\r\n if assigned(V) then\r\n Notify(V, lnDeleted);\r\nend;\r\n\r\nclass procedure TList.Error(const Msg: string; Data: String);\r\nbegin\r\n Raise EListError.CreateFmt(Msg,[Data]);\r\nend;\r\n\r\nprocedure TList.Exchange(Index1, Index2: Integer);\r\nbegin\r\n FList.Exchange(Index1, Index2);\r\nend;\r\n\r\nfunction TList.Expand: TList;\r\nbegin\r\n FList.Expand;\r\n Result:=Self;\r\nend;\r\n\r\nfunction TList.Extract(Item: JSValue): JSValue;\r\nvar c : integer;\r\nbegin\r\n c := FList.Count;\r\n Result := FList.Extract(Item);\r\n if c <> FList.Count then\r\n Notify (Result, lnExtracted);\r\nend;\r\n\r\nfunction TList.First: JSValue;\r\nbegin\r\n Result := FList.First;\r\nend;\r\n\r\nfunction TList.GetEnumerator: TListEnumerator;\r\nbegin\r\n Result:=TListEnumerator.Create(Self);\r\nend;\r\n\r\nfunction TList.IndexOf(Item: JSValue): Integer;\r\nbegin\r\n Result := FList.IndexOf(Item);\r\nend;\r\n\r\nprocedure TList.Insert(Index: Integer; Item: JSValue);\r\nbegin\r\n FList.Insert(Index, Item);\r\n if Assigned(Item) then\r\n Notify(Item,lnAdded);\r\nend;\r\n\r\nfunction TList.Last: JSValue;\r\nbegin\r\n Result := FList.Last;\r\nend;\r\n\r\nprocedure TList.Move(CurIndex, NewIndex: Integer);\r\nbegin\r\n FList.Move(CurIndex, NewIndex);\r\nend;\r\n\r\nprocedure TList.Assign(ListA: TList; AOperator: TListAssignOp; ListB: TList);\r\nbegin\r\n case AOperator of\r\n laCopy : DoCopy (ListA, ListB); // replace dest with src\r\n laSrcUnique : DoSrcUnique (ListA, ListB); // replace dest with src that are not in dest\r\n laAnd : DoAnd (ListA, ListB); // remove from dest that are not in src\r\n laDestUnique: DoDestUnique (ListA, ListB);// remove from dest that are in src\r\n laOr : DoOr (ListA, ListB); // add to dest from src and not in dest\r\n laXOr : DoXOr (ListA, ListB); // add to dest from src and not in dest, remove from dest that are in src\r\n end;\r\nend;\r\n\r\nfunction TList.Remove(Item: JSValue): Integer;\r\nbegin\r\n Result := IndexOf(Item);\r\n if Result <> -1 then\r\n Self.Delete(Result);\r\nend;\r\n\r\nprocedure TList.Pack;\r\nbegin\r\n FList.Pack;\r\nend;\r\n\r\nprocedure TList.Sort(const Compare: TListSortCompare);\r\nbegin\r\n FList.Sort(Compare);\r\nend;\r\n\r\n{ TPersistent }\r\n\r\nprocedure TPersistent.AssignError(Source: TPersistent);\r\nvar\r\n SourceName: String;\r\nbegin\r\n if Source<>Nil then\r\n SourceName:=Source.ClassName\r\n else\r\n SourceName:='Nil';\r\n raise EConvertError.Create('Cannot assign a '+SourceName+' to a '+ClassName+'.');\r\nend;\r\n\r\nprocedure TPersistent.AssignTo(Dest: TPersistent);\r\nbegin\r\n Dest.AssignError(Self);\r\nend;\r\n\r\nfunction TPersistent.GetOwner: TPersistent;\r\nbegin\r\n Result:=nil;\r\nend;\r\n\r\nprocedure TPersistent.Assign(Source: TPersistent);\r\nbegin\r\n If Source<>Nil then\r\n Source.AssignTo(Self)\r\n else\r\n AssignError(Nil);\r\nend;\r\n\r\nfunction TPersistent.GetNamePath: string;\r\nvar\r\n OwnerName: String;\r\n TheOwner: TPersistent;\r\nbegin\r\n Result:=ClassName;\r\n TheOwner:=GetOwner;\r\n if TheOwner<>Nil then\r\n begin\r\n OwnerName:=TheOwner.GetNamePath;\r\n if OwnerName<>'' then Result:=OwnerName+'.'+Result;\r\n end;\r\nend;\r\n\r\n{\r\n This file is part of the Free Component Library (FCL)\r\n Copyright (c) 1999-2000 by the Free Pascal development team\r\n\r\n See the file COPYING.FPC, included in this distribution,\r\n for details about the copyright.\r\n\r\n This program is distributed in the hope that it will be useful,\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n **********************************************************************}\r\n\r\n{****************************************************************************}\r\n{* TStringsEnumerator *}\r\n{****************************************************************************}\r\n\r\nconstructor TStringsEnumerator.Create(AStrings: TStrings);\r\nbegin\r\n inherited Create;\r\n FStrings := AStrings;\r\n FPosition := -1;\r\nend;\r\n\r\nfunction TStringsEnumerator.GetCurrent: String;\r\nbegin\r\n Result := FStrings[FPosition];\r\nend;\r\n\r\nfunction TStringsEnumerator.MoveNext: Boolean;\r\nbegin\r\n Inc(FPosition);\r\n Result := FPosition < FStrings.Count;\r\nend;\r\n\r\n{****************************************************************************}\r\n{* TStrings *}\r\n{****************************************************************************}\r\n\r\n// Function to quote text. Should move maybe to sysutils !!\r\n// Also, it is not clear at this point what exactly should be done.\r\n\r\n{ //!! is used to mark unsupported things. }\r\n\r\n(*\r\nFunction QuoteString (Const S : String; Const Quote : String) : String;\r\nVar\r\n I,J : Integer;\r\nbegin\r\n J:=0;\r\n Result:=S;\r\n for i:=1 to length(s) do\r\n begin\r\n inc(j);\r\n if S[i]=Quote then\r\n begin\r\n Insert(Quote,Result,J);\r\n inc(j);\r\n end;\r\n end;\r\n Result:=Quote+Result+Quote;\r\nend;\r\n*)\r\n\r\n{\r\n For compatibility we can't add a Constructor to TSTrings to initialize\r\n the special characters. Therefore we add a routine which is called whenever\r\n the special chars are needed.\r\n}\r\n\r\nProcedure Tstrings.CheckSpecialChars;\r\n\r\nbegin\r\n If Not FSpecialCharsInited then\r\n begin\r\n FQuoteChar:='\"';\r\n FDelimiter:=',';\r\n FNameValueSeparator:='=';\r\n FLBS:=DefaultTextLineBreakStyle;\r\n FSpecialCharsInited:=true;\r\n FLineBreak:=sLineBreak;\r\n end;\r\nend;\r\n\r\nFunction TStrings.GetSkipLastLineBreak : Boolean;\r\n\r\nbegin\r\n CheckSpecialChars;\r\n Result:=FSkipLastLineBreak;\r\nend;\r\n\r\nprocedure TStrings.SetSkipLastLineBreak(const AValue : Boolean);\r\n\r\nbegin\r\n CheckSpecialChars;\r\n FSkipLastLineBreak:=AValue;\r\nend;\r\n\r\nFunction TStrings.GetLBS : TTextLineBreakStyle;\r\nbegin\r\n CheckSpecialChars;\r\n Result:=FLBS;\r\nend;\r\n\r\nProcedure TStrings.SetLBS (AValue : TTextLineBreakStyle);\r\nbegin\r\n CheckSpecialChars;\r\n FLBS:=AValue;\r\nend;\r\n\r\nprocedure TStrings.SetDelimiter(c:Char);\r\nbegin\r\n CheckSpecialChars;\r\n FDelimiter:=c;\r\nend;\r\n\r\nFunction TStrings.GetDelimiter : Char;\r\nbegin\r\n CheckSpecialChars;\r\n Result:=FDelimiter;\r\nend;\r\n\r\nprocedure TStrings.SetLineBreak(Const S : String);\r\nbegin\r\n CheckSpecialChars;\r\n FLineBreak:=S;\r\nend;\r\n\r\nFunction TStrings.GetLineBreak : String;\r\nbegin\r\n CheckSpecialChars;\r\n Result:=FLineBreak;\r\nend;\r\n\r\n\r\nprocedure TStrings.SetQuoteChar(c:Char);\r\nbegin\r\n CheckSpecialChars;\r\n FQuoteChar:=c;\r\nend;\r\n\r\nFunction TStrings.GetQuoteChar :Char;\r\nbegin\r\n CheckSpecialChars;\r\n Result:=FQuoteChar;\r\nend;\r\n\r\nprocedure TStrings.SetNameValueSeparator(c:Char);\r\nbegin\r\n CheckSpecialChars;\r\n FNameValueSeparator:=c;\r\nend;\r\n\r\nFunction TStrings.GetNameValueSeparator :Char;\r\nbegin\r\n CheckSpecialChars;\r\n Result:=FNameValueSeparator;\r\nend;\r\n\r\n\r\nfunction TStrings.GetCommaText: string;\r\n\r\nVar\r\n C1,C2 : Char;\r\n FSD : Boolean;\r\n\r\nbegin\r\n CheckSpecialChars;\r\n FSD:=StrictDelimiter;\r\n C1:=Delimiter;\r\n C2:=QuoteChar;\r\n Delimiter:=',';\r\n QuoteChar:='\"';\r\n StrictDelimiter:=False;\r\n Try\r\n Result:=GetDelimitedText;\r\n Finally\r\n Delimiter:=C1;\r\n QuoteChar:=C2;\r\n StrictDelimiter:=FSD;\r\n end;\r\nend;\r\n\r\n\r\nFunction TStrings.GetDelimitedText: string;\r\n\r\nVar\r\n I: integer;\r\n RE : string;\r\n S : String;\r\n doQuote : Boolean;\r\n\r\nbegin\r\n CheckSpecialChars;\r\n result:='';\r\n RE:=QuoteChar+'|'+Delimiter;\r\n if not StrictDelimiter then\r\n RE:=' |'+RE;\r\n RE:='/'+RE+'/';\r\n // Check for break characters and quote if required.\r\n For i:=0 to count-1 do\r\n begin\r\n S:=Strings[i];\r\n doQuote:=FAlwaysQuote or (TJSString(s).search(RE)=-1);\r\n if DoQuote then\r\n Result:=Result+QuoteString(S,QuoteChar)\r\n else\r\n Result:=Result+S;\r\n if I0 then\r\n begin\r\n AName:=Copy(AValue,1,L-1);\r\n // System.Delete(AValue,1,L);\r\n AValue:=Copy(AValue,L+1,length(AValue)-L);\r\n end\r\n else\r\n AName:='';\r\nend;\r\n\r\nfunction TStrings.ExtractName(const s:String):String;\r\nvar\r\n L: Longint;\r\nbegin\r\n CheckSpecialChars;\r\n L:=Pos(FNameValueSeparator,S);\r\n If L<>0 then\r\n Result:=Copy(S,1,L-1)\r\n else\r\n Result:='';\r\nend;\r\n\r\nfunction TStrings.GetName(Index: Integer): string;\r\n\r\nVar\r\n V : String;\r\n\r\nbegin\r\n GetNameValue(Index,Result,V);\r\nend;\r\n\r\nFunction TStrings.GetValue(const Name: string): string;\r\n\r\nVar\r\n L : longint;\r\n N : String;\r\n\r\nbegin\r\n Result:='';\r\n L:=IndexOfName(Name);\r\n If L<>-1 then\r\n GetNameValue(L,N,Result);\r\nend;\r\n\r\nFunction TStrings.GetValueFromIndex(Index: Integer): string;\r\n\r\nVar\r\n N : String;\r\n\r\nbegin\r\n GetNameValue(Index,N,Result);\r\nend;\r\n\r\nProcedure TStrings.SetValueFromIndex(Index: Integer; const Value: string);\r\n\r\nbegin\r\n If (Value='') then\r\n Delete(Index)\r\n else\r\n begin\r\n If (Index<0) then\r\n Index:=Add('');\r\n CheckSpecialChars;\r\n Strings[Index]:=GetName(Index)+FNameValueSeparator+Value;\r\n end;\r\nend;\r\n\r\nProcedure TStrings.SetDelimitedText(const AValue: string);\r\nvar i,j:integer;\r\n aNotFirst:boolean;\r\nbegin\r\n CheckSpecialChars;\r\n BeginUpdate;\r\n\r\n i:=1;\r\n j:=1;\r\n aNotFirst:=false;\r\n\r\n { Paraphrased from Delphi XE2 help:\r\n Strings must be separated by Delimiter characters or spaces.\r\n They may be enclosed in QuoteChars.\r\n QuoteChars in the string must be repeated to distinguish them from the QuoteChars enclosing the string.\r\n }\r\n try\r\n Clear;\r\n If StrictDelimiter then\r\n begin\r\n while i<=length(AValue) do begin\r\n // skip delimiter\r\n if aNotFirst and (i<=length(AValue)) and (AValue[i]=FDelimiter) then inc(i);\r\n\r\n // read next string\r\n if i<=length(AValue) then begin\r\n if AValue[i]=FQuoteChar then begin\r\n // next string is quoted\r\n j:=i+1;\r\n while (j<=length(AValue)) and\r\n ( (AValue[j]<>FQuoteChar) or\r\n ( (j+1<=length(AValue)) and (AValue[j+1]=FQuoteChar) ) ) do begin\r\n if (j<=length(AValue)) and (AValue[j]=FQuoteChar) then inc(j,2)\r\n else inc(j);\r\n end;\r\n // j is position of closing quote\r\n Add( StringReplace (Copy(AValue,i+1,j-i-1),\r\n FQuoteChar+FQuoteChar,FQuoteChar, [rfReplaceAll]));\r\n i:=j+1;\r\n end else begin\r\n // next string is not quoted; read until delimiter\r\n j:=i;\r\n while (j<=length(AValue)) and\r\n (AValue[j]<>FDelimiter) do inc(j);\r\n Add( Copy(AValue,i,j-i));\r\n i:=j;\r\n end;\r\n end else begin\r\n if aNotFirst then Add('');\r\n end;\r\n\r\n aNotFirst:=true;\r\n end;\r\n end\r\n else\r\n begin\r\n while i<=length(AValue) do begin\r\n // skip delimiter\r\n if aNotFirst and (i<=length(AValue)) and (AValue[i]=FDelimiter) then inc(i);\r\n\r\n // skip spaces\r\n while (i<=length(AValue)) and (Ord(AValue[i])<=Ord(' ')) do inc(i);\r\n\r\n // read next string\r\n if i<=length(AValue) then begin\r\n if AValue[i]=FQuoteChar then begin\r\n // next string is quoted\r\n j:=i+1;\r\n while (j<=length(AValue)) and\r\n ( (AValue[j]<>FQuoteChar) or\r\n ( (j+1<=length(AValue)) and (AValue[j+1]=FQuoteChar) ) ) do begin\r\n if (j<=length(AValue)) and (AValue[j]=FQuoteChar) then inc(j,2)\r\n else inc(j);\r\n end;\r\n // j is position of closing quote\r\n Add( StringReplace (Copy(AValue,i+1,j-i-1),\r\n FQuoteChar+FQuoteChar,FQuoteChar, [rfReplaceAll]));\r\n i:=j+1;\r\n end else begin\r\n // next string is not quoted; read until control character/space/delimiter\r\n j:=i;\r\n while (j<=length(AValue)) and\r\n (Ord(AValue[j])>Ord(' ')) and\r\n (AValue[j]<>FDelimiter) do inc(j);\r\n Add( Copy(AValue,i,j-i));\r\n i:=j;\r\n end;\r\n end else begin\r\n if aNotFirst then Add('');\r\n end;\r\n\r\n // skip spaces\r\n while (i<=length(AValue)) and (Ord(AValue[i])<=Ord(' ')) do inc(i);\r\n\r\n aNotFirst:=true;\r\n end;\r\n end;\r\n finally\r\n EndUpdate;\r\n end;\r\nend;\r\n\r\nProcedure TStrings.SetCommaText(const Value: string);\r\n\r\nVar\r\n C1,C2 : Char;\r\n\r\nbegin\r\n CheckSpecialChars;\r\n C1:=Delimiter;\r\n C2:=QuoteChar;\r\n Delimiter:=',';\r\n QuoteChar:='\"';\r\n Try\r\n SetDelimitedText(Value);\r\n Finally\r\n Delimiter:=C1;\r\n QuoteChar:=C2;\r\n end;\r\nend;\r\n\r\nProcedure TStrings.SetValue(const Name, Value: string);\r\n\r\nVar L : longint;\r\n\r\nbegin\r\n CheckSpecialChars;\r\n L:=IndexOfName(Name);\r\n if L=-1 then\r\n Add (Name+FNameValueSeparator+Value)\r\n else\r\n Strings[L]:=Name+FNameValueSeparator+value;\r\nend;\r\n\r\n\r\nProcedure TStrings.Error(const Msg: string; Data: Integer);\r\nbegin\r\n Raise EStringListError.CreateFmt(Msg,[IntToStr(Data)]);\r\nend;\r\n\r\nFunction TStrings.GetCapacity: Integer;\r\n\r\nbegin\r\n Result:=Count;\r\nend;\r\n\r\n\r\n\r\nFunction TStrings.GetObject(Index: Integer): TObject;\r\n\r\nbegin\r\n if Index=0 then ;\r\n Result:=Nil;\r\nend;\r\n\r\nFunction TStrings.GetTextStr: string;\r\n\r\nVar\r\n I : Longint;\r\n S,NL : String;\r\n\r\nbegin\r\n CheckSpecialChars;\r\n // Determine needed place\r\n if FLineBreak<>sLineBreak then\r\n NL:=FLineBreak\r\n else\r\n Case FLBS of\r\n tlbsLF : NL:=#10;\r\n tlbsCRLF : NL:=#13#10;\r\n tlbsCR : NL:=#13;\r\n end;\r\n Result:='';\r\n For i:=0 To count-1 do\r\n begin\r\n S:=Strings[I];\r\n Result:=Result+S;\r\n if (I Capacity then\r\n Capacity := Count + High(TheStrings)+1;\r\n For Runner:=Low(TheStrings) to High(TheStrings) do\r\n self.Add(Thestrings[Runner]);\r\nend;\r\n\r\n\r\nProcedure TStrings.AddStrings(const TheStrings: array of string; ClearFirst : Boolean);\r\n\r\nbegin\r\n beginupdate;\r\n try\r\n if ClearFirst then\r\n Clear;\r\n AddStrings(TheStrings);\r\n finally\r\n EndUpdate;\r\n end;\r\nend;\r\n\r\n\r\nfunction TStrings.AddPair(const AName, AValue: string): TStrings;\r\n\r\nbegin\r\n Result:=AddPair(AName,AValue,Nil);\r\nend;\r\n\r\nfunction TStrings.AddPair(const AName, AValue: string; AObject: TObject): TStrings;\r\n\r\nbegin\r\n Result := Self;\r\n AddObject(AName+NameValueSeparator+AValue, AObject);\r\nend;\r\n\r\n\r\nProcedure TStrings.Assign(Source: TPersistent);\r\n\r\nVar\r\n S : TStrings;\r\n\r\nbegin\r\n If Source is TStrings then\r\n begin\r\n S:=TStrings(Source);\r\n BeginUpdate;\r\n Try\r\n clear;\r\n FSpecialCharsInited:=S.FSpecialCharsInited;\r\n FQuoteChar:=S.FQuoteChar;\r\n FDelimiter:=S.FDelimiter;\r\n FNameValueSeparator:=S.FNameValueSeparator;\r\n FLBS:=S.FLBS;\r\n FLineBreak:=S.FLineBreak;\r\n AddStrings(S);\r\n finally\r\n EndUpdate;\r\n end;\r\n end\r\n else\r\n Inherited Assign(Source);\r\nend;\r\n\r\n\r\n\r\nProcedure TStrings.BeginUpdate;\r\n\r\nbegin\r\n if FUpdateCount = 0 then SetUpdateState(true);\r\n inc(FUpdateCount);\r\nend;\r\n\r\n\r\n\r\nProcedure TStrings.EndUpdate;\r\n\r\nbegin\r\n If FUpdateCount>0 then\r\n Dec(FUpdateCount);\r\n if FUpdateCount=0 then\r\n SetUpdateState(False);\r\nend;\r\n\r\n\r\n\r\nFunction TStrings.Equals(Obj: TObject): Boolean;\r\n\r\nbegin\r\n if Obj is TStrings then\r\n Result := Equals(TStrings(Obj))\r\n else\r\n Result := inherited Equals(Obj);\r\nend;\r\n\r\n\r\n\r\nFunction TStrings.Equals(TheStrings: TStrings): Boolean;\r\n\r\nVar Runner,Nr : Longint;\r\n\r\nbegin\r\n Result:=False;\r\n Nr:=Self.Count;\r\n if Nr<>TheStrings.Count then exit;\r\n For Runner:=0 to Nr-1 do\r\n If Strings[Runner]<>TheStrings[Runner] then exit;\r\n Result:=True;\r\nend;\r\n\r\n\r\n\r\nProcedure TStrings.Exchange(Index1, Index2: Integer);\r\n\r\nVar\r\n Obj : TObject;\r\n Str : String;\r\n\r\nbegin\r\n beginUpdate;\r\n Try\r\n Obj:=Objects[Index1];\r\n Str:=Strings[Index1];\r\n Objects[Index1]:=Objects[Index2];\r\n Strings[Index1]:=Strings[Index2];\r\n Objects[Index2]:=Obj;\r\n Strings[Index2]:=Str;\r\n finally\r\n EndUpdate;\r\n end;\r\nend;\r\n\r\n\r\nfunction TStrings.GetEnumerator: TStringsEnumerator;\r\nbegin\r\n Result:=TStringsEnumerator.Create(Self);\r\nend;\r\n\r\n\r\nFunction TStrings.DoCompareText(const s1,s2 : string) : PtrInt;\r\nbegin\r\n result:=CompareText(s1,s2);\r\nend;\r\n\r\n\r\nFunction TStrings.IndexOf(const S: string): Integer;\r\nbegin\r\n Result:=0;\r\n While (Result0) do Result:=Result+1;\r\n if Result=Count then Result:=-1;\r\nend;\r\n\r\n\r\nFunction TStrings.IndexOfName(const Name: string): Integer;\r\nVar\r\n len : longint;\r\n S : String;\r\nbegin\r\n CheckSpecialChars;\r\n Result:=0;\r\n while (Result=0) and (DoCompareText(Name,Copy(S,1,Len))=0) then\r\n exit;\r\n inc(result);\r\n end;\r\n result:=-1;\r\nend;\r\n\r\n\r\nFunction TStrings.IndexOfObject(AObject: TObject): Integer;\r\nbegin\r\n Result:=0;\r\n While (ResultAObject) do Result:=Result+1;\r\n If Result=Count then Result:=-1;\r\nend;\r\n\r\n\r\nProcedure TStrings.InsertObject(Index: Integer; const S: string;\r\n AObject: TObject);\r\n\r\nbegin\r\n Insert (Index,S);\r\n Objects[Index]:=AObject;\r\nend;\r\n\r\nProcedure TStrings.Move(CurIndex, NewIndex: Integer);\r\nVar\r\n Obj : TObject;\r\n Str : String;\r\nbegin\r\n BeginUpdate;\r\n Try\r\n Obj:=Objects[CurIndex];\r\n Str:=Strings[CurIndex];\r\n Objects[CurIndex]:=Nil; // Prevent Delete from freeing.\r\n Delete(Curindex);\r\n InsertObject(NewIndex,Str,Obj);\r\n finally\r\n EndUpdate;\r\n end;\r\nend;\r\n\r\n\r\n{****************************************************************************}\r\n{* TStringList *}\r\n{****************************************************************************}\r\n\r\n\r\nprocedure TStringList.ExchangeItemsInt(Index1, Index2: Integer);\r\n\r\nVar\r\n S : String;\r\n O : TObject;\r\n\r\nbegin\r\n S:=Flist[Index1].FString;\r\n O:=Flist[Index1].FObject;\r\n Flist[Index1].Fstring:=Flist[Index2].Fstring;\r\n Flist[Index1].FObject:=Flist[Index2].FObject;\r\n Flist[Index2].Fstring:=S;\r\n Flist[Index2].FObject:=O;\r\nend;\r\n\r\nfunction TStringList.GetSorted: Boolean;\r\nbegin\r\n Result:=FSortStyle in [sslUser,sslAuto];\r\nend;\r\n\r\n\r\nprocedure TStringList.ExchangeItems(Index1, Index2: Integer);\r\nbegin\r\n ExchangeItemsInt(Index1, Index2);\r\nend;\r\n\r\n\r\nprocedure TStringList.Grow;\r\n\r\nVar\r\n NC : Integer;\r\n\r\nbegin\r\n NC:=Capacity;\r\n If NC>=256 then\r\n NC:=NC+(NC Div 4)\r\n else if NC=0 then\r\n NC:=4\r\n else\r\n NC:=NC*4;\r\n SetCapacity(NC);\r\nend;\r\n\r\nprocedure TStringList.InternalClear(FromIndex: Integer; ClearOnly: Boolean);\r\n\r\nVar\r\n I: Integer;\r\n\r\nbegin\r\n if FromIndex < FCount then\r\n begin\r\n if FOwnsObjects then\r\n begin\r\n For I:=FromIndex to FCount-1 do\r\n begin\r\n Flist[I].FString:='';\r\n freeandnil(Flist[i].FObject);\r\n end;\r\n end\r\n else\r\n begin\r\n For I:=FromIndex to FCount-1 do\r\n Flist[I].FString:='';\r\n end;\r\n FCount:=FromIndex;\r\n end;\r\n if Not ClearOnly then\r\n SetCapacity(0);\r\nend;\r\n\r\n\r\nprocedure TStringList.QuickSort(L, R: Integer; CompareFn: TStringListSortCompare\r\n );\r\n\r\n\r\nvar\r\n Pivot, vL, vR: Integer;\r\n\r\nbegin\r\n //if ExchangeItems is override call that, else call (faster) ExchangeItemsInt\r\n\r\n if R - L <= 1 then begin // a little bit of time saver\r\n if L < R then\r\n if CompareFn(Self, L, R) > 0 then\r\n ExchangeItems(L, R);\r\n\r\n Exit;\r\n end;\r\n\r\n vL := L;\r\n vR := R;\r\n\r\n Pivot := L + Random(R - L); // they say random is best\r\n\r\n while vL < vR do begin\r\n while (vL < Pivot) and (CompareFn(Self, vL, Pivot) <= 0) do\r\n Inc(vL);\r\n\r\n while (vR > Pivot) and (CompareFn(Self, vR, Pivot) > 0) do\r\n Dec(vR);\r\n\r\n ExchangeItems(vL, vR);\r\n\r\n if Pivot = vL then // swap pivot if we just hit it from one side\r\n Pivot := vR\r\n else if Pivot = vR then\r\n Pivot := vL;\r\n end;\r\n\r\n if Pivot - 1 >= L then\r\n QuickSort(L, Pivot - 1, CompareFn);\r\n if Pivot + 1 <= R then\r\n QuickSort(Pivot + 1, R, CompareFn);\r\nend;\r\n\r\n\r\nprocedure TStringList.InsertItem(Index: Integer; const S: string);\r\nbegin\r\n InsertItem(Index, S, nil);\r\nend;\r\n\r\n\r\nprocedure TStringList.InsertItem(Index: Integer; const S: string; O: TObject);\r\n\r\nVar\r\n It : TStringItem;\r\n \r\nbegin\r\n Changing;\r\n If FCount=Capacity then Grow;\r\n it.FString:=S;\r\n it.FObject:=O;\r\n TJSArray(FList).Splice(Index,0,It);\r\n Inc(FCount);\r\n Changed;\r\nend;\r\n\r\n\r\nprocedure TStringList.SetSorted(Value: Boolean);\r\n\r\nbegin\r\n If Value then\r\n SortStyle:=sslAuto\r\n else\r\n SortStyle:=sslNone\r\nend;\r\n\r\n\r\n\r\nprocedure TStringList.Changed;\r\n\r\nbegin\r\n If (FUpdateCount=0) Then\r\n begin\r\n If Assigned(FOnChange) then\r\n FOnchange(Self);\r\n end;\r\nend;\r\n\r\n\r\n\r\nprocedure TStringList.Changing;\r\n\r\nbegin\r\n If FUpdateCount=0 then\r\n if Assigned(FOnChanging) then\r\n FOnchanging(Self);\r\nend;\r\n\r\n\r\n\r\nfunction TStringList.Get(Index: Integer): string;\r\n\r\nbegin\r\n CheckIndex(Index);\r\n Result:=Flist[Index].FString;\r\nend;\r\n\r\n\r\n\r\nfunction TStringList.GetCapacity: Integer;\r\n\r\nbegin\r\n Result:=Length(FList);\r\nend;\r\n\r\n\r\n\r\nfunction TStringList.GetCount: Integer;\r\n\r\nbegin\r\n Result:=FCount;\r\nend;\r\n\r\n\r\n\r\nfunction TStringList.GetObject(Index: Integer): TObject;\r\n\r\nbegin\r\n CheckIndex(Index);\r\n Result:=Flist[Index].FObject;\r\nend;\r\n\r\n\r\n\r\nprocedure TStringList.Put(Index: Integer; const S: string);\r\n\r\nbegin\r\n If Sorted then\r\n Error(SSortedListError,0);\r\n CheckIndex(Index);\r\n Changing;\r\n Flist[Index].FString:=S;\r\n Changed;\r\nend;\r\n\r\n\r\n\r\nprocedure TStringList.PutObject(Index: Integer; AObject: TObject);\r\n\r\nbegin\r\n CheckIndex(Index);\r\n Changing;\r\n Flist[Index].FObject:=AObject;\r\n Changed;\r\nend;\r\n\r\n\r\n\r\nprocedure TStringList.SetCapacity(NewCapacity: Integer);\r\n\r\nbegin\r\n If (NewCapacity<0) then\r\n Error (SListCapacityError,NewCapacity);\r\n If NewCapacity<>Capacity then\r\n SetLength(FList,NewCapacity)\r\nend;\r\n\r\n\r\n\r\nprocedure TStringList.SetUpdateState(Updating: Boolean);\r\n\r\nbegin\r\n If Updating then\r\n Changing\r\n else\r\n Changed\r\nend;\r\n\r\n\r\n\r\ndestructor TStringList.Destroy;\r\n\r\nbegin\r\n InternalClear;\r\n Inherited destroy;\r\nend;\r\n\r\n\r\n\r\nfunction TStringList.Add(const S: string): Integer;\r\n\r\nbegin\r\n If Not (SortStyle=sslAuto) then\r\n Result:=FCount\r\n else\r\n If Find (S,Result) then\r\n Case DUplicates of\r\n DupIgnore : Exit;\r\n DupError : Error(SDuplicateString,0)\r\n end;\r\n InsertItem (Result,S);\r\nend;\r\n\r\nprocedure TStringList.Clear;\r\n\r\nbegin\r\n if FCount = 0 then Exit;\r\n Changing;\r\n InternalClear;\r\n Changed;\r\nend;\r\n\r\nprocedure TStringList.Delete(Index: Integer);\r\n\r\nbegin\r\n CheckIndex(Index);\r\n Changing;\r\n if FOwnsObjects then\r\n FreeAndNil(Flist[Index].FObject);\r\n TJSArray(FList).splice(Index,1); \r\n FList[Count-1].FString:='';\r\n Flist[Count-1].FObject:=Nil;\r\n Dec(FCount);\r\n Changed;\r\nend;\r\n\r\nprocedure TStringList.Exchange(Index1, Index2: Integer);\r\n\r\nbegin\r\n CheckIndex(Index1);\r\n CheckIndex(Index2);\r\n Changing;\r\n ExchangeItemsInt(Index1,Index2);\r\n changed;\r\nend;\r\n\r\nprocedure TStringList.SetCaseSensitive(b : boolean);\r\nbegin\r\n if b=FCaseSensitive then\r\n Exit;\r\n FCaseSensitive:=b;\r\n if FSortStyle=sslAuto then\r\n begin\r\n FForceSort:=True;\r\n try\r\n Sort;\r\n finally\r\n FForceSort:=False;\r\n end;\r\n end;\r\nend;\r\n\r\nprocedure TStringList.SetSortStyle(AValue: TStringsSortStyle);\r\nbegin\r\n if FSortStyle=AValue then Exit;\r\n if (AValue=sslAuto) then\r\n Sort;\r\n FSortStyle:=AValue;\r\nend;\r\n\r\nprocedure TStringList.CheckIndex(AIndex: Integer);\r\nbegin\r\n If (AIndex<0) or (AIndex>=FCount) then\r\n Error(SListIndexError,AIndex);\r\nend;\r\n\r\n\r\nfunction TStringList.DoCompareText(const s1, s2: string): PtrInt;\r\nbegin\r\n if FCaseSensitive then\r\n result:=CompareStr(s1,s2)\r\n else\r\n result:=CompareText(s1,s2);\r\nend;\r\n\r\n\r\nfunction TStringList.CompareStrings(const s1,s2 : string) : Integer;\r\nbegin\r\n Result := DoCompareText(s1, s2);\r\nend;\r\n\r\n\r\nfunction TStringList.Find(const S: string; out Index: Integer): Boolean;\r\n\r\nvar\r\n L, R, I: Integer;\r\n CompareRes: PtrInt;\r\nbegin\r\n Result := false;\r\n Index:=-1;\r\n if Not Sorted then\r\n Raise EListError.Create(SErrFindNeedsSortedList);\r\n // Use binary search.\r\n L := 0;\r\n R := Count - 1;\r\n while (L<=R) do\r\n begin\r\n I := L + (R - L) div 2;\r\n CompareRes := DoCompareText(S, Flist[I].FString);\r\n if (CompareRes>0) then\r\n L := I+1\r\n else begin\r\n R := I-1;\r\n if (CompareRes=0) then begin\r\n Result := true;\r\n if (Duplicates<>dupAccept) then\r\n L := I; // forces end of while loop\r\n end;\r\n end;\r\n end;\r\n Index := L;\r\nend;\r\n\r\n\r\n\r\nfunction TStringList.IndexOf(const S: string): Integer;\r\n\r\nbegin\r\n If Not Sorted then\r\n Result:=Inherited indexOf(S)\r\n else\r\n // faster using binary search...\r\n If Not Find (S,Result) then\r\n Result:=-1;\r\nend;\r\n\r\n\r\n\r\nprocedure TStringList.Insert(Index: Integer; const S: string);\r\n\r\nbegin\r\n If SortStyle=sslAuto then\r\n Error (SSortedListError,0)\r\n else\r\n begin\r\n If (Index<0) or (Index>FCount) then\r\n Error(SListIndexError,Index); // Cannot use CheckIndex, because there >= FCount...\r\n InsertItem (Index,S);\r\n end;\r\nend;\r\n\r\n\r\nprocedure TStringList.CustomSort(CompareFn: TStringListSortCompare);\r\n\r\nbegin\r\n If (FForceSort or (Not (FSortStyle=sslAuto))) and (FCount>1) then\r\n begin\r\n Changing;\r\n QuickSort(0,FCount-1, CompareFn);\r\n Changed;\r\n end;\r\nend;\r\n\r\nfunction StringListAnsiCompare(List: TStringList; Index1, Index: Integer): Integer;\r\n\r\nbegin\r\n Result := List.DoCompareText(List.FList[Index1].FString,\r\n List.FList[Index].FString);\r\nend;\r\n\r\nprocedure TStringList.Sort;\r\n\r\nbegin\r\n CustomSort(@StringListAnsiCompare);\r\nend;\r\n\r\n{****************************************************************************}\r\n{* TCollectionItem *}\r\n{****************************************************************************}\r\n\r\n\r\nfunction TCollectionItem.GetIndex: Integer;\r\n\r\nbegin\r\n if FCollection<>nil then\r\n Result:=FCollection.FItems.IndexOf(Self)\r\n else\r\n Result:=-1;\r\nend;\r\n\r\n\r\n\r\nprocedure TCollectionItem.SetCollection(Value: TCollection);\r\n\r\nbegin\r\n IF Value<>FCollection then\r\n begin\r\n If FCollection<>Nil then FCollection.RemoveItem(Self);\r\n if Value<>Nil then Value.InsertItem(Self);\r\n end;\r\nend;\r\n\r\n\r\n\r\nprocedure TCollectionItem.Changed(AllItems: Boolean);\r\n\r\nbegin\r\n If (FCollection<>Nil) and (FCollection.UpdateCount=0) then\r\n begin\r\n If AllItems then\r\n FCollection.Update(Nil)\r\n else\r\n FCollection.Update(Self);\r\n end;\r\nend;\r\n\r\n\r\n\r\nfunction TCollectionItem.GetNamePath: string;\r\n\r\nbegin\r\n If FCollection<>Nil then\r\n Result:=FCollection.GetNamePath+'['+IntToStr(Index)+']'\r\n else\r\n Result:=ClassName;\r\nend;\r\n\r\n\r\nfunction TCollectionItem.GetOwner: TPersistent;\r\n\r\nbegin\r\n Result:=FCollection;\r\nend;\r\n\r\n\r\n\r\nfunction TCollectionItem.GetDisplayName: string;\r\n\r\nbegin\r\n Result:=ClassName;\r\nend;\r\n\r\n\r\n\r\nprocedure TCollectionItem.SetIndex(Value: Integer);\r\n\r\nVar Temp : Longint;\r\n\r\nbegin\r\n Temp:=GetIndex;\r\n If (Temp>-1) and (Temp<>Value) then\r\n begin\r\n FCollection.FItems.Move(Temp,Value);\r\n Changed(True);\r\n end;\r\nend;\r\n\r\n\r\nprocedure TCollectionItem.SetDisplayName(const Value: string);\r\n\r\nbegin\r\n Changed(False);\r\n if Value='' then ;\r\nend;\r\n\r\n\r\n\r\nconstructor TCollectionItem.Create(ACollection: TCollection);\r\n\r\nbegin\r\n Inherited Create;\r\n SetCollection(ACollection);\r\nend;\r\n\r\n\r\n\r\ndestructor TCollectionItem.Destroy;\r\n\r\nbegin\r\n SetCollection(Nil);\r\n Inherited Destroy;\r\nend;\r\n\r\n{****************************************************************************}\r\n{* TCollectionEnumerator *}\r\n{****************************************************************************}\r\n\r\nconstructor TCollectionEnumerator.Create(ACollection: TCollection);\r\nbegin\r\n inherited Create;\r\n FCollection := ACollection;\r\n FPosition := -1;\r\nend;\r\n\r\nfunction TCollectionEnumerator.GetCurrent: TCollectionItem;\r\nbegin\r\n Result := FCollection.Items[FPosition];\r\nend;\r\n\r\nfunction TCollectionEnumerator.MoveNext: Boolean;\r\nbegin\r\n Inc(FPosition);\r\n Result := FPosition < FCollection.Count;\r\nend;\r\n\r\n\r\n{****************************************************************************}\r\n{* TCollection *}\r\n{****************************************************************************}\r\n\r\nfunction TCollection.Owner: TPersistent;\r\nbegin\r\n result:=getowner;\r\nend;\r\n\r\n\r\nfunction TCollection.GetCount: Integer;\r\n\r\nbegin\r\n Result:=FItems.Count;\r\nend;\r\n\r\n\r\nProcedure TCollection.SetPropName;\r\n\r\n{\r\nVar\r\n TheOwner : TPersistent;\r\n PropList : PPropList;\r\n I, PropCount : Integer;\r\n}\r\nbegin\r\n FPropName:='';\r\n{\r\n TheOwner:=GetOwner;\r\n // TODO: This needs to wait till Mattias finishes typeinfo.\r\n // It's normally only used in the designer so should not be a problem currently.\r\n if (TheOwner=Nil) Or (TheOwner.Classinfo=Nil) Then Exit;\r\n // get information from the owner RTTI\r\n PropCount:=GetPropList(TheOwner, PropList);\r\n Try\r\n For I:=0 To PropCount-1 Do\r\n If (PropList^[i]^.PropType^.Kind=tkClass) And\r\n (GetObjectProp(TheOwner, PropList^[i], ClassType)=Self) Then\r\n Begin\r\n FPropName:=PropList^[i]^.Name;\r\n Exit;\r\n End;\r\n Finally\r\n FreeMem(PropList);\r\n End;\r\n}\r\nend;\r\n\r\n\r\nfunction TCollection.GetPropName: string;\r\n\r\n{Var\r\n TheOwner : TPersistent;}\r\n\r\nbegin\r\n Result:=FPropNAme;\r\n// TheOwner:=GetOwner;\r\n// If (Result<>'') or (TheOwner=Nil) Or (TheOwner.Classinfo=Nil) then exit;\r\n SetPropName;\r\n Result:=FPropName;\r\nend;\r\n\r\n\r\nprocedure TCollection.InsertItem(Item: TCollectionItem);\r\nbegin\r\n If Not(Item Is FitemClass) then\r\n exit;\r\n FItems.add(Item);\r\n Item.FCollection:=Self;\r\n Item.FID:=FNextID;\r\n inc(FNextID);\r\n SetItemName(Item);\r\n Notify(Item,cnAdded);\r\n Changed;\r\nend;\r\n\r\n\r\nprocedure TCollection.RemoveItem(Item: TCollectionItem);\r\n\r\nVar\r\n I : Integer;\r\n\r\nbegin\r\n Notify(Item,cnExtracting);\r\n I:=FItems.IndexOfItem(Item,fromEnd);\r\n If (I<>-1) then\r\n FItems.Delete(I);\r\n Item.FCollection:=Nil;\r\n Changed;\r\nend;\r\n\r\n\r\nfunction TCollection.GetAttrCount: Integer;\r\nbegin\r\n Result:=0;\r\nend;\r\n\r\n\r\nfunction TCollection.GetAttr(Index: Integer): string;\r\nbegin\r\n Result:='';\r\n if Index=0 then ;\r\nend;\r\n\r\n\r\nfunction TCollection.GetItemAttr(Index, ItemIndex: Integer): string;\r\nbegin\r\n Result:=TCollectionItem(FItems.Items[ItemIndex]).DisplayName;\r\n if Index=0 then ;\r\nend;\r\n\r\n\r\nfunction TCollection.GetEnumerator: TCollectionEnumerator;\r\nbegin\r\n Result := TCollectionEnumerator.Create(Self);\r\nend;\r\n\r\n\r\nfunction TCollection.GetNamePath: string;\r\nvar o : TPersistent;\r\nbegin\r\n o:=getowner;\r\n if assigned(o) and (propname<>'') then\r\n result:=o.getnamepath+'.'+propname\r\n else\r\n result:=classname;\r\nend;\r\n\r\n\r\nprocedure TCollection.Changed;\r\nbegin\r\n if FUpdateCount=0 then\r\n Update(Nil);\r\nend;\r\n\r\n\r\nfunction TCollection.GetItem(Index: Integer): TCollectionItem;\r\nbegin\r\n Result:=TCollectionItem(FItems.Items[Index]);\r\nend;\r\n\r\n\r\nprocedure TCollection.SetItem(Index: Integer; Value: TCollectionItem);\r\nbegin\r\n TCollectionItem(FItems.items[Index]).Assign(Value);\r\nend;\r\n\r\n\r\nprocedure TCollection.SetItemName(Item: TCollectionItem);\r\nbegin\r\n if Item=nil then ;\r\nend;\r\n\r\nprocedure TCollection.Update(Item: TCollectionItem);\r\nbegin\r\n if Item=nil then ;\r\nend;\r\n\r\n\r\nconstructor TCollection.Create(AItemClass: TCollectionItemClass);\r\nbegin\r\n inherited create;\r\n FItemClass:=AItemClass;\r\n FItems:=TFpList.Create;\r\nend;\r\n\r\n\r\ndestructor TCollection.Destroy;\r\nbegin\r\n FUpdateCount:=1; // Prevent OnChange\r\n try\r\n DoClear;\r\n Finally\r\n FUpdateCount:=0;\r\n end;\r\n if assigned(FItems) then\r\n FItems.Destroy;\r\n Inherited Destroy;\r\nend;\r\n\r\n\r\nfunction TCollection.Add: TCollectionItem;\r\nbegin\r\n Result:=FItemClass.Create(Self);\r\nend;\r\n\r\n\r\nprocedure TCollection.Assign(Source: TPersistent);\r\nVar I : Longint;\r\nbegin\r\n If Source is TCollection then\r\n begin\r\n Clear;\r\n For I:=0 To TCollection(Source).Count-1 do\r\n Add.Assign(TCollection(Source).Items[I]);\r\n exit;\r\n end\r\n else\r\n Inherited Assign(Source);\r\nend;\r\n\r\n\r\nprocedure TCollection.BeginUpdate;\r\nbegin\r\n inc(FUpdateCount);\r\nend;\r\n\r\n\r\nprocedure TCollection.Clear;\r\nbegin\r\n if FItems.Count=0 then\r\n exit; // Prevent Changed\r\n BeginUpdate;\r\n try\r\n DoClear;\r\n finally\r\n EndUpdate;\r\n end;\r\nend;\r\n\r\n\r\nprocedure TCollection.DoClear;\r\nvar\r\n Item: TCollectionItem;\r\nbegin\r\n While FItems.Count>0 do\r\n begin\r\n Item:=TCollectionItem(FItems.Last);\r\n if Assigned(Item) then\r\n Item.Destroy;\r\n end;\r\nend;\r\n\r\n\r\nprocedure TCollection.EndUpdate;\r\nbegin\r\n if FUpdateCount>0 then\r\n dec(FUpdateCount);\r\n if FUpdateCount=0 then\r\n Changed;\r\nend;\r\n\r\n\r\nfunction TCollection.FindItemID(ID: Integer): TCollectionItem;\r\nVar\r\n I : Longint;\r\nbegin\r\n For I:=0 to Fitems.Count-1 do\r\n begin\r\n Result:=TCollectionItem(FItems.items[I]);\r\n If Result.Id=Id then\r\n exit;\r\n end;\r\n Result:=Nil;\r\nend;\r\n\r\n\r\nprocedure TCollection.Delete(Index: Integer);\r\nVar\r\n Item : TCollectionItem;\r\nbegin\r\n Item:=TCollectionItem(FItems[Index]);\r\n Notify(Item,cnDeleting);\r\n If assigned(Item) then\r\n Item.Destroy;\r\nend;\r\n\r\n\r\nfunction TCollection.Insert(Index: Integer): TCollectionItem;\r\nbegin\r\n Result:=Add;\r\n Result.Index:=Index;\r\nend;\r\n\r\n\r\nprocedure TCollection.Notify(Item: TCollectionItem;Action: TCollectionNotification);\r\nbegin\r\n if Item=nil then ;\r\n if Action=cnAdded then ;\r\nend;\r\n\r\nprocedure TCollection.Sort(Const Compare : TCollectionSortCompare);\r\n\r\nbegin\r\n BeginUpdate;\r\n try\r\n FItems.Sort(TListSortCompare(Compare));\r\n Finally\r\n EndUpdate;\r\n end;\r\nend;\r\n\r\nprocedure TCollection.Exchange(Const Index1, index2: integer);\r\n\r\nbegin\r\n FItems.Exchange(Index1,Index2);\r\nend;\r\n\r\n\r\n{****************************************************************************}\r\n{* TOwnedCollection *}\r\n{****************************************************************************}\r\n\r\n\r\n\r\nConstructor TOwnedCollection.Create(AOwner: TPersistent; AItemClass: TCollectionItemClass);\r\n\r\nBegin\r\n FOwner := AOwner;\r\n inherited Create(AItemClass);\r\nend;\r\n\r\nFunction TOwnedCollection.GetOwner: TPersistent;\r\n\r\nbegin\r\n Result:=FOwner;\r\nend;\r\n\r\n{****************************************************************************}\r\n{* TComponent *}\r\n{****************************************************************************}\r\n\r\n\r\nFunction TComponent.GetComponent(AIndex: Integer): TComponent;\r\n\r\nbegin\r\n If not assigned(FComponents) then\r\n Result:=Nil\r\n else\r\n Result:=TComponent(FComponents.Items[Aindex]);\r\nend;\r\n\r\nFunction TComponent.GetComponentCount: Integer;\r\n\r\nbegin\r\n If not assigned(FComponents) then\r\n result:=0\r\n else\r\n Result:=FComponents.Count;\r\nend;\r\n\r\n\r\nFunction TComponent.GetComponentIndex: Integer;\r\n\r\nbegin\r\n If Assigned(FOwner) and Assigned(FOwner.FComponents) then\r\n Result:=FOWner.FComponents.IndexOf(Self)\r\n else\r\n Result:=-1;\r\nend;\r\n\r\n\r\nProcedure TComponent.Insert(AComponent: TComponent);\r\n\r\nbegin\r\n If not assigned(FComponents) then\r\n FComponents:=TFpList.Create;\r\n FComponents.Add(AComponent);\r\n AComponent.FOwner:=Self;\r\nend;\r\n\r\n\r\nProcedure TComponent.Remove(AComponent: TComponent);\r\n\r\nbegin\r\n AComponent.FOwner:=Nil;\r\n If assigned(FCOmponents) then\r\n begin\r\n FComponents.Remove(AComponent);\r\n IF FComponents.Count=0 then\r\n begin\r\n FComponents.Destroy;\r\n FComponents:=Nil;\r\n end;\r\n end;\r\nend;\r\n\r\n\r\nProcedure TComponent.RemoveNotification(AComponent: TComponent);\r\n\r\nbegin\r\n if FFreeNotifies<>nil then\r\n begin\r\n FFreeNotifies.Remove(AComponent);\r\n if FFreeNotifies.Count=0 then\r\n begin\r\n FFreeNotifies.Destroy;\r\n FFreeNotifies:=nil;\r\n Exclude(FComponentState,csFreeNotification);\r\n end;\r\n end;\r\nend;\r\n\r\n\r\nProcedure TComponent.SetComponentIndex(Value: Integer);\r\n\r\nVar Temp,Count : longint;\r\n\r\nbegin\r\n If Not assigned(Fowner) then exit;\r\n Temp:=getcomponentindex;\r\n If temp<0 then exit;\r\n If value<0 then value:=0;\r\n Count:=Fowner.FComponents.Count;\r\n If Value>=Count then value:=count-1;\r\n If Value<>Temp then\r\n begin\r\n FOWner.FComponents.Delete(Temp);\r\n FOwner.FComponents.Insert(Value,Self);\r\n end;\r\nend;\r\n\r\n\r\nProcedure TComponent.ChangeName(const NewName: TComponentName);\r\n\r\nbegin\r\n FName:=NewName;\r\nend;\r\n\r\n\r\nProcedure TComponent.GetChildren(Proc: TGetChildProc; Root: TComponent);\r\n\r\nbegin\r\n // Does nothing.\r\n if Proc=nil then ;\r\n if Root=nil then ;\r\nend;\r\n\r\n\r\nFunction TComponent.GetChildOwner: TComponent;\r\n\r\nbegin\r\n Result:=Nil;\r\nend;\r\n\r\n\r\nFunction TComponent.GetChildParent: TComponent;\r\n\r\nbegin\r\n Result:=Self;\r\nend;\r\n\r\n\r\nFunction TComponent.GetNamePath: string;\r\n\r\nbegin\r\n Result:=FName;\r\nend;\r\n\r\n\r\nFunction TComponent.GetOwner: TPersistent;\r\n\r\nbegin\r\n Result:=FOwner;\r\nend;\r\n\r\n\r\nProcedure TComponent.Loaded;\r\n\r\nbegin\r\n Exclude(FComponentState,csLoading);\r\nend;\r\n\r\nProcedure TComponent.Loading;\r\n\r\nbegin\r\n Include(FComponentState,csLoading);\r\nend;\r\n\r\n\r\nProcedure TComponent.Notification(AComponent: TComponent;\r\n Operation: TOperation);\r\n\r\nVar\r\n C : Longint;\r\n\r\nbegin\r\n If (Operation=opRemove) then\r\n RemoveFreeNotification(AComponent);\r\n If Not assigned(FComponents) then\r\n exit;\r\n C:=FComponents.Count-1;\r\n While (C>=0) do\r\n begin\r\n TComponent(FComponents.Items[C]).Notification(AComponent,Operation);\r\n Dec(C);\r\n if C>=FComponents.Count then\r\n C:=FComponents.Count-1;\r\n end;\r\nend;\r\n\r\n\r\nprocedure TComponent.PaletteCreated;\r\nbegin\r\nend;\r\n\r\n\r\n\r\nProcedure TComponent.SetAncestor(Value: Boolean);\r\n\r\nVar Runner : Longint;\r\n\r\nbegin\r\n If Value then\r\n Include(FComponentState,csAncestor)\r\n else\r\n Exclude(FCOmponentState,csAncestor);\r\n if Assigned(FComponents) then\r\n For Runner:=0 To FComponents.Count-1 do\r\n TComponent(FComponents.Items[Runner]).SetAncestor(Value);\r\nend;\r\n\r\n\r\nProcedure TComponent.SetDesigning(Value: Boolean; SetChildren : Boolean = True);\r\n\r\nVar Runner : Longint;\r\n\r\nbegin\r\n If Value then\r\n Include(FComponentState,csDesigning)\r\n else\r\n Exclude(FComponentState,csDesigning);\r\n if Assigned(FComponents) and SetChildren then\r\n For Runner:=0 To FComponents.Count - 1 do\r\n TComponent(FComponents.items[Runner]).SetDesigning(Value);\r\nend;\r\n\r\nProcedure TComponent.SetDesignInstance(Value: Boolean);\r\n\r\nbegin\r\n If Value then\r\n Include(FComponentState,csDesignInstance)\r\n else\r\n Exclude(FComponentState,csDesignInstance);\r\nend;\r\n\r\nProcedure TComponent.SetInline(Value: Boolean);\r\n\r\nbegin\r\n If Value then\r\n Include(FComponentState,csInline)\r\n else\r\n Exclude(FComponentState,csInline);\r\nend;\r\n\r\n\r\nProcedure TComponent.SetName(const NewName: TComponentName);\r\n\r\nbegin\r\n If FName=NewName then exit;\r\n If (NewName<>'') and not IsValidIdent(NewName) then\r\n Raise EComponentError.CreateFmt(SInvalidName,[NewName]);\r\n If Assigned(FOwner) Then\r\n FOwner.ValidateRename(Self,FName,NewName)\r\n else\r\n ValidateRename(Nil,FName,NewName);\r\n ChangeName(NewName);\r\nend;\r\n\r\n\r\nProcedure TComponent.SetChildOrder(Child: TComponent; Order: Integer);\r\n\r\nbegin\r\n // does nothing\r\n if Child=nil then ;\r\n if Order=0 then ;\r\nend;\r\n\r\n\r\nProcedure TComponent.SetParentComponent(Value: TComponent);\r\n\r\nbegin\r\n // Does nothing\r\n if Value=nil then ;\r\nend;\r\n\r\n\r\nProcedure TComponent.Updating;\r\n\r\nbegin\r\n Include (FComponentState,csUpdating);\r\nend;\r\n\r\n\r\nProcedure TComponent.Updated;\r\n\r\nbegin\r\n Exclude(FComponentState,csUpdating);\r\nend;\r\n\r\n\r\nProcedure TComponent.ValidateRename(AComponent: TComponent;\r\n const CurName, NewName: string);\r\n\r\nbegin\r\n//!! This contradicts the Delphi manual.\r\n If (AComponent<>Nil) and (CompareText(CurName,NewName)<>0) and (AComponent.Owner = Self) and\r\n (FindComponent(NewName)<>Nil) then\r\n raise EComponentError.Createfmt(SDuplicateName,[newname]);\r\n If (csDesigning in FComponentState) and (FOwner<>Nil) then\r\n FOwner.ValidateRename(AComponent,Curname,Newname);\r\nend;\r\n\r\n\r\nProcedure TComponent.ValidateContainer(AComponent: TComponent);\r\n\r\nbegin\r\n AComponent.ValidateInsert(Self);\r\nend;\r\n\r\n\r\nProcedure TComponent.ValidateInsert(AComponent: TComponent);\r\n\r\nbegin\r\n // Does nothing.\r\n if AComponent=nil then ;\r\nend;\r\n\r\nfunction TComponent._AddRef: Integer;\r\nbegin\r\n Result:=-1;\r\nend;\r\n\r\nfunction TComponent._Release: Integer;\r\nbegin\r\n Result:=-1;\r\nend;\r\n\r\n\r\nConstructor TComponent.Create(AOwner: TComponent);\r\n\r\nbegin\r\n FComponentStyle:=[csInheritable];\r\n If Assigned(AOwner) then AOwner.InsertComponent(Self);\r\nend;\r\n\r\n\r\nDestructor TComponent.Destroy;\r\n\r\nVar\r\n I : Integer;\r\n C : TComponent;\r\n\r\nbegin\r\n Destroying;\r\n If Assigned(FFreeNotifies) then\r\n begin\r\n I:=FFreeNotifies.Count-1;\r\n While (I>=0) do\r\n begin\r\n C:=TComponent(FFreeNotifies.Items[I]);\r\n // Delete, so one component is not notified twice, if it is owned.\r\n FFreeNotifies.Delete(I);\r\n C.Notification (self,opRemove);\r\n If (FFreeNotifies=Nil) then\r\n I:=0\r\n else if (I>FFreeNotifies.Count) then\r\n I:=FFreeNotifies.Count;\r\n dec(i);\r\n end;\r\n FreeAndNil(FFreeNotifies);\r\n end;\r\n DestroyComponents;\r\n If FOwner<>Nil Then FOwner.RemoveComponent(Self);\r\n inherited destroy;\r\nend;\r\n\r\n\r\nProcedure TComponent.BeforeDestruction;\r\nbegin\r\n if not(csDestroying in FComponentstate) then\r\n Destroying;\r\nend;\r\n\r\n\r\nProcedure TComponent.DestroyComponents;\r\n\r\nVar acomponent: TComponent;\r\n\r\nbegin\r\n While assigned(FComponents) do\r\n begin\r\n aComponent:=TComponent(FComponents.Last);\r\n Remove(aComponent);\r\n Acomponent.Destroy;\r\n end;\r\nend;\r\n\r\n\r\nProcedure TComponent.Destroying;\r\n\r\nVar Runner : longint;\r\n\r\nbegin\r\n If csDestroying in FComponentstate Then Exit;\r\n include (FComponentState,csDestroying);\r\n If Assigned(FComponents) then\r\n for Runner:=0 to FComponents.Count-1 do\r\n TComponent(FComponents.Items[Runner]).Destroying;\r\nend;\r\n\r\nfunction TComponent.QueryInterface(const IID: TGUID; out Obj): integer;\r\nbegin\r\n if GetInterface(IID, Obj) then\r\n Result := S_OK\r\n else\r\n Result := E_NOINTERFACE;\r\n\r\nend;\r\n\r\n\r\nFunction TComponent.FindComponent(const AName: string): TComponent;\r\n\r\nVar I : longint;\r\n\r\nbegin\r\n Result:=Nil;\r\n If (AName='') or Not assigned(FComponents) then exit;\r\n For i:=0 to FComponents.Count-1 do\r\n if (CompareText(TComponent(FComponents[I]).Name,AName)=0) then\r\n begin\r\n Result:=TComponent(FComponents.Items[I]);\r\n exit;\r\n end;\r\nend;\r\n\r\n\r\nProcedure TComponent.FreeNotification(AComponent: TComponent);\r\n\r\nbegin\r\n If (Owner<>Nil) and (AComponent=Owner) then exit;\r\n If not (Assigned(FFreeNotifies)) then\r\n FFreeNotifies:=TFpList.Create;\r\n If FFreeNotifies.IndexOf(AComponent)=-1 then\r\n begin\r\n FFreeNotifies.Add(AComponent);\r\n AComponent.FreeNotification (self);\r\n end;\r\nend;\r\n\r\n\r\nprocedure TComponent.RemoveFreeNotification(AComponent: TComponent);\r\nbegin\r\n RemoveNotification(AComponent);\r\n AComponent.RemoveNotification (self);\r\nend;\r\n\r\n\r\nFunction TComponent.GetParentComponent: TComponent;\r\n\r\nbegin\r\n Result:=Nil;\r\nend;\r\n\r\n\r\nFunction TComponent.HasParent: Boolean;\r\n\r\nbegin\r\n Result:=False;\r\nend;\r\n\r\n\r\nProcedure TComponent.InsertComponent(AComponent: TComponent);\r\n\r\nbegin\r\n AComponent.ValidateContainer(Self);\r\n ValidateRename(AComponent,'',AComponent.FName);\r\n Insert(AComponent);\r\n If csDesigning in FComponentState then\r\n AComponent.SetDesigning(true);\r\n Notification(AComponent,opInsert);\r\nend;\r\n\r\n\r\nProcedure TComponent.RemoveComponent(AComponent: TComponent);\r\n\r\nbegin\r\n Notification(AComponent,opRemove);\r\n Remove(AComponent);\r\n Acomponent.Setdesigning(False);\r\n ValidateRename(AComponent,AComponent.FName,'');\r\nend;\r\n\r\nprocedure TComponent.SetSubComponent(ASubComponent: Boolean);\r\nbegin\r\n if ASubComponent then\r\n Include(FComponentStyle, csSubComponent)\r\n else\r\n Exclude(FComponentStyle, csSubComponent);\r\nend;\r\n\r\nfunction TComponent.GetEnumerator: TComponentEnumerator;\r\nbegin\r\n Result:=TComponentEnumerator.Create(Self);\r\nend;\r\n\r\n\r\n{ ---------------------------------------------------------------------\r\n Global routines\r\n ---------------------------------------------------------------------}\r\n\r\nvar\r\n ClassList : TJSObject;\r\n \r\nProcedure RegisterClass(AClass : TPersistentClass);\r\n\r\nbegin\r\n ClassList[AClass.ClassName]:=AClass;\r\nend;\r\n\r\nFunction GetClass(AClassName : string) : TPersistentClass;\r\n\r\nbegin\r\n Result:=nil;\r\n if AClassName='' then exit;\r\n if not ClassList.hasOwnProperty(AClassName) then exit;\r\n Result:=TPersistentClass(ClassList[AClassName]);\r\nend;\r\n\r\ninitialization\r\n ClassList:=TJSObject.create(nil);\r\nend.\r\n\r\n","{\r\n This file is part of the Pas2JS run time library.\r\n Copyright (c) 2017 by Mattias Gaertner\r\n\r\n See the file COPYING.FPC, included in this distribution,\r\n for details about the copyright.\r\n\r\n This program is distributed in the hope that it will be useful,\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n **********************************************************************}\r\n\r\n{$mode objfpc}\r\n{$modeswitch externalclass}\r\n\r\nunit Web;\r\n\r\ninterface\r\n\r\nuses Types, JS;\r\n\r\nType\r\n // Forward definitions\r\n TJSWindow = class;\r\n TJSDOMTokenList = class;\r\n TJSXPathResult = CLass;\r\n TJSNodeList = class;\r\n TJSDocument = class;\r\n TJSElement = class;\r\n TJSCSSStyleSheet = Class;\r\n TJSNodeFilter = Class;\r\n TJSIDBObjectStore = Class;\r\n TIDBDatabase = class;\r\n TJSIDBRequest = class;\r\n TJSEventTarget = class;\r\n TJSMouseEvent = Class;\r\n TJSWheelEvent = Class;\r\n TJSKeyBoardEvent = class;\r\n TJSPointerEvent = Class;\r\n TJSUIEvent = class;\r\n TJSTouchEvent = Class;\r\n\r\n TJSAttr = class external name 'Attr'\r\n Private\r\n fLocalName : String; external name 'localName';\r\n fNameSpaceURI : String external name 'namespaceURI';\r\n fPrefix : string; external name 'prefix';\r\n fName : string; external name 'name';\r\n public\r\n value : JSValue;\r\n property localName : String Read fLocalName;\r\n property namespaceURI : string Read fNameSpaceURI;\r\n property prefix : string read fPrefix;\r\n property name : string Read fName;\r\n end;\r\n\r\n\r\n { TEventListenerEvent }\r\n\r\n TEventListenerEvent = class external name 'EventListener_Event'\r\n private\r\n FTarget: TJSEventTarget; external name 'target';\r\n public\r\n Property target: TJSEventTarget Read FTarget;\r\n end;\r\n\r\n TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;\r\n\r\n TJSEventTarget = class external name 'EventTarget'\r\n public\r\n procedure addEventListener(aname : string; aListener : TJSEventHandler);\r\n procedure addEventListener(aname : string; aListener : JSValue);\r\n function dispatchEvent(event : JSValue) : Boolean;\r\n procedure removeEventListener(aname : string; aListener : TJSEventHandler);\r\n procedure removeEventListener(aname : string; aListener : JSValue);\r\n end;\r\n\r\n TJSNode = class external name 'Node' (TJSEventTarget)\r\n Private\r\n FBaseURI : String; external name 'baseURI';\r\n FChildNodes: TJSNodeList; external name 'childNodes';\r\n FFirstChild : TJSNode; external name 'firstChild';\r\n FNextSibling : TJSNode; external name 'nextSibling';\r\n FNodeName : String; external name 'nodeName';\r\n FNodeType : NativeInt; external name 'nodeType';\r\n FOwnerDocument : TJSDocument; external name 'ownerDocument';\r\n FParentElement : TJSElement; external name 'parentElement';\r\n FParentNode : TJSNode; external name 'parentNode';\r\n FPreviousSibling : TJSNode; external name 'previousSibling';\r\n Public \r\n Const\r\n ELEMENT_NODE \t=1;\r\n TEXT_NODE \t=3;\r\n PROCESSING_INSTRUCTION_NODE = \t7;\r\n COMMENT_NODE \t=8;\r\n DOCUMENT_NODE \t=9;\r\n DOCUMENT_TYPE_NODE \t= 10;\r\n DOCUMENT_FRAGMENT_NODE = 11;\r\n\r\n DOCUMENT_POSITION_DISCONNECTED \t= 1;\r\n DOCUMENT_POSITION_PRECEDING \t= 2;\r\n DOCUMENT_POSITION_FOLLOWING \t= 4;\r\n DOCUMENT_POSITION_CONTAINS \t= 8;\r\n DOCUMENT_POSITION_CONTAINED_BY \t= 16;\r\n DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;\r\n Public \r\n nodeValue: string;\r\n innerText : string;\r\n textContent : string;\r\n function appendChild(aChild : TJSNode) : TJSNode;\r\n function cloneNode(deep: boolean): TJSNode;\r\n function compareDocumentPosition(aNode : TJSNode) : NativeInt;\r\n function contains(aNode : TJSNode) : boolean;\r\n function hasChildNodes : boolean;\r\n function insertBefore(newNode, referenceNode : TJSNode) : TJSNode;\r\n function isDefaultNameSpace(aNameSpaceURI : String) : Boolean;\r\n function isEqualNode(aNode : TJSNode) : boolean;\r\n function isSameNode(aNode : TJSNode) : boolean;\r\n function lookupNamespaceURI(aPrefix : string) : string;\r\n function lookupPrefix(aPrefix : string) : string;\r\n procedure normalize;\r\n function removeChild(aChild: TJSNode) : TJSNode;\r\n function replaceChild(aNewChild, aOldChild : TJSNode) : TJSNode;\r\n property baseURI : string read FBaseURI;\r\n property childNodes : TJSNodeList read FChildNodes;\r\n property firstChild : TJSNode Read FFirstChild;\r\n property nextSibling : TJSNode Read FNextSibling;\r\n property nodeName : String Read FNodeName;\r\n property nodeType : NativeInt Read FNodeType;\r\n property ownerDocument : TJSDocument read FOwnerDocument; \r\n property parentElement : TJSElement read FParentElement;\r\n property parentNode : TJSNode read FParentNode;\r\n property previousSibling : TJSNode Read FPreviousSibling;\r\n end;\r\n\r\n TJSNodeListCallBack = procedure (currentValue : TJSNode; currentIndex: NativeInt; list : TJSNodeList);\r\n TJSNodeListEvent = procedure (currentValue : TJSNode; currentIndex: NativeInt; list : TJSNodeList) of object;\r\n \r\n TJSNodeList = class external name 'NodeList'\r\n Private\r\n FLength : NativeInt; external name 'length';\r\n Public\r\n procedure forEach(const aCallBack : TJSNodeListCallBack);\r\n procedure forEach(const aCallBack : TJSNodeListEvent);\r\n function item(aIndex : NativeInt) : TJSNode;\r\n Property length : NativeInt Read FLength;\r\n Property Nodes [aIndex : NativeInt] : TJSNode Read item; default;\r\n end;\r\n \r\n TJSNamedNodeMap = class external name 'NamedNodeMap'\r\n Public\r\n function getNamedItem(aName : string) : TJSAttr;\r\n Property Attrs[aIndex : String] : TJSattr Read getNamedItem; default;\r\n end;\r\n \r\n TJSHTMLCollection = class external name 'HTMLCollection'\r\n Private\r\n FLength : NativeInt; external name 'length';\r\n public\r\n Function item(aIndex : Integer) : TJSNode;\r\n Function namedItem(aName : string) : TJSNode;\r\n property Items[aIndex : Integer] : TJSNode Read item; default;\r\n property NamedItems[aName : String] : TJSNode Read namedItem; \r\n Property length : NativeInt Read FLength;\r\n end; \r\n \r\n TJSDOMString = String;\r\n\r\n TDOMTokenlistCallBack = Procedure (Current : JSValue; currentIndex : NativeInt; list : TJSDOMTokenList);\r\n \r\n // Interface\r\n TJSDOMTokenList = class external name 'DOMTokenList'\r\n Private\r\n FLength : NativeInt; external name 'length';\r\n public\r\n Procedure add(aToken : TJSDOMString); varargs;\r\n Procedure remove(aToken : TJSDOMString); varargs;\r\n function item(aIndex : NativeInt) : String;\r\n function contains(aToken : TJSDOMString) : Boolean;\r\n Procedure replace(aOldToken, ANewToken : TJSDOMString);\r\n function supports(aToken : TJSDOMString) : Boolean;\r\n function toggle(aToken : TJSDOMString) : Boolean;\r\n // entries,keys, values\r\n procedure forEach(const callback: TDOMTokenlistCallBack);\r\n property length : NativeInt read FLength;\r\n end;\r\n\r\n TJSDOMRect = class external name 'DOMRect'\r\n public\r\n left,top,right,bottom,x,y,width,height : double;\r\n {$IFDEF FIREFOX}\r\n constructor New;\r\n {$ENDIF}\r\n end;\r\n TJSClientRect = record\r\n left,top,right,bottom : double;\r\n {$IFDEF FIREFOX}\r\n width, height: double;\r\n {$ENDIF}\r\n end;\r\n \r\n TJSClientRectArray = array of TJSClientRect;\r\n \r\n TJSElement = class external name 'Element' (TJSNode)\r\n Private\r\n FAttributes : TJSNamedNodeMap; external name 'attributes';\r\n FChildElementCount : NativeInt; external name 'childElementCount';\r\n FChildren : TJSHTMLCollection; external name 'children';\r\n FClassList : TJSDOMTokenList; external name 'classList';\r\n FCLientHeight : NativeInt; external name 'clientHeight';\r\n FCLientLeft : NativeInt; external name 'clientLeft';\r\n FCLientTop : NativeInt; external name 'clientTop';\r\n FCLientWidth : NativeInt; external name 'clientWidth';\r\n FFirstElementChild : TJSElement; external name 'firstElementChild';\r\n FLastElementChild : TJSElement; external name 'lastElementChild';\r\n FLocalName : string; external name 'localName';\r\n FNameSpaceURI : String; external name 'namespaceURI';\r\n FNextElementSibling : TJSElement; external name 'nextElementSibling';\r\n FPreviousElementSibling : TJSElement; external name 'previousElementSibling';\r\n FPrefix : String; external name 'prefix';\r\n FScrollHeight : NativeInt; external name 'scrollHeight';\r\n{$IFDEF FIREFOX}\r\n FScrollLeftMax : NativeInt; external name 'scrollLeftMax';\r\n FScrollTopMax : NativeInt; external name 'scrollTopMax';\r\n{$endif}\r\n FScrollWidth : NativeInt; external name 'scrollWidth';\r\n FTagName : string; external name 'tagName';\r\n Public\r\n name : string;\r\n className : string;\r\n id : string;\r\n innerHTML : String;\r\n outerHTML : string;\r\n scrollLeft : NativeInt;\r\n scrollTop : NativeInt;\r\n procedure append(aText : String); overload;\r\n procedure append(aNode : TJSElement); overload;\r\n procedure append(aText : String; aNode : TJSElement); varargs; overload;\r\n procedure append(aNode1,aNode2: TJSElement); varargs; overload;\r\n function getAttribute(aName : string) : string;\r\n function getAttributeNode(aName : string) : TJSAttr;\r\n function getAttributeNodeNS(aNameSpace, aName : string) : TJSAttr;\r\n function getAttributeNS(aNameSpace, aName : string) : string;\r\n function getBoundingClientRect : TJSDOMRect;\r\n function getClientRects : TJSClientRectArray;\r\n function getElementsByClassName(aClassName: string) : TJSHTMLCollection;\r\n function getElementsByTagNameNS(aNameSpace, aTagName : String): TJSHTMLCollection;\r\n function getElementsByTagName(aTagName : String): TJSHTMLCollection;\r\n function hasAttribute(aName : String) : Boolean;\r\n function hasAttributeNS(aNameSpace,aName : String) : Boolean;\r\n function hasAttributes : Boolean;\r\n function insertAdjacentElement(aPosition : string; aElement : TJSElement) : TJSElement;\r\n procedure insertAdjacentHTML(aPosition,aHTML : string);\r\n procedure insertAdjacentText(aPosition,aText : string);\r\n function matches(aSelectorString : String) : Boolean;\r\n function querySelector(aSelectors : String) : TJSElement;\r\n function querySelectorAll(aSelectors : String) : TJSNodeList;\r\n procedure releasePointerCapture(evID : JSValue);\r\n procedure removeAttribute(aName: string);\r\n procedure removeAttributeNS(aNameSpace,aName: string);\r\n function removeAttributeNode(aAttr : TJSAttr) : TJSAttr;\r\n procedure setAttribute(aName : string; AValue : String);\r\n function setAttributeNode(aNode: TJSAttr) : TJSAttr;\r\n function setAttributeNodeNS(aNode: TJSAttr) : TJSAttr;\r\n procedure setAttributeNS(aNameSpace,aName : string; AValue : String);\r\n procedure setCapture(retargetToElement : Boolean);\r\n procedure setPointerCapture(pointerID : JSValue);\r\n procedure requestFullScreen; \r\n Property attributes : TJSNamedNodeMap read FAttributes;\r\n Property childElementCount : NativeInt Read FChildElementCount;\r\n Property children : TJSHTMLCollection Read FChildren;\r\n Property classList : TJSDOMTokenList read FClassList;\r\n property clientHeight : NativeInt read FClientHeight;\r\n property clientLeft : NativeInt read FClientLeft;\r\n property clientTop : NativeInt read FClientTop;\r\n property clientWidth : NativeInt read FClientWidth;\r\n property firstElementChild : TJSElement Read FFirstElementChild;\r\n property lastElementChild : TJSElement Read FLastElementChild;\r\n property localName : string Read FLocalName;\r\n property namespaceURI : String read FNameSpaceURI;\r\n property nextElementSibling : TJSElement Read FNextElementSibling;\r\n property previousElementSibling : TJSElement Read FPreviousElementSibling;\r\n property prefix : String read FPrefix;\r\n property scrollHeight : NativeInt Read FScrollHeight;\r\n{$IFDEF FIREFOX}\r\n property scrollLeftMax : NativeInt Read FScrollLeftMax;\r\n property scrollTopMax : NativeInt Read FScrollTopMax;\r\n{$ENDIF}\r\n property scrollWidth : NativeInt Read FScrollWidth;\r\n property tagName : String read FTagName;\r\n Property Attrs[aName : string] : String read getAttribute write setAttribute; default;\r\n end;\r\n \r\n TJSElementCreationOptions = record\r\n named : string;\r\n end;\r\n \r\n TJSDocumentType = class external name 'DocumentType' (TJSNode)\r\n private\r\n FName : String; external name 'name';\r\n FPublicID : String; external name 'publicId';\r\n FSystemID : String; external name 'systemId';\r\n public\r\n property name : String read FName;\r\n property publicId : String Read FPublicID;\r\n property systemId : String read FSystemID;\r\n end;\r\n\r\n TJSDOMImplementation = class external name 'DocumentImplementation'\r\n Public \r\n function createDocument(aNamespaceURI, aQualifiedNameStr : String; aDocumentType : TJSDocumentType) : TJSDocument;\r\n function createDocumentType(aQualifiedNameStr,aPublicId,aSystemId : String) : TJSDocumentType;\r\n function createHTMLDocument(aTitle : String) : TJSDocument;\r\n end;\r\n\r\n TJSLocation = class external name 'Location'\r\n Private\r\n FOrigin : string;\r\n Public\r\n hash : string;\r\n host : string;\r\n hostname : string;\r\n href : string;\r\n password : string;\r\n pathname : string;\r\n port : string;\r\n protocol : string;\r\n search : string;\r\n username : string;\r\n procedure assign(aURL : String);\r\n procedure reload(aForce : Boolean);\r\n procedure replace(aURL : String);\r\n function toString : String;\r\n property origin : string read FOrigin;\r\n end;\r\n \r\n TJSStyleSheet = class external name 'StyleSheet' (TJSEventTarget)\r\n Private\r\n FHRef : String; external name 'href';\r\n FOwnerNode : TJSNode; external name 'ownerNode';\r\n FParentStyleSheet : TJSStyleSheet; external name 'parentStyleSheet';\r\n FTitle : String; external name 'title';\r\n FType : String; external name 'type';\r\n Public\r\n disabled : String;\r\n Property href : String read FHRef;\r\n property ownerNode : TJSNode Read FOwnerNode;\r\n property parentStyleSheet : TJSStyleSheet read FParentStyleSheet;\r\n property title : string Read FTitle;\r\n property _type : String read FType;\r\n end;\r\n\r\n\r\n TJSCSSRule = class external name 'CSSRule'\r\n Private\r\n FCSSText : String; external name 'cssText';\r\n FParentStyleSheet : TJSCSSStyleSheet; external name 'parentStyleSheet';\r\n FparentRule : TJSCSSRule; external name 'parentRule';\r\n Public\r\n property cssText : String Read FCSSText;\r\n property parentRule : TJSCSSRule read FparentRule;\r\n property parentStyleSheet : TJSCSSStyleSheet Read FParentStyleSheet;\r\n end;\r\n \r\n TJSCSSRuleList = Class external name 'CSSRuleList'\r\n Private\r\n FLength : NativeInt; external name 'length';\r\n Public\r\n function item(index : NativeInt) : TJSCSSRule;\r\n property length : NativeInt Read FLength;\r\n Property items[aIndex : NativeInt] : TJSCSSRule read item; default;\r\n end;\r\n \r\n \r\n TJSCSSStyleSheet = class external name 'CSSStyleSheet' (TJSStyleSheet)\r\n Private\r\n FCSSRules : TJSCSSRuleList; external name 'cssRules';\r\n Public\r\n procedure deleteRule(aIndex : NativeInt);\r\n function insertRule(aRule : String; aIndex : NativeInt) : NativeInt;\r\n Property cssRules : TJSCSSRuleList read FCSSRules;\r\n end;\r\n\r\n TJSStyleSheetList = Class external name 'StyleSheetList'\r\n Private\r\n FLength : NativeInt; external name 'length';\r\n Public\r\n function item(index : NativeInt) : TJSStyleSheet;\r\n property length : NativeInt Read FLength;\r\n Property items[aIndex : NativeInt] : TJSStyleSheet read item; default;\r\n end;\r\n\r\n { TJSDocumentFragment }\r\n\r\n TJSDocumentFragment = Class external name 'DocumentFragment' (TJSNode)\r\n private\r\n FchildElementCount: Integer; external name 'childElementCount';\r\n Fchildren: TJSHTMLCollection; external name 'children';\r\n FfirstElementChild: TJSElement; external name 'firstElementChild';\r\n FlastElementChild: TJSElement; external name 'lastElementChild';\r\n public\r\n constructor new;\r\n function querySelector(aSelector : String) : TJSElement;\r\n function querySelectorAll(aSelector : String) : TJSNodeList;\r\n property childElementCount : Integer read FchildElementCount;\r\n property children : TJSHTMLCollection read Fchildren;\r\n property firstElementChild : TJSElement read FfirstElementChild;\r\n property lastElementChild : TJSElement read FlastElementChild;\r\n end;\r\n\r\n TJSEventInit = record\r\n bubbles : boolean;\r\n cancelable : boolean;\r\n scoped : boolean;\r\n composed : boolean;\r\n end;\r\n\r\n TJSEvent = class external name 'Event'\r\n Private\r\n FBubbles : Boolean; external name 'bubbles';\r\n FCancelable : Boolean; external name 'cancelable';\r\n FComposed : Boolean; external name 'composed';\r\n FCurrentTarget : TJSElement; external name 'currentTarget';\r\n FdefaultPrevented : Boolean; external name 'defaultPrevented';\r\n FEventPhase : NativeInt; external name 'eventPhase';\r\n FTarget : TJSElement; external name 'target';\r\n FTimeStamp : NativeInt; external name 'timestamp';\r\n FType : String; external name 'type';\r\n FIsTrusted : Boolean; external name 'isTrusted';\r\n Public\r\n Const\r\n NONE = 0;\r\n CAPTURING_PHASE = 1;\r\n AT_TARGET = 2;\r\n BUBBLING_PHASE = 3;\r\n public \r\n cancelBubble : Boolean;\r\n constructor new (aType : String; const aInit : TJSEventInit); overload;\r\n constructor new (aType : String; const aInit : TJSObject); overload;\r\n procedure preventDefault;\r\n procedure stopImmediatePropagation;\r\n procedure stopPropagation;\r\n Property bubbles : Boolean Read FBubbles;\r\n Property cancelable : Boolean Read FCancelable;\r\n Property composed : Boolean Read FComposed;\r\n property currentTarget : TJSElement Read FCurrentTarget;\r\n property defaultPrevented : Boolean Read FdefaultPrevented;\r\n property eventPhase : NativeInt Read FEventPhase;\r\n property target : TJSElement Read FTarget;\r\n Property timestamp : NativeInt Read FTimeStamp;\r\n property _type : string read FType;\r\n property isTrusted : Boolean Read FIsTrusted;\r\n end;\r\n\r\n\r\n TJSXPathExpression = class external name 'XPathExpression'\r\n Public\r\n function evaluate(contextNode : TJSNode; aType : NativeInt; aResult : TJSXPathResult) : TJSXPathResult;\r\n function evaluateWithContext(contextNode : TJSNode; aPosition, aSize, aType : NativeInt; aResult : TJSXPathResult) : TJSXPathResult;\r\n end;\r\n\r\n TJSXPathNSResolver = class external name 'XPathNSResolver'\r\n Public\r\n function lookupNamespaceURI(prefix : string) : string;\r\n end;\r\n\r\n { TJSCharacterData }\r\n\r\n TJSCharacterData = class external name 'CharacterData' (TJSNode)\r\n private\r\n FnextElementSibling: TJSElement; external name 'nextElementSibling';\r\n FpreviousElementSibling: TJSElement; external name 'previousElementSibling';\r\n public\r\n property nextElementSibling : TJSElement read FnextElementSibling;\r\n property previousElementSibling : TJSElement read FpreviousElementSibling;\r\n end;\r\n\r\n TJSProcessingInstruction = class external name 'ProcessingInstruction' (TJSCharacterData);\r\n\r\n { TJSRange }\r\n\r\n TJSRange = class external name 'Range'\r\n private\r\n FCollapsed: boolean; external name 'collapsed';\r\n FcommonAncestorContainer: TJSNode; external name 'commonAncestorContainer';\r\n FendContainer: TJSNode; external name 'endContainer';\r\n FEndOffset: NativeInt; external name 'endOffset';\r\n FstartContainer: TJSNode; external name 'startContainer';\r\n FstartOffset: NativeInt; external name 'startOffset';\r\n Public\r\n const\r\n END_TO_END = 0;\r\n END_TO_START = 1;\r\n START_TO_END = 2;\r\n START_TO_START = 3;\r\n Public\r\n constructor new;\r\n function cloneContents : TJSDocumentFragment;\r\n function cloneRange : TJSRange;\r\n procedure collapse;\r\n function compareBoundaryPoints(aHow : NativeInt) : NativeInt;\r\n function createContextualFragment(aTagstring : String) : TJSDocumentFragment;\r\n procedure deleteContents;\r\n procedure detach;\r\n function extractContents : TJSDocumentFragment;\r\n procedure insertNode(aNode : TJSNode);\r\n procedure selectNode(aNode : TJSNode);\r\n procedure selectNodeContents(aNode : TJSNode);\r\n procedure setEnd(aEndNode : TJSNode; aEndOffset : NativeInt); \r\n procedure setEndAfter(aEndNode : TJSNode);\r\n procedure setEndBefore(aEndNode : TJSNode);\r\n procedure setStart(aStartNode : TJSNode; aStartOffset : NativeInt); \r\n procedure setStartAfter(aStartNode : TJSNode);\r\n procedure setStartBefore(aStartNode : TJSNode);\r\n procedure surroundContents(aNode : TJSNode);\r\n function toString : string;\r\n property collapsed : boolean read FCollapsed;\r\n property commonAncestorContainer : TJSNode read FcommonAncestorContainer ;\r\n property endContainer : TJSNode read FendContainer;\r\n property endOffset : NativeInt Read FEndOffset;\r\n property startContainer : TJSNode read FstartContainer;\r\n property startOffset : NativeInt Read FstartOffset;\r\n end;\r\n\r\n\r\n { TJSTreeWalker }\r\n\r\n TJSTreeWalker = class external name 'TreeWalker'\r\n private\r\n FCurrentNode: TJSNode; external name 'currentNode';\r\n FexpandEntityReference: Boolean; external name 'expandEntityReference';\r\n FFilter: TJSNodeFilter; external name 'filter';\r\n FRoot: TJSNode; external name 'root';\r\n FWhatToShow: NativeInt; external name 'whatToShow';\r\n Public\r\n function firstChild : TJSNode;\r\n function lastChild : TJSNode;\r\n function nextNode : TJSNode;\r\n function nextSibling : TJSNode;\r\n function parentNode : TJSNode;\r\n function previousNode : TJSNode;\r\n function previousSibling : TJSNode;\r\n\r\n property root : TJSNode read FRoot;\r\n property whatToShow : NativeInt read FWhatToShow;\r\n property filter : TJSNodeFilter Read FFilter;\r\n property expandEntityReference : Boolean Read FexpandEntityReference;\r\n property currentNode : TJSNode Read FCurrentNode;\r\n end;\r\n\r\n TJSNodeFilter = class external name 'NodeFilter'\r\n const\r\n SHOW_ALL = -1;\r\n SHOW_ATTRIBUTE = 2;\r\n SHOW_CDATA_SECTION = 8;\r\n SHOW_COMMENT = 128;\r\n SHOW_DOCUMENT = 256;\r\n SHOW_DOCUMENT_FRAGMENT = 1024;\r\n SHOW_DOCUMENT_TYPE = 512;\r\n SHOW_ELEMENT = 1;\r\n SHOW_ENTITY = 32;\r\n SHOW_ENTITY_REFERENCE = 16;\r\n SHOW_NOTATION = 2048;\r\n SHOW_PROCESSING_INSTRUCTION = 64;\r\n SHOW_TEXT = 4;\r\n function acceptNode (aNode : TJSNode) : NativeInt;\r\n end;\r\n\r\n TJSXPathResult = class external name 'XPathResult'\r\n private\r\n FBooleanValue : Boolean; external name 'booleanValue';\r\n FNumberValue : Double; external name 'numberValue';\r\n FResultType : NativeInt; external name 'resultType';\r\n FSingleNodeValue : TJSNode; external name 'singleNodeValue';\r\n FSnaphotLength : NativeInt; external name 'snapshotLength';\r\n FStringValue : String; external name 'stringValue';\r\n public \r\n Function iterateNext : TJSNode;\r\n Function snapshotItem(Index: NativeInt) : TJSNode;\r\n Property booleanValue : Boolean Read FBooleanValue;\r\n Property numberValue : Double Read FNumberValue;\r\n property resultType : NativeInt Read FResultType;\r\n Property singleNodeValue : TJSNode Read FSingleNodeValue;\r\n property snapshotLength : NativeInt read FSnaphotLength;\r\n property stringValue : String Read FStringValue;\r\n end;\r\n\r\n TJSSelection = class external name 'Selection'\r\n Private\r\n FanchorNode : TJSNode ; external name 'anchorNode';\r\n FanchorOffset : NativeInt ; external name 'anchorOffset';\r\n FfocusNode : TJSNode ; external name 'focusNode';\r\n FfocusOffset : NativeInt ; external name 'focusOffset';\r\n FisCollapsed : Boolean ; external name 'isCollapsed';\r\n FrangeCount : NativeInt ; external name 'rangeCount';\r\n Ftype : String ; external name 'type';\r\n Public\r\n function getRangeAt(aIndex : NativeInt) : TJSRange;\r\n procedure collapse(aParentNode : TJSNode; Offset : NativeInt);\r\n procedure extend(aParentNode : TJSNode; Offset : NativeInt);\r\n procedure collapseToStart;\r\n procedure collapseToEnd;\r\n procedure selectAllChildren(aParentNode : TJSNode);\r\n procedure addRange(aRange : TJSRange);\r\n procedure removeRange(aRange : TJSRange);\r\n procedure removeAllRanges;\r\n procedure deleteFromDocument;\r\n function containsNode(aNode : TJSNode; aPartlyContained : Boolean) : Boolean;\r\n procedure setBaseAndExtent(aAnchorNode : TJSNode; aAnchorOffset : NativeInt; aFocusNode : TJSNode; aFocusOffset : NativeInt);\r\n function toString : String;\r\n property anchorNode : TJSNode read FAnchorNode;\r\n property anchorOffset : NativeInt read FAnchorOffset;\r\n property focusNode : TJSNode read FFocusNode;\r\n property focusOffset : NativeInt read FFocusOffset;\r\n property isCollapsed : Boolean read FIsCollapsed;\r\n property rangeCount : NativeInt read FRangeCount;\r\n property _type : String Read FType;\r\n end;\r\n TJSNameSpaceMapperCallback = function (aNameSpace : string ) : String;\r\n\r\n TJSHTMLFile = class;\r\n TJSHTMLFileList = Class;\r\n\r\n { TJSDataTransferItem }\r\n\r\n TJSDataTransferItemCallBack = reference to Procedure(aData : String);\r\n\r\n TJSDataTransferItem = class external name 'DataTransferItem'\r\n private\r\n FKind: String; external name 'kind';\r\n FType: string; external name 'type';\r\n Public\r\n function getAsFile : TJSHTMLFile;\r\n Procedure getAsString(aCallBack : TJSDataTransferItemCallBack);\r\n property Kind : String read FKind;\r\n property _Type : string read FType;\r\n end;\r\n\r\n TJSDataTransferItemList = class external name 'DataTransferItemList'\r\n private\r\n FLength: NativeInt; external name 'length';\r\n function getitem(aIndex : nativeInt) : TJSDataTransferItem ; external name '[]';\r\n Public\r\n Function add(aData : string; AType: string) : TJSDataTransferItem; overload;\r\n Function add(aFile : TJSHTMLFile) : TJSDataTransferItem; overload;\r\n Procedure clear;\r\n procedure remove(aIndex : integer);\r\n property length : NativeInt read FLength;\r\n property Items[aIndex : NativeInt] : TJSDataTransferItem Read getitem; default;\r\n end;\r\n\r\n { TDataTransfer }\r\n\r\n TJSDataTransfer = class external name 'DataTransfer'\r\n private\r\n FFiles: TJSHTMLFileList; external name 'files';\r\n FItems: TJSDataTransferItemList; external name 'items';\r\n FTypes: TJSStringDynArray; external name 'types';\r\n Public\r\n dropEffect : string;\r\n effectAllowed : string;\r\n Procedure clearData; overload;\r\n Procedure clearData(aFormat : string); overload;\r\n function getData(aFormat : string) : String;\r\n procedure setData(aFormat : String; aData : String);\r\n procedure setDragImage(aImage: TJSElement; xOffset,yOffset : integer);\r\n property files : TJSHTMLFileList Read FFiles;\r\n property items : TJSDataTransferItemList read FItems;\r\n property types : TJSStringDynArray read FTypes;\r\n end;\r\n\r\n { TJSDragEvent }\r\n\r\n TJSDragEvent = class external name 'DragEvent' (TJSEvent)\r\n Private\r\n FDataTransfer: TJSDataTransfer; external name 'dataTransfer';\r\n FrelatedTarget : TJSEventTarget external name 'relatedTarget';\r\n FscreenX : NativeInt external name 'screenX';\r\n FscreenY : NativeInt external name 'screenY';\r\n FclientX : NativeInt external name 'clientX';\r\n FclientY : NativeInt external name 'clientY';\r\n Fbutton : NativeInt external name 'button';\r\n Fbuttons : NativeInt external name 'buttons';\r\n FctrlKey : Boolean external name 'ctrlKey';\r\n FshiftKey : Boolean external name 'shiftKey';\r\n FaltKey : Boolean external name 'altKey';\r\n FmetaKey : Boolean external name 'metaKey';\r\n Public\r\n Property relatedTarget : TJSEventTarget Read FRelatedTarget;\r\n Property screenX : NativeInt Read FScreenX;\r\n Property screenY : NativeInt Read FScreenY;\r\n Property clientX : NativeInt Read FClientX;\r\n Property clientY : NativeInt Read FClientY;\r\n Property button : NativeInt Read FButton;\r\n Property buttons : NativeInt Read FButtons;\r\n Property ctrlKey : Boolean Read FctrlKey;\r\n Property shiftKey : Boolean Read FshiftKey;\r\n Property altKey : Boolean Read FaltKey;\r\n Property metaKey : Boolean Read FmetaKey;\r\n property dataTransfer : TJSDataTransfer Read FDataTransfer;\r\n end;\r\n TJSDragDropEventHandler = reference to function(aEvent: TJSDragEvent) : Boolean;\r\n THTMLClickEventHandler = reference to function(aEvent : TJSMouseEvent) : boolean;\r\n { Various events }\r\n\r\n{$IFNDEF FIREFOX}\r\n TJSFocusEvent = TJSEvent;\r\n{$ELSE}\r\n TJSFocusEvent = Class(TJSEvent)\r\n private\r\n FrelatedTarget : TJSElement external name 'relatedTarget';\r\n public\r\n property relatedTarget : TJSElement Read FrelatedTarget;\r\n end;\r\n{$ENDIF}\r\n TJSAnimationEvent = Class(TJSEvent);\r\n TJSLoadEvent = Class(TJSEvent);\r\n\r\n TJSErrorEvent = class external name 'ErrorEvent' (TJSEvent)\r\n Private\r\n Fmessage : String external name 'message';\r\n Ffilename : string external name 'filename';\r\n Flineno : integer external name 'lineno';\r\n Fcolno : integer external name 'colno';\r\n Ferror : TJSObject external name 'error';\r\n Public\r\n Property message : String read FMessage;\r\n property filename : string Read FFileName;\r\n property lineno : integer read FLineNo;\r\n Property colno : integer read FColNo;\r\n Property error : TJSObject read FError;\r\n end;\r\n\r\n TJsPageTransitionEvent = class(TJSEvent)\r\n end;\r\n\r\n TJSHashChangeEvent = class external name 'HashChangeEvent' (TJSEvent)\r\n Private\r\n FnewURL : String external name 'newURL';\r\n FoldURL : String external name 'oldURL';\r\n public\r\n property newURL : String Read FNewURL;\r\n property oldURL : String Read FOldURL;\r\n end;\r\n\r\n TJSPopStateEvent = class external name 'PopStateEvent' (TJSEvent)\r\n Private\r\n FState : JSValue; external name 'state';\r\n Public\r\n property state : JSValue read FState;\r\n end;\r\n\r\n TJSStorageEvent = class external name 'StorageEvent' (TJSEvent)\r\n private\r\n Fkey : String external name 'key';\r\n FoldValue : String external name 'oldValue';\r\n FnewValue : String external name 'newValue';\r\n Furl : String external name 'url';\r\n FstorageArea : String external name 'storageArea';\r\n public\r\n Property key : String Read FKey;\r\n Property oldValue : String Read FOldValue;\r\n Property newValue : String Read FNewValue;\r\n Property url : String Read FURL;\r\n Property storageArea : String Read FstorageArea;\r\n end;\r\n\r\n { TJSProgressEvent }\r\n\r\n TJSProgressEvent = class external name 'ProgressEvent' (TJSEvent)\r\n Private\r\n FlengthComputable : Boolean external name 'lengthComputable';\r\n Floaded : NativeUINT external name 'loaded';\r\n FTotal : NativeUINT external name 'Total';\r\n Public\r\n property lengthComputable : Boolean Read FlengthComputable;\r\n property loaded : NativeUINT Read FLoaded;\r\n property Total : NativeUINT Read FTotal;\r\n end;\r\n\r\n TJSPageTransitionEventHandler = reference to function(aEvent : TJsPageTransitionEvent) : boolean;\r\n TJSHashChangeEventhandler = reference to function(aEvent : TJSHashChangeEvent) : boolean;\r\n TJSMouseWheelEventHandler = reference to function(aEvent : TJSWheelEvent) : boolean;\r\n TJSMouseEventHandler = reference to function(aEvent : TJSMouseEvent) : boolean;\r\n THTMLAnimationEventHandler = reference to function(aEvent : TJSAnimationEvent) : boolean;\r\n TJSErrorEventHandler = reference to function(aEvent : TJSErrorEvent) : boolean;\r\n TJSFocusEventHandler = reference to function(aEvent : TJSFocusEvent) : boolean;\r\n TJSKeyEventhandler = reference to function (aEvent : TJSKeyBoardEvent) : boolean;\r\n TJSLoadEventhandler = reference to function (aEvent : TJSLoadEvent) : boolean;\r\n TJSPointerEventHandler = reference to function(aEvent : TJSPointerEvent) : boolean;\r\n TJSUIEventHandler = reference to function(aEvent : TJSUIEvent) : Boolean;\r\n TJSPopStateEventHandler = reference to function(aEvent : TJSPopStateEvent) : Boolean;\r\n TJSStorageEventHandler = reference to function(aEvent : TJSStorageEvent) : Boolean;\r\n TJSProgressEventhandler = reference to function(aEvent : TJSProgressEvent) : Boolean;\r\n TJSTouchEventHandler = reference to function(aEvent : TJSTouchEvent) : boolean;\r\n\r\n TJSDocument = class external name 'Document' (TJSNode)\r\n Private\r\n fActiveElement : TJSElement; external name 'activeElement';\r\n FCharacterSet: String; external name 'characterSet';\r\n FChildElementCount: NativeInt; external name 'childElementCount';\r\n FCompatMode: String; external name 'compatMode';\r\n FCurrentScript: TJSElement; external name 'currentScript';\r\n FDefaultView: TJSWindow; external name 'defaultView';\r\n FDocType: TJSDocumentType; external name 'docrype';\r\n FDocumentElement: TJSElement; external name 'documentElement';\r\n FDocumentURI: String; external name 'documentURI';\r\n FEmbeds: TJSHTMLCollection; external name 'embeds';\r\n FFirstElementChild : TJSElement; external name 'firstElementChild';\r\n FForms: TJSHTMLCollection; external name 'forms';\r\n FFullScreenElement: TJSElement; external name 'fullscreenElement';\r\n FFullscreenEnabled: Boolean; external name 'fullscreenEnabled';\r\n FHead: TJSElement; external name 'head';\r\n FHidden: Boolean; external name 'hidden';\r\n FImages: TJSHTMLCollection; external name 'images';\r\n FImplementation: TJSDOMImplementation; external name 'implementation';\r\n FLastElementChild : TJSElement; external name 'lastElementChild';\r\n FLastModified: String; external name 'lastModified';\r\n FLastStyleSheetSet: String; external name 'lastStyleSheetSet';\r\n FLinks: TJSHTMLCollection; external name 'links';\r\n FLocation: TJSLocation; external name 'location';\r\n FLocationString: String; external name 'location';\r\n FPlugins: TJSHTMLCollection; external name 'plugins';\r\n FPointerLockElement: TJSElement; external name 'pointerLockElement';\r\n FPreferredStyleSheetSet: String; external name 'preferredStyleSheetSet';\r\n FReadyState: String; external name 'readyState';\r\n FReferrer: String; external name 'referrer';\r\n FScripts: TJSHTMLCollection; external name 'scripts';\r\n FStyleSheets: TJSStyleSheetList; external name 'styleSheets';\r\n FStyleSheetSets: TJSValueDynArray; external name 'styleSheetSets';\r\n FURL: String; external name 'URL';\r\n FVisibilityState: string; external name 'visibilityState';\r\n Public\r\n function adoptNode(aExternalNode : TJSNode) : TJSNode;\r\n procedure close;\r\n function createAttribute(aName : string) : TJSAttr;\r\n function createCDATASection(S : String) : TJSNode;\r\n function createComment(S : String) : TJSNode;\r\n function createDocumentFragment : TJSDocumentFragment;\r\n function createElement(tagName : string) : TJSElement; overload;\r\n function createElement(tagName : string; const options : TJSElementCreationOptions) : TJSElement; overload;\r\n function createElementNS(aNameSpace,tagName : string) : TJSElement; overload;\r\n function createElementNS(aNameSpace,tagName : string; const options : TJSElementCreationOptions) : TJSElement; overload;\r\n function createEvent(aType : string) : TJSEvent;\r\n function createExpression(xPathText : String; aNameSpaceMapper: TJSNameSpaceMapperCallback) : TJSXPathExpression;\r\n function createNSResolver(aNode : TJSNode) : TJSXPathNSResolver;\r\n function createProcessingInstruction(target, data : String) : TJSProcessingInstruction;\r\n function createRange : TJSRange;\r\n function createTextNode(S : String) : TJSNode;\r\n function createTreeWalker(root : TJSNode; whatToShow : NativeInt; filter : TJSNodeFilter) : TJSTreeWalker;\r\n function elementFromPoint(x,y : integer) : TJSElement;\r\n procedure enableStyleSheetsForSet(aSet : String);\r\n function evaluate(xpathExpression : String; ContextNode : TJSNode; NameSpaceResolver : TJSNamespaceMapperCallBack; resultType : NativeInt; aResult : TJSXPathResult) : TJSXPathResult;\r\n function execCommand(aCommandName : String; aShowDefaultUI : Boolean; AValueArgument : String) : boolean; overload;\r\n function execCommand(aCommandName : String; aShowDefaultUI : Boolean) : boolean; overload;\r\n Procedure exitFullScreen;\r\n function getElementById(aID : String) : TJSElement;\r\n function getElementsyClassName(aNames : string) : TJSHTMLCollection;\r\n function getElementsByName(aName : String) : TJSNodeList;\r\n function getElementsByTagName(aName : String) : TJSHTMLCollection;\r\n function getElementsByTagNameNS(aNameSpace,aName : String) : TJSHTMLCollection;\r\n function getSelection : TJSSelection;\r\n function hasFocus : boolean;\r\n function importNode(aExternalNode : TJSNode; Deep: boolean) : TJSNode;\r\n function querySelector(aSelectors : String) : TJSElement;\r\n function querySelectorAll(aSelectors : String) : TJSNodeList;\r\n procedure open;\r\n procedure releaseCapture;\r\n procedure write(aLine : string);\r\n procedure writeln(aLine : String);\r\n Public\r\n body : TJSElement;\r\n designMode : string;\r\n dir : string;\r\n domain : string;\r\n selectedStyleSheetSet : string;\r\n title : string;\r\n onabort : TJSEventHandler;\r\n onblur : TJSEventHandler;\r\n oncancel : TJSEventHandler;\r\n oncanplay : TJSEventHandler;\r\n oncanplaythrough : TJSEventHandler;\r\n onchange : TJSEventHandler;\r\n onclick: THTMLClickEventHandler;\r\n onclose : TJSEventHandler;\r\n oncontextmenu : TJSEventHandler;\r\n oncuechange : TJSEventHandler;\r\n ondblclick : THTMLClickEventHandler;\r\n ondrag : TJSDragDropEventHandler;\r\n ondragend : TJSDragDropEventHandler;\r\n ondragenter : TJSDragDropEventHandler;\r\n ondragexit : TJSDragDropEventHandler;\r\n ondragover : TJSDragDropEventHandler;\r\n ondragleave : TJSDragDropEventHandler;\r\n ondragstart: TJSDragDropEventHandler;\r\n ondrop : TJSDragDropEventHandler;\r\n ondurationchange : TJSEventHandler;\r\n onemptied : TJSEventHandler;\r\n onended : TJSEventHandler;\r\n onerror : TJSErrorEventHandler;\r\n onfocus : TJSFocusEventhandler;\r\n ongotpointercapture : TJSPointerEventHandler;\r\n oninput : TJSEventhandler;\r\n oninvalid : TJSEventhandler;\r\n onkeydown : TJSKeyEventhandler;\r\n onkeypress : TJSKeyEventhandler;\r\n onkeyup : TJSKeyEventhandler;\r\n onload : TJSEventhandler;\r\n onloadeddata : TJSEventhandler;\r\n onloadedmetadata : TJSEventhandler;\r\n onloadend : TJSProgressEventhandler;\r\n onloadstart : TJSProgressEventhandler;\r\n onlostpointercapture : TJSPointerEventHandler;\r\n onmessage : TJSEventHandler;\r\n onmousedown : TJSMouseEventHandler;\r\n onmouseenter : TJSMouseEventHandler;\r\n onmouseleave : TJSMouseEventHandler;\r\n onmousemove : TJSMouseEventHandler;\r\n onmouseout : TJSMouseEventHandler;\r\n onmouseover : TJSMouseEventHandler;\r\n onmouseup : TJSMouseEventHandler;\r\n onmousewheel : TJSMouseEventHandler;\r\n onpause : TJSEventHandler;\r\n onplay : TJSEventHandler;\r\n onplaying : TJSEventHandler;\r\n onpointercancel : TJSPointerEventHandler;\r\n onpointerdown : TJSPointerEventHandler;\r\n onpointerenter : TJSPointerEventHandler;\r\n onpointerleave : TJSPointerEventHandler;\r\n onpointermove : TJSPointerEventHandler;\r\n onpointerout : TJSPointerEventHandler;\r\n onpointerover : TJSPointerEventHandler;\r\n onpointerup : TJSPointerEventHandler;\r\n onpointerlockchange : TJSPointerEventHandler;\r\n onprogress : TJSProgressEventhandler;\r\n onreset : TJSUIEventHandler;\r\n onratechange : TJSEventHandler;\r\n onscroll : TJSUIEventHandler;\r\n onseekend : TJSEventHandler;\r\n onseeking : TJSEventHandler;\r\n onselect : TJSEventHandler;\r\n onselectionchange : TJSEventHandler;\r\n onsshow : TJSEventHandler;\r\n onsubmit : TJSEventHandler;\r\n onunload : TJSUIEventHandler;\r\n onwaiting : TJSEventHandler;\r\n touchstart : TJSTouchEventHandler;\r\n touchend : TJSTouchEventHandler;\r\n touchmove : TJSTouchEventHandler;\r\n touchcancel : TJSTouchEventHandler;\r\n Property activeElement : TJSElement Read FActiveElement;\r\n Property characterSet : String Read FCharacterSet;\r\n property childElementCount : NativeInt Read FChildElementCount;\r\n property compatMode : String Read FCompatMode;\r\n property currentScript : TJSElement Read FCurrentScript;\r\n property defaultView : TJSWindow Read FDefaultView;\r\n property doctype : TJSDocumentType read FDocType;\r\n property documentElement : TJSElement read FDocumentElement;\r\n property documentURI : String Read FDocumentURI;\r\n property embeds : TJSHTMLCollection Read FEmbeds;\r\n property firstElementChild : TJSElement Read FFirstElementChild;\r\n property lastElementChild : TJSElement Read FLastElementChild;\r\n property Forms : TJSHTMLCollection Read FForms;\r\n property fullscreenElement : TJSElement Read FFullScreenElement;\r\n property fullscreenEnabled : Boolean Read FFullscreenEnabled;\r\n property head : TJSElement read FHead;\r\n Property hidden : Boolean read FHidden;\r\n property images : TJSHTMLCollection Read FImages;\r\n property _implementation : TJSDOMImplementation Read FImplementation;\r\n property lastModified : String Read FLastModified;\r\n property lastStyleSheetSet : String read FLastStyleSheetSet;\r\n property links : TJSHTMLCollection Read FLinks;\r\n property location : TJSLocation read FLocation;\r\n Property LocationString : String Read FURL Write FLocationString; // On purpose\r\n property plugins : TJSHTMLCollection Read FPlugins;\r\n property pointerLockElement : TJSElement Read FPointerLockElement;\r\n property preferredStyleSheetSet : String Read FPreferredStyleSheetSet;\r\n Property readyState : String Read FReadyState;\r\n Property referrer : String Read FReferrer;\r\n property scripts : TJSHTMLCollection Read FScripts;\r\n property styleSheets : TJSStyleSheetList Read FStyleSheets;\r\n property styleSheetSets : TJSValueDynArray Read FStyleSheetSets; // No type documented ?\r\n Property URL : String Read FURL;\r\n property visibilityState : string read FVisibilityState;\r\n end;\r\n\r\n TJSConsole = class external name 'Console'\r\n Public\r\n procedure assert(anAssertion : string; Obj1 : JSValue); varargs;\r\n Procedure clear; \r\n procedure count; overload;\r\n procedure count(aCounter : String);\r\n procedure error(Obj1 : JSValue); varargs;\r\n procedure group; overload;\r\n procedure group(aLabel : String); overload;\r\n procedure groupCollapsed; overload;\r\n procedure groupCollapsed(aLabel : String);overload;\r\n procedure groupEnd;\r\n procedure info(Obj1 : JSValue); varargs;\r\n procedure log(Obj1 : JSValue); varargs;\r\n procedure table(args: array of JSValue); overload;\r\n procedure table(args: array of JSValue; Columns : Array of string);\r\n procedure table(args: TJSObject); overload;\r\n procedure table(args: TJSObject; Columns : Array of string); overload;\r\n procedure time(aName : string);\r\n procedure timeEnd(aName : string);\r\n procedure trace;\r\n procedure warn(Obj1 : JSValue); varargs;\r\n end;\r\n\r\n { TJSCryptoKey }\r\n\r\n TJSCryptoKey = class external name 'CryptoKey'\r\n private\r\n FAlgorithm: JSValue; external name 'algorithm';\r\n FExtractable: Boolean; external name 'extractable';\r\n FType: string; external name 'type';\r\n FUsages: TStringDynArray; external name 'usages';\r\n Public\r\n property _type : string read FType;\r\n property extractable: Boolean read FExtractable;\r\n property algorithm : JSValue read FAlgorithm;\r\n property usages : TStringDynArray Read FUsages;\r\n end;\r\n \r\n { TJSSubtleCrypto }\r\n\r\n// TJSBufferSource = class external name 'BufferSource' end;\r\n// TJSTypedArray = class external name 'TypedArray' end;\r\n\r\n TJSSubtleCrypto = class external name 'SubtleCrypto'\r\n Public\r\n function decrypt(algorithm : JSValue; aKey : TJSCryptoKey; aData : TJSBufferSource) : TJSPromise;\r\n function deriveKey(algorithm : JSValue; aMasterKey : TJSCryptoKey; aDerivedAlgo : JSValue; extractable : Boolean; Usages : TStringDynArray) : TJSPromise;\r\n function digest(algorithm : string; Buffer : TJSArrayBuffer) : TJSPromise; overload;\r\n function digest(algorithm : string; Buffer : TJSTypedArray) : TJSPromise; overload;\r\n function encrypt(algorithm : JSValue; aKey : TJSCryptoKey; aData : TJSBufferSource) : TJSPromise;\r\n function exportKey(algorithm : String; AKey : TJSCryptoKey) : TJSPromise;\r\n function generateKey(algorithm : JSValue; extractable : Boolean; Usages : TStringDynArray) : TJSPromise;\r\n function importKey(format : String; KeyData : TJSArrayBuffer; algorithm : String; extractable : Boolean; Usages : TStringDynArray) : TJSPromise;\r\n function sign(algorithm : string; Key : TJSCryptoKey; aText : TJSArrayBuffer) : TJSPromise; overload;\r\n function unwrapKey(algorithm : string; wrappedKey : TJSArrayBuffer; Key: TJSCryptoKey;\r\n unwrapAlgo : string; unwrappedKeyAlgo : string; \r\n extractable : Boolean; Usages : TStringDynArray) : TJSPromise;\r\n function verify(algorithm : String; key : TJSCryptoKey; Signature : TJSArrayBuffer; \r\n textToVerify : TJSArrayBuffer): TJSPromise;\r\n function wrapKey(aFormat : string; Key,WrappingKey : TJSCryptoKey; WrapAlgorithm : String) : TJSPromise; \r\n end;\r\n \r\n { TJSCrypto }\r\n\r\n TJSCrypto = class external name 'Crypto'\r\n private\r\n FsubtleCrypto: TJSSubtleCrypto;\r\n Public\r\n procedure getRandomValues (anArray : TJSTypedArray);\r\n property subtleCrypto : TJSSubtleCrypto Read FsubtleCrypto;\r\n end;\r\n \r\n { TJSHistory }\r\n\r\n TJSHistory = class external name 'History'\r\n private\r\n FLength: NativeInt; external name 'length';\r\n{$IFDEF FIREFOX}\r\n FState : JSValue; external name 'state';\r\n{$ENDIF}\r\n Public\r\n procedure back;\r\n procedure forward;\r\n procedure go(aIndex : NativeInt);\r\n procedure go;\r\n procedure pushState(aState : jsValue; aTitle : String; AURL : String);\r\n procedure pushState(aState : jsValue; aTitle : String);\r\n procedure replaceState(aState : jsValue; aTitle : String; AURL : String);\r\n procedure replaceState(aState : jsValue; aTitle : String);\r\n procedure replaceState(aState : jsValue);\r\n{$IFDEF FIREFOX}\r\n property state : JSValue read FState;\r\n{$ENDIF}\r\n property length: NativeInt read FLength;\r\n end;\r\n\r\n TJSIDBTransactionMode = class\r\n const\r\n readonly = 'readonly';\r\n readwrite = 'readwrite';\r\n versionchange = 'versionchange';\r\n end;\r\n\r\n\r\n { TJSIDBTransaction }\r\n\r\n TJSIDBTransaction = class external name 'IDBTransaction' (TJSEventTarget)\r\n private\r\n FDB : TIDBDatabase; external name 'db';\r\n FError: JSValue; external name 'error';\r\n FMode: String; external name 'mode';\r\n FObjectStoreNames: TStringDynArray; external name 'objectStoreNames';\r\n public\r\n procedure abort;\r\n function objectStore(aName : String) : TJSIDBObjectStore;\r\n property db : TIDBDatabase read FDB;\r\n property mode : String read FMode;\r\n property objectStoreNames : TStringDynArray read FObjectStoreNames;\r\n property error : JSValue read FError;\r\n end;\r\n\r\n\r\n { TJSIDBKeyRange }\r\n\r\n TJSIDBKeyRange = class external name 'IDBKeyRange'\r\n private\r\n FLower: JSValue;\r\n FLowerOpen: Boolean;\r\n FUpper: JSValue;\r\n FUpperOpen: Boolean;\r\n Public\r\n Class Function bound(aLower,aUpper : JSValue) : TJSIDBKeyRange; overload;\r\n Class Function bound(aLower,aUpper : JSValue; aLowerOpen : Boolean) : TJSIDBKeyRange; overload;\r\n Class Function bound(aLower,aUpper : JSValue; aLowerOpen,aUpperOpen : Boolean) : TJSIDBKeyRange; overload;\r\n Class Function lowerBound(aLower : JSValue) : TJSIDBKeyRange; overload;\r\n Class Function lowerBound(aLower : JSValue; aOpen: Boolean) : TJSIDBKeyRange; overload;\r\n Class Function only(aValue : JSValue) : TJSIDBKeyRange;\r\n Class Function upperBound(aUpper : JSValue) : TJSIDBKeyRange; overload;\r\n Class Function upperBound(aUpper : JSValue; aOpen: Boolean) : TJSIDBKeyRange; overload;\r\n function includes (aValue : JSValue) : Boolean;\r\n property lower : JSValue read FLower;\r\n property lowerOpen : Boolean read FLowerOpen;\r\n property upper : JSValue read FUpper;\r\n property upperOpen : Boolean read FUpperOpen;\r\n end;\r\n\r\n TJSIDBIndexParameters = record\r\n unique : boolean;\r\n multiEntry : boolean;\r\n locale : string;\r\n end;\r\n\r\n\r\n { TJSIDBIndex }\r\n\r\n TJSIDBIndex = class external name 'IDBIndex'\r\n private\r\n FKeyPath: JSValue; external name 'keyPath';\r\n FMultiEntry: Boolean; external name 'multiEntry';\r\n FObjectStore: TJSIDBObjectStore; external name 'objectStore';\r\n FUnique: boolean; external name 'unique';\r\n public\r\n name : string;\r\n function count : TJSIDBRequest;\r\n function get(aKey : jsValue) : TJSIDBRequest; overload;\r\n function get(aKey : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function getAll(aKey : jsValue) : TJSIDBRequest; overload;\r\n function getAll(aKey : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function getAll(aKey : jsValue; ACount : NativeInt) : TJSIDBRequest; overload;\r\n function getAll(aKey : TJSIDBKeyRange; ACount : NativeInt) : TJSIDBRequest; overload;\r\n function getAllKeys(aKey : jsValue) : TJSIDBRequest; overload;\r\n function getAllKeys(aKey : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function getAllKeys(aKey : jsValue; ACount : NativeInt) : TJSIDBRequest; overload;\r\n function getAllKeys(aKey : TJSIDBKeyRange; ACount : NativeInt) : TJSIDBRequest; overload;\r\n function getKey(aKey : jsValue) : TJSIDBRequest;\r\n function openCursor : TJSIDBRequest; overload;\r\n function openCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function openCursor(aKeyRange : TJSIDBKeyRange; ADirection : String) : TJSIDBRequest;overload;\r\n function openKeyCursor : TJSIDBRequest;overload;\r\n function openKeyCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest;overload;\r\n function openKeyCursor(aKeyRange : TJSIDBKeyRange; ADirection : String) : TJSIDBRequest;overload;\r\n Property keyPath : JSValue Read FKeyPath;\r\n property multiEntry : Boolean read FMultiEntry;\r\n property objectStore : TJSIDBObjectStore read FObjectStore;\r\n property unique : boolean read FUnique;\r\n end;\r\n\r\n TJSIDBCursorDirection = class external name 'IDBCursorDirection'\r\n Const\r\n next = 'next';\r\n nextUnique = 'nextUnique';\r\n prev = 'prev';\r\n prevUnique = 'prevUnique';\r\n end;\r\n\r\n\r\n { TJSIDBCursor }\r\n\r\n TJSIDBCursor = class external name 'IDBCursor'\r\n private\r\n FDirection: string; external name 'direction';\r\n FKey: JSValue; external name 'key';\r\n FPrimaryKey: JSValue; external name 'primaryKey';\r\n FSource: JSValue; external name 'source';\r\n FSourceAsIndex: TJSIDBIndex; external name 'source';\r\n FSourceAsStore: TJSIDBObjectStore; external name 'source';\r\n Public\r\n procedure advance(aCount : NativeInt); overload;\r\n procedure advance(aKey : JSValue); overload;\r\n procedure continue(aKey : JSValue); overload;\r\n procedure continue; overload;\r\n procedure continuePrimaryKey(aKey : JSValue); overload;\r\n procedure continuePrimaryKey(aKey,aPrimaryKey : JSValue); overload;\r\n procedure delete;\r\n procedure update(aValue : JSValue);\r\n property source : JSValue read FSource;\r\n property sourceAsStore : TJSIDBObjectStore read FSourceAsStore;\r\n property sourceAsIndex : TJSIDBIndex read FSourceAsIndex;\r\n property key : JSValue read FKey;\r\n property primaryKey : JSValue read FPrimaryKey;\r\n property direction : string read FDirection;\r\n end;\r\n\r\n TJSIDBObjectStore = class external name 'IDBObjectStore' (TJSEventTarget)\r\n public\r\n function add(aValue : JSValue; aKey : String) : TJSIDBRequest;\r\n function add(aValue : JSValue) : TJSIDBRequest;\r\n function clear : TJSIDBRequest;\r\n function delete(aKey : string) : TJSIDBRequest;\r\n function delete(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest;\r\n function get(aKey : string) : TJSIDBRequest; overload;\r\n function get(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function getKey(aKey : string) : TJSIDBRequest; overload;\r\n function getKey(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function getAll : TJSIDBRequest; overload;\r\n function getAll(aKey : String) : TJSIDBRequest; overload;\r\n function getAll(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function getAll(aKey : String; aCount: NativeInt) : TJSIDBRequest; overload;\r\n function getAll(aKeyRange : TJSIDBKeyRange; aCount: NativeInt) : TJSIDBRequest; overload;\r\n function getAllKeys(aKey : String) : TJSIDBRequest; overload;\r\n function getAllKeys(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function getAllKeys(aKey : String; aCount: NativeInt) : TJSIDBRequest; overload;\r\n function getAllKeys(aKeyRange : TJSIDBKeyRange; aCount: NativeInt) : TJSIDBRequest; overload;\r\n function createIndex (aIndexName : String; KeyPath : String) : TJSIDBIndex; overload;\r\n function createIndex (aIndexName : String; KeyPath : String; Options : TJSIDBIndexParameters) : TJSIDBIndex; overload;\r\n function createIndex (aIndexName : String; KeyPath : Array of String) : TJSIDBIndex; overload;\r\n function createIndex (aIndexName : String; KeyPath : Array of String; Options : TJSIDBIndexParameters) : TJSIDBIndex; overload;\r\n Procedure deleteIndex (aIndexName : String);\r\n function index (aIndexName : String) : TJSIDBIndex;\r\n function put(aValue : JSValue; aKey : String) : TJSIDBRequest; overload;\r\n function put(aValue : JSValue) : TJSIDBRequest; overload;\r\n function openCursor : TJSIDBRequest; overload;\r\n function openCursor(aKey : String) : TJSIDBRequest; overload;\r\n function openCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function openCursor(aKey : String; aDirection : string) : TJSIDBRequest; overload;\r\n function openCursor(aKeyRange : TJSIDBKeyRange; aDirection : string) : TJSIDBRequest; overload;\r\n function openKeyCursor : TJSIDBRequest; overload;\r\n function openKeyCursor(aKey : String) : TJSIDBRequest; overload;\r\n function openKeyCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n function openKeyCursor(aKey : String; aDirection : string) : TJSIDBRequest; overload;\r\n function openKeyCursor(aKeyRange : TJSIDBKeyRange; aDirection : string) : TJSIDBRequest; overload;\r\n function count : TJSIDBRequest; overload;\r\n function count(aKey : String) : TJSIDBRequest; overload;\r\n function count(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;\r\n property Indexes [aIndexName : String] : TJSIDBIndex read index;\r\n end;\r\n\r\n { TJSIDBRequest }\r\n\r\n TJSIDBRequest = class external name 'IDBRequest' (TJSEventTarget)\r\n private\r\n Ferror : JSValue; external name 'error'; // standards are not quite clear on this one\r\n FReadyState: string; external name 'readyState';\r\n FResult: JSValue; external name 'result';\r\n FResultDatabase: TIDBDatabase; external name 'result';\r\n FResultIndex: TJSIDBIndex; external name 'result';\r\n FResultObjectStore : TJSIDBObjectStore; external name 'result';\r\n FResultCursor : TJSIDBCursor; external name 'result';\r\n FSourceDatabase: TIDBDatabase; external name 'source';\r\n FSourceIndex: TJSIDBIndex; external name 'source';\r\n FSourceObjectStore : TJSIDBObjectStore; external name 'source';\r\n FSourceCursor : TJSIDBCursor; external name 'source';\r\n FSource: JSValue; external name 'source';\r\n FTransaction: TJSIDBTransaction; external name 'transaction';\r\n Public\r\n onerror : TJSEventHandler;\r\n onsuccess : TJSEventHandler;\r\n Property error : JSValue read FError;\r\n property readyState : string read FReadyState;\r\n\r\n property result : JSValue read FResult;\r\n property resultAsObjectStore : TJSIDBObjectStore read FResultObjectStore;\r\n property resultAsCursor : TJSIDBCursor read FResultCursor;\r\n property resultAsIndex : TJSIDBIndex read FResultIndex;\r\n property resultAsDatabase : TIDBDatabase read FResultDatabase;\r\n\r\n property source : JSValue read FSource;\r\n property sourceAsObjectStore : TJSIDBObjectStore read FSourceObjectStore;\r\n property sourceAsCursor : TJSIDBCursor read FSourceCursor;\r\n property sourceAsIndex : TJSIDBIndex read FSourceIndex;\r\n property sourceAsDatabase : TIDBDatabase read FSourceDatabase;\r\n\r\n property transaction : TJSIDBTransaction read FTransaction;\r\n end;\r\n\r\n TJSIDBOpenDBRequest = class external name 'IDBOpenDBRequest' (TJSIDBRequest)\r\n Public\r\n onblocked : TJSEventHandler;\r\n onupgradeneeded : TJSEventHandler;\r\n end;\r\n\r\n TJSCreateObjectStoreOptions = record\r\n keyPath : jsValue;\r\n autoIncrement : boolean;\r\n end;\r\n\r\n { TIDBDatabase }\r\n\r\n TIDBDatabase = class external name 'IDBDatabase' (TJSEventTarget)\r\n private\r\n FName: string; external name 'name';\r\n FobjectStoreNames: TStringDynArray; external name 'objectStoreNames';\r\n FVersion: integer; external name 'version';\r\n public\r\n procedure close;\r\n function createObjectStore(aName : string) : TJSIDBObjectStore; overload;\r\n function createObjectStore(aName : string; Options: TJSCreateObjectStoreOptions) : TJSIDBObjectStore; overload;\r\n procedure deleteObjectStore(aName : string);\r\n function transaction(aStoreNames : array of string) : TJSIDBTransaction; overload;\r\n function transaction(aStoreNames : array of string; aMode : string) : TJSIDBTransaction; overload;\r\n property name : string read FName;\r\n property version : integer read FVersion;\r\n property objectStoreNames : TStringDynArray read FobjectStoreNames;\r\n end;\r\n\r\n TJSIDBFactory = class external name 'IDBFactory' (TJSEventTarget)\r\n public\r\n function open(aName : string) : TJSIDBOpenDBRequest;\r\n function open(aName : string; aVersion : Integer) : TJSIDBOpenDBRequest;\r\n function deleteDatabase(aName : string) : TJSIDBOpenDBRequest;\r\n function cmp (a,b : jsValue) : NativeInt;\r\n end;\r\n \r\n { TJSStorage }\r\n\r\n TJSStorage = class external name 'Storage' (TJSEventTarget)\r\n private\r\n FLength: NativeInt; external name 'length';\r\n public\r\n function key(aIndex : Integer) : String;\r\n function getItem(aKeyName : string) : string;\r\n procedure setItem(aKeyName : string; aValue : string);\r\n procedure removeItem(aKeyName : string);\r\n procedure clear;\r\n property Keys[AIndex : Integer] : String read key;\r\n property Items[aKeyName: String] : String read getItem write setItem; default;\r\n property length : NativeInt Read FLength;\r\n end;\r\n\r\n // Fake object, used for objects whose visible can be checked\r\n TJSVisibleItem = class external name 'IVisible'\r\n Private\r\n FVisible : boolean; external name 'visible';\r\n Public\r\n Property visible : boolean read FVisible;\r\n end;\r\n \r\n TJSLocationBar = class external name 'LocationBar' (TJSVisibleItem);\r\n TJSMenuBar = class external name 'MenuBar' (TJSVisibleItem);\r\n TJSToolBar = class external name 'ToolBar' (TJSVisibleItem);\r\n TJSPersonalBar = class external name 'PersonalBar' (TJSVisibleItem);\r\n TJSScrollBars = class external name 'ScrollBars' (TJSVisibleItem);\r\n\r\n TJSPositionError = record\r\n code : integer;\r\n message : string;\r\n end;\r\n\r\n TJSPositionOptions = record\r\n enableHighAccuracy : boolean;\r\n timeout : integer;\r\n maximumAge : integer;\r\n end;\r\n\r\n TJSCoordinates = record\r\n latitude : double;\r\n longitude : double;\r\n altitude : double;\r\n accuracy : double;\r\n altitudeAccuracy : double;\r\n heading : double;\r\n speed : double;\r\n end;\r\n\r\n TJSPosition = record\r\n coords : TJSCoordinates;\r\n timestamp : String;\r\n end;\r\n\r\n TJSGeoLocationCallback = procedure (aPosition : TJSPosition);\r\n TJSGeoLocationEvent = procedure (aPosition : TJSPosition) of object;\r\n TJSGeoLocationErrorCallback = procedure (aValue : TJSPositionError);\r\n TJSGeoLocationErrorEvent = procedure (aValue : TJSPositionError) of object;\r\n\r\n TJSGeoLocation = class external name 'GeoLocation'\r\n Public\r\n Procedure getCurrentPosition(ASuccess : TJSGeoLocationCallback); overload;\r\n Procedure getCurrentPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback); overload;\r\n Procedure getCurrentPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback; AOptions : TJSPositionOptions); overload;\r\n Function watchPosition(ASuccess : TJSGeoLocationCallback) : NativeInt; overload;\r\n Function watchPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback) : NativeInt; overload;\r\n Function watchPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback; AOptions : TJSPositionOptions) : NativeInt; overload;\r\n procedure clearWatch(AID : NativeInt);\r\n end;\r\n\r\n TJSMediaDevices = class external name 'MediaDevices' (TJSEventTarget)\r\n end;\r\n\r\n TJSWorker = class external name 'Worker' (TJSEventTarget)\r\n public\r\n constructor new(aURL : string);\r\n procedure postMessage(aValue : JSValue);\r\n procedure postMessage(aValue : JSValue; aList : TJSValueDynArray);\r\n procedure terminate;\r\n end;\r\n\r\n TJSMessagePort = class external name 'MessagePort' (TJSEventTarget)\r\n Public\r\n procedure close;\r\n procedure postMessage(aValue : JSValue);\r\n procedure postMessage(aValue : JSValue; aList : TJSValueDynArray);\r\n procedure start;\r\n end;\r\n\r\n { TJSSharedWorker }\r\n\r\n TJSSharedWorker = class external name 'SharedWorker' (TJSEventTarget)\r\n private\r\n FPort: TJSMessagePort; external name 'port';\r\n Public\r\n constructor new(aURL : String); overload;\r\n constructor new(aURL : String; aName : string); overload;\r\n property port : TJSMessagePort Read FPort;\r\n end;\r\n\r\n { TJSServiceWorker }\r\n\r\n TJSServiceWorker = class external name 'ServiceWorker' (TJSWorker)\r\n private\r\n FscriptURL: String; external name 'scriptURL';\r\n FState: string; external name 'state';\r\n Public\r\n property state : string read FState;\r\n property scriptURL : String Read FscriptURL;\r\n end;\r\n\r\n { TJSServiceWorkerRegistration }\r\n\r\n TJSServiceWorkerRegistration = class external name 'ServiceWorkerRegistration'\r\n private\r\n FActive: TJSServiceWorker; external name 'active';\r\n FInstalling: TJSServiceWorker; external name 'installing';\r\n FScope: string; external name 'scope';\r\n FWaiting: TJSServiceWorker; external name 'waiting';\r\n public\r\n function unregister : TJSPromise;\r\n procedure update;\r\n property active : TJSServiceWorker read FActive;\r\n property scope : string read FScope;\r\n property waiting : TJSServiceWorker read FWaiting;\r\n property installing : TJSServiceWorker read FInstalling;\r\n end;\r\n\r\n TJSServiceWorkerContainerOptions = record\r\n scope : string;\r\n end;\r\n\r\n { TJSServiceWorkerContainer }\r\n\r\n TJSServiceWorkerContainer = class external name 'ServiceWorkerContainer'\r\n private\r\n FController: TJSServiceWorker; external name 'controller';\r\n FReady: TJSPromise; external name 'ready';\r\n Public\r\n function register(aURL : String) : TJSPromise; overload;\r\n function register(aURL : String; aOptions : TJSServiceWorkerContainerOptions) : TJSPromise; overload;\r\n function getRegistration(aURL : String) : TJSPromise; overload;\r\n function getRegistration : TJSPromise; overload;\r\n function getRegistrations : TJSPromise;\r\n property controller : TJSServiceWorker read FController;\r\n property ready : TJSPromise read FReady;\r\n end;\r\n\r\n\r\n { TJSNavigator }\r\n\r\n TJSNavigator = class external name 'Navigator'\r\n{$IFDEF FIREFOX}\r\n FbuildID : String ; external name 'buildID';\r\n FOSCPU : String ; external name 'oscpu';\r\n FproductSub : string; external name 'productSub';\r\n FVendor : string; external name 'vendor';\r\n{$ENDIF}\r\n private\r\n FCookieEnabled: Boolean; external name 'cookieEnabled';\r\n FGeoLocation: TJSGeoLocation; external name 'geolocation';\r\n FLanguage: String; external name 'language';\r\n FMaxTouchPoints: NativeInt; external name 'maxTouchPoints';\r\n FMediaDevices: TJSMediaDevices; external name 'mediaDevices';\r\n FOnline: boolean; external name 'onLine';\r\n FPlatform: string; external name 'platform';\r\n FServiceWorker: TJSServiceWorkerContainer; external name 'serviceWorker';\r\n FUserAgent: string; external name 'userAgent';\r\n public\r\n function getBattery : TJSPromise;\r\n function requestMediaKeySystemAccess(aKeySystem : String; supportedConfigurations : TJSValueDynArray) : TJSPromise;\r\n Procedure registerContentHandler(aMimeType,aURI,aTitle : string);\r\n Procedure registerProtocolHandler(aProtocol,aURI,aTitle : string);\r\n Procedure vibrate(aPattern : NativeInt);\r\n Procedure vibrate(aPattern : Array of NativeInt);\r\n{$IFDEF FIREFOX}\r\n property buildID : String read FBuildID;\r\n property oscpu : string read FOSCPU;\r\n property productSub: string read FproductSub;\r\n property vendor : string read Fvendor;\r\n{$ENDIF}\r\n property cookieEnabled : Boolean read FCookieEnabled;\r\n property geoLocation : TJSGeoLocation Read FGeoLocation;\r\n property language : String read FLanguage;\r\n property maxTouchPoints : NativeInt read FMaxTouchPoints;\r\n property mediaDevices : TJSMediaDevices read FMediaDevices;\r\n property onLine : boolean read FOnline;\r\n property platform : string read FPlatform;\r\n property userAgent : string read FUserAgent;\r\n property serviceWorker : TJSServiceWorkerContainer read FServiceWorker;\r\n end;\r\n\r\n { TJSTouchEvent }\r\n TTouchCoord = longint;\r\n\r\n TJSTouch = class external name 'Touch'\r\n private\r\n FClientX: TTouchCoord; external name 'clientX';\r\n FClientY: TTouchCoord; external name 'clientY';\r\n FIDentifier: longint; external name 'identifier';\r\n FPageX: TTouchCoord; external name 'pageX';\r\n FPageY: TTouchCoord; external name 'pageY';\r\n FScreenX: TTouchCoord; external name 'screenX';\r\n FScreenY: TTouchCoord; external name 'screenY';\r\n FTarget: TJSElement; external name 'target';\r\n Public\r\n Property identifier : longint read FIDentifier;\r\n Property ScreenX : TTouchCoord Read FScreenX;\r\n Property ScreenY : TTouchCoord Read FScreenY;\r\n Property ClientX : TTouchCoord Read FClientX;\r\n Property ClientY : TTouchCoord Read FClientY;\r\n Property PageX : TTouchCoord Read FPageX;\r\n Property PageY : TTouchCoord Read FPageY;\r\n Property Target : TJSElement Read FTarget;\r\n end;\r\n\r\n { TJSTouchList }\r\n\r\n TJSTouchList = class external name 'TouchList'\r\n private\r\n FLength: NativeInt; external name 'length';\r\n Public\r\n function item (aIndex : Integer) : TJSTouch;\r\n property length : NativeInt Read FLength;\r\n Property Touches[AIndex : Integer] : TJSTouch Read item; default;\r\n end;\r\n\r\n\r\n TJSPerformance = class external name 'Performance' (TJSObject);\r\n\r\n TJSScreen = class external name 'Screen' (TJSObject);\r\n\r\n TJSURL = class external name 'URL' (TJSObject);\r\n \r\n TJSCSSStyleDeclaration = class; // forward\r\n\r\n TJSTimerCallBack = reference to procedure;\r\n\r\n { TJSMediaQueryList }\r\n\r\n TJSMediaQueryList = class external name 'MediaQueryList' (TJSObject)\r\n private\r\n FMatches: Boolean; external name 'matches';\r\n FMedia: String; external name 'media';\r\n Public\r\n Property matches : Boolean Read FMatches;\r\n Property media : String Read FMedia;\r\n end;\r\n\r\n { TJSWindow }\r\n TJSDOMHighResTimeStamp = Double;\r\n TFrameRequestCallback = procedure (aTime: TJSDOMHighResTimeStamp);\r\n\r\n TJSWindowArray = Array of TJSWindow;\r\n TJSWindow = class external name 'Window' (TJSObject)\r\n Private\r\n FClosed: boolean; external name 'closed';\r\n FConsole : TJSConsole; external name 'console';\r\n FCrypto: TJSCrypto; external name 'crypto';\r\n FDevicePixelRatio: Double; external name 'devicePixelRatio';\r\n FDocument: TJSDocument; external name 'document';\r\n FFrameElement: TJSElement; external name 'frameElement';\r\n FFrames: TJSWindowArray; external name 'frames';\r\n FHistory: TJSHistory; external name 'history';\r\n FIndexedDB: TJSIDBFactory; external name 'indexedDB';\r\n FInnerheight: NativeInt; external name 'innerHeight';\r\n FInnerWidth: NativeInt; external name 'innerWidth';\r\n FLength: NativeInt; external name 'length';\r\n FLocalStorage: TJSStorage; external name 'localStorage';\r\n FLocation: TJSLocation; external name 'location';\r\n FLocationBar: TJSLocationBar; external name 'locationbar';\r\n FLocationString: string; external name 'location';\r\n FMenuBar: TJSMenuBar; external name 'menubar';\r\n FNavigator: TJSNavigator; external name 'navigator';\r\n FOpener: TJSWindow; external name 'opener';\r\n FOuterheight: NativeInt; external name 'outerHeight';\r\n FOuterWidth: NativeInt; external name 'outerWidth';\r\n FParent: TJSWindow; external name 'parent';\r\n FPerformance: TJSPerformance; external name 'Performance';\r\n FPersonalBar: TJSPersonalBar; external name 'personalbar';\r\n FScreen: TJSScreen; external name 'screen';\r\n FScreenX: NativeInt; external name 'screenX';\r\n FScreenY: NativeInt; external name 'screenY';\r\n FScrollbar: TJSScrollBars; external name 'scrollbar';\r\n FScrollX: NativeInt; external name 'scrollX';\r\n FScrollY: NativeInt; external name 'scrollY';\r\n FSelf: TJSWindow; external name 'self';\r\n FSessionStorage: TJSStorage; external name 'sessionStorage';\r\n FToolBar: TJSToolBar; external name 'toolbar';\r\n FTop: TJSWindow; external name 'top';\r\n FURL: TJSURL; external name 'URL';\r\n Public\r\n fullSreen : Boolean; \r\n name : string;\r\n status : string;\r\n onabort : TJSEventHandler;\r\n onafterprint : TJSEventHandler;\r\n onbeforeprint : TJSEventHandler;\r\n onbeforeinstallprompt : TJSEventHandler;\r\n onbeforeunloadprompt : TJSEventHandler;\r\n onblur : TJSEventHandler;\r\n onchange : TJSEventHandler;\r\n onclick: THTMLClickEventHandler;\r\n onclose : TJSEventHandler;\r\n oncontextmenu : TJSEventHandler;\r\n ondblclick : THTMLClickEventHandler;\r\n onerror : TJSErrorEventHandler;\r\n onfocus : TJSFocusEventhandler;\r\n onhashchange : TJSHashChangeEventhandler;\r\n oninput : TJSEventhandler;\r\n onkeydown : TJSKeyEventhandler;\r\n onkeypress : TJSKeyEventhandler;\r\n onkeyup : TJSKeyEventhandler;\r\n onlanguagechange : TJSEventhandler;\r\n onload : TJSEventhandler;\r\n onloadend : TJSLoadEventhandler;\r\n onloadstart : TJSLoadEventhandler;\r\n onmessage : TJSEventHandler;\r\n onmousedown : TJSMouseEventHandler;\r\n onmouseenter : TJSMouseEventHandler;\r\n onmouseleave : TJSMouseEventHandler;\r\n onmousemove : TJSMouseEventHandler;\r\n onmouseout : TJSMouseEventHandler;\r\n onmouseover : TJSMouseEventHandler;\r\n onmouseup : TJSMouseEventHandler;\r\n onmousewheel : TJSMouseEventHandler;\r\n onoffline : TJSEventHandler;\r\n ononline : TJSEventHandler;\r\n onpagehide : TJSPageTransitionEventHandler;\r\n onpageshow : TJSPageTransitionEventHandler;\r\n onpaint : TJSEventHandler;\r\n onpointercancel : TJSPointerEventHandler;\r\n onpointerdown : TJSPointerEventHandler;\r\n onpointerenter : TJSPointerEventHandler;\r\n onpointerleave : TJSPointerEventHandler;\r\n onpointermove : TJSPointerEventHandler;\r\n onpointerout : TJSPointerEventHandler;\r\n onpointerover : TJSPointerEventHandler;\r\n onpointerup : TJSPointerEventHandler;\r\n onpointerlockchange : TJSPointerEventHandler;\r\n onprogress : TJSProgressEventhandler;\r\n onpopstate : TJSPopStateEventHandler;\r\n onreset : TJSUIEventHandler;\r\n onscroll : TJSUIEventHandler;\r\n onselect : TJSEventHandler;\r\n onselectionchange : TJSEventHandler;\r\n onstorage : TJSStorageEventHandler;\r\n onsubmit : TJSEventHandler;\r\n onunload : TJSUIEventHandler;\r\n touchstart : TJSTouchEventHandler;\r\n touchend : TJSTouchEventHandler;\r\n touchmove : TJSTouchEventHandler;\r\n touchcancel : TJSTouchEventHandler;\r\n procedure addEventListener(aname : string; aListener : TJSEventHandler);\r\n procedure addEventListener(aname : string; aListener : JSValue);\r\n Procedure alert(Const Msg : String);\r\n Function atob(Const aValue : string) : string;\r\n procedure blur;\r\n Procedure clearInterval(aID: NativeInt);\r\n Procedure clearTimeout(aID: NativeInt);\r\n Function btoa(Const aValue : string) : string;\r\n procedure cancelAnimationFrame(aHandle: Integer);\r\n Procedure close;\r\n Function confirm(Const aMsg : String) : boolean;\r\n procedure focus;\r\n Function getComputedStyle(aElement : TJSElement) : TJSCSSStyleDeclaration; overload;\r\n Function getComputedStyle(aElement,aPseudoElement : TJSElement) : TJSCSSStyleDeclaration; overload;\r\n function matchMedia(aQuery : String) : TJSMediaQueryList;\r\n procedure moveBy(x,y : NativeInt);\r\n procedure moveTo(x,y : NativeInt);\r\n function open : TJSWindow;\r\n function open(Const aURL : String) : TJSWindow; overload;\r\n function open(Const aURL,aTarget : String) : TJSWindow; overload;\r\n function open(Const aURL,aTarget : String; AOptions : TJSObject) : TJSWindow; overload;\r\n procedure print;\r\n function prompt(const aMessage : String) : String; overload;\r\n function prompt(const aMessage,aDefault : String) : String; overload;\r\n procedure removeEventListener(aname : string; aListener : TJSEventHandler);\r\n procedure removeEventListener(aname : string; aListener : JSValue);\r\n function requestAnimationFrame(aCallback: TFrameRequestCallback): Integer;\r\n procedure resizeBy(aWidth,aHeight : NativeInt);\r\n procedure resizeTo(aWidth,aHeight : NativeInt);\r\n procedure scrollBy(x,y : NativeInt);\r\n procedure scrollTo(x,y : NativeInt);\r\n Function setInterval(ahandler : TJSTimerCallBack; aInterval : NativeUInt) : NativeInt; varargs;\r\n Function setTimeout(ahandler : TJSTimerCallBack; aTimeout : NativeUInt) : NativeInt; varargs;\r\n Function setTimeout(ahandler : TJSTimerCallBack) : NativeInt;\r\n procedure stop;\r\n { public methods }\r\n property console : TJSConsole Read FConsole;\r\n property closed : boolean read FClosed;\r\n property crypto : TJSCrypto Read FCrypto;\r\n property devicePixelRatio : Double read FDevicePixelRatio;\r\n property document : TJSDocument read FDocument;\r\n property frameElement : TJSElement Read FFrameElement;\r\n Property frames : TJSWindowArray read FFrames;\r\n Property history : TJSHistory read FHistory;\r\n Property indexedDB : TJSIDBFactory read FIndexedDB;\r\n Property innerHeight : NativeInt Read FInnerheight;\r\n Property innerWidth : NativeInt Read FInnerWidth;\r\n Property length : NativeInt Read FLength;\r\n Property localStorage : TJSStorage Read FLocalStorage; \r\n property location : TJSLocation Read FLocation;\r\n Property locationString : String read FLocationString write FLocationString;\r\n property locationbar : TJSLocationBar Read FLocationBar;\r\n property menubar : TJSMenuBar Read FMenuBar;\r\n property navigator : TJSNavigator Read FNavigator;\r\n property opener : TJSWindow read FOpener;\r\n Property outerHeight : NativeInt Read FOuterheight;\r\n Property outerWidth : NativeInt Read FOuterWidth;\r\n Property parent : TJSWindow Read FParent;\r\n Property Performance : TJSPerformance Read FPerformance;\r\n property personalbar : TJSPersonalBar Read FPersonalBar;\r\n property screen : TJSScreen read FScreen;\r\n property screenX : NativeInt read FScreenX;\r\n Property screenY : NativeInt read FScreenY;\r\n Property scrollbar : TJSScrollBars Read FScrollbar;\r\n property scrollX : NativeInt read FScrollX;\r\n Property scrollY : NativeInt read FScrollY;\r\n Property _Self : TJSWindow read FSelf;\r\n Property sessionStorage : TJSStorage Read FSessionStorage; \r\n property toolbar : TJSToolBar Read FToolBar;\r\n property top : TJSWindow Read FTop;\r\n property URL : TJSURL Read FURL; \r\n end;\r\n\r\n { TJSCSSStyleDeclaration }\r\n\r\n TJSCSSStyleDeclaration = class external name 'CSSStyleDeclaration'\r\n private\r\n FLength: NativeInt; external name 'length';\r\n FParentRule: TJSCSSRule; external name 'parentRule';\r\n public\r\n cssText : string;\r\n function item(aIndex : Integer) : string;\r\n function removeProperty(const aProperty : String) : string;\r\n function getPropertyPriority(const aProperty : String) : string;\r\n function getPropertyValue(const aProperty : String) : string;\r\n procedure setProperty(const aProperty,aValue : String);overload;\r\n procedure setProperty(const aProperty,aValue,aPriority : string); overload;\r\n property length : NativeInt read FLength;\r\n property parentRule : TJSCSSRule read FParentRule;\r\n end;\r\n\r\n\r\n\r\n\r\n\r\n { TJSHTMLElement }\r\n TJSHTMLElement = class external name 'HTMLELement' (TJSElement)\r\n private\r\n FDataset: TJSObject ; external name 'dataset';\r\n FIsContentEditable: Boolean ; external name 'isContentEditable';\r\n FOffsetHeight: Double; external name 'offsetHeight';\r\n FOffsetLeft: Double; external name 'offsetLeft';\r\n FOffsetParent: TJSElement; external name 'offsetParent';\r\n FOffsetTop: Double; external name 'offsetTop';\r\n FOffsetWidth: Double; external name 'offsetWidth';\r\n Public\r\n accessKey : string;\r\n contentEditable : string;\r\n dir : string;\r\n draggable : boolean;\r\n hidden : boolean;\r\n lang : string;\r\n spellcheck : boolean;\r\n style : TJSCSSStyleDeclaration;\r\n tabIndex : Integer;\r\n title: string;\r\n onabort : TJSEventHandler;\r\n onanimationcancel: THTMLAnimationEventHandler;\r\n onanimationend: THTMLAnimationEventHandler;\r\n onblur : TJSEventHandler;\r\n oncancel : TJSEventHandler;\r\n oncanplay : TJSEventHandler;\r\n oncanplaythrough : TJSEventHandler;\r\n onchange : TJSEventHandler;\r\n onclick: THTMLClickEventHandler;\r\n onclose : TJSEventHandler;\r\n oncontextmenu : TJSEventHandler;\r\n ondblclick : THTMLClickEventHandler;\r\n ondrag : TJSDragDropEventHandler;\r\n ondragend : TJSDragDropEventHandler;\r\n ondragenter : TJSDragDropEventHandler;\r\n ondragexit : TJSDragDropEventHandler;\r\n ondragover : TJSDragDropEventHandler;\r\n ondragleave : TJSDragDropEventHandler;\r\n ondragstart: TJSDragDropEventHandler;\r\n ondrop : TJSDragDropEventHandler;\r\n onerror : TJSErrorEventHandler;\r\n onfocus : TJSFocusEventhandler;\r\n ondurationchange : TJSEventHandler;\r\n onemptied : TJSEventHandler;\r\n onended : TJSEventHandler;\r\n ongotpointercapture : TJSPointerEventHandler;\r\n oninput : TJSEventhandler;\r\n oninvalid : TJSEventhandler;\r\n onkeydown : TJSKeyEventhandler;\r\n onkeypress : TJSKeyEventhandler;\r\n onkeyup : TJSKeyEventhandler;\r\n onload : TJSEventhandler;\r\n onloadeddata : TJSEventhandler;\r\n onloadedmetadata : TJSEventhandler;\r\n onloadend : TJSLoadEventhandler;\r\n onloadstart : TJSLoadEventhandler;\r\n onlostpointercapture : TJSPointerEventHandler;\r\n onmousedown : TJSMouseEventHandler;\r\n onmouseenter : TJSMouseEventHandler;\r\n onmouseleave : TJSMouseEventHandler;\r\n onmousemove : TJSMouseEventHandler;\r\n onmouseout : TJSMouseEventHandler;\r\n onmouseover : TJSMouseEventHandler;\r\n onmouseup : TJSMouseEventHandler;\r\n onmousewheel : TJSMouseEventHandler;\r\n onpause : TJSPointerEventHandler;\r\n onplay : TJSPointerEventHandler;\r\n onplaying : TJSPointerEventHandler;\r\n onpointercancel : TJSPointerEventHandler;\r\n onpointerdown : TJSPointerEventHandler;\r\n onpointerenter : TJSPointerEventHandler;\r\n onpointerleave : TJSPointerEventHandler;\r\n onpointermove : TJSPointerEventHandler;\r\n onpointerout : TJSPointerEventHandler;\r\n onpointerover : TJSPointerEventHandler;\r\n onpointerup : TJSPointerEventHandler;\r\n onpointerlockchange : TJSPointerEventHandler;\r\n onprogress : TJSProgressEventhandler;\r\n onseeked : TJSEventHandler;\r\n onseeking : TJSEventHandler;\r\n onreset : TJSUIEventHandler;\r\n onscroll : TJSUIEventHandler;\r\n onselect : TJSEventHandler;\r\n onselectstart : TJSEventHandler;\r\n onselectionchange : TJSEventHandler;\r\n onshow : TJSEventHandler;\r\n onstalled : TJSEventHandler;\r\n ontimeupdate : TJSEventHandler;\r\n ontransitioncancel : TJSEventHandler;\r\n ontransitionend : TJSEventHandler;\r\n onvolumechange : TJSEventHandler;\r\n onsubmit : TJSEventHandler;\r\n onwheel : TJSMouseWheelEventHandler;\r\n onwaiting : TJSEventHandler;\r\n touchstart : TJSTouchEventHandler;\r\n touchend : TJSTouchEventHandler;\r\n touchmove : TJSTouchEventHandler;\r\n touchcancel : TJSTouchEventHandler;\r\n Procedure blur;\r\n Procedure focus;\r\n Procedure click;\r\n property dataset : TJSObject read FDataset;\r\n property isContentEditable : Boolean read FIsContentEditable;\r\n property offsetHeight : Double Read FOffsetHeight;\r\n property offsetLeft : Double Read FOffsetLeft;\r\n property offsetTop : Double Read FOffsetTop;\r\n property offsetWidth : Double Read FOffsetWidth;\r\n property offsetParent : TJSElement Read FOffsetParent;\r\n end;\r\n\r\n TJSHTMLFormControlsCollection = class external name 'HTMLFormControlsCollection' (TJSHTMLCollection)\r\n Public\r\n function namedItem(S : String) : TJSElement; reintroduce; external name 'namedItem';\r\n property Items[S : String] : TJSElement read namedItem; default;\r\n end;\r\n\r\n { TJSHTMLFormElement }\r\n\r\n TJSHTMLFormElement = class external name 'HTMLFormElement' (TJSHTMLElement)\r\n private\r\n FElements: TJSHTMLFormControlsCollection; external name 'elements';\r\n FLength: NativeInt; external name 'length';\r\n Public\r\n method : string;\r\n target : string;\r\n action : string;\r\n encoding : string;\r\n enctype : string;\r\n acceptCharset : string;\r\n autocomplete : string;\r\n noValidate : boolean;\r\n property elements : TJSHTMLFormControlsCollection read FElements;\r\n Property length : NativeInt Read FLength;\r\n end;\r\n\r\n { TJSValidityState }\r\n\r\n TJSValidityState = class external name 'ValidityState'\r\n private\r\n FBadInput: Boolean; external name 'badInput';\r\n FCustomError: Boolean; external name 'customError';\r\n FPatternMismatch: Boolean; external name 'patternMisMatch';\r\n FRangeOverflow: Boolean; external name 'rangeOverflow';\r\n FRangeUnderflow: Boolean; external name 'rangeUnderflow';\r\n FStepMismatch: Boolean; external name 'stepMismatch';\r\n FTooLong: Boolean; external name 'tooLong';\r\n FTooShort: Boolean; external name 'tooShort';\r\n FTypeMismatch: Boolean; external name 'typeMisMatch';\r\n FValid: Boolean; external name 'valid';\r\n FValueMissing: Boolean; external name 'valueMissing';\r\n public\r\n property badInput : Boolean read FBadInput;\r\n property customError : Boolean read FCustomError;\r\n property patternMisMatch : Boolean read FPatternMismatch;\r\n property rangeOverflow : Boolean read FRangeOverflow;\r\n property rangeUnderflow : Boolean read FRangeUnderflow;\r\n property stepMismatch : Boolean read FStepMismatch;\r\n property tooLong : Boolean read FTooLong;\r\n property tooShort : Boolean read FTooShort;\r\n property typeMisMatch : Boolean read FTypeMismatch;\r\n property valid : Boolean Read FValid;\r\n property valueMissing : Boolean read FValueMissing;\r\n end;\r\n\r\n { TJSBlob }\r\n\r\n TJSBlob = class external name 'Blob' (TJSEventTarget)\r\n private\r\n FSize: NativeInt; external name 'size';\r\n FType: string; external name 'type';\r\n Public\r\n procedure close;\r\n function slice : TJSBlob; overload;\r\n function slice(aStart : NativeInt) : TJSBlob; overload;\r\n function slice(aStart,aEnd : NativeInt) : TJSBlob; overload;\r\n function slice(aStart,aEnd : NativeInt; AContentType : String) : TJSBlob; overload;\r\n property size : NativeInt read FSize;\r\n property _type : string read FType;\r\n end;\r\n\r\n\r\n { TJSHTMLFile }\r\n\r\n TJSHTMLFile = class external name 'File' (TJSBlob)\r\n private\r\n FLastModified: NativeInt; external name 'lastModified';\r\n FLastModifiedDate: TJSDate; external name 'lastModifiedDate';\r\n FName: string; external name 'name';\r\n Public\r\n property name : string read FName;\r\n property lastModified : NativeInt read FLastModified;\r\n property lastModifiedDate : TJSDate read FLastModifiedDate;\r\n end;\r\n\r\n { TJSHTMLFileList }\r\n\r\n TJSHTMLFileList = class external name 'FileList' (TJSEventTarget)\r\n private\r\n FLength: NativeInt; external name 'length';\r\n Public\r\n function item(aIndex : NativeInt) : TJSHTMLFile;\r\n property length : NativeInt read FLength;\r\n property Files[aIndex : NativeInt] : TJSHTMLFile Read item; default;\r\n end;\r\n\r\n { TJSHTMLInputElement }\r\n // https://html.spec.whatwg.org/multipage/forms.html#the-input-element\r\n\r\n TJSHTMLInputElement = class external name 'HTMLInputElement' (TJSHTMLElement)\r\n private\r\n FFiles: TJSHTMLFileList; external name 'files';\r\n FForm: TJSHTMLFormElement; external name 'form';\r\n FLabels: TJSNodeList; external name 'labels';\r\n FList: TJSHTMLElement; external name 'list';\r\n FValidationmMessage: string; external name 'validationMessage';\r\n FValidity: TJSValidityState; external name 'validity';\r\n FWillValidate: boolean; external name 'willValidate';\r\n Public\r\n procedure select;\r\n procedure setCustomValidity(aText : string);\r\n procedure stepUp; overload;\r\n procedure stepUp(n : Integer); overload;\r\n function checkValidity : Boolean;\r\n function reportValidity : Boolean;\r\n procedure setSelectionRange(selectionStart, selectionEnd: NativeInt) ; overload;\r\n procedure setSelectionRange(selectionStart, selectionEnd: NativeInt; Direction : string) ; overload;\r\n procedure setRangeText(aText : string; selectionStart, selectionEnd: NativeInt) ; overload;\r\n procedure setRangeText(aText : string; selectionStart, selectionEnd: NativeInt; Direction : string) ; overload;\r\n Public\r\n accept : string;\r\n allowDirs : boolean;\r\n align : string;\r\n alt : string;\r\n autofocus : boolean;\r\n autocapitalize : string;\r\n autocomplete : string;\r\n defaultValue : string;\r\n defaultChecked : string;\r\n checked : boolean;\r\n dirName : string;\r\n disabled : boolean;\r\n formAction : string;\r\n formEncType : string;\r\n formMethod : string;\r\n formNoValidate : Boolean;\r\n formTarget : string;\r\n height : Boolean;\r\n indeterminate : boolean;\r\n inputMode : string;\r\n max : string;\r\n maxLength : NativeInt;\r\n min : string;\r\n minLength : NativeInt;\r\n multiple : boolean;\r\n pattern : string;\r\n placeholder : string;\r\n readOnly : boolean;\r\n required : boolean;\r\n size : NativeInt;\r\n src : string;\r\n step : string;\r\n _type : string; external name 'type';\r\n selectionStart : NativeInt;\r\n selectionEnd : NativeInt;\r\n selectionDirection : string;\r\n useMap : string;\r\n value : string;\r\n width : NativeInt;\r\n property files : TJSHTMLFileList Read FFiles;\r\n property form : TJSHTMLFormElement read FForm;\r\n property labels : TJSNodeList read FLabels;\r\n property list : TJSHTMLElement Read FList;\r\n property validationMessage : string read FValidationmMessage;\r\n property willValidate : boolean read FWillValidate;\r\n property validity : TJSValidityState read FValidity;\r\n end;\r\n\r\n { TJSHTMLOptionElement }\r\n\r\n TJSHTMLOptionElement = class external name 'Option' (TJSHTMLElement)\r\n private\r\n FForm: TJSHTMLFormElement; external name 'form';\r\n FIndex: NativeInt; external name 'index';\r\n Public\r\n Constructor New; overload;\r\n Constructor New(aText : String); overload;\r\n Constructor New(aText,aValue : String); overload;\r\n Constructor New(aText,aValue : String; aDefaultSelected : Boolean); overload;\r\n Constructor New(aText,aValue : String; aDefaultSelected,Selected : Boolean); overload;\r\n Public\r\n defaultSelected : boolean;\r\n disabled : boolean;\r\n _label : string ; external name 'label';\r\n selected : boolean;\r\n text : string;\r\n value : string;\r\n property index : NativeInt Read FIndex;\r\n property form : TJSHTMLFormElement Read FForm;\r\n end;\r\n\r\n TJSHTMLOptGroupElement = class external name 'HTMLOptGroupElement' (TJSHTMLElement)\r\n end;\r\n\r\n TJSHTMLOptionsCollection = class external name 'HTMLOptionsCollection' (TJSHTMLCollection)\r\n end;\r\n\r\n { TJSHTMLSelectElement }\r\n\r\n TJSHTMLSelectElement = Class external name 'HTMLSelectElement' (TJSHTMLElement)\r\n private\r\n FForm: TJSHTMLFormElement; external name 'form';\r\n FLabels: TJSNodeList; external name 'labels';\r\n FLength: NativeInt; external name 'length';\r\n FOptions: TJSHTMLOptionsCollection; external name 'options';\r\n FSelectedOptions: TJSHTMLCollection; external name 'selectedOptions';\r\n FType: String; external name 'type';\r\n FValidationMessage: string; external name 'validationMessage';\r\n FValidity: TJSValidityState; external name 'validity';\r\n fwillValidate: Boolean; external name 'willValidate';\r\n Public\r\n Procedure add(anItem : TJSHTMLOptionElement); overload;\r\n Procedure add(anItem, before : TJSHTMLOptionElement); overload;\r\n function item(aIndex : NativeInt): TJSHTMLOptionElement;\r\n function namedItem(aName : String): TJSHTMLOptionElement;\r\n procedure remove(aIndex : NativeInt);\r\n procedure checkValidity;\r\n procedure setCustomValidity(aMessage : String);\r\n Public\r\n multiple : boolean;\r\n required: boolean;\r\n selectedIndex : NativeInt;\r\n size : NativeInt;\r\n value : string;\r\n property length : NativeInt read FLength;\r\n Property options : TJSHTMLOptionsCollection read FOptions;\r\n Property selectedOptions : TJSHTMLCollection read FSelectedOptions;\r\n Property form : TJSHTMLFormElement read FForm;\r\n property labels : TJSNodeList Read FLabels;\r\n property _type : String Read FType;\r\n property validity : TJSValidityState Read FValidity;\r\n property validationMessage : string Read FValidationMessage;\r\n property willValidate : Boolean read fwillValidate;\r\n end;\r\n\r\n { TJSHTMLTableElement }\r\n\r\n TJSHTMLTableSectionElement = class;\r\n TJSHTMLTableRowElement = class;\r\n\r\n TJSHTMLTableElement = Class external name 'HTMLTableElement'(TJSHTMLElement)\r\n private\r\n FAlign: String; external name 'align';\r\n FBGColor: String; external name 'bgColor';\r\n FBorder: String; external name 'border';\r\n FCaption: TJSHTMLElement; external name 'caption';\r\n FCellPadding: String; external name 'cellPadding';\r\n FCellSpacing: String; external name 'cellSpacing';\r\n FFrame: String; external name 'frame';\r\n FRows: TJSHTMLCollection; external name 'rows';\r\n FRules: String; external name 'rules';\r\n FSummary: String; external name 'summary';\r\n FTBodies: TJSHTMLCollection; external name 'tBodies';\r\n FTfoot: TJSHTMLTableSectionElement; external name 'tfoot';\r\n FTHead: TJSHTMLTableSectionElement; external name 'tHead';\r\n FWidth: String; external name 'width';\r\n public\r\n { Methods }\r\n function createCaption: TJSHTMLElement;\r\n function createTFoot: TJSHTMLTableSectionElement;\r\n function createTHead: TJSHTMLTableSectionElement;\r\n procedure deleteCaption;\r\n procedure deleteRow(index: Integer);\r\n procedure deleteTFoot;\r\n procedure deleteTHead;\r\n function insertRow(index: Integer): TJSHTMLTableRowElement;\r\n { Properties }\r\n property align: String read FAlign write FAlign;\r\n property bgColor: String read FBGColor write FBGColor;\r\n property border: String read FBorder write FBorder;\r\n property caption: TJSHTMLElement read FCaption;\r\n property cellPadding: String read FCellPadding write FCellPadding;\r\n property cellSpacing: String read FCellSpacing write FCellSpacing;\r\n property frame: String read FFrame write FFrame;\r\n property rows: TJSHTMLCollection read FRows;\r\n property rules: String read FRules write FRules;\r\n property summary: String read FSummary write FSummary;\r\n property tBodies: TJSHTMLCollection read FTBodies;\r\n property tfoot: TJSHTMLTableSectionElement read FTfoot;\r\n property tHead: TJSHTMLTableSectionElement read FTHead;\r\n property width: String read FWidth write FWidth;\r\n end;\r\n\r\n { TJSHTMLTableSectionElement }\r\n\r\n TJSHTMLTableSectionElement = Class external name 'HTMLTableSectionElement' (TJSHTMLElement)\r\n private\r\n Falign: String; external name 'align';\r\n Frows: TJSHTMLCollection external name 'rows';\r\n Fch: String; external name 'ch';\r\n FchOff: String; external name 'chOff';\r\n FvAlign: String; external name 'vAlign';\r\n public\r\n { Methods }\r\n procedure deleteRow(index: Integer);\r\n function insertRow(index: Integer): TJSHTMLTableRowElement;\r\n { Properties }\r\n property align: String read Falign write Falign;\r\n property rows: TJSHTMLCollection read Frows;\r\n property ch: String read Fch write Fch;\r\n property chOff: String read FchOff write FchOff;\r\n property vAlign: String read FvAlign write FvAlign;\r\n end;\r\n\r\n { TJSHTMLTableCellElement }\r\n\r\n TJSHTMLTableCellElement = Class external name 'HTMLTableCellElement' (TJSHTMLElement)\r\n private\r\n Fabbr: String; external name 'abbr';\r\n Falign: String; external name 'align';\r\n Faxis: String; external name 'axis';\r\n FbgColor: String; external name 'bgColor';\r\n FcellIndex: Integer; external name 'cellIndex';\r\n Fch: String; external name 'ch';\r\n FchOff: String; external name 'chOff';\r\n FcolSpan: Integer; external name 'colSpan';\r\n Fheaders: String; external name 'headers';\r\n Fheight: String; external name 'height';\r\n FnoWrap: Boolean; external name 'noWrap';\r\n FrowSpan: Integer; external name 'rowSpan';\r\n Fscope: String; external name 'scope';\r\n FvAlign: String; external name 'vAlign';\r\n Fwidth: String; external name 'width';\r\n public\r\n { Properties }\r\n property abbr: String read Fabbr write Fabbr;\r\n property align: String read Falign write Falign;\r\n property axis: String read Faxis write Faxis;\r\n property bgColor: String read FbgColor write FbgColor;\r\n property cellIndex: Integer read FcellIndex;\r\n property ch: String read Fch write Fch;\r\n property chOff: String read FchOff write FchOff;\r\n property colSpan: Integer read FcolSpan write FcolSpan;\r\n property headers: String read Fheaders write Fheaders;\r\n property height: String read Fheight write Fheight;\r\n property noWrap: Boolean read FnoWrap write FnoWrap;\r\n property rowSpan: Integer read FrowSpan write FrowSpan;\r\n property scope: String read Fscope write Fscope;\r\n property vAlign: String read FvAlign write FvAlign;\r\n property width: String read Fwidth write Fwidth;\r\n end;\r\n\r\n { TJSHTMLTableRowElement }\r\n\r\n TJSHTMLTableRowElement = Class external name 'HTMLTableRowElement' (TJSHTMLElement)\r\n private\r\n Falign: String; external name 'align';\r\n FbgColor: String; external name 'bgColor';\r\n Fcells: TJSHTMLCollection; external name 'cells';\r\n Fch: String; external name 'ch';\r\n FchOff: String; external name 'chOff';\r\n FrowIndex: Integer; external name 'rowIndex';\r\n FsectionRowIndex: Integer; external name 'sectionRowIndex';\r\n FvAlign: String; external name 'vAlign';\r\n public\r\n { Methods }\r\n procedure deleteCell(index: Integer);\r\n function insertCell(index: Integer): TJSHTMLTableCellElement;\r\n { Properties }\r\n property align: String read Falign write Falign;\r\n property bgColor: String read FbgColor write FbgColor;\r\n property cells: TJSHTMLCollection read Fcells;\r\n property ch: String read Fch write Fch;\r\n property chOff: String read FchOff write FchOff;\r\n property rowIndex: Integer read FrowIndex;\r\n property sectionRowIndex: Integer read FsectionRowIndex;\r\n property vAlign: String read FvAlign write FvAlign;\r\n end;\r\n\r\n { TJSHTMLTableDataCellElement }\r\n\r\n TJSHTMLTableDataCellElement = Class external name 'HTMLTableDataCellElement' (TJSHTMLElement)\r\n private\r\n Fabbr: String; external name 'abbr';\r\n public\r\n { Properties }\r\n property abbr: String read Fabbr write Fabbr;\r\n end;\r\n\r\n\r\n TJSCanvasRenderingContext2D = Class;\r\n\r\n THTMLCanvasToBlobCallback = Reference to function (aBlob : TJSBlob) : boolean;\r\n\r\n TJSHTMLCanvasElement = Class external name 'HTMLCanvasElement' (TJSHTMLElement)\r\n Public\r\n height : integer;\r\n width : integer;\r\n Function getContext(contextType : string) : TJSObject;\r\n Function getContext(contextType : string; contextAttributes : TJSObject) : TJSObject;\r\n Function getContextAs2DContext(contextType : string; contextAttributes : TJSObject) : TJSCanvasRenderingContext2D; external name 'getContext';\r\n Function getContextAs2DContext(contextType : string) : TJSCanvasRenderingContext2D; external name 'getContext';\r\n Procedure toBlob (aCallBack : THTMLCanvasToBlobCallback; aMimeType : String); overload;\r\n Procedure toBlob (aCallBack : THTMLCanvasToBlobCallback; aMimeType : String; aQuality : Double); overload;\r\n Function toDataURL : String; overload;\r\n Function toDataURL(aMimeType : String) : String; overload;\r\n Function toDataURL(aMimeType : String; aQuality : Double) : String; overload;\r\n end;\r\n\r\n // Opaque objects\r\n TJSCanvasGradient = class external name 'CanvasGradient'\r\n end;\r\n\r\n TJSCanvasPattern = class external name 'CanvasPattern'\r\n end;\r\n\r\n TJSPath2D = class external name 'Path2D'\r\n end;\r\n\r\n { TJSImageData }\r\n\r\n TJSImageData = class external name 'ImageData'\r\n private\r\n FData: TJSUint8ClampedArray; external name 'data';\r\n FHeight: Integer; external name 'height';\r\n FWidth: Integer; external name 'width';\r\n Public\r\n constructor new(awidth,aheight : integer); overload;\r\n constructor new(anArray :TJSUint8ClampedArray; awidth,aheight : integer); overload;\r\n property data : TJSUint8ClampedArray read FData;\r\n property height : Integer Read FHeight;\r\n property width : Integer Read FWidth;\r\n end;\r\n\r\n TCanvasCoordType = double; // Is in fact a number.\r\n\r\n TJSTextMetrics = record\r\n width : TCanvasCoordType;\r\n actualBoundingBoxLeft : TCanvasCoordType;\r\n actualBoundingBoxRight : TCanvasCoordType;\r\n fontBoundingBoxAscent : TCanvasCoordType;\r\n fontBoundingBoxDescent : TCanvasCoordType;\r\n actualBoundingBoxAscent : TCanvasCoordType;\r\n actualBoundingBoxDescent : TCanvasCoordType;\r\n emHeightAscent : TCanvasCoordType;\r\n emHeightDescent : TCanvasCoordType;\r\n hangingBaseline : TCanvasCoordType;\r\n alphabeticBaseline : TCanvasCoordType;\r\n ideographicBaseline : TCanvasCoordType;\r\n end;\r\n\r\n { TJSCanvasRenderingContext2D }\r\n TJSCanvasRenderingContext2D = class external name 'CanvasRenderingContext2D'\r\n private\r\n FCanvas: TJSHTMLCanvasElement; external name 'canvas';\r\n FfillStyleColor: String; external name 'fillStyle';\r\n FfillStyleGradient: TJSCanvasGradient; external name 'fillStyle';\r\n FfillStylePattern: TJSCanvasPattern; external name 'fillStyle';\r\n FstrokeStyleColor: String; external name 'strokeStyle';\r\n FstrokeStyleGradient: TJSCanvasGradient; external name 'strokeStyle';\r\n FstrokeStylePattern: TJSCanvasPattern; external name 'strokeStyle';\r\n Public\r\n fillStyle : JSValue;\r\n font : string;\r\n globalAlpha : double;\r\n globalCompositeOperation : String;\r\n lineCap : string;\r\n lineDashOffset : Double;\r\n lineJoin : String;\r\n lineWidth : Double;\r\n miterLimit : Double;\r\n shadowBlur : Double;\r\n shadowColor : String;\r\n shadowOffsetX : Double;\r\n shadowOffsetY : Double;\r\n strokeStyle : JSValue;\r\n textAlign : String;\r\n textBaseline : String;\r\n procedure arc(x,y, radius,startAngle,endAngle : TCanvasCoordType); overload;\r\n procedure arc(x,y, radius,startAngle,endAngle : TCanvasCoordType; antiClockWise : boolean); overload;\r\n procedure arcTo(x1,y1,x2,y2,radius : TCanvasCoordType); overload;\r\n procedure beginPath;\r\n procedure bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y : TCanvasCoordType); overload;\r\n procedure clearRect(x,y,width,height : TCanvasCoordType);\r\n procedure clip; overload;\r\n procedure clip(aFillRule : String); overload;\r\n procedure clip(aPath : TJSPath2D); overload;\r\n procedure closePath;\r\n function createImageData(aWidth,aHeight : Integer) : TJSImageData; overload;\r\n function createImageData(aImage : TJSImageData) : TJSImageData; overload;\r\n function createLinearGradient(x0,y0,x1,y1 : TCanvasCoordType) : TJSCanvasGradient;\r\n function createPattern(aImage : TJSObject; repetition : string) : TJSCanvasPattern;\r\n function createRadialGradient(x0,y0,r0,x1,y1,r1 : TCanvasCoordType) : TJSCanvasGradient;\r\n procedure drawFocusIfNeeded(aElement : TJSElement); overload;\r\n procedure drawFocusIfNeeded(aPath : TJSPath2D; aElement : TJSElement); overload;\r\n procedure drawImage(image : TJSObject; dx,dy : TCanvasCoordType); overload;\r\n procedure drawImage(image : TJSObject; dx,dy,dwidth,dheight : TCanvasCoordType); overload;\r\n procedure drawImage(image : TJSObject; sx,sy,sWidth,sHeight,dx,dy,dwidth,dheight : TCanvasCoordType); overload;\r\n procedure fill; overload;\r\n procedure fill(aRule : String); overload;\r\n procedure fill(aPath : TJSPath2D); overload;\r\n procedure fill(aPath : TJSPath2D;aRule : String); overload;\r\n procedure fillRect(x,y,awidth,aheight: TCanvasCoordType); overload;\r\n procedure fillText(aText : string; x,y : TCanvasCoordType); overload;\r\n procedure fillText(aText : string; x,y, aMaxWidth : TCanvasCoordType); overload;\r\n function getImageData(x,y,awidth,aheight: TCanvasCoordType) : TJSImageData; overload;\r\n function getLineDash : TJSArray;\r\n function isPointInPath(x,y : TCanvasCoordType) : Boolean; overload;\r\n function isPointInPath(x,y : TCanvasCoordType; aFillRule : String) : Boolean; overload;\r\n function isPointInPath(aPath : TJSPath2D; x,y : TCanvasCoordType) : Boolean; overload;\r\n function isPointInPath(aPath : TJSPath2D; x,y : TCanvasCoordType; aFillRule : String) : Boolean; overload;\r\n function isPointInStroke(x,y : TCanvasCoordType) : Boolean; overload;\r\n function isPointInStroke(aPath : TJSPath2D; x,y : TCanvasCoordType) : Boolean; overload;\r\n procedure lineTo(x,y : TCanvasCoordType);\r\n function measureText(S : String) : TJSTextMetrics;\r\n procedure moveTo(x,y : TCanvasCoordType);\r\n procedure putImageData(aData : TJSImageData; x,y: TCanvasCoordType) ; overload;\r\n procedure putImageData(aData : TJSImageData; x,y,dityX,dirtyY,dirtyWidth,dirtyHeight: TCanvasCoordType) ; overload;\r\n procedure quadraticCurveTo(cpx,cpy,x,y : TCanvasCoordType);\r\n procedure rect(x,y,awidth,aheight: TCanvasCoordType); overload;\r\n procedure restore;\r\n procedure rotate(anAngle : double);\r\n procedure save;\r\n procedure scale(x,y : double);\r\n procedure setLineDash(segments : TJSArray); overload;\r\n procedure setLineDash(segments : array of integer); overload;\r\n procedure setTransform(a,b,c,d,e,f : double);\r\n procedure stroke; overload;\r\n procedure stroke(aPath : TJSPath2D); overload;\r\n procedure strokeRect(x,y,awidth,aheight: TCanvasCoordType);\r\n procedure strokeText(aText : string; x,y : TCanvasCoordType); overload;\r\n procedure strokeText(aText : string; x,y, aMaxWidth : TCanvasCoordType); overload;\r\n procedure transform(a,b,c,d,e,f : double);\r\n procedure translate(x,y : TCanvasCoordType);\r\n\r\n property canvas : TJSHTMLCanvasElement Read FCanvas;\r\n property fillStyleAsColor : String Read FfillStyleColor Write FfillStyleColor;\r\n property fillStyleAsGradient : TJSCanvasGradient Read FfillStyleGradient Write FfillStyleGradient;\r\n property fillStyleAsPattern : TJSCanvasPattern Read FfillStylePattern Write FfillStylePattern;\r\n property strokeStyleAsColor : String Read FstrokeStyleColor Write FstrokeStyleColor;\r\n property strokeStyleAsGradient : TJSCanvasGradient Read FstrokeStyleGradient Write FstrokeStyleGradient;\r\n property strokeStyleAsPattern : TJSCanvasPattern Read FstrokeStylePattern Write FstrokeStylePattern;\r\n end;\r\n\r\n { TJSHTMLIFrameElement }\r\n\r\n TJSHTMLIFrameElement = Class external name 'HTMLIFrameElement' (TJSHTMLElement)\r\n private\r\n FAllowPaymentRequest: Boolean; external name 'allowPaymentRequest';\r\n FContentDocument: TJSDocument; external name 'contentDocument';\r\n FContentWindow: TJSWindow; external name 'contentWindow';\r\n FSandbox: string; external name 'sandbox';\r\n Public\r\n height : string;\r\n src : string;\r\n srcdoc : string;\r\n width : string;\r\n Property allowPaymentRequest : Boolean Read FAllowPaymentRequest;\r\n property contentWindow : TJSWindow Read FContentWindow;\r\n property contentDocument : TJSDocument Read FContentDocument;\r\n property sandbox : string read FSandbox;\r\n end;\r\n\r\n TJSHTMLScriptElement = Class external name 'HTMLScriptElement' (TJSHTMLElement)\r\n Public\r\n type_ : String;\r\n src : String;\r\n charset : string;\r\n async : boolean;\r\n defer : boolean;\r\n text : string;\r\n noModule : boolean;\r\n end;\r\n\r\n\r\n\r\n TJSXMLHttpRequestEventTarget = class external name 'XMLHttpRequestEventTarget' (TJSEventTarget)\r\n end;\r\n\r\n TJSXMLHttpRequestUpload = class external name 'XMLHttpRequestUpload' (TJSXMLHttpRequestEventTarget)\r\n end;\r\n\r\n { TJSXMLHttpRequest }\r\n TJSOnReadyStateChangeHandler = reference to procedure;\r\n\r\n TJSXMLHttpRequest = class external name 'XMLHttpRequest' (TJSXMLHttpRequestEventTarget)\r\n private\r\n FReadyState: NativeInt; external name 'readyState';\r\n FResponse: JSValue; external name 'response';\r\n FResponseText: string; external name 'responseText';\r\n FResponseType: string; external name 'responseType';\r\n FresponseURL: string; external name 'responseURL';\r\n FresponseXML: TJSDocument; external name 'responseXML';\r\n FUpload: TJSXMLHttpRequestUpload; external name 'upload';\r\n FStatus : integer; external name 'status';\r\n FStatusText : string; external name 'statusText';\r\n public\r\n const\r\n UNSENT = 0;\r\n OPENED = 1;\r\n HEADERS_RECEIVED = 3;\r\n LOADING = 3;\r\n DONE = 4;\r\n public\r\n timeout : LongWord;\r\n withCredentials : Boolean;\r\n onreadystatechange : TJSOnReadyStateChangeHandler;\r\n constructor new;\r\n procedure abort;\r\n function getResponseHeader(aName : string) : String;\r\n function getAllResponseHeaders : String;\r\n procedure open(aMethod,aURL : String); overload;\r\n procedure open(aMethod,aURL : String; Async : Boolean); overload;\r\n procedure open(aMethod,aURL : String; Async : Boolean; AUserame : String); overload;\r\n procedure open(aMethod,aURL : String; Async : Boolean; AUserame,APassword : String); overload;\r\n procedure overrideMimeType(aType : String);\r\n procedure send(aBody : jsValue);overload;\r\n procedure send;overload;\r\n procedure setRequestHeader(aName, AValue : string);\r\n\r\n property readyState : NativeInt read FReadyState;\r\n property ResponseHeaders[aName : string] : string Read getResponseHeader;\r\n property responseXML : TJSDocument read FresponseXML;\r\n property responseURL : string read FresponseURL;\r\n property responseType : string read FResponseType;\r\n property response : JSValue Read FResponse;\r\n property responseText : string read FResponseText;\r\n property Status : integer read FStatus;\r\n property StatusText : string read FStatusText;\r\n property upload : TJSXMLHttpRequestUpload read FUpload;\r\n\r\n end;\r\n\r\n { TJSUIEvent }\r\n\r\n TJSUIEvent = class external name 'UIEvent' (TJSEvent)\r\n private\r\n FDetail: NativeInt; external name 'detail';\r\n FView: TJSWindow; external name 'view';\r\n Public\r\n property detail : NativeInt read FDetail;\r\n property view : TJSWindow read FView;\r\n end;\r\n\r\n { TJSMouseEvent }\r\n\r\n TJSAbstractView = class external name 'AbstractView'\r\n end;\r\n\r\n TJSMouseEvent = class external name 'MouseEvent' (TJSUIevent)\r\n private\r\n FAltKey: Boolean; external name 'altKey';\r\n FBUtton: NativeInt; external name 'button';\r\n FBUttons: NativeInt; external name 'buttons';\r\n FClientX: Double; external name 'clientX';\r\n FClientY: Double; external name 'clientY';\r\n FCtrlKey: Boolean; external name 'ctrlKey';\r\n FMetaKey: Boolean; external name 'metaKey';\r\n FmovementX: Double; external name 'movementX';\r\n FmovementY: Double; external name 'movementY';\r\n FoffsetX: Double; external name 'offsetX';\r\n FoffsetY: Double; external name 'offsetY';\r\n FRegion: String; external name 'region';\r\n FRelatedTarget: TJSEventTarget; external name 'relatedTarget';\r\n FscreenX: Double; external name 'screenX';\r\n FscreenY: Double; external name 'screenY';\r\n FShiftKey: Boolean; external name 'shiftKey';\r\n Public\r\n Property altKey : Boolean read FAltKey;\r\n Property button: NativeInt read FBUtton;\r\n Property buttons: NativeInt read FBUttons;\r\n property clientX : Double read FClientX;\r\n property clientY : Double read FClientY;\r\n property ctrlKey : Boolean read FCtrlKey;\r\n property metaKey : Boolean read FMetaKey;\r\n property movementX : Double read FmovementX;\r\n property movementY : Double read FmovementY;\r\n property offsetX : Double read FoffsetX;\r\n property offsetY : Double read FoffsetY;\r\n{$IFDEF FIREFOX}\r\n property pageX : Double read FpageX;\r\n property pageY : Double read FpageY;\r\n{$ENDIF}\r\n property region : String read FRegion;\r\n property relatedTarget : TJSEventTarget read FRelatedTarget;\r\n property screenX : Double read FscreenX;\r\n property screenY : Double read FscreenY;\r\n property shiftKey : Boolean read FShiftKey;\r\n property x : Double read FClientX;\r\n property y : Double read FClientY;\r\n { public methods }\r\n function getModifierState(keyArg: String): boolean;\r\n procedure initMouseEvent(const typeArg: string; bubblesArg, cancelableArg: boolean;\r\n viewArg: TJSAbstractView; detailArg, screenXArg, screenYArg, clientXArg,\r\n clientYArg: Integer; ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg: boolean;\r\n buttonArg: Integer; relatedTargetArg: TJSEventTarget); overload;\r\n procedure initMouseEvent(const typeArg: string; bubblesArg, cancelableArg: boolean;\r\n viewArg: TJSWindow; detailArg, screenXArg, screenYArg, clientXArg,\r\n clientYArg: Integer; ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg: boolean;\r\n buttonArg: Integer; relatedTargetArg: TJSEventTarget); overload;\r\n end;\r\n\r\n { TJSWheelEvent }\r\n TJSWheelEventInit = record\r\n deltaX : Double;\r\n deltaY : Double;\r\n deltaZ : Double;\r\n deltaMode : NativeInt;\r\n end;\r\n\r\n TJSWheelEvent = class external name 'WheelEvent' (TJSMouseEvent)\r\n private\r\n FDeltaMode: NativeInt; external name 'deltaMode';\r\n FDeltaX: Double; external name 'deltaX';\r\n FDeltaY: Double; external name 'deltaY';\r\n FDeltaZ: Double; external name 'deltaZ';\r\n Public\r\n constructor new(atype : String); overload;\r\n constructor new(atype : String; aInit : TJSWheelEventInit); overload;\r\n Property deltaX : Double Read FDeltaX;\r\n Property deltaY : Double Read FDeltaY;\r\n Property deltaZ : Double Read FDeltaZ;\r\n Property deltaMode : NativeInt Read FDeltaMode;\r\n end;\r\n\r\n TJSPointerEvent = Class external name 'PointerEvent' (TJSMouseEvent);\r\n\r\n TJSTouchEvent = Class external name 'TouchEvent'(TJSUIEvent)\r\n private\r\n FAltKey: Boolean; external name 'altKey';\r\n FChangedTouches: TJSTouchList; external name 'changedTouches';\r\n FCtrlKey: Boolean; external name 'ctrlKey';\r\n FMetaKey: Boolean; external name 'metaKey';\r\n FShiftKey: Boolean; external name 'shiftKey';\r\n FTargetTouches: TJSTouchList; external name 'targetTouches';\r\n FTouches: TJSTouchList; external name 'touches';\r\n Public\r\n Property altKey : Boolean Read FAltKey;\r\n Property ctrlKey : Boolean Read FCtrlKey;\r\n Property metaKey : Boolean Read FMetaKey;\r\n Property shiftKey : Boolean Read FShiftKey;\r\n property changedTouches : TJSTouchList Read FChangedTouches;\r\n property touches : TJSTouchList Read FTouches;\r\n property targetTouches : TJSTouchList Read FTargetTouches;\r\n end;\r\n\r\n\r\n // Namespace for standard key names.\r\n // See list at https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values\r\n TJSKeyNames = Class\r\n Const\r\n Alt = 'Alt';\r\n AltGraph = 'AltGraph';\r\n CapsLock = 'CapsLock';\r\n Control = 'Control';\r\n Fn = 'Fn';\r\n FnLock = 'FnLock';\r\n Hyper = 'Hyper';\r\n Meta = 'Meta';\r\n NumLock = 'NumLock';\r\n ScrollLock = 'ScrollLock';\r\n Shift = 'Shift';\r\n Super = 'Super';\r\n Symbol = 'Symbol';\r\n SymbolLock = 'SymbolLock';\r\n Enter = 'Enter';\r\n Tab = 'Tab';\r\n Space = ' ';\r\n ArrowDown = 'ArrowDown';\r\n ArrowLeft = 'ArrowLeft';\r\n ArrowRight = 'ArrowRight';\r\n ArrowUp = 'ArrowUp';\r\n _End = 'End';\r\n Home = 'Home';\r\n PageDown = 'PageDown';\r\n PageUp = 'PageUp';\r\n BackSpace = 'Backspace';\r\n Clear = 'Clear';\r\n Copy = 'Copy';\r\n CrSel = 'CrSel';\r\n Cut = 'Cut';\r\n Delete = 'Delete';\r\n EraseEof = 'EraseEof';\r\n ExSel = 'ExSel';\r\n Insert = 'Insert';\r\n Paste = 'Paste';\r\n Redo = 'Redo';\r\n Undo = 'Undo';\r\n Accept = 'Accept';\r\n Again = 'Again';\r\n Attn = 'Attn';\r\n Cancel = 'Cancel';\r\n ContextMenu = 'Contextmenu';\r\n Escape = 'Escape';\r\n Execute = 'Execute';\r\n Find = 'Find';\r\n Finish = 'Finish';\r\n Help = 'Help';\r\n Pause = 'Pause';\r\n Play = 'Play';\r\n Props = 'Props';\r\n Select = 'Select';\r\n ZoomIn = 'ZoomIn';\r\n ZoomOut = 'ZoomOut';\r\n BrightnessDown = 'BrightnessDown';\r\n BrightnessUp = 'BrightnessUp';\r\n Eject = 'Eject';\r\n LogOff = 'LogOff';\r\n Power = 'Power';\r\n PowerOff = 'PowerOff';\r\n PrintScreen = 'PrintScreen';\r\n Hibernate = 'Hibernate';\r\n Standby = 'Standby';\r\n WakeUp = 'WakeUp';\r\n AllCandidates = 'AllCandidates';\r\n Alphanumeric = 'Alphanumeric';\r\n CodeInput = 'CodeInput';\r\n Compose = 'Compose';\r\n Convert = 'Convert';\r\n Dead = 'Dead';\r\n FinalMode = 'FinalMode';\r\n GroupFirst = 'GroupFirst';\r\n GroupLast = 'GroupLast';\r\n GroupNext = 'GroupNext';\r\n GroupPrevious = 'GroupPrevious';\r\n ModelChange = 'ModelChange';\r\n NextCandidate = 'NextCandidate';\r\n NonConvert = 'NonConvert';\r\n PreviousCandidate = 'PreviousCandidate';\r\n Process = 'Process';\r\n SingleCandidate = 'SingleCandidate';\r\n HangulMode = 'HangulMode';\r\n HanjaMode = 'HanjaMode';\r\n JunjaMode = 'JunjaMode';\r\n Eisu = 'Eisu';\r\n Hankaku = 'Hankaku';\r\n Hiranga = 'Hiranga';\r\n HirangaKatakana = 'HirangaKatakana';\r\n KanaMode = 'KanaMode';\r\n Katakana = 'Katakana';\r\n Romaji = 'Romaji';\r\n Zenkaku = 'Zenkaku';\r\n ZenkakuHanaku = 'ZenkakuHanaku';\r\n F1 = 'F1';\r\n F2 = 'F2';\r\n F3 = 'F3';\r\n F4 = 'F4';\r\n F5 = 'F5';\r\n F6 = 'F6';\r\n F7 = 'F7';\r\n F8 = 'F8';\r\n F9 = 'F9';\r\n F10 = 'F10';\r\n F11 = 'F11';\r\n F12 = 'F12';\r\n F13 = 'F13';\r\n F14 = 'F14';\r\n F15 = 'F15';\r\n F16 = 'F16';\r\n F17 = 'F17';\r\n F18 = 'F18';\r\n F19 = 'F19';\r\n F20 = 'F20';\r\n Soft1 = 'Soft1';\r\n Soft2 = 'Soft2';\r\n Soft3 = 'Soft3';\r\n Soft4 = 'Soft4';\r\n Decimal = 'Decimal';\r\n Key11 = 'Key11';\r\n Key12 = 'Key12';\r\n Multiply = 'Multiply';\r\n Add = 'Add';\r\n NumClear = 'Clear';\r\n Divide = 'Divide';\r\n Subtract = 'Subtract';\r\n Separator = 'Separator';\r\n AppSwitch = 'AppSwitch';\r\n Call = 'Call';\r\n Camera = 'Camera';\r\n CameraFocus = 'CameraFocus';\r\n EndCall = 'EndCall';\r\n GoBack = 'GoBack';\r\n GoHome = 'GoHome';\r\n HeadsetHook = 'HeadsetHook';\r\n LastNumberRedial = 'LastNumberRedial';\r\n Notification = 'Notification';\r\n MannerMode = 'MannerMode';\r\n VoiceDial = 'VoiceDial';\r\n // TODO : Multimedia keys\r\n // TODO : Audio control keys\r\n // TODO : TV control keys\r\n // TODO : Media controller keys\r\n // TODO : Speech recognition keys\r\n // TODO : Document keys\r\n // TODO : Application selector keys\r\n // TODO : Browser Control keys\r\n end;\r\n\r\n\r\n { TJSKeyboardEvent }\r\n\r\n TJSKeyboardEvent = class external name 'KeyboardEvent' (TJSUIEvent)\r\n private\r\n FAltKey: Boolean; external name 'altKey';\r\n FCode: string; external name 'code';\r\n FCtrlKey: Boolean; external name 'ctrlKey';\r\n FIsComposing: Boolean; external name 'isComposing';\r\n FKey: String; external name 'key';\r\n FLocale: string; external name 'locale';\r\n FLocation: NativeInt; external name 'location';\r\n FMetaKey: Boolean; external name 'metaKey';\r\n FRepeat: Boolean; external name 'repeat';\r\n FShiftKey: Boolean; external name 'shiftKey';\r\n Public\r\n function getModifierState(aKey : string) : Boolean;\r\n property code : string read FCode;\r\n Property altKey : Boolean read FAltKey;\r\n property ctrlKey : Boolean read FCtrlKey;\r\n property isComposing : Boolean read FIsComposing;\r\n property Key : String read FKey;\r\n property locale : string read FLocale;\r\n property location : NativeInt read FLocation;\r\n property metaKey : Boolean read FMetaKey;\r\n property _repeat : Boolean read FRepeat;\r\n property shiftKey : Boolean read FShiftKey;\r\n end;\r\n\r\n\r\nvar\r\n document : TJSDocument; external name 'document';\r\n window : TJSWindow; external name 'window';\r\n console : TJSConsole; external name 'window.console';\r\n \r\nimplementation\r\n \r\nend.\r\n","unit uMutationObserver;\r\n\r\n{$mode objfpc}{$H+}\r\n{$MODESWITCH externalclass}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web;\r\n\r\n\r\nfunction beginMethod: JSValue; external name 'function(){//';\r\nfunction endMethod: JSValue; external name '}//';\r\n\r\ntype\r\n TJSMutationRecord = class;\r\n TJSMutationObserver = class;\r\n TJSMutationObserverInit = class;\r\n TStringDynArray = array of String;\r\n TJSMutationCallback = procedure(mutations: array of TJSMutationRecord;\r\n observer: TJSMutationObserver);\r\n TJSSubscribeCallback = procedure(mutationRecordsList: array of TJSMutationRecord) of object;\r\n\r\ntype\r\n\r\nTJSMutationEvent = class external name 'MutationEvent' (TJSEvent)\r\nprivate\r\n FrelatedNode: TJSNode; external name 'relatedNode';\r\n FprevValue: String; external name 'prevValue';\r\n FnewValue: String; external name 'newValue';\r\n FattrName: String; external name 'attrName';\r\n FattrChange: Integer; external name 'attrChange';\r\npublic\r\n { public methods }\r\n procedure initMutationEvent(&type: String; canBubble: Boolean; cancelable: Boolean;\r\n relatedNode: TJSNode; prevValue: String; newValue: String; attrName: String;\r\n attrChange: Integer);\r\n { public properties }\r\n property relatedNode: TJSNode read FrelatedNode;\r\n property prevValue: String read FprevValue;\r\n property newValue: String read FnewValue;\r\n property attrName: String read FattrName;\r\n property attrChange: Integer read FattrChange;\r\nend;\r\n\r\n(* ==========================================================================\r\n Constructor for instantiating new DOM mutation observers.\r\n More info here: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver\r\n Objects list: https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord\r\n ========================================================================== *)\r\n\r\nTJSMutationRecord = class external name 'MutationRecord'\r\nprivate\r\n Ftype: String; external name 'type';\r\n Ftarget: TJSNode; external name 'target';\r\n FaddedNodes: TJSNodeList; external name 'addedNodes';\r\n FremovedNodes: TJSNodeList; external name 'removedNodes';\r\n FpreviousSibling: TJSNode; external name 'previousSibling';\r\n FnextSibling: TJSNode; external name 'nextSibling';\r\n FattributeName: String; external name 'attributeName';\r\n FattributeNamespace: String; external name 'attributeNamespace';\r\n FoldValue: String; external name 'oldValue';\r\npublic\r\n { public properties }\r\n property &type: String read Ftype;\r\n property target: TJSNode read Ftarget;\r\n property addedNodes: TJSNodeList read FaddedNodes;\r\n property removedNodes: TJSNodeList read FremovedNodes;\r\n property previousSibling: TJSNode read FpreviousSibling;\r\n property nextSibling: TJSNode read FnextSibling;\r\n property attributeName: String read FattributeName;\r\n property attributeNamespace: String read FattributeNamespace;\r\n property oldValue: String read FoldValue;\r\nend;\r\n\r\ntype\r\n TJSMutationRecordArray = array of TJSMutationRecord;\r\n\r\nTJSMutationObserver = class external name 'MutationObserver'\r\npublic\r\n { public methods }\r\n constructor new(mutationCallback: TJSMutationCallback); overload;\r\n constructor new(mutationCallback: TJSSubscribeCallback); overload;\r\n\r\n procedure observe(target: TJSNode); overload;\r\n procedure observe(target: TJSNode; options: TJSMutationObserverInit); overload;\r\n procedure observe(target: TJSNode; options: TJSObject); overload;\r\n procedure disconnect;\r\n function takeRecords: TJSMutationRecordArray;\r\nend;\r\n\r\n\r\nTJSMutationObserverInit = class external name 'MutationObserverInit'(TJSObject)\r\nprivate\r\n FchildList: Boolean; external name 'childList';\r\n Fattributes: Boolean; external name 'attributes';\r\n FcharacterData: Boolean; external name 'characterData';\r\n Fsubtree: Boolean; external name 'subtree';\r\n FattributeOldValue: Boolean; external name 'attributeOldValue';\r\n FcharacterDataOldValue: Boolean; external name 'characterDataOldValue';\r\n FattributeFilter: TStringDynArray; external name 'attributeFilter';\r\npublic\r\n { public properties }\r\n constructor new;\r\n property childList: Boolean read FchildList;\r\n property attributes: Boolean read Fattributes;\r\n property characterData: Boolean read FcharacterData;\r\n property subtree: Boolean read Fsubtree;\r\n property attributeOldValue: Boolean read FattributeOldValue;\r\n property characterDataOldValue: Boolean read FcharacterDataOldValue;\r\n property attributeFilter: TStringDynArray read FattributeFilter;\r\nend;\r\n\r\nimplementation\r\n\r\nend.\r\n\r\n","unit jElement;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, types, JS, Web, uMutationObserver;\r\n\r\ntype\r\n TMouseClickEv = procedure(sender:TObject);\r\n TMouseClickEvent = procedure(sender:TObject) of object;\r\n TResizeEvent = procedure(sender:TObject) of object;\r\n TReadyExecuteEvent = procedure(sender:TObject) of object;\r\n\r\ntype\r\n TW3CustomControl = class // the visual designer expects a TW3CustomControl\r\n // including references to event-handling\r\n private\r\n //FOnClick: TMouseClickEv;\r\n //FOnResize: TResizeEvent;\r\n published\r\n //property OnClick: TMouseClickEv read FOnClick write FOnClick;\r\n //property ReSize: TResizeEvent read FOnResize write FOnResize;\r\n public\r\n name: string;\r\nend;\r\n\r\n\r\ntype\r\n\r\n { TElement }\r\n //TElement = class //therefore TElement derives from the\r\n TElement = class(TW3CustomControl) //fake TW3CustomControl above.\r\n private\r\n procedure SetLeft(aLeft: integer);\r\n function GetLeft: Integer;\r\n procedure SetTop(aTop: integer);\r\n function GetTop: Integer;\r\n procedure SetWidth(aWidth: integer);\r\n function GetWidth: Integer;\r\n procedure SetHeight(aHeight: integer);\r\n function GetHeight: Integer;\r\n\r\n FOnClick: TMouseClickEvent;\r\n FOnResize: TResizeEvent;\r\n FOnReadyExecute: TReadyExecuteEvent;\r\n procedure _setMouseClick(const aValue: TMouseClickEvent);\r\n procedure _setOnResize(const aValue: TResizeEvent);\r\n procedure _setOnReadyExecute(const aValue: TReadyExecuteEvent);\r\n public\r\n FElement: TJSHTMLElement;\r\n Handle: JSValue;\r\n constructor Create(element: String; parent: TElement);\r\n destructor Destroy; override;\r\n\r\n Procedure SetProperty(S1: String; S2: String);\r\n Procedure SetAttribute(S1: String; S2: String);\r\n\r\n Procedure SetBounds(aleft, atop, awidth, aheight: integer);\r\n Procedure SetinnerHTML(S1: String);\r\n Function GetinnerHTML : String;\r\n\r\n property Left: Integer read getLeft write setLeft;\r\n property Top: Integer read getTop write setTop;\r\n property Width: Integer read getWidth write setWidth;\r\n property Height: Integer read getHeight write setHeight;\r\n\r\n property OnClick: TMouseClickEvent read FOnClick write _setMouseClick;\r\n procedure CBClick(eventObj: TJSEvent); virtual;\r\n\r\n property OnReSize: TResizeEvent read FOnResize write _setOnResize;\r\n procedure CBResize(eventObj: TJSEvent); virtual;\r\n\r\n property OnReadyExecute: TReadyExecuteEvent read FOnReadyExecute write _setOnReadyExecute;\r\n procedure CBReadyExecute(eventObj: TJSEvent); virtual;\r\n\r\n procedure Observe;\r\n procedure Clear;\r\n //procedure ReadyExecute(const OnReady: TProcedure); //not needed when using observe.\r\n procedure touch2Mouse(e: TJSEvent);\r\n tag: string;\r\nend;\r\n\r\nvar\r\n ScreenWidth : Integer;\r\n\r\nimplementation\r\n\r\nvar\r\n vUniqueNumber: Integer;\r\n\r\nfunction w3_getUniqueObjId: String;\r\nbegin\r\n Inc(vUniqueNumber);\r\n Result := 'OBJ' + IntToStr(vUniqueNumber);\r\nend;\r\n\r\nfunction w3_getUniqueNumber: Integer;\r\nbegin\r\n Inc(vUniqueNumber);\r\n Result := vUniqueNumber;\r\nend;\r\n\r\nfunction StrEndsWith(s: String; e: JSValue): JSValue;\r\nbegin\r\n asm\r\n { return s.substr(s.length-e.length)==e }\r\n end;\r\nend;\r\n\r\n{ TElement }\r\n\r\nconstructor TElement.Create(element: String; parent: TElement);\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\n //s1: TJSStyleSheetList;\r\n //style1: TJSElement;\r\nbegin\r\n // cache element\r\n FElement := TJSHTMLElement(document.createElement(element));\r\n FElement.className := element;\r\n FElement.id := w3_getUniqueObjId;\r\n\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n FElementStyle.setProperty('visibility','visible');\r\n FElementStyle.setProperty('display','inline-block');\r\n FElementStyle.setProperty('position','absolute');\r\n FElementStyle.setProperty('overflow','auto');\r\n\r\n If parent = nil then\r\n Handle := document.body.appendChild(FElement) else\r\n Handle := parent.FElement.appendChild(FElement);\r\n\r\n SetBounds(0,0,0,0);\r\n\r\n FElement.addEventListener('click', @CBClick);\r\n window.addEventListener('resize', @CBResize);\r\n FElement.addEventListener('readyexecute', @CBReadyExecute);\r\n Observe;\r\n\r\n (*s1 := document.styleSheets;\r\n if s1.length = 0 then begin\r\n style1 := document.createElement('STYLE');\r\n document.head.appendChild(style1);\r\n end;*)\r\n\r\nend;\r\n\r\ndestructor TElement.Destroy;\r\nbegin\r\n FElement.parentNode.removeChild(FElement);\r\n inherited Destroy;\r\nend;\r\n\r\nprocedure TElement.SetProperty(S1: String; S2: String);\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n FElementStyle.setProperty(S1, S2);\r\nend;\r\n\r\nprocedure TElement.SetAttribute(S1: String; S2: String);\r\nbegin\r\n FElement.setAttribute(S1, S2);\r\nend;\r\n\r\nprocedure TElement.SetBounds(aleft, atop, awidth, aheight: integer);\r\nbegin\r\n left := aleft;\r\n top := atop;\r\n width := awidth;\r\n height := aheight;\r\nend;\r\n\r\nprocedure TElement.SetinnerHTML(S1: String);\r\nbegin\r\n FElement.innerHTML := S1;\r\nend;\r\n\r\nfunction TElement.GetinnerHTML: String;\r\nbegin\r\n Result := FElement.innerHTML;\r\nend;\r\n\r\nprocedure TElement._setMouseClick(const aValue: TMouseClickEvent);\r\nbegin\r\n FOnClick := aValue;\r\nend;\r\n\r\nprocedure TElement.CBClick(eventObj: TJSEvent);\r\nbegin\r\n eventObj.stopPropagation;\r\n if Assigned(FOnClick) then\r\n FOnClick(Self);\r\nend;\r\n\r\nprocedure TElement._setOnResize(const aValue: TResizeEvent);\r\nbegin\r\n FOnResize := aValue;\r\nend;\r\n\r\nprocedure TElement._setOnReadyExecute(const aValue: TReadyExecuteEvent);\r\nbegin\r\n FOnReadyExecute := aValue;\r\nend;\r\n\r\nprocedure TElement.CBResize(eventObj: TJSEvent);\r\nbegin\r\n if Assigned(FOnResize) then\r\n FOnResize(Self);\r\nend;\r\n\r\nprocedure TElement.CBReadyExecute(eventObj: TJSEvent);\r\nbegin\r\n // eventObj.stopPropagation;\r\n if Assigned(FOnReadyExecute) then\r\n FOnReadyExecute(Self);\r\nend;\r\n\r\nprocedure TElement.SetLeft(aLeft: integer);\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n FElementStyle.setProperty('left',inttostr(aLeft)+'px');\r\nend;\r\n\r\nfunction TElement.GetLeft: Integer;\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\n S: String;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n\r\n S := FElementStyle.getPropertyValue('left');\r\n if StrEndsWith(S,'px') then\r\n SetLength(S, TJSString(S).Length-2);\r\n// alternatively : if Pos('px',S) > 0 then SetLength(S, TJSString(S).Length-2);\r\n Result := StrToInt(S);\r\nend;\r\n\r\nprocedure TElement.SetTop(aTop: integer);\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n FElementStyle.setProperty('top',inttostr(aTop)+'px');\r\nend;\r\n\r\nfunction TElement.GetTop: Integer;\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\n S: String;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n\r\n S:= FElementStyle.getPropertyValue('top');\r\n if StrEndsWith(S,'px') then\r\n SetLength(S, TJSString(S).Length-2);\r\n\r\n Result := StrToInt(S);\r\nend;\r\n\r\nprocedure TElement.SetWidth(aWidth: integer);\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n if aWidth = screenwidth then\r\n FElementStyle.setProperty('width','calc(100%)') else\r\n FElementStyle.setProperty('width',inttostr(aWidth)+'px');\r\nend;\r\n\r\nfunction TElement.GetWidth: Integer;\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\n S: String;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n\r\n S:= FElementStyle.getPropertyValue('width');\r\n if StrEndsWith(S,'px') then\r\n SetLength(S, TJSString(S).Length-2);\r\n Result := StrToInt(S);\r\nend;\r\n\r\nprocedure TElement.SetHeight(aHeight: integer);\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n FElementStyle.setProperty('height',inttostr(aHeight)+'px');\r\nend;\r\n\r\nfunction TElement.GetHeight: Integer;\r\nvar\r\n FElementStyle: TJSCSSStyleDeclaration;\r\n S: String;\r\nbegin\r\n FElementStyle := TJSHTMLElement(FElement).style;\r\n\r\n S:= FElementStyle.getPropertyValue('height');\r\n if StrEndsWith(S,'px') then\r\n SetLength(S, TJSString(S).Length-2);\r\n Result := StrToInt(S);\r\nend;\r\n\r\nprocedure TElement.Clear;\r\nbegin\r\n While assigned(FElement.firstChild) do\r\n FElement.removeChild(FElement.firstChild);\r\nend;\r\n\r\n(*procedure TElement.Observe;\r\nbegin\r\n var MyObserver := TMutationObserver.Create;\r\n var v: variant := new JObject;\r\n v.attributes := true;\r\n v.attributeOldValue := true;\r\n// v.childList := true;\r\n\r\n MyObserver.FHandle.observe(handle, v);\r\nend;*)\r\n\r\ntype\r\n TProcedureRef = procedure(data: array of TJSMutationRecord) of object;\r\n\r\ntype\r\n TMutationObserver = class\r\n protected\r\n Constructor Create; virtual;\r\n procedure CBMutationChange(mutationRecordsList: array of TJSMutationRecord); virtual;\r\n public\r\n FHandle: JSValue;\r\nend;\r\n\r\n//#############################################################################\r\n// TMutationObserver\r\n//#############################################################################\r\n\r\nConstructor TMutationObserver.Create;\r\nvar\r\n mRef: TProcedureRef;\r\n mhandle: TJSMutationObserver; //array of TJSMutationRecord;\r\n\r\n procedure subscribe(mutationRecordsList: array of TJSMutationRecord);\r\n begin\r\n mRef(mutationRecordsList);\r\n end;\r\n\r\nbegin\r\n inherited Create;\r\n\r\n mRef:=@CBMutationChange;\r\n //asm\r\n // mHandle = new MutationObserver(function (_a_d) {mRef(_a_d);});\r\n //end;\r\n mHandle := TJSMutationObserver.new(@subscribe);\r\n Fhandle:=mHandle;\r\nend;\r\n\r\n\r\nprocedure TMutationObserver.CBMutationChange(mutationRecordsList: array of TJSMutationRecord);\r\nvar\r\n LEvent: JSValue;\r\nbegin\r\n TJSMutationObserver(FHandle).disconnect();\r\n asm LEvent = new Event('readyexecute'); end;\r\n// mutationRecordsList[length(mutationRecordsList)-1].target.dispatchEvent(LEvent);\r\n mutationRecordsList[TJSArray(mutationRecordsList).Length-1].target.dispatchEvent(LEvent);\r\nend;\r\n\r\nfunction observerConfig: TJSObject;\r\n{ ╔════Initialize paramater═════════════════════════════════════════════════╗\r\n ║ Options for the observer (which mutations to observe) ║\r\n ║ by default all false. However, you can pick as many as you want, ║\r\n ║ but at least one of - attributes, characterData, or childList ║\r\n ║ ║\r\n ║ var optParams = {\"childList\": true, \"attributes\": true} ║\r\n ╚═════════════════════════════════════════════════════════════════════════╝ }\r\nbegin\r\n Result :=\r\n new([\r\n 'attributes', true { attribute changes will be observed | on add/remove/change attributes }\r\n ,'attributeOldValue', true { will show oldValue of attribute | on add/remove/change attributes | default: null }\r\n //,'characterData', true { data changes will be observed | on add/remove/change characterData }\r\n //,'characterDataOldValue', true { will show OldValue of characterData | on add/remove/change characterData | default: null }\r\n //,'childList', true { target childs will be observed | on add/remove }\r\n //,'subtree', true { target childs will be observed | on attributes/characterData changes if they observed on target }\r\n //,'attributeFilter', TJSArray.new('style') { filter for attributes | array of attributes that should be observed, in this case only style }\r\n ]);\r\nend;\r\n\r\nprocedure TElement.Observe;\r\nvar\r\n MyObserver: TMutationObserver;\r\nbegin\r\n //console.log('Observe was called');\r\n MyObserver := TMutationObserver.Create;\r\n TJSMutationObserver(MyObserver.FHandle).observe(TJSNode(Handle), observerConfig);\r\nend;\r\n\r\n(*procedure TElement.ReadyExecute(const OnReady: TProcedure);\r\n procedure doReadyExecute;\r\n begin\r\n ReadyExecute(OnReady);\r\n end;\r\n\r\nvar\r\n LExists: Boolean;\r\nBegin\r\n LExists := document.body.contains(TJSNode(self.handle));\r\n if LExists then\r\n OnReady()\r\n else\r\n window.setTimeout(@doReadyExecute, 100);\r\nend; *)\r\n\r\nprocedure TElement.touch2Mouse(e: TJSEvent);\r\nvar\r\n theTouch: TJSTouch;\r\n mouseEv: String;\r\n mouseEvent: TJSEvent;\r\n eventOptions: TJSObject;\r\n op: TJSEventInit;\r\n event: TJSMouseEvent;\r\nbegin\r\n//mapping touch events to mouse events. See JSplitter for example\r\n//https://www.codicode.com/art/easy_way_to_add_touch_support_to_your_website.aspx\r\n\r\n theTouch := TJSTouchEvent(e).changedTouches[0];\r\n\r\n case e._type of\r\n 'touchstart': mouseEv := 'mousedown';\r\n 'touchend' : mouseEv := 'mouseup';\r\n 'touchmove' : mouseEv := 'mousemove';\r\n else exit;\r\n end;\r\n\r\n mouseEvent := document.createEvent('MouseEvent');\r\n TJSMouseEvent(mouseEvent).initMouseEvent(mouseEv, true, true, window, 1, theTouch.screenX, theTouch.screenY, theTouch.clientX, theTouch.clientY, false, false, false, false, 0, nil);\r\n theTouch.target.dispatchEvent(mouseEvent);\r\n e.preventDefault();\r\n\r\n(*\r\n //op.bubbles:= true;\r\n //op.cancelable:= true;\r\n //op.composed:=;\r\n //op.scoped:=;\r\n\r\n eventOptions := new([\r\n 'view', window,\r\n 'bubbles', true,\r\n 'cancelable', true,\r\n 'screenX', theTouch.screenX,\r\n 'screenY', theTouch.screenY,\r\n 'clientX', theTouch.clientX,\r\n 'clientY', theTouch.clientY,\r\n 'button', 0\r\n //'offsetX': mouseX - player.offset().left,\r\n //'offsetY': mouseY - player.offset().top,\r\n //'pageX': mouseX,\r\n //'pageY': mouseY\r\n ]);\r\n\r\n (* Though the MouseEvent.initMouseEvent() method is kept for backward compatibility,\r\n creating of a MouseEvent object should be done using the MouseEvent() constructor. *)\r\n //event := TJSMouseEvent.new(mouseEv, eventOptions);\r\n theTouch.target.dispatchEvent(event);\r\n *)\r\n\r\n\r\n\r\n\r\n (*\r\n var event = new MouseEvent('mousedown', {\r\n 'view': window,\r\n 'bubbles': true,\r\n 'cancelable': true,\r\n 'screenX': datePosition.left,\r\n 'screenY': datePosition.top\r\n });\r\n\r\n dateTile.dispatchEvent(event);\r\n *)\r\nend;\r\n\r\ninitialization\r\nScreenWidth := window.innerWidth;\r\n\r\nend.\r\n\r\n(*\r\nprocedure initMouseEvent(const\r\n typeArg: string; = mouseEv\r\n bubblesArg: boolean; = true\r\n cancelableArg: boolean; = true\r\n viewArg: TJSWindow; = window\r\n detailArg: Integer; = 1\r\n screenXArg: Integer; = theTouch.screenX\r\n screenYArg: Integer; = theTouch.screenY\r\n clientXArg: Integer; = theTouch.clientX\r\n clientYArg: Integer; = theTouch.clientY\r\n ctrlKeyArg: boolean; = false\r\n altKeyArg: boolean; = false\r\n shiftKeyArg: boolean; = false\r\n metaKeyArg: boolean; = false\r\n buttonArg: Integer; = 0\r\n relatedTargetArg: TJSEventTarget = nil\r\n );\r\n*)\r\n","unit jForm;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, JElement;\r\n\r\ntype\r\n TW3Form = class(TElement)\r\n public\r\n procedure InitializeForm; virtual;\r\n procedure InitializeObject; virtual;\r\n procedure ReSize; virtual;\r\n constructor Create(parent: TElement); virtual;\r\n Caption : String;\r\n end;\r\n\r\n TFormClass = class of TW3Form;\r\n\r\nimplementation\r\n\r\nuses\r\n JGlobals;\r\n\r\n{ TW3Form }\r\n\r\nconstructor TW3Form.Create(parent: TElement);\r\n\r\n procedure doOnResize(sender: TObject);\r\n begin\r\n screenwidth := window.innerWidth;\r\n ReSize;\r\n end;\r\n\r\nbegin\r\n inherited Create('div', parent);\r\n SetProperty('border','1px double #2196f3');\r\n Left := 5; Top := 5;\r\n setProperty('width','calc(100% - 12px)');\r\n setProperty('height','calc(100% - 12px)');\r\n setProperty('background-color','white');\r\n\r\n (* This forces the browsers that support it to\r\n use the GPU rather than CPU for movement *)\r\n self.setProperty('will-change','transform');\r\n self.setProperty('-webkit-transform','translateZ(0px)');\r\n self.setProperty( '-moz-transform','translateZ(0px)');\r\n self.setProperty( '-ms-transform','translateZ(0px)');\r\n self.setProperty( '-o-transform','translateZ(0px)');\r\n self.setProperty( 'transform','translateZ(0px)');\r\n\r\n OnResize := @doOnResize;\r\n\r\nend;\r\n\r\nProcedure TW3Form.InitializeForm;\r\nbegin\r\n //clear form\r\n self.Clear;\r\nend;\r\n\r\nProcedure TW3Form.InitializeObject;\r\nbegin\r\n//\r\nend;\r\n\r\nProcedure TW3Form.ReSize;\r\nbegin\r\n//\r\nend;\r\n\r\nend.\r\n\r\n","unit jApplication;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, types, JS, Web, JElement, JForm;\r\n\r\ntype\r\n JW3Application = class(TElement)\r\n public\r\n FormNames: Array of String;\r\n FormsClasses: Array of TFormClass; //TFormClass = class of JW3Form;\r\n FormsInstances: Array of TW3Form;\r\n constructor Create(parent: TElement); virtual;\r\n procedure CreateForm(FormName: String; aClassType: TFormClass);\r\n procedure GoToForm(FormName: String);\r\n end;\r\n\r\nimplementation\r\n\r\nuses jGlobals;\r\n\r\n{ JW3Application }\r\n\r\nconstructor JW3Application.Create(parent: TElement);\r\nbegin\r\n inherited Create('div', parent);\r\n\r\n setProperty('width','100%');\r\n setProperty('height','100%');\r\n setProperty('background-color','white');\r\n\r\nend;\r\n\r\nprocedure JW3Application.CreateForm(FormName: String; aClassType: TFormClass);\r\nbegin\r\n TJSArray(FormNames).push(FormName);\r\n TJSArray(FormsClasses).push(aClassType);\r\n TJSArray(FormsInstances).push(nil);\r\nend;\r\n\r\n(*\r\n,Show:function(Self, FormName$1) {\r\n var i = 0;\r\n var $temp1;\r\n for(i=0,$temp1=Self.FormNames.length;i<$temp1;i++) {\r\n if (Self.FormsInstances[i]!==null) {\r\n TElement.SetProperty(Self.FormsInstances[i],\"display\",\"none\");\r\n }\r\n if (Self.FormNames[i]==FormName$1) {\r\n if (Self.FormsInstances[i]===null) {\r\n Self.FormsInstances[i]=JW3Form.Create$5($NewDyn(Self.FormsClasses[i],\"\"),Self);\r\n JW3Form.ShowForm$(Self.FormsInstances[i]);\r\n } else {\r\n JW3Form.ClearForm(Self.FormsInstances[i]);\r\n JW3Form.ShowForm$(Self.FormsInstances[i]);\r\n TElement.SetProperty(Self.FormsInstances[i],\"display\",\"inline-block\");\r\n }\r\n }\r\n }\r\n}\r\n*)\r\nprocedure JW3Application.GoToForm(FormName: String);\r\nvar\r\n i: integer;\r\nbegin\r\n//\r\n For i := 0 to TJSArray(FormNames).length -1 do begin\r\n If FormsInstances[i] <> nil then\r\n FormsInstances[i].SetProperty('display','none');\r\n If FormNames[i] = FormName then begin\r\n If FormsInstances[i] = nil then //form has never been displayed yet\r\n FormsInstances[i] := FormsClasses[i].Create(self) else\r\n FormsInstances[i].SetProperty('display','inline-block');\r\n\r\n //TW3Form(FormsInstances[i]).InitializeForm; //ClearForm;\r\n //console.log(FormsClasses[i]); //ClearForm;\r\n { TODO warleyalex }\r\n (*\r\n this.Dt$ = function ($) {\r\n \t\treturn $.ClassType.Dt($)\r\n \t},\r\n \tthis.YC$ = function ($) {\r\n \t\treturn $.ClassType.YC($)\r\n \t},\r\n *)\r\n //*this.FormsClasses[i](this.FormsInstances[i])\r\n TW3Form(FormsInstances[i]).InitializeForm;\r\n TW3Form(FormsInstances[i]).InitializeObject;\r\n //(FormsInstances[i] as FormsClasses[i]).InitializeForm; //ClearForm;\r\n //(FormsInstances[i] as FormsClasses[i]).InitializeObject; //ShowForm;\r\n end;\r\n end;\r\nend;\r\n\r\nend.\r\n\r\n","unit jGlobals;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, JElement, JApplication, JForm;\r\n\r\n\r\nvar\r\n Application : JW3Application;\r\n\r\n { global methods }\r\n function StrBefore(s: String; d: String): String;\r\n\r\nimplementation\r\n\r\nfunction StrBefore(s: String; d: String): String;\r\nbegin\r\n asm\r\n if(!d)return s;var p=s.indexOf(d);return(p<0)?s:s.substr(0,p)\r\n end;\r\nend;\r\n\r\n\r\ninitialization\r\n\r\nApplication := JW3Application.Create(nil);\r\n\r\nend.\r\n\r\n","unit jPanel;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, JElement;\r\n\r\ntype\r\n JW3Panel = class(TElement)\r\n public\r\n constructor Create(parent: TElement); virtual;\r\n end;\r\n\r\n\r\nimplementation\r\n\r\n{ JW3Panel }\r\n\r\nconstructor JW3Panel.Create(parent: TElement);\r\nbegin\r\n inherited Create('div', parent);\r\nend;\r\n\r\nend.\r\n\r\n","unit jListBox;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, JElement, JPanel;\r\n\r\ntype\r\n JW3ListBox = class(TElement)\r\n public\r\n ItemCount : integer;\r\n constructor Create(parent: TElement); virtual;\r\n Procedure Add(item: TElement);\r\n Procedure Clear;\r\n end;\r\n\r\nimplementation\r\n\r\nuses\r\n jGlobals;\r\n\r\n{ JW3ListBox }\r\n\r\nconstructor JW3ListBox.Create(parent: TElement);\r\nvar\r\n atop, aheight: Integer;\r\n\r\n function doListBox(event : TJSUIEvent): Boolean;\r\n var\r\n i: integer;\r\n c: TJSHTMLCollection;\r\n begin\r\n c := TJSElement(self.handle).children;\r\n for i := 0 to c.length -1 do\r\n begin\r\n atop := StrToInt(StrBefore(TJSHTMLElement(c[i]).style.getPropertyValue('top'), 'px'));\r\n aheight := StrToInt(StrBefore(TJSHTMLElement(c[i]).style.getPropertyValue('height'), 'px'));\r\n\r\n TJSHTMLElement(c[c.length-1]).style.setProperty('display', 'inline-block'); //set last one visible\r\n\r\n if ((atop + aheight) < TJSElement(self.Handle).scrollTop) and //all previous visible set to none\r\n (TJSHTMLElement(c[i]).style.getPropertyValue('display') = 'inline-block') then\r\n TJSHTMLElement(c[i]).style.setProperty('display', 'none');\r\n\r\n if (atop + aheight >= TJSElement(self.handle).scrollTop) and //if in viewport make visible\r\n (atop <= TJSElement(self.handle).scrollTop + self.height + 2) then\r\n begin\r\n TJSHTMLElement(c[i]).style.setProperty('display' ,'inline-block');\r\n end;\r\n\r\n if (atop > TJSElement(self.handle).scrollTop + self.height + 2) and //if past viewport then set invisible\r\n (TJSHTMLElement(c[i]).style.getPropertyValue('display') = 'inline-block') and\r\n (i < c.length-1) then\r\n TJSHTMLElement(c[i]).style.setProperty('display', 'none');\r\n end;\r\n end;\r\n\r\nbegin\r\n inherited Create('div', parent);\r\n\r\n ItemCount := 0;\r\n TJSElement(self.handle).setAttribute('will-change', 'transform'); //'scroll-position'\r\n\r\n TJSHTMLElement(self.handle).onscroll := @doListBox;\r\n\r\nend;\r\n\r\n(*procedure JW3ListBox.Add(item: TElement);\r\nbegin\r\n//\r\n console.log(item.width);\r\n item.setProperty('width','calc(100% - 40px)');\r\n\r\n\r\n //TJSHTMLElement(item.handle).style.setProperty('width','calc(100%-10px)');\r\n// console.log( TJSHTMLElement(item.handle).style.getPropertyValue('width') );\r\n\r\n //item.SetBounds(2, 2 + (ItemCount * item.height) + (ItemCount * 2), item.width, item.height);\r\n item.SetBounds(2, 2 + (ItemCount * item.height) + (ItemCount * 2), 200, item.height);\r\n //TJSHTMLElement(item.handle).style.SetProperty('cursor','pointer');\r\n\r\n //the following construct sets all entries which are not visible (outside the viewport)\r\n //to display-none, except the last entry which always will have display-inlineblock\r\n //this will render a correctly dimensioned proportional scroller\r\n\r\n //1-set the last entry to disply-none if it is not visible\r\n If (item.Top > (self.Height + item.height)) and (self.height > 0) then\r\n TJSHTMLElement( TJSElement(self.handle).children[TJSElement(self.handle).children.length-1]).style.setProperty('display', 'none');\r\n\r\n //2-append the new item\r\n self.FElement.appendchild(item.FElement);\r\n\r\n //3-always set the last entry to inline-block.\r\n TJSHTMLElement(TJSElement(self.handle).children[TJSElement(self.handle).children.length-1]).style.setProperty('display', 'inline-block');\r\n\r\n Inc(ItemCount);\r\nend;*)\r\n\r\nprocedure JW3ListBox.Add(item: TElement);\r\nbegin\r\n//\r\n\r\n //item.setProperty('width','calc(100% - 4px)');\r\n TJSHTMLElement(item.handle).style.setProperty('width','calc(100%-10px)');\r\n self.FElement.appendchild(item.FElement);\r\n item.SetBounds(2, 2 + (ItemCount * item.height) + (ItemCount * 2), item.width, item.height);\r\n //item.SetBounds(2, 2 + (ItemCount * item.height) + (ItemCount * 2), 100, item.height);\r\n item.SetProperty('cursor','pointer');\r\n If (item.Top > self.Height) and (self.height > 0)\r\n then item.SetProperty('display','none');\r\n\r\n Inc(ItemCount);\r\nend;\r\n\r\nprocedure JW3ListBox.Clear;\r\nbegin\r\n While assigned(FElement.firstChild) do\r\n FElement.removeChild(FElement.firstChild);\r\n ItemCount := 0;\r\nend;\r\n\r\n(*\r\n//old version\r\nprocedure JW3ListBox.Add(item: TElement);\r\nbegin\r\n//\r\n item.setProperty('width','calc(100% - 4px)');\r\n self.FElement.appendchild(item.FElement);\r\n item.SetBounds(2, 2 + (ItemCount * item.height) + (ItemCount * 2), item.width, item.height);\r\n item.SetProperty('cursor','pointer');\r\n If (item.Top > self.Height) and (self.height > 0)\r\n then item.SetProperty('display','none');\r\n\r\n Inc(ItemCount);\r\nend;\r\n*)\r\n\r\nend.\r\n\r\n","unit jButton;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, jElement;\r\n\r\ntype\r\n JW3Button = class(TElement)\r\n public\r\n constructor Create(parent: TElement); virtual;\r\n end;\r\n\r\nimplementation\r\n\r\nconstructor JW3Button.Create(parent: TElement);\r\nbegin\r\n inherited Create('button', parent);\r\n SetProperty('color','white');\r\n SetProperty('border-radius', '4px');\r\n SetProperty('background', '#699BCE');\r\n SetProperty('cursor','pointer');\r\n SetProperty('box-shadow','0 -1px 1px 0 rgba(0, 0, 0, 0.25) inset, 0 1px 1px 0 rgba(0, 0, 0, 0.10) inset;)');\r\n\r\nend;\r\n\r\nend.\r\n\r\n","unit jImage;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, JElement;\r\n\r\ntype\r\n JW3Image = class(TElement)\r\n public\r\n constructor Create(parent: TElement); virtual;\r\n end;\r\n\r\nimplementation\r\n\r\n\r\n{ JW3Image }\r\n\r\nconstructor JW3Image.Create(parent: TElement);\r\nbegin\r\n inherited Create('img', parent);\r\nend;\r\n\r\n\r\nend.\r\n\r\n","unit jToolBar;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, types, JS, Web, JElement, JPanel;\r\n\r\ntype\r\n JW3ToolBar = class(TElement)\r\n private\r\n ToolBarItems: Array of JW3Panel;\r\n public\r\n constructor Create(parent: TElement); virtual;\r\n Procedure AddMenu(menuText, GotoForm, color: string);\r\n Procedure SetActiveMenu(formname: string);\r\n end;\r\n\r\nimplementation\r\n\r\nuses jGlobals;\r\n\r\n{ JW3MenuBar }\r\n\r\nconstructor JW3ToolBar.Create(parent: TElement);\r\nbegin\r\n inherited Create('div', parent);\r\nend;\r\n\r\nprocedure JW3ToolBar.AddMenu(menuText, GotoForm, color: string);\r\n var\r\n Panel0 : JW3Panel;\r\n\r\n procedure Panel0Click(Sender:TObject);\r\n procedure postMessage(aList : TJSValueDynArray; aValue : JSValue); external name 'window.postMessage';\r\n begin\r\n if TJSArray(Application.FormNames).IndexOf((Sender as JW3Panel).tag) > -1 then //if form\r\n Application.GoToForm((Sender as JW3Panel).tag) else //then gotoform\r\n postMessage([TJSElement(self.handle).id,'click',GoToForm],'*'); //else send message\r\n end;\r\n\r\nbegin\r\n//\r\n Panel0 := JW3Panel.Create(self);\r\n Panel0.SetBounds(20 + ((TJSArray(ToolBarItems).Length) * 100), 14, 90, 26);\r\n Panel0.SetinnerHtml(menuText);\r\n Panel0.setProperty('color', color);\r\n Panel0.setProperty('cursor','pointer');\r\n Panel0.SetProperty('font-size', '0.9em');\r\n\r\n TJSArray(ToolBarItems).push(Panel0);\r\n Panel0.Tag := GotoForm;\r\n Panel0.OnClick := @Panel0Click;\r\nend;\r\n\r\nprocedure JW3ToolBar.SetActiveMenu(FormName: String);\r\nvar\r\n i: integer;\r\n\r\nbegin\r\n//\r\n for i := 0 to TJSArray(ToolBarItems).Length - 1 do begin\r\n ToolBarItems[i].setProperty('font-weight', 'normal');\r\n ToolBarItems[i].setProperty('text-decoration', 'none');\r\n If ToolBarItems[i].Tag = FormName then\r\n begin\r\n ToolBarItems[i].setProperty('font-weight', 'bold');\r\n ToolBarItems[i].setProperty('text-decoration', 'underline');\r\n end;\r\n end;\r\nend;\r\n\r\nend.\r\n\r\n","unit jProgressBar;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, JElement, JPanel;\r\n\r\ntype\r\n Float = double;\r\n\r\ntype\r\n JW3Progress = class(TElement)\r\n private\r\n procedure SetPerc(aPerc: float);\r\n function GetPerc: float;\r\n Light: TElement;\r\n timer : NativeInt;\r\n public\r\n constructor Create(parent: TElement); virtual;\r\n property Perc: float read getPerc write setPerc;\r\n ProgressBar : TElement;\r\n end;\r\n\r\n\r\nimplementation\r\n\r\nuses jGlobals;\r\n\r\n{ JW3Progress }\r\n\r\nconstructor JW3Progress.Create(parent: TElement);\r\n procedure doOnTimer;\r\n begin\r\n Light.Left := Light.Left + 4;\r\n If Light.Left + Light.Width > ProgressBar.Width then Light.Left := 0;\r\n If Light.Left + Light.Width + 2 >= Width then\r\n begin\r\n Light.Left := -Light.Width;\r\n window.clearInterval(timer);\r\n end;\r\n end;\r\n\r\nbegin\r\n inherited Create('div', parent);\r\n\r\n ProgressBar := JW3Panel.Create(self);\r\n\r\n Light := JW3Panel.Create(ProgressBar);\r\n Light.SetProperty('border-radius','2px');\r\n Light.SetProperty('background-color','white');\r\n Light.SetProperty('opacity','0.5');\r\n\r\n Light.Left := 0;\r\n timer := window.setInterval(@doOnTimer, 20);\r\n//\r\nend;\r\n\r\nprocedure JW3Progress.SetPerc(aPerc: Float);\r\nvar\r\n f : float;\r\nbegin\r\n If aPerc > 100 then aPerc := 100;\r\n If aPerc < 0 then aPerc := 0;\r\n\r\n f := (Width * aPerc)/100;\r\n ProgressBar.SetProperty('width',FloatToStr(f) + 'px');\r\n ProgressBar.SetBounds(0,0,ProgressBar.Width,self.height);\r\n ProgressBar.SetProperty('overflow','hidden');\r\n\r\n Light.Width := ProgressBar.Height * 2;\r\n Light.Height := ProgressBar.Height - 4;\r\n Light.Top := 2;\r\nend;\r\n\r\nfunction JW3Progress.GetPerc: float;\r\nvar\r\n f : float;\r\nbegin\r\n f := (ProgressBar.width / width) * 100;\r\n Result := f;\r\nend;\r\n\r\nend.\r\n\r\n","unit JSplitter;\r\n\r\n{$mode objfpc}{$H+}\r\n{$modeswitch externalclass}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, JElement, JPanel;\r\n\r\ntype\r\n TJSEvtHandler = function(event: TJSEvent): boolean of object;\r\n\r\n JTouchEventHandlers = class external name 'TouchEventHandlers'\r\n public\r\n ontouchstart: TJSEvtHandler;\r\n ontouchend: TJSEvtHandler;\r\n ontouchmove: TJSEvtHandler;\r\n ontouchenter: TJSEvtHandler;\r\n ontouchleave: TJSEvtHandler;\r\n ontouchcancel: TJSEvtHandler;\r\n end;\r\n\r\ntype\r\n JW3Splitter = class(TElement)\r\n public\r\n constructor Create(parent: TElement); virtual;\r\n PanelLeft, PanelRight, ReSizer: JW3Panel;\r\n end;\r\n\r\nimplementation\r\n\r\nuses jGlobals;\r\n\r\n{ JW3Splitter }\r\n\r\nconstructor JW3Splitter.create(parent: TElement);\r\n\r\n procedure doSplitterOnReadyExecute(sender: TObject);\r\n\r\n function doReSizerOnTouchStart(event : TJSEvent): Boolean;\r\n begin\r\n touch2Mouse(event);\r\n end;\r\n\r\n function doReSizerOnMouseDown(e : TJSMouseEvent): Boolean;\r\n var\r\n saveX : NativeInt;\r\n function doOnMouseMove(e : TJSMouseEvent): Boolean;\r\n begin\r\n PanelRight.left := PanelRight.Left - Trunc(saveX - e.clientX);\r\n saveX := Trunc(e.clientX);\r\n PanelRight.width := self.Width - PanelRight.Left;\r\n PanelLeft.SetProperty ('cursor','w-resize');\r\n PanelRight.SetProperty('cursor','w-resize');\r\n end;\r\n Begin\r\n saveX := Trunc(e.clientX);\r\n TJSHTMLElement(self.handle).onmousemove := @doOnMouseMove;\r\n end;\r\n\r\n function doSplitterOnMouseUp(event : TJSMouseEvent): Boolean;\r\n function doOnMouseMove(e : TJSMouseEvent): Boolean;\r\n begin\r\n //nullify mousemove\r\n end;\r\n Begin\r\n PanelLeft.SetProperty ('cursor','default');\r\n PanelRight.SetProperty('cursor','default');\r\n TJSHTMLElement(self.handle).onmousemove := @doOnMouseMove;\r\n end;\r\n\r\n Begin\r\n console.log('OnReadyExecute');\r\n\r\n PanelLeft.SetProperty('height','100%');\r\n PanelLeft.SetProperty('width','100%');\r\n\r\n PanelRight.SetProperty('height','100%');\r\n PanelRight.Width := trunc(self.width/2);\r\n PanelRight.Left := trunc(self.width/2);\r\n\r\n ReSizer.SetProperty('height','100%');\r\n\r\n //\r\n // event handling splitter movement\r\n //\r\n //mapping touchstart to mousedown, touchend to mouseup and touchmove to mousemove\r\n //see touch2Mouse in JElement.\r\n JTouchEventHandlers(ReSizer.handle).ontouchstart := @doReSizerOnTouchStart;\r\n JTouchEventHandlers(ReSizer.handle).ontouchmove := JTouchEventHandlers(ReSizer.handle).ontouchstart;\r\n JTouchEventHandlers(ReSizer.handle).ontouchend := JTouchEventHandlers(ReSizer.handle).ontouchstart;\r\n\r\n TJSHTMLElement(ReSizer.handle).onmousedown := @doReSizerOnMouseDown;\r\n\r\n TJSHTMLElement(self.handle).onmouseup := @doSplitterOnMouseUp;\r\n\r\n end;\r\n\r\n\r\nBegin\r\n inherited Create('div', parent);\r\n\r\n PanelLeft := JW3Panel.Create(self);\r\n PanelRight := JW3Panel.Create(self);\r\n\r\n ReSizer := JW3Panel.Create(PanelRight);\r\n ReSizer.SetProperty('background-color','#ccc');\r\n ReSizer.SetProperty('cursor','w-resize');\r\n ReSizer.width := 4;\r\n\r\n //self.Observe;\r\n self.OnReadyExecute := @doSplitterOnReadyExecute;\r\nend;\r\n\r\nend.\r\n\r\n","unit Form1;\r\n\r\n{$mode objfpc}{$H+}\r\n\r\ninterface\r\n\r\nuses\r\n Classes, SysUtils, types, JS, Web,\r\n JElement, JForm, JListBox, JPanel, JButton, JImage, JToolBar, JProgressBar,\r\n JSplitter;\r\n\r\ntype\r\n TProcedure = procedure of object;\r\n\r\ntype\r\n\r\n TComponentRec = class\r\n name : string;\r\n ShowIt : TProcedure;\r\n end;\r\n\r\n\r\ntype\r\n TForm1 = class(TW3Form)\r\n private\r\n //{$I 'Form1:intf'}\r\n ToolBar : JW3ToolBar;\r\n ListBox1 : JW3ListBox;\r\n Components : array of TComponentRec;\r\n DisplayDiv : JW3Panel;\r\n ComponentRec: TComponentRec;\r\n procedure populateListBox;\r\n protected\r\n procedure InitializeForm; override;\r\n procedure InitializeObject; override;\r\n procedure Resize; override;\r\n\r\n end;\r\n\r\nimplementation\r\n\r\nuses jGlobals;\r\n\r\nprocedure TForm1.InitializeForm;\r\nbegin\r\n inherited;\r\n // this is a good place to initialize components\r\nend;\r\n\r\n\r\nprocedure TForm1.populateListBox;\r\nvar\r\n i: Integer;\r\n Panel0: JW3Panel;\r\n\r\n procedure doPanel0OnClick(Sender: TObject);\r\n var\r\n disp: TJSCSSStyleDeclaration;\r\n begin\r\n //clear DisplayDiv\r\n While assigned(DisplayDiv.FElement.firstChild) do\r\n DisplayDiv.FElement.removeChild(DisplayDiv.FElement.firstChild);\r\n //optionally clear select element, see JInput\r\n if document.getElementById(TJSElement(self.handle).getAttribute('data-select')) <> null then\r\n TJSHTMLElement(document.getElementById(TJSElement(self.handle).getAttribute('data-select'))).style.setProperty('display' ,'none');\r\n //execute component\r\n Components[strtoint((Sender as JW3Panel).tag)].ShowIt;\r\n //adjust height and width of DisplayDiv to componentheight and -width\r\n disp := TJSHTMLElement(TJSElement(DisplayDiv.handle).children[0]).style;\r\n disp.setProperty('height', 'px');\r\n\r\n //DisplayDiv.Height := StrToInt(StrBefore(TJSElement(DisplayDiv.handle).children[0].style.height, 'px')) + 30;\r\n //DisplayDiv.Width := StrToInt(StrBefore(TJSElement(DisplayDiv.handle).children[0].style.width, 'px')) + 30;\r\n\r\n //TElement.SetHeight(Self.DisplayDiv,parseInt(StrBefore(String(Self.DisplayDiv.Handle.children[0].style.height),\"px\"),10)+30);\r\n //TElement.SetWidth(Self.DisplayDiv,parseInt(StrBefore(String(Self.DisplayDiv.Handle.children[0].style.width),\"px\"),10)+30);\r\n DisplayDiv.Height :=\r\n StrToInt(\r\n StrBefore(\r\n TJSHTMLElement(TJSElement(DisplayDiv.handle).children[0])\r\n .style.getPropertyValue('height'), 'px')\r\n ) + 30;\r\n\r\n DisplayDiv.Width :=\r\n StrToInt(\r\n StrBefore(\r\n TJSHTMLElement(TJSElement(DisplayDiv.handle).children[0])\r\n .style.getPropertyValue('width'), 'px')\r\n ) + 30;\r\n\r\n// DisplayDiv.Height := 250;\r\n// DisplayDiv.Width := 300;\r\n end;\r\n\r\nbegin\r\n ///////////////////////////////////////////////////////\r\n //\r\n //populate the menu (listbox) with all component names\r\n //when clicked, execute the saved ShowIt procedure\r\n //\r\n ListBox1 := JW3ListBox.Create(self);\r\n ListBox1.SetBounds(17, 85, 200, 200);\r\n ListBox1.setProperty('background-color', 'white');\r\n ListBox1.SetProperty('border','2px double whitesmoke');\r\n\r\n For i := 0 to TJSArray(Components).Length -1 do begin\r\n Panel0 := JW3Panel.Create(ListBox1);\r\n Panel0.setProperty('background-color', 'whitesmoke');\r\n Panel0.SetBounds(2,2,170,22);\r\n Panel0.SetinnerHTML(Components[i].Name);\r\n Panel0.SetProperty('font-size', '0.85em');\r\n Panel0.tag := inttostr(i);\r\n Panel0.OnClick := @doPanel0OnClick;\r\n\r\n ListBox1.Add(Panel0);\r\n end;\r\n\r\nend;\r\n\r\n\r\nprocedure TForm1.InitializeObject;\r\nvar\r\n i: Integer;\r\n Panel0, Panel1: JW3Panel;\r\n Fpanel1: JW3Panel;\r\n Fbutton1: JW3Button;\r\n Image0: JW3Image;\r\n\r\n procedure doPanel0OnClick(Sender: TObject);\r\n begin\r\n console.log('clicked silver item #' + (Sender as JW3Panel).tag);\r\n end;\r\n procedure doPanel1OnClick(Sender: TObject);\r\n begin\r\n //console.log('clicked green item #' + (Sender as JW3Panel).tag);\r\n console.log('button clicked');\r\n end;\r\n\r\n procedure doPanel1;\r\n var\r\n Panel1: JW3Panel;\r\n begin\r\n {--------------------------------------------------------------------------}\r\n { Component JW3Panel }\r\n { Updated: 01/09/2017 }\r\n {--------------------------------------------------------------------------}\r\n Panel1 := JW3Panel.Create(DisplayDiv);\r\n Panel1.SetBounds(0, 0, 100, 100);\r\n Panel1.setProperty('background-color', 'gold');\r\n Panel1.SetProperty('border','1px double grey');\r\n end;\r\n\r\n procedure doButton1;\r\n var\r\n Button1 : JW3Button;\r\n procedure Button1OnClick(sender: TObject);\r\n begin\r\n window.alert('clicked');\r\n end;\r\n begin\r\n {--------------------------------------------------------------------------}\r\n { Component JW3Button }\r\n { Updated: 01/09/2017 }\r\n {--------------------------------------------------------------------------}\r\n Button1 := JW3Button.Create(DisplayDiv);\r\n Button1.SetBounds(0, 0, 100, 50);\r\n Button1.SetInnerHTML('Button');\r\n Button1.OnClick := @Button1OnClick;\r\n end;\r\n\r\n procedure doProgress1;\r\n var\r\n Progress1 : JW3Progress;\r\n id: Integer;\r\n\r\n procedure ProgressIt;\r\n begin\r\n Progress1.Perc := Progress1.Perc + 1;\r\n if Progress1.Perc > 100 then\r\n window.clearInterval(id);\r\n end;\r\n\r\n begin\r\n {------------------------------------------------------------------------------}\r\n { Component JW3Progress }\r\n { Updated: 01/09/2017 }\r\n {------------------------------------------------------------------------------}\r\n Progress1 := JW3Progress.Create(DisplayDiv);\r\n Progress1.SetBounds(0, 0, 300, 12);\r\n Progress1.setProperty('background-color', 'lightgrey');\r\n Progress1.ProgressBar.setProperty('background-color', 'salmon');\r\n Progress1.Perc := 25;\r\n id := window.setInterval(@ProgressIt, 30);\r\n end;\r\n\r\n procedure doImage1;\r\n var\r\n Image1 : JW3Image;\r\n begin\r\n {--------------------------------------------------------------------------}\r\n { Component JW3Image }\r\n { Updated: 01/09/2017 }\r\n {--------------------------------------------------------------------------}\r\n Image1 := JW3Image.Create(DisplayDiv);\r\n Image1.SetBounds(0, 0, 194, 45);\r\n Image1.setAttribute('src','images/logo.png');\r\n end;\r\n\r\n procedure doSplitter1;\r\n var\r\n Splitter1 : JW3Splitter;\r\n Button1 : JW3Button;\r\n Button2 : JW3Button;\r\n begin\r\n {--------------------------------------------------------------------------}\r\n { Component JW3Splitter }\r\n { Updated: 01/09/2017 }\r\n {--------------------------------------------------------------------------}\r\n Splitter1 := JW3Splitter.Create(DisplayDiv);\r\n Splitter1.SetBounds(0, 0, 300, 200);\r\n Splitter1.PanelLeft.setProperty('background-color', 'white');\r\n Splitter1.PanelRight.setProperty('background-color', 'whitesmoke');\r\n Splitter1.SetProperty('border','1px solid silver');\r\n\r\n Button1 := JW3Button.Create(Splitter1.PanelLeft);\r\n Button1.SetinnerHTML('Left');\r\n Button1.SetBounds(20,20,60,30);\r\n Button2 := JW3Button.Create(Splitter1.PanelRight);\r\n Button2.SetinnerHTML('Right');\r\n Button2.SetBounds(20,20,60,30);\r\n end;\r\n\r\nBegin\r\n inherited;\r\n //ToolBar.SetActiveMenu('Form1');\r\n //Init Logo\r\n Image0 := JW3Image.Create(self);\r\n Image0.SetBounds(0, 0, 194, 45);\r\n Image0.setAttribute('src','images/logo.png');\r\n\r\n //Init ToolBar\r\n ToolBar := JW3ToolBar.Create(self);\r\n ToolBar.SetBounds(0, 45, 0, 40);\r\n ToolBar.setProperty('min-width','100%');\r\n ToolBar.setProperty('background-color', '#699BCE');\r\n ToolBar.AddMenu('Components','Form1','white');\r\n ToolBar.AddMenu('Projects','Form2','white');\r\n ToolBar.SetActiveMenu('Form1');\r\n\r\n(* Fpanel1 := JW3Panel.Create(Self);\r\n Fpanel1.setProperty('background-color', 'silver');\r\n Fpanel1.SetBounds(150, 10, 100, 35);\r\n Fpanel1.tag := IntToStr(i);\r\n Fpanel1.OnClick := @doPanel0OnClick;\r\n\r\n Fbutton1 := JW3Button.Create(Self);\r\n Fbutton1.SetBounds(150, 50, 100, 50);\r\n Fbutton1.SetInnerHTML('Button1');\r\n Fbutton1.OnClick := @doPanel1OnClick;*)\r\n\r\n //create kitchen sink components and add to Component array\r\n TJSArray(Components).Length:=0; //--> Components.clear;\r\n DisplayDiv := JW3Panel.Create(self);\r\n DisplayDiv.SetBounds(20, 300, 0, 0);\r\n\r\n (*===== components ======*)\r\n //JPanel\r\n ComponentRec := TComponentRec.Create;\r\n ComponentRec.Name := 'JPanel';\r\n ComponentRec.ShowIt := @doPanel1;\r\n TJSArray(Components).Push(ComponentRec);\r\n\r\n //JButton\r\n ComponentRec := TComponentRec.Create;\r\n ComponentRec.Name := 'JButton';\r\n ComponentRec.ShowIt := @doButton1;\r\n TJSArray(Components).Push(ComponentRec);\r\n\r\n //JProgress\r\n ComponentRec := TComponentRec.Create;\r\n ComponentRec.Name := 'JProgress';\r\n ComponentRec.ShowIt := @doProgress1;\r\n TJSArray(Components).Push(ComponentRec);\r\n\r\n //JImage\r\n ComponentRec := TComponentRec.Create;\r\n ComponentRec.Name := 'JImage';\r\n ComponentRec.ShowIt := @doImage1;\r\n TJSArray(Components).Push(ComponentRec);\r\n\r\n //JSplitter\r\n ComponentRec := TComponentRec.Create;\r\n ComponentRec.Name := 'JSplitter';\r\n ComponentRec.ShowIt := @doSplitter1;\r\n TJSArray(Components).Push(ComponentRec);\r\n(*\r\n//JListBox\r\n ListBox1 := JW3ListBox.Create(self);\r\n ListBox1.SetBounds(20, 150, trunc(screenwidth*0.8), 200);\r\n ListBox1.setProperty('background-color', 'gold');\r\n\r\n For i := 1 to 50 do begin\r\n Panel0 := JW3Panel.Create(ListBox1);\r\n Panel0.setProperty('background-color', 'silver');\r\n Panel0.height := 30;\r\n Panel0.tag := inttostr(i);\r\n Panel0.OnClick := @doPanel0OnClick;\r\n\r\n Panel1 := JW3Panel.Create(Panel0);\r\n Panel1.setProperty('background-color', 'lightgreen');\r\n Panel1.SetBounds(30,2,26,26);\r\n Panel1.SetinnerHTML(IntToStr(i));\r\n Panel1.tag := inttostr(i);\r\n Panel1.OnClick := @doPanel1OnClick;\r\n\r\n ListBox1.Add(Panel0);\r\n end;*)\r\n\r\n populateListBox;\r\nend;\r\n\r\nprocedure TForm1.Resize;\r\nbegin\r\n inherited;\r\nend;\r\n\r\n\r\nend.\r\n\r\n","program project1;\r\n\r\n{$mode objfpc}\r\n\r\nuses\r\n Classes, SysUtils, JS, Web, uMain, jGlobals, jApplication,\r\n Form1, JSplitter;\r\n\r\n(*\r\nuses\r\n Classes, SysUtils, JS, Web, uMain, jGlobals,\r\n jForm, jApplication, jImage,jToolBar, jListBox,jProgressBar,JTextArea,\r\n jVideo, JAnchor, JLoader,JIframe,JStreetView,jGrid,JObjectTable,JStringTable,\r\n jCanvas,JTreeView,jCheckBox,jSpinner,jFieldSet,jRadioButton,jInput,\r\n jFlipScroll,jDialog,jWindow,\r\n jPanel, jButton, JSelect, Form1;\r\n\r\n\r\ntype\r\n TApp = class\r\n private\r\n Fpanel1 : JW3Panel;\r\n Fbutton1: JW3Button;\r\n public\r\n procedure panel1Click(Sender: TObject);\r\n procedure button1Click(Sender: TObject);\r\n end;\r\n\r\nprocedure TApp.panel1Click(Sender: TObject);\r\nbegin\r\n console.log('clicked silver item #' + (Sender as JW3Panel).tag);\r\nend;\r\n\r\nprocedure TApp.button1Click(Sender:TObject);\r\nbegin\r\n console.log('button1 clicked');\r\nend;\r\n\r\n\r\nvar\r\n i: integer;\r\n app: TApp;\r\n *)\r\nbegin\r\n // Your code here\r\n (*app:= TApp.Create;\r\n try\r\n with app do\r\n begin\r\n Fpanel1 := JW3Panel.Create(nil);\r\n Fpanel1.setProperty('background-color', 'silver');\r\n Fpanel1.SetBounds(5, 10, 100, 35);\r\n Fpanel1.tag := IntToStr(i);\r\n Fpanel1.OnClick := @panel1Click;\r\n\r\n Fbutton1 := JW3Button.Create(nil);\r\n Fbutton1.SetBounds(5, 50, 100, 50);\r\n Fbutton1.SetInnerHTML('Button1');\r\n Fbutton1.OnClick := @button1Click;\r\n end;\r\n finally\r\n app.free;\r\n end;*)\r\n\r\n //create forms\r\n Application.CreateForm('Form1',TForm1);\r\n (*Application.CreateForm('Form2',TForm2);\r\n Application.CreateForm('Form3',TForm3);\r\n Application.CreateForm('Form4',TForm4);\r\n Application.CreateForm('Form5',TForm5);\r\n Application.CreateForm('Form6',TForm6);\r\n Application.CreateForm('Form7',TForm7);\r\n Application.CreateForm('Form8',TForm8);\r\n Application.CreateForm('Form9',TForm9);\r\n Application.CreateForm('Form10',TForm10);*)\r\n\r\n //show initial form\r\n Application.GoToForm('Form1');\r\nend.\r\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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