mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-20 05:00:32 +02:00
* Data module demo
This commit is contained in:
parent
b414442d95
commit
b0b52a9edf
116
demo/datamodule/datamoduletest.lpi
Normal file
116
demo/datamodule/datamoduletest.lpi
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="12"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<SaveOnlyProjectUnits Value="True"/>
|
||||||
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
<MainUnitHasTitleStatement Value="False"/>
|
||||||
|
<MainUnitHasScaledStatement Value="False"/>
|
||||||
|
<Runnable Value="False"/>
|
||||||
|
<SaveJumpHistory Value="False"/>
|
||||||
|
<SaveFoldState Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<Title Value="datamoduletest"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
</General>
|
||||||
|
<CustomData Count="4">
|
||||||
|
<Item0 Name="MaintainHTML" Value="1"/>
|
||||||
|
<Item1 Name="Pas2JSProject" Value="1"/>
|
||||||
|
<Item2 Name="PasJSPort" Value="3001"/>
|
||||||
|
<Item3 Name="PasJSWebBrowserProject" Value="1"/>
|
||||||
|
</CustomData>
|
||||||
|
<BuildModes>
|
||||||
|
<Item Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<UseFileFilters Value="True"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<FormatVersion Value="2"/>
|
||||||
|
</RunParams>
|
||||||
|
<RequiredPackages>
|
||||||
|
<Item>
|
||||||
|
<PackageName Value="pas2jscomponents"/>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<PackageName Value="Pas2JSDsgn"/>
|
||||||
|
</Item>
|
||||||
|
</RequiredPackages>
|
||||||
|
<Units>
|
||||||
|
<Unit>
|
||||||
|
<Filename Value="datamoduletest.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit>
|
||||||
|
<Unit>
|
||||||
|
<Filename Value="index.html"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<CustomData Count="1">
|
||||||
|
<Item0 Name="PasJSIsProjectHTMLFile" Value="1"/>
|
||||||
|
</CustomData>
|
||||||
|
</Unit>
|
||||||
|
<Unit>
|
||||||
|
<Filename Value="dmtest.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<ComponentName Value="TestModule"/>
|
||||||
|
<HasResources Value="True"/>
|
||||||
|
<ResourceBaseClass Value="DataModule"/>
|
||||||
|
</Unit>
|
||||||
|
<Unit>
|
||||||
|
<Filename Value="htmlactions.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit>
|
||||||
|
<Unit>
|
||||||
|
<Filename Value="htmleventnames.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<Target FileExt=".js">
|
||||||
|
<Filename Value="datamoduletest"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="js"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Parsing>
|
||||||
|
<SyntaxOptions>
|
||||||
|
<AllowLabel Value="False"/>
|
||||||
|
<CPPInline Value="False"/>
|
||||||
|
<UseAnsiStrings Value="False"/>
|
||||||
|
</SyntaxOptions>
|
||||||
|
</Parsing>
|
||||||
|
<CodeGeneration>
|
||||||
|
<TargetOS Value="browser"/>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="False"/>
|
||||||
|
<UseLineInfoUnit Value="False"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CustomOptions Value="-Jeutf-8 -Jirtl.js -Jc -Jminclude -JRjs"/>
|
||||||
|
<CompilerPath Value="$(pas2js)"/>
|
||||||
|
</Other>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions>
|
||||||
|
<Item>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
13
demo/datamodule/datamoduletest.lpr
Normal file
13
demo/datamodule/datamoduletest.lpr
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
program datamoduletest;
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
uses
|
||||||
|
JS, Classes, SysUtils, Web, dmtest, htmlactions, htmleventnames;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
begin
|
||||||
|
With TTestModule.Create(Nil) do
|
||||||
|
DoSomething;
|
||||||
|
end.
|
28
demo/datamodule/dmtest.lfm
Normal file
28
demo/datamodule/dmtest.lfm
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
object TestModule: TTestModule
|
||||||
|
OldCreateOrder = True
|
||||||
|
Height = 152
|
||||||
|
HorizontalOffset = 465
|
||||||
|
VerticalOffset = 225
|
||||||
|
Width = 277
|
||||||
|
object alHTML: THTMLElementActionList
|
||||||
|
Left = 104
|
||||||
|
Top = 33
|
||||||
|
object actTitle: THTMLElementAction
|
||||||
|
Events = []
|
||||||
|
ElementID = 'hdrTitle'
|
||||||
|
end
|
||||||
|
object actSetTitle: THTMLElementAction
|
||||||
|
Events = [heClick]
|
||||||
|
ElementID = 'btnSetTitle'
|
||||||
|
OnExecute = actSetTitleExecute
|
||||||
|
end
|
||||||
|
object acthdrTitle_2: THTMLElementAction
|
||||||
|
Events = []
|
||||||
|
ElementID = 'hdrTitle-2'
|
||||||
|
end
|
||||||
|
object actbtnSetTitle_2: THTMLElementAction
|
||||||
|
Events = []
|
||||||
|
ElementID = 'btnSetTitle-2'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
48
demo/datamodule/dmtest.pp
Normal file
48
demo/datamodule/dmtest.pp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
unit dmtest;
|
||||||
|
|
||||||
|
{$mode ObjFPC}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, htmlactions, Web;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
{ TTestModule }
|
||||||
|
|
||||||
|
TTestModule = class(TDataModule)
|
||||||
|
actbtnSetTitle_2: THTMLElementAction;
|
||||||
|
acthdrTitle_2: THTMLElementAction;
|
||||||
|
actSetTitle: THTMLElementAction;
|
||||||
|
alHTML: THTMLElementActionList;
|
||||||
|
actTitle: THTMLElementAction;
|
||||||
|
procedure actSetTitleExecute(Sender: TObject; Event: TJSEvent);
|
||||||
|
private
|
||||||
|
|
||||||
|
public
|
||||||
|
Procedure DoSomething;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
TestModule: TTestModule;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
|
{ TTestModule }
|
||||||
|
|
||||||
|
procedure TTestModule.actSetTitleExecute(Sender: TObject; Event: TJSEvent);
|
||||||
|
begin
|
||||||
|
ActTitle.Element.innerHTML:='Title is now set';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestModule.DoSomething;
|
||||||
|
begin
|
||||||
|
Writeln('DoSomething');
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
20
demo/datamodule/index.html
Normal file
20
demo/datamodule/index.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Project1</title>
|
||||||
|
<script src="datamoduletest.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 id="hdrTitle"></h1>
|
||||||
|
<button id="btnSetTitle">Set title</button>
|
||||||
|
<h2 id="hdrTitle-2">Subtitle</h2>
|
||||||
|
<button id="btnSetTitle-2">Clear Title</button>
|
||||||
|
<script>
|
||||||
|
rtl.run();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user