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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
--[[
/*
* Baltisot
* Copyright (C) 1999-2008 Nicolas "Pixel" Noble
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
]]--
local common_javascript
function urlEncode(str)
if str then
str = string.gsub(str, "\n", "\r\n")
str = string.gsub(str, "([^%w ])",
function (c)
return string.format("%%%02X", string.byte(c))
end)
str = string.gsub(str, " ", "+")
end
return str
end
function write_common_javascript(out)
out:write(common_javascript)
end
common_javascript = [=[
function getObjById(id) {
var returnVar = null;
if (document.getElementById)
returnVar = document.getElementById(id);
else if (document.all)
returnVar = document.all[id];
else if (document.layers)
returnVar = document.layers[id];
return returnVar;
}
function removeAllOptions(selectbox)
{
var i;
selectbox = getObjById(selectbox);
for (i = selectbox.options.length - 1; i >= 0; i--)
{
//selectbox.options.remove(i);
selectbox.remove(i);
}
}
function addOption(selectbox, value, text )
{
selectbox = getObjById(selectbox);
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
//=============================================================================
// Image Preloader
function ImagePreloader(images, callback) {
// store the callback
this.callback = callback;
// initialize internal state.
this.nLoaded = 0;
this.nProcessed = 0;
this.aImages = new Array;
// record the number of images.
this.nImages = images.length;
// for each image, call preload()
for (var i = 0; i < images.length; i++)
this.preload(images[i]);
}
ImagePreloader.prototype.preload = function(image) {
// create new Image object and add to array
var oImage = new Image;
this.aImages.push(oImage);
// set up event handlers for the Image object
oImage.onload = ImagePreloader.prototype.onload;
oImage.onerror = ImagePreloader.prototype.onerror;
oImage.onabort = ImagePreloader.prototype.onabort;
// assign pointer back to this.
oImage.oImagePreloader = this;
oImage.bLoaded = false;
oImage.source = image;
// assign the .src property of the Image object
oImage.src = image;
}
ImagePreloader.prototype.onComplete = function() {
this.nProcessed++;
if (this.nProcessed == this.nImages)
this.callback(this.aImages);
}
ImagePreloader.prototype.onload = function() {
this.bLoaded = true;
this.oImagePreloader.nLoaded++;
this.oImagePreloader.onComplete();
}
ImagePreloader.prototype.onerror = function() {
this.bError = true;
this.oImagePreloader.onComplete();
}
ImagePreloader.prototype.onabort = function() {
this.bAbort = true;
this.oImagePreloader.onComplete();
}
//=============================================================================
/////////////////////////////////////////////////////////////////////
/*-------------------------------------------------------------------
AKX GetVariables
-------------------------------------------------------------------
Class to get HTTP GET-style variables from the document URL.
Usage:
1) declare a variable as GetVariables ex.
vars=new GetVariables();
2) call the variable's Init function ex.
vars.Init();
3) call IsVar to check whether the named variable is found ex.
vars.IsVar("username");
IsVar returns either true or false.
4) call GetVar to retrieve a variable.
alert(vars.GetVar("username"));
GetVar returns "" if the variable is not found.
You can also iterate through the variables using
for(i=0;i<vars.VarCount();i++)
{
alert(vars.GetVarNN(i)+"="+vars.GetVarNV(i));
}
THIS CODE IS COPYRIGHTED AND MAY BE FREELY DISTRIBUTED AS LONG AS
THIS COPYRIGHT NOTICE IS ENCLOSED WITHIN THE FILE. THIS SCRIPT HAS
BEEN CODED BY AKX (www.theakx.tk). IF YOU WANT TO MODIFY THE
CODE, GO RIGHT AWAY, BUT ENSURE THAT THIS COPYRIGHT NOTICE IS ALSO
ENCLOSED. THANKS AND HAVE FUN. STEALING IS EV0L, AS YOU SURELY KNOW.
START OF CODE
*/
function GV_Init() {
s = location.href;
p = s.lastIndexOf("?");
if (p == -1) {
this.Vars = 0;
return;
}
vs = s.substr(p + 1);
n = 0;
end = 0;
while (!end) {
e = vs.indexOf("=");
x = vs.indexOf("&");
if ((e == -1 && x == 0) || vs == "")
break;
if (x == -1)
x = vs.length;
vr = vs.substr(0, e);
va = vs.substring(e + 1, x);
this.Varslist[n] = vr;
this.Values[vr] = unescape(va);
n++;
vs = vs.substr(x + 1);
}
this.Vars = n;
}
function GV_Vc() {
return this.Vars;
}
function GV_GetVar(name) {
for (i = 0; i < this.Vars; i++) {
fn = this.Varslist[i];
if (fn == name)
return this.Values[fn];
}
return "";
}
function GV_IsVar(name) {
for (i = 0; i < this.Vars; i++) {
fn = this.Varslist[i];
if (fn == name)
return true;
}
return false;
}
function GV_GetVarPlace(name) {
for (i = 0; i < this.Vars; i++) {
fn = this.Varslist[i];
if (fn == name)
return i;
}
return -1;
}
/*
* be careful, in a case of duplicate names the first added takes precedence.
*/
function GV_AddVar(name, value) {
this.Varslist[this.Vars] = name;
this.Values[name] = value;
this.Vars++;
}
function GV_GetVarNV(n) {
if (this.Vars >= n)
return this.Values[this.Varslist[n]];
}
function GV_GetVarNN(n) {
if (this.Vars >= n)
return this.Varslist[n];
}
function GV_ListVars() {
s = "";
for (i = 0; i < this.VarCount(); i++) {
s += this.GetVarNN(i) + "=" + this.GetVarNV(i) + "\n";
}
alert(s);
}
function GetVariables() {
this.Values = new Array();
this.Varslist = new Array();
this.Vars = 0;
this.Init = GV_Init;
this.VarCount = GV_Vc;
this.GetVar = GV_GetVar;
this.GetVarNV = GV_GetVarNV;
this.GetVarNN = GV_GetVarNN;
this.IsVar = GV_IsVar;
this.AddVar = GV_AddVar;
this.GetVarPlace = GV_GetVarPlace;
this.ListVars = GV_ListVars;
}
/////////////////////////////////////////////////////////////////////
]=]
|