-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMyPlugin.html
More file actions
107 lines (88 loc) · 3.65 KB
/
MyPlugin.html
File metadata and controls
107 lines (88 loc) · 3.65 KB
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
<!DOCTYPE html>
<html>
<head>
<title>MyPlugin</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
</style>
</head>
<body>
<div data-role="page" data-theme="a">
<div data-role="header" data-position="fixed">
<a href='#' class='ui-btn-left' data-icon='arrow-l' data-theme="c" onclick="history.back(); return false">Back</a>
<h1>MyPlugin</h1>
</div><!-- /header -->
<div data-role="content">
<p> Todo: Documentation for MyPlugin</p>
<p>In order to use MyPlugin, you must first load the plugin at the top of your script
using the <b>LoadPlugin</b> method like this:</p>
<div class="samp"> app.LoadPlugin( "MyPlugin" );</div>
<p>Then you can create an instance of the plugin object when you need it like this:</p>
<div class="samp"> plg = app.CreateMyPlugin();</div>
<br>
<p>Examples:</p>
<div data-role="collapsible" data-collapsed="true" data-mini="true" data-theme="a" data-content-theme="b">
<h3>Example - Get Version</h3>
<div id="examp1" style="font-size:70%">
app.LoadPlugin( "MyPlugin" );<br>
<br>
function OnStart()<br>
{<br>
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );<br><br>
btn = app.CreateButton( "Press Me" );<br>
btn.SetOnTouch( CallPlugin );<br>
lay.AddChild( btn );<br><br>
<b id="snip1" style="font-size:100%">
plg = app.CreateMyPlugin();<br>
</b><br>
app.AddLayout( lay );<br>
}<br>
<br>
function CallPlugin()<br>
{<br>
alert( plg.GetVersion() );<br>
}<br><br>
</div>
<div name="divCopy" align="right">
<a href="#" data-role="button" data-mini="true" data-inline="true" onclick="copy(snip1)"> Copy </a>
<a href="#" data-role="button" data-mini="true" data-inline="true" onclick="copy(examp1)">Copy All</a>
<a href="#" data-role="button" data-mini="true" data-inline="true" onclick="demo(examp1)"> Run </a>
</div>
</div>
<div data-role="collapsible" data-collapsed="true" data-mini="true" data-theme="a" data-content-theme="b">
<h3>Example - Test Callback</h3>
<div id="examp2" style="font-size:70%">
app.LoadPlugin( "MyPlugin" );<br>
<br>
function OnStart()<br>
{<br>
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );<br><br>
btn = app.CreateButton( "Press Me" );<br>
btn.SetOnTouch( CallPlugin );<br>
lay.AddChild( btn );<br><br>
<b id="snip2" style="font-size:100%">
plg = app.CreateMyPlugin();<br>
plg.SetOnMyReply( OnMyReply );<br>
</b><br>
app.AddLayout( lay );<br>
}<br>
<br>
function CallPlugin()<br>
{<br>
plg.MyFunc( "hello", 21, true );<br>
}<br><br>
function OnMyReply( txt, num, bool )<br>
{<br>
alert( "txt=" + txt + " num=" + num + " bool=" + bool );<br>
}<br>
</div>
<div name="divCopy" align="right">
<a href="#" data-role="button" data-mini="true" data-inline="true" onclick="copy(snip2)"> Copy </a>
<a href="#" data-role="button" data-mini="true" data-inline="true" onclick="copy(examp2)">Copy All</a>
<a href="#" data-role="button" data-mini="true" data-inline="true" onclick="demo(examp2)"> Run </a>
</div>
</div>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>