Mercurial > hg > fapweb
annotate ajax.js @ 730:c71948773f03
Add preliminary preview zoom function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 18 Nov 2014 23:37:46 +0200 |
parents | 8b1abca34033 |
children | c7b4139eb217 |
rev | line source |
---|---|
728
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 function jsCloseMessageBox(callback, cb_data) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 var nitem = document.getElementById("messageBox"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 if (nitem && nitem.style.display != "none") |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 nitem.style.display = "none"; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 if (callback && typeof(callback) === "function") |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 callback(cb_data); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 function jsMessageBox(msg) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 var nitem = document.getElementById("messageBox"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 if (nitem) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 nitem.innerHTML = "<div class='messageBoxInner'>"+ msg + |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 "<div class='messageBoxControls'>"+ |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 "<input id='msgBoxConfirmClose' type='button' value=' OK '>"+ |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 "</div></div>"; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 var elem = document.getElementById("msgBoxConfirmClose"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 elem.onclick = function () { jsCloseMessageBox(0, 0); } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 nitem.style.display = "block"; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 function jsConfirmBox(msg, cb_ok, cb_cancel, cb_data) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 var nitem = document.getElementById("messageBox"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 if (nitem) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 nitem.innerHTML = "<div class='messageBoxInner'><h1>Confirmation</h1><p>"+ msg +"</p>"+ |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 "<div class='messageBoxControls'>"+ |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 "<input id='msgBoxConfirmCancel' type='button' value=' Cancel '>"+ |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 "<input id='msgBoxConfirmOK' type='button' value=' OK '>"+ |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 "</div></div>"; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 var elem = document.getElementById("msgBoxConfirmCancel"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 elem.onclick = function () { jsCloseMessageBox(cb_cancel, cb_data); } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 elem = document.getElementById("msgBoxConfirmOK"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 elem.onclick = function () { jsCloseMessageBox(cb_ok, cb_data); } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 nitem.style.display = "block"; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 function statusMsg(msg) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 var nitem = document.getElementById("nstatus"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 if (nitem) nstatus.innerHTML = msg; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 function strtrim(str) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 if (!str || str == null) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 return ""; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 return str.replace(/^\s+|\s+$/g,'') |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 function strencode(str) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 return encodeURIComponent(str); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 function jsCreateXMLRequest() |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 var req; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 if (window.XMLHttpRequest) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 // Modern browsers |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 req = new XMLHttpRequest(); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 else |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 // Old IE versions |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 req = new ActiveXObject("Microsoft.XMLHTTP"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 return req; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 // |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 // Function for creating AJAX POST request arguments list based |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 // on fields and giving them specified types. Also basic check |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 // for validity can be performed (e.g. field empty or not) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 // |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 var lastPostArgs = Object(); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 function jsMakePostArgs(fields, fprefix, fsuffix, nofail) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 var res = []; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 lastPostArgs = Object(); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 for (var id in fields) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 var elname = fprefix + id + fsuffix; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 switch (fields[id]) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 case 4: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 elname += "Sel"; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 break; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 var elem = document.getElementById(elname); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 if (!elem && !nofail) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 jsMessageBox("No such DOM element '"+ elname +"'."); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 return ""; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 if (elem) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 switch (fields[id]) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 case 1: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 var vstr = strtrim(elem.value); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 res.push(id+"="+strencode(vstr)); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 lastPostArgs[id] = vstr; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 break; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 case 2: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 var vint = parseInt(strtrim(elem.value)); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 res.push(id+"="+vint); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 lastPostArgs[id] = vint; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 break; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 case 3: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 res.push(id+"="+(elem.checked ? "1" : "0")); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 lastPostArgs[id] = elem.checked; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 break; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
141 case 4: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 var vval = (elem.selectedIndex != -1) ? elem.options[elem.selectedIndex].value : -1; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 res.push(id+"="+vval); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 lastPostArgs[id] = vval; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
145 break; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
147 default: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 jsMessageBox("Unsupported field type in "+ elname); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 return ""; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
153 return res.join("&"); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 function jsGetValue(elname, eltype) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 var elem = document.getElementById(elname); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 if (!elem) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 jsMessageBox("No such DOM element '"+ elname +"'."); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 return ""; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 switch (eltype) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 { |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 case 1: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 var vstr = strtrim(elem.value); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
170 return strencode(vstr); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
171 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 case 2: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 var vint = parseInt(strtrim(elem.value)); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 return vint; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
175 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 case 3: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 return elem.checked ? "1" : "0"; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 case 4: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 if (elem.selectedIndex != -1) |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 return elem.options[elem.selectedIndex].value; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 else |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 return null; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
184 |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
185 default: |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 jsMessageBox("Unsupported field type in "+ elname); |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 return ""; |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
189 } |
8b1abca34033
Move code around, for cleaner structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 |
730
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
191 |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
192 function jsShowPreviewImage(file) |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
193 { |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
194 var nitem = document.getElementById("messageBox"); |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
195 if (nitem) |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
196 { |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
197 nitem.innerHTML = "<img src='"+file+"' alt='"+file+"' /><br />"+ |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
198 "<div class='messageBoxControls'>"+ |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
199 "<input id='messageBoxClose' type='button' value=' Close '>"+ |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
200 "</div>"; |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
201 |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
202 var elem = document.getElementById("messageBoxClose"); |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
203 elem.onclick = function () { jsCloseMessageBox(0, 0); } |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
204 |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
205 nitem.style.display = "block"; |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
206 } |
c71948773f03
Add preliminary preview zoom function.
Matti Hamalainen <ccr@tnsp.org>
parents:
728
diff
changeset
|
207 } |