-
Notifications
You must be signed in to change notification settings - Fork 2
/
WebAPI3.pas
93 lines (64 loc) · 3.33 KB
/
WebAPI3.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
unit WebAPI;
interface
type
JJSON = class external
function Parse(s : String) : Variant; external 'parse';
function Stringify(v : Variant) : String; overload; external 'stringify';
function Stringify(v, replacer, space : Variant) : String; overload; external 'stringify';
end;
JRegExp = class external 'RegExp'
constructor Create(filter, options : String); default;
function Test(s : String) : Boolean; external 'test';
end;
JDate = class external 'Date'
constructor Create(); overload; external;
constructor Create(millisecondsSinceEpoch : Float); overload; external;
constructor Create(dateString : String); overload; external;
function GetSeconds : Integer; external 'getSeconds';
function GetMinutes : Integer; external 'getMinutes';
function GetHours : Integer; external 'getHours';
function GetDate : Integer; external 'getDate'; // 1-31
function GetMonth : Integer; external 'getMonth'; // 0-11
function GetFullYear : Integer; external 'getFullYear'; // 2016
function GetTime : Float; external 'getTime';
class function Now : Float; external 'now';
function GetTimezoneOffset : Float; external 'getTimezoneOffset';
class function Parse(s : String) : JDate; external 'parse';
end;
function JSON : JJSON; external 'JSON' property;
function This : Variant; external 'this' property;
function Arguments : Variant; external 'arguments' property;
function Document : Variant; external 'document' property;
function Window : Variant; external 'window' property;
function Navigator : Variant; external 'navigator' property;
function Console : Variant; external 'console' property;
function Math : Variant; external 'Math' property;
function LocalStorage : Variant; external 'localStorage' property;
function Event : Variant; external 'event' property;
function DevicePixelRatio : Float; external 'devicePixelRatio' property;
function ElementByID(id : String) : Variant; external 'document.getElementById';
function QuerySelector(selector : String) : Variant; external 'document.querySelector';
function QuerySelectorAll(selector : String) : array of Variant; external 'document.querySelectorAll';
procedure Alert(msg : String); external 'alert';
function SetTimeout(proc : procedure; delayMilliseconds : Integer) : Integer; external 'setTimeout';
function SetInterval(proc : procedure; delayMilliseconds : Integer) : Integer; external 'setInterval';
procedure ClearTimeout(timeoutId : Integer); external 'clearTimeout';
procedure ClearInterval(intervalId : Integer); external 'clearInterval';
procedure RequestAnimationFrame(proc : procedure); external 'requestAnimationFrame';
function PerformanceNow : Float; external 'performance.now';
function EncodeURI(s : String) : String; external 'encodeURI';
function DecodeURI(s : String) : String; external 'decodeURI';
function EncodeURIComponent(s : String) : String; external 'encodeURIComponent';
function DecodeURIComponent(s : String) : String; external 'decodeURIComponent';
function EscapeHTML(s : String) : String;
function StrToUTF8(s : String) : String;
implementation
function EscapeHTML(s : String) : String;
begin
Result := s.ToHtml;
end;
function Unescape(s : String) : String; external 'unescape';
function StrToUTF8(s: String): String;
begin
Result := Unescape(EncodeURIComponent(s));
end;