-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuLeafJs.pas
108 lines (94 loc) · 2.33 KB
/
uLeafJs.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
unit uLeafJs;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.WebBrowser, FMX.Controls.Presentation, SG.Scriptgate
{$IFDEF MSWINDOWS}
,System.Win.Registry
{$ENDIF}
;
type
TForm2 = class(TForm)
Panel1: TPanel;
WebBrowser1: TWebBrowser;
btnedit: TButton;
procedure btneditClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FScriptgate:TScriptgate;
{$IFDEF MSWINDOWS}
procedure SetPermissions;
{$ENDIF}
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.fmx}
uses System.IOUtils;
//android js webbrowser devuelve "nombres" con doble comilla
function FixQuotes(text:string):string;
begin
result := StringReplace(text,'"','',[rfReplaceAll]);
end;
procedure TForm2.btneditClick(Sender: TObject);
begin
if btnedit.text = 'ReadOnly' then
begin
FScriptGate.CallScript('toggle("read")',
procedure(const iResult:string)
begin
btnedit.Text:= FixQuotes(iResult);
end
);
end
else
if btnedit.text = 'Editing' then
begin
FScriptGate.CallScript('toggle("edit")',
procedure(const iResult:string)
begin
btnedit.Text:= FixQuotes(iResult);
end
);
end;
end;
{$IFDEF MSWINDOWS}
procedure TForm2.SetPermissions;
const
cHomePath = 'SOFTWARE';
cFeatureBrowserEmulation =
'Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\';
cIE11 = 11001;
var
Reg: TRegIniFile;
sKey: string;
begin
sKey := ExtractFileName(ParamStr(0));
Reg := TRegIniFile.Create(cHomePath);
try
if Reg.OpenKey(cFeatureBrowserEmulation, True) and
not(TRegistry(Reg).KeyExists(sKey) and (TRegistry(Reg).ReadInteger(sKey)
= cIE11)) then
TRegistry(Reg).WriteInteger(sKey, cIE11);
finally
Reg.Free;
end;
end;
{$ENDIF}
procedure TForm2.FormCreate(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
SetPermissions;
WebBrowser1.URL := 'file://' + GetCurrentDir + '/../../plotter.html';
{$ENDIF}
{$IFDEF ANDROID}
WebBrowser1.URL := 'file://' + TPath.GetDocumentsPath + PathDelim + 'plotter.html';
{$ENDIF}
btnedit.text := 'ReadOnly' ;
Fscriptgate:= TScriptgate.create(self,Webbrowser1,'yourorgScheme');
end;
end.