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\startJSpreamble request1 used now
27
28 var examplemethod = "HTML" ;
29 var examplehost = "" ;
30 var exampleport = "" ;
31 var exampleurl = "" ;
32 var examplefile = "" ;
33
34 var examplelog = true ;
35
36 function strippedexavalue( name ) {
37 f = this.getField(name) ;
38 if (f) {
39 str = f.value ;
40 if (str.indexOf(name)==0) {
41 str = str.substr(name.length1) ;
42 }
43 return str ;
44 } else {
45 return "" ;
46 }
47 }
48
49 function identifyexampleurl ( ) {
50 if (examplelog) {
51 console.clear ;
52 console.println("base url: "this.baseURL) ;
53 console.println("this url: "this.URL) ;
54 }
55 if (this.baseURL != "") {
56 exampleurl = this.baseURL ;
57 } else {
58 if (this.URL != "") {
59 exampleurl = this.URL
60 }
61 }
62 if (exampleurl.indexOf("file:")>=0) {
63 exampleurl = "" ;
64 }
65 str = strippedexavalue("examplehost") ;
66 if (str != "auto") {
67 examplehost = str ;
68 if (str == "localhost") {
69 exampleport = "8061"
70 }
71 }
72 str = strippedexavalue("exampleport") ;
73 if (str != "auto") {
74 exampleport = str ;
75 }
76 if (examplelog) {
77 console.println("exampleurl: "exampleurl) ;
78 console.println("examplehost: "examplehost) ;
79 console.println("exampleport: "exampleport) ;
80 }
81 }
82
83 function checkexampleurl ( url ) {
84 if (url.indexOf("file:")>=0) {
85 url = "http:localhost:8061" ;
86 console.println("file url replaced by: "url) ;
87 } else {
88 if (url.indexOf(":")<0) {
89 url = "http:" url ;
90 }
91 if (examplelog) {
92 console.println("url before check: "url) ;
93 }
94
95 url = url.replace((https*:\\\/\\\/.?)(\\\/.*$), "$1exarequest") ;
96 if (examplelog) {
97 console.println("url after check: "url) ;
98 }
99 }
100 return url ;
101 }
102
103 function setexamplexfdf ( method ) {
104 examplemethod = method ;
105 }
106
107 function setexamplefile ( file ) {
108 examplemethod = file ;
109 }
110
111 function setexamplehost ( host ) {
112 examplehost = host ;
113 }
114
115 function setexampleport ( port ) {
116 examplehost = host ;
117 }
118
119 function doeraseexamplefile(tag) {
120 f = this.getField(tag) ;
121 if (f) {
122 f.value = "" ;
123 }
124 }
125
126 function doeraseexamplelist(tag) {
127 for (i=1;i<=100;i) {
128 f = this.getField(tag""i) ;
129 if (f) {
130 f.value = "" ;
131 } else {
132 return
133 }
134 }
135 }
136
137 function dosubmitexampleurl ( url ) {
138 if ((examplemethod == "XFDF" ) (url.indexOf("localhost")>=0)) {
139 doeraseexamplefile("fakename") ;
140 doeraseexamplelist("fakename") ;
141 }
142 url = checkexampleurl(url) ;
143 if (examplelog) {
144 console.println("submitting form to "url" using method "examplemethod) ;
145 }
146 if (examplefile != "") {
147 url = url "" examplefile ;
148 }
149
150 this.submitForm({cURL : url, bFDF : false, cSubmitAs : examplemethod}) ;
151 }
152
153 function submitexampleform ( ) {
154 identifyexampleurl() ;
155 if (examplehost != "") {
156 if (exampleport != "") {
157 dosubmitexampleurl(examplehost":"exampleport) ;
158 } else {
159 dosubmitexampleurl(examplehost) ;
160 }
161 } else {
162 if (exampleurl != "") {
163 dosubmitexampleurl(exampleurl) ;
164 } else {
165 if (exampleport != "") {
166 dosubmitexampleurl("localhost"":"exampleport) ;
167 } else {
168 dosubmitexampleurl("localhost:8061") ;
169 }
170 }
171 }
172 resetfilename () ;
173 }
174
175 function submitform ( host, port) {
176 setexamplehost(host) ;
177 setexamplepost(post) ;
178 submitexampleform ;
179 }
180
181\stopJSpreamble
182
183\startJSpreamble request2 used now
184
185 var exacommand = "" ;
186 var exaoption = "" ;
187 var exafilename = "" ;
188 var exafilelist = "" ;
189 var exaregistered = "" ;
190
191 function setrequest (command,option) {
192 exacommand = command ;
193 if (exacommand == "") {
194 exaoption = option ;
195 } else { if (option == "") {
196 exaoption = "" ;
197 } else { if (option.indexOf("")<0) {
198 exaoption = "action=" option ;
199 } else {
200 exaoption = option ;
201 } } }
202 }
203
204 function assemblerequest ( ) {
205 v = this.getField(filename) ;
206 if (v) {
207 exafilename = v.value ;
208 }
209 v = this.getField(filelist) ;
210 if (v) {
211 exafilelist = v.value ;
212 }
213
214
215 str = "<?xml version=1.0 ?>\\n" ;
216 str = str"<exa:request xmlns:exa=http:www.pragmaade.comschemasexample.rng><exa:application>" ;
217 if (exafilelist == "") {
218 exafilelist = exaregistered ;
219 } else { if (exaregistered != "") {
220 exafilelist = exafilelist "\\n" exaregistered ;
221 } }
222 if (exacommand != "") {
223 str = str"<exa:command>"exacommand"<exa:command>" ;
224 }
225 if (exaoption != "") {
226 str = str"<exa:option>"exaoption"<exa:option>" ;
227 }
228 if (exafilename != "") {
229 str = str"<exa:filename>"exafilename"<exa:filename>" ;
230 }
231 var fls = "" ;
232 if (exafilelist != "") {
233
234 lst = exafilelist.split(\\s) ;
235 for (i=0;i<lst.length;i) {
236 fls = fls"<exa:entry>"lst[i]"<exa:entry>" ;
237 }
238 } else { if (examultiple) {
239 for (i=1;i<=100;i) {
240
241 f = this.getField("filename" i) ;
242
243
244
245
246
247
248
249
250
251 if (f) { if (f.value != "") {
252 fls = fls "<exa:entry" ;
253 g = this.getField("dataname" i) ;
254 if (g) { if (g.value == "") {
255
256 fls = fls ">" ;
257 } else {
258
259 fls = fls " label=" g.value ">" ;
260 } } else {
261
262 fls = fls ">" ;
263 }
264 fls = fls f.value "<exa:entry>" ;
265 } }
266 }
267 } }
268 if (fls != "") {
269 str = str "<exa:filelist>" fls "<exa:filelist>" ;
270 }
271 str = str "<exa:application><exa:request>" ;
272 v = this.getField(exa:request) ;
273 if (v) {
274 v.value = str ;
275 }
276 }
277
278\stopJSpreamble
279
280\startJSpreamble request3 used now
281
282 var examultiple = false ;
283
284 function setfilename ( suffixes ) {
285 if (event.targetName) {
286 var name = event.targetName ;
287 var fake = name.replace(filename,"fakename") ;
288 } else {
289 var name = filename ;
290 var fake = fakename ;
291 }
292 f = this.getField(fake) ;
293 if (f) {
294 f.browseForFileToSubmit() ;
295 if ((suffixes != "") (f.value != "")) {
296
297 s = suffixes.replace(,g,"") ;
298 r = new RegExp() ;
299 s = "\\\\.(" s ")$" ;
300 r.compile(s, "i") ;
301 if (f.value.search(r)<=0) {
302 f.value = "" ;
303 app.alert(This filetype is not permitted.) ;
304
305
306
307
308
309
310
311
312
313
314
315
316 }
317 }
318 g = this.getField(name) ;
319 if (g) {
320 g.value = f.value ;
321 }
322
323
324
325
326
327
328
329
330
331
332
333 }
334 this.dirty = false ;
335 }
336
337 function addfilename () {
338 if (examultiple) {
339 h = this.getField("filelist") ;
340 g = this.getField("filename") ;
341 if ((g) (h)) {
342 str = g.value ;
343 if (h.value == "") {
344 h.value = str ;
345 } else {
346 h.value = h.value "\\n" str ;
347 }
348 g.value = "" ;
349 this.value = "" ;
350 }
351 }
352 this.dirty = false ;
353 }
354
355
356
357 function registerfilename (str) {
358 if (str!="") {
359 h = this.getField("filelist") ;
360 if (h) {
361 if (h.value != "") {
362 h.value = h.value "\\n" ;
363 }
364 h.value = h.value str ;
365 } else {
366 if (exaregistered != "") {
367 exaregistered = exaregistered "\\n" ;
368 }
369 exaregistered = exaregistered str ;
370 }
371 }
372 console.show ;
373 console.println(registered files) ;
374 console.println("file: "str) ;
375 console.println("list: "exaregistered) ;
376 this.dirty = false ;
377 }
378
379 function checkfilename () {
380 }
381
382 function getfilename ( suffixes ) {
383 setfilename(suffixes) ;
384 checkfilename() ;
385 addfilename() ;
386 }
387
388 function resetfilename () {
389 doeraseexamplefile("fakename") ;
390 doeraseexamplefile("filename") ;
391 doeraseexamplefile("filelist") ;
392 doeraseexamplelist("filename") ;
393 doeraseexamplelist("fakename") ;
394 }
395
396\stopJSpreamble
397
398\endinput
399 |