-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
202 lines (142 loc) · 5.35 KB
/
example.html
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!--
@Project: GunBasic-JS
@Website: http://code.google.com/p/gunbasic-js/
@Author: Gunesh Raj
@Email: [email protected]
@Version: 0.2
@License: GNU General Public License v2
@Notes: The Author reserves the right to change the Licence.
Please Send me bugs & Notices via http://code.google.com/p/gunbasic-js/
-->
<html>
<head>
<title>GunBasic-JS Example Page</title>
<script src="gunbasic.js"></script>
<script>
function showworking() {
var dx = document.getElementById('divworking');
var vis = dx.style;
vis.display = 'block';
//console.log('SHOW...');
//alert('Working');
}
function hideworking() {
var dx = document.getElementById('divworking');
var vis = dx.style;
vis.display = 'none';
//console.log('HIDE...');
}
</script>
</head>
<body style="font-family:Geneva, Arial, Helvetica, sans-serif">
<div id="divworking" style="background-color:#FF6600; width: 100px; height: 25px; position:absolute; z-index: 100; left: 300px; color:#FFFFFF; top: 0px; text-align:center; display: none">
Working...
</div>
<h1>GunBasic-JS Example Page</h1>
<p>
Version 0.5<br>
Gunesh Raj<br>
<a href="http://code.google.com/p/gunbasic-js/">http://code.google.com/p/gunbasic-js/</a><br>
</p>
<br>
Working Box: <a href="#" onClick="showworking()">Show</a> | <a href="#" onClick="hideworking()">Hide</a>
<br>
For this update, the AutoAjax Call would call a Function on Starting & Call another Function on Ended. I have added the Javascript Alert because localhost calls are very fast, you cant see the Working Orange Box.
<br>
<h2>Example 1: DIV alone via Ajax</h2>
<p>
In this example, GunBasic-JS would be used to populate these DIV's (div1example1 and div2example1) with Ajax Data, which would be any HTML content.
We would only call this function once.
<br /><br />
<a href="#" onClick="autoajaxcall (null, 'POST', 'ajax.html?a=1&b=2', 'data={"name": "test"}', showworking, hideworking);">Run Example 1</a>
</p>
Div1
<div id="div1example1" style="width: 400px; height: 70px; background:#99CCFF; border-color:#FF9933; padding: 10px"></div>
Div2
<div id="div2example1" style="width: 400px; height: 70px; background:#99CCFF; border-color:#FF9933; padding: 10px"></div>
<p>
Note that both Div boxes are filled with 1 call to the the server.
Normal Ajax calls rely on parsing the results and assigning the values to each DIV.
In this Case. this is done Automatically for you.
</p>
<h3>Source Code : Client</h3>
<pre style="background:#EFEFEF; border-color:#FF9933; padding: 10px">
To make a GunBasic Call:
<script src="gunbasic.js"></script>
autoajaxcall (null, 'GET', 'ajax.html', 'exampleparam=123', showworking, hideworking);
Params:
1. Just Ignore for now, use null.
2. HTTP Method, [GET|POST]
3. URL of the Ajax Call
4. Parameters for the Ajax Call
5. Function OnStart (Optional)
6. Function OnComplete (Optional)
</pre>
<h3>Source Code : Server [ajax.html]</h3>
<pre style="background:#EFEFEF; border-color:#FF9933; padding: 10px">
<!-- [SGUN:] -->
div1example1|div2example1|
<!-- [EGUN:] -->
<!-- [SGUN:div1example1] -->
For the first <b>Example</b><br />
This is for the first DIV
<!-- [EGUN:div1example1] -->
<!-- [SGUN:div2example1] -->
For the First <b>Example</b><br />
This is for the Second DIV
<!-- [EGUN:div2example1] -->
</pre>
<h2>Example 2: Adding Javascript Interpreting in the Call</h2>
<p>
This example extends the 1st example by adding the ability to run Javascript codes as well as displaying content to DIVS.
It would display the values in those DIVs and change the Title of this Page with a JS Alert.
<br /><br />
<a href="#" onClick="autoajaxcall (null, 'GET', 'js.html', 'exampleparam=123', showworking, hideworking);">Run Example 2</a> (Scroll down for the div after running this example)
</p>
Div1
<div id="div1example2" style="width: 400px; height: 70px; background:#99CCFF; border-color:#FF9933; padding: 10px"></div>
Div2
<div id="div2example2" style="width: 400px; height: 70px; background:#99CCFF; border-color:#FF9933; padding: 10px"></div>
<p>
Same effect
</p>
<h3>Source Code : Client</h3>
<pre style="background:#EFEFEF; border-color:#FF9933; padding: 10px">
To make a GunBasic Call:
<script src="gunbasic.js"></script>
autoajaxcall (null, 'GET', 'js.html', 'exampleparam=123', showworking, hideworking);
Params:
1. Just Ignore for now, use null.
2. HTTP Method, [GET|POST]
3. URL of the Ajax Call
4. Parameters for the Ajax Call
5. Function OnStart (Optional)
6. Function OnComplete (Optional)
</pre>
<h3>Source Code : Server [js.html]</h3>
<pre style="background:#EFEFEF; border-color:#FF9933; padding: 10px">
<!-- [SGUN:] -->
div1example2|div2example2|
<!-- [EGUN:] -->
<!-- [SVAL:] -->
TITLE|HEY|
<!-- [EVAL:] -->
<!-- [SGUN:div1example2] -->
For the first <b>Example</b><br />
This is for the first DIV<br />
Changed for Example 2
<!-- [EGUN:div1example2] -->
<!-- [SGUN:div2example2] -->
For the First <b>Example</b><br />
This is for the Second DIV<br />
Changed for Example 2
<!-- [EGUN:div2example2] -->
<!-- [SVAL:TITLE] -->
document.title="New Title, changed for Example 2"
<!-- [EVAL:TITLE] -->
<!-- [SVAL:HEY] -->
alert('As Expected, GunBasic sends this Alert via Ajax, One Line of Code, Check Page Title!');
<!-- [EVAL:HEY] -->
</pre>
</body>
</html>