| 119 |
ghuddy |
1 |
/*
|
|
|
2 |
* COMMON JAVASCRIPTS
|
|
|
3 |
*/
|
|
|
4 |
|
|
|
5 |
<!--
|
|
|
6 |
var clickedButton = false;
|
|
|
7 |
function check() {
|
|
|
8 |
if (clickedButton) {
|
|
|
9 |
clickedButton = false;
|
|
|
10 |
return true;
|
|
|
11 |
} else {
|
|
|
12 |
return false;
|
|
|
13 |
}
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
function MM_reloadPage(init) { //reloads the window if Nav4 resized
|
|
|
17 |
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
|
|
|
18 |
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
|
|
|
19 |
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
|
|
|
20 |
}
|
|
|
21 |
MM_reloadPage(true);
|
|
|
22 |
|
|
|
23 |
function MM_preloadImages() { //v3.0
|
|
|
24 |
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
|
|
|
25 |
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
|
|
|
26 |
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
function MM_swapImgRestore() { //v3.0
|
|
|
30 |
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
function MM_findObj(n, d) { //v4.0
|
| 121 |
hknight |
34 |
var p,i,x;
|
|
|
35 |
if(!d) d=document;
|
| 119 |
ghuddy |
36 |
if((p=n.indexOf("?"))>0&&parent.frames.length) {
|
|
|
37 |
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
|
|
|
38 |
}
|
| 121 |
hknight |
39 |
if(!(x=d[n])&&d.all) x=d.all[n];
|
| 119 |
ghuddy |
40 |
for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
|
|
|
41 |
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
|
| 121 |
hknight |
42 |
if(!x && document.getElementById) x=document.getElementById(n);
|
| 119 |
ghuddy |
43 |
return x;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
function MM_swapImage() { //v3.0
|
|
|
47 |
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
|
|
|
48 |
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
function MM_openBrWindow(theURL,winName,features) { //v2.0
|
|
|
52 |
window.open(theURL,winName,features);
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
function MM_jumpMenu(targ,selObj,restore){ //v3.1
|
|
|
56 |
if (selObj.options[selObj.selectedIndex].value) {
|
|
|
57 |
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
|
|
|
58 |
if (restore) selObj.selectedIndex=0;
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
function Cascaded_Menu(targ,url,selObj,restore){ //v3.1
|
|
|
63 |
if (selObj.options[selObj.selectedIndex].value) {
|
|
|
64 |
eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
|
|
|
65 |
if (restore) selObj.selectedIndex=0;
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
function MM_validateForm() { //v5.0
|
|
|
70 |
var i,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
|
|
|
71 |
var REresults,HTMLchr,urlRE,pkgRE,versionRE,cleanStrRE;
|
|
|
72 |
var pass,passc;
|
|
|
73 |
//character range allowed
|
|
|
74 |
cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
|
|
|
75 |
pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
|
|
|
76 |
versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
|
| 121 |
hknight |
77 |
versionNumberRE = /^\d+\.\d+\.\d+$/;
|
| 119 |
ghuddy |
78 |
urlRE = "^https?://[a-z1-9]";
|
|
|
79 |
//character range disallowed
|
|
|
80 |
HTMLchr = /[\<\>\'\"]+/i;
|
| 121 |
hknight |
81 |
|
|
|
82 |
|
|
|
83 |
for (i=0; i<(args.length-2); i+=3) {
|
|
|
84 |
test=args[i+2];
|
| 119 |
ghuddy |
85 |
val=MM_findObj(args[i]);
|
| 121 |
hknight |
86 |
|
|
|
87 |
if (val) {
|
| 119 |
ghuddy |
88 |
nm=args[i+1];
|
|
|
89 |
val=val.value;
|
| 121 |
hknight |
90 |
|
|
|
91 |
|
|
|
92 |
|
| 119 |
ghuddy |
93 |
if (val!="") {
|
| 121 |
hknight |
94 |
if (test.indexOf('isEmail')!=-1) {
|
| 119 |
ghuddy |
95 |
p=val.indexOf('@');
|
|
|
96 |
if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
|
| 121 |
hknight |
97 |
}
|
|
|
98 |
|
| 119 |
ghuddy |
99 |
if (test.indexOf('isDate') != -1) {
|
| 121 |
hknight |
100 |
if (val.indexOf("/") != -1) {
|
| 119 |
ghuddy |
101 |
tmpARR = val.split("/");
|
|
|
102 |
if (tmpARR.length == 3) {
|
|
|
103 |
if (!(tmpARR[0]>0 && tmpARR[0]<32 && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
|
|
|
104 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
|
|
105 |
}
|
|
|
106 |
} else {
|
|
|
107 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
|
|
108 |
}
|
|
|
109 |
} else {
|
|
|
110 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
|
|
111 |
}
|
|
|
112 |
}
|
| 121 |
hknight |
113 |
|
| 119 |
ghuddy |
114 |
if (test.indexOf('isPackage')!=-1) {
|
|
|
115 |
REresults = val.search(pkgRE);
|
|
|
116 |
if (REresults < 0) errors += val += ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
|
|
|
117 |
+ 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
|
|
|
118 |
}
|
| 121 |
hknight |
119 |
|
| 119 |
ghuddy |
120 |
if (test.indexOf('isCleanStr')!=-1) {
|
|
|
121 |
REresults = val.search(cleanStrRE);
|
|
|
122 |
if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
|
|
123 |
}
|
| 121 |
hknight |
124 |
|
| 119 |
ghuddy |
125 |
if (test.indexOf('isVersionStr')!=-1) {
|
|
|
126 |
REresults = val.search(versionRE);
|
|
|
127 |
if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
|
|
128 |
}
|
| 121 |
hknight |
129 |
|
|
|
130 |
if (test.indexOf('isVersionNumber')!=-1) {
|
|
|
131 |
REresults = val.search(versionNumberRE);
|
|
|
132 |
if (REresults < 0) errors += val += ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
|
|
|
133 |
}
|
|
|
134 |
|
| 119 |
ghuddy |
135 |
if (test.indexOf('isURL')!=-1) {
|
|
|
136 |
REresults = val.match(urlRE);
|
|
|
137 |
if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
|
|
|
138 |
}
|
| 121 |
hknight |
139 |
|
| 119 |
ghuddy |
140 |
if (test.indexOf('isChangePassword')!=-1) {
|
|
|
141 |
pass=MM_findObj('FRpassword');
|
|
|
142 |
passc=MM_findObj('FRpasswordc');
|
|
|
143 |
if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
|
|
|
144 |
}
|
| 121 |
hknight |
145 |
|
| 119 |
ghuddy |
146 |
if (test.indexOf('maxLength')!=-1) {
|
|
|
147 |
p=test.indexOf(':');
|
|
|
148 |
max=test.substring(p+1);
|
|
|
149 |
if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
|
|
|
150 |
}
|
| 121 |
hknight |
151 |
|
| 119 |
ghuddy |
152 |
if (test.indexOf('notHTML')!=-1) {
|
|
|
153 |
if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
|
|
|
154 |
}
|
| 121 |
hknight |
155 |
|
| 119 |
ghuddy |
156 |
if (test.charAt(0)=='R') {
|
| 121 |
hknight |
157 |
|
|
|
158 |
if (test.indexOf('isNumber') != -1) {
|
| 119 |
ghuddy |
159 |
if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
|
|
|
160 |
}
|
| 121 |
hknight |
161 |
|
|
|
162 |
if (test.indexOf('inRange') != -1) {
|
| 119 |
ghuddy |
163 |
p=test.indexOf(':');
|
| 121 |
hknight |
164 |
min=test.substring(8,p);
|
| 119 |
ghuddy |
165 |
max=test.substring(p+1);
|
|
|
166 |
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
|
| 121 |
hknight |
167 |
}
|
|
|
168 |
|
| 119 |
ghuddy |
169 |
if (test.indexOf('inLength')!=-1) {
|
|
|
170 |
pl=test.indexOf('inLength')
|
|
|
171 |
p=test.indexOf(':');
|
| 121 |
hknight |
172 |
min=test.substring(pl+8,p);
|
| 119 |
ghuddy |
173 |
if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
|
| 121 |
hknight |
174 |
}
|
|
|
175 |
}
|
|
|
176 |
} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
|
|
|
177 |
|
|
|
178 |
|
| 119 |
ghuddy |
179 |
if (test.indexOf('isPassword')!=-1) {
|
|
|
180 |
pass=MM_findObj('FRpassword');
|
|
|
181 |
passc=MM_findObj('FRpasswordc');
|
|
|
182 |
if (!MM_findObj('FRdomainauth').checked) {
|
|
|
183 |
if (test.indexOf('inLength')!=-1) {
|
|
|
184 |
pl=test.indexOf('inLength')
|
|
|
185 |
p=test.indexOf(':');
|
| 121 |
hknight |
186 |
min=test.substring(pl+8,p);
|
| 119 |
ghuddy |
187 |
if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
|
| 121 |
hknight |
188 |
}
|
| 119 |
ghuddy |
189 |
if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
|
|
|
190 |
} else {
|
| 121 |
hknight |
191 |
if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
|
| 119 |
ghuddy |
192 |
}
|
| 121 |
hknight |
193 |
}
|
|
|
194 |
|
| 119 |
ghuddy |
195 |
if (test.indexOf('isDomainName')!=-1) {
|
|
|
196 |
if (MM_findObj('FRdomainauth').checked) {
|
| 121 |
hknight |
197 |
if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
|
| 119 |
ghuddy |
198 |
}
|
|
|
199 |
}
|
| 121 |
hknight |
200 |
|
| 119 |
ghuddy |
201 |
}
|
| 121 |
hknight |
202 |
}
|
|
|
203 |
|
| 119 |
ghuddy |
204 |
if (errors) {
|
|
|
205 |
alert('The following error(s) occurred:\n\n'+errors);
|
|
|
206 |
clickedButton=false;
|
|
|
207 |
} else {
|
|
|
208 |
clickedButton=true;
|
|
|
209 |
}
|
|
|
210 |
document.MM_returnValue = (errors == '');
|
| 121 |
hknight |
211 |
|
| 119 |
ghuddy |
212 |
if (MM_findObj('ProgressBar') && document.MM_returnValue) MM_findObj('ProgressBar').style.visibility='visible';
|
|
|
213 |
}
|
|
|
214 |
|
|
|
215 |
function isChecked(boxName, buttonId) {
|
|
|
216 |
var formButton = document.getElementById(buttonId);
|
|
|
217 |
var boxes = document.getElementsByName(boxName);
|
|
|
218 |
var btnChecked = false;
|
|
|
219 |
if (formButton) {
|
|
|
220 |
for (var i = 0; i < boxes.length; i++) {
|
|
|
221 |
if (boxes[i].checked) {
|
|
|
222 |
btnChecked = true;
|
|
|
223 |
}
|
|
|
224 |
}
|
| 121 |
hknight |
225 |
|
| 119 |
ghuddy |
226 |
if (btnChecked) {
|
|
|
227 |
formButton.disabled = false;
|
|
|
228 |
formButton.style.color="";
|
|
|
229 |
}
|
|
|
230 |
else {
|
|
|
231 |
formButton.disabled = true;
|
|
|
232 |
formButton.style.color="silver";
|
|
|
233 |
}
|
|
|
234 |
}
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
function confirmDelete(m)
|
|
|
238 |
{
|
|
|
239 |
var agree=confirm('Are you sure you want to delete '+m+'?');
|
|
|
240 |
if (agree) {
|
|
|
241 |
if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
|
|
|
242 |
return true;
|
|
|
243 |
} else {
|
|
|
244 |
return false;
|
| 121 |
hknight |
245 |
}
|
| 119 |
ghuddy |
246 |
}
|
|
|
247 |
|
|
|
248 |
function confirmAction(m)
|
|
|
249 |
{
|
|
|
250 |
var agree=confirm(m);
|
|
|
251 |
if (agree) {
|
|
|
252 |
if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
|
|
|
253 |
return true;
|
|
|
254 |
} else {
|
|
|
255 |
return false;
|
| 121 |
hknight |
256 |
}
|
| 119 |
ghuddy |
257 |
}
|
|
|
258 |
|
|
|
259 |
function DisplaySPAN(show) {
|
|
|
260 |
if (show) {
|
|
|
261 |
MM_findObj("spanHideDetails").style.display = "block";
|
|
|
262 |
MM_findObj("spanPkgInfo").style.display = "block";
|
|
|
263 |
MM_findObj("spanShowDetails").style.display = "none";
|
|
|
264 |
} else {
|
|
|
265 |
MM_findObj("spanHideDetails").style.display = "none";
|
|
|
266 |
MM_findObj("spanPkgInfo").style.display = "none";
|
|
|
267 |
MM_findObj("spanShowDetails").style.display = "block";
|
|
|
268 |
}
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
function ToggleDisplay () {
|
|
|
272 |
var i, args, div_name, visibility
|
|
|
273 |
args=ToggleDisplay.arguments;
|
|
|
274 |
for (i=0; i<(args.length); i+=1) {
|
|
|
275 |
div_name=args[i];
|
|
|
276 |
if ( MM_findObj(div_name).style.display == 'block' ) {
|
|
|
277 |
MM_findObj(div_name).style.display = 'none';
|
|
|
278 |
} else {
|
|
|
279 |
MM_findObj(div_name).style.display = 'block';
|
|
|
280 |
}
|
| 121 |
hknight |
281 |
|
| 119 |
ghuddy |
282 |
}
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
function Visible () {
|
| 121 |
hknight |
286 |
|
| 119 |
ghuddy |
287 |
var i, args, div_name, visibility
|
|
|
288 |
args=Visible.arguments;
|
|
|
289 |
for (i=0; i<(args.length); i+=2) {
|
|
|
290 |
div_name=args[i];
|
|
|
291 |
visibility=args[i+1]
|
|
|
292 |
MM_findObj(div_name).style.display = visibility;
|
| 121 |
hknight |
293 |
|
| 119 |
ghuddy |
294 |
}
|
|
|
295 |
}
|
|
|
296 |
|
|
|
297 |
function DisplayObjects () {
|
|
|
298 |
var i, args, div_name
|
|
|
299 |
args=DisplayObjects.arguments;
|
|
|
300 |
for (i=0; i<(args.length); i+=1) {
|
|
|
301 |
div_name=args[i];
|
|
|
302 |
MM_findObj(div_name).style.display = 'block';
|
|
|
303 |
}
|
|
|
304 |
}
|
|
|
305 |
|
| 121 |
hknight |
306 |
function GetCookieVal (offset) {
|
|
|
307 |
var endstr = document.cookie.indexOf (";", offset);
|
| 119 |
ghuddy |
308 |
if (endstr == -1) { endstr = document.cookie.length; }
|
|
|
309 |
return unescape(document.cookie.substring(offset, endstr));
|
|
|
310 |
}
|
|
|
311 |
|
|
|
312 |
|
| 121 |
hknight |
313 |
function GetCookie (name) {
|
|
|
314 |
var arg = name + "=";
|
|
|
315 |
var alen = arg.length;
|
|
|
316 |
var clen = document.cookie.length;
|
|
|
317 |
var i = 0;
|
| 119 |
ghuddy |
318 |
|
| 121 |
hknight |
319 |
while (i < clen) {
|
|
|
320 |
var j = i + alen;
|
|
|
321 |
if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
|
|
|
322 |
i = document.cookie.indexOf(" ", i) + 1;
|
|
|
323 |
if (i == 0) break;
|
|
|
324 |
}
|
| 119 |
ghuddy |
325 |
|
|
|
326 |
return null;
|
|
|
327 |
}
|
|
|
328 |
|
|
|
329 |
function go_submit( formname, actionname )
|
|
|
330 |
{
|
|
|
331 |
formname.action.value = actionname;
|
|
|
332 |
formname.submit();
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
function ExpandAll()
|
|
|
336 |
{
|
|
|
337 |
var elem
|
| 121 |
hknight |
338 |
|
| 119 |
ghuddy |
339 |
if (document.all)
|
|
|
340 |
{
|
|
|
341 |
// Run this for IE
|
|
|
342 |
elem = document.all;
|
|
|
343 |
} else {
|
|
|
344 |
// Run this for other browsers
|
|
|
345 |
elem = document.getElementsByTagName('div');
|
|
|
346 |
}
|
| 121 |
hknight |
347 |
|
| 119 |
ghuddy |
348 |
for (i in elem)
|
|
|
349 |
{
|
|
|
350 |
if (elem[i].id)
|
| 121 |
hknight |
351 |
{
|
| 119 |
ghuddy |
352 |
if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
|
|
|
353 |
if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
|
|
|
354 |
}
|
|
|
355 |
}
|
| 121 |
hknight |
356 |
|
| 119 |
ghuddy |
357 |
}
|
|
|
358 |
|
|
|
359 |
function CollapseAll()
|
|
|
360 |
{
|
|
|
361 |
var elem
|
| 121 |
hknight |
362 |
|
| 119 |
ghuddy |
363 |
if (document.all)
|
|
|
364 |
{
|
|
|
365 |
// Run this for IE
|
|
|
366 |
elem = document.all;
|
|
|
367 |
} else {
|
|
|
368 |
// Run this for other browsers
|
|
|
369 |
elem = document.getElementsByTagName('div');
|
|
|
370 |
}
|
| 121 |
hknight |
371 |
|
| 119 |
ghuddy |
372 |
for (i in elem)
|
|
|
373 |
{
|
|
|
374 |
if (elem[i].id)
|
| 121 |
hknight |
375 |
{
|
| 119 |
ghuddy |
376 |
if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
|
|
|
377 |
if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
|
|
|
378 |
}
|
|
|
379 |
}
|
| 121 |
hknight |
380 |
|
| 119 |
ghuddy |
381 |
}
|
|
|
382 |
|
|
|
383 |
|
|
|
384 |
function height()
|
| 121 |
hknight |
385 |
{
|
|
|
386 |
if( typeof( window.innerWidth ) == 'number' )
|
| 119 |
ghuddy |
387 |
{
|
|
|
388 |
h = window.innerHeight;
|
|
|
389 |
}
|
|
|
390 |
else if(document.documentElement&&(document.documentElement.clientHeight ))
|
|
|
391 |
{
|
|
|
392 |
h = document.documentElement.clientHeight;
|
| 121 |
hknight |
393 |
}
|
| 119 |
ghuddy |
394 |
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
|
|
|
395 |
{
|
|
|
396 |
h = document.body.clientHeight;
|
| 121 |
hknight |
397 |
}
|
|
|
398 |
|
| 119 |
ghuddy |
399 |
var e = document.getElementById("LayerDescription");
|
| 121 |
hknight |
400 |
|
| 119 |
ghuddy |
401 |
if (navigator.userAgent.indexOf('Internet Explorer'))
|
|
|
402 |
{
|
|
|
403 |
e.style.height = h - 350 + "px";
|
|
|
404 |
e.style.overflow = "auto";
|
|
|
405 |
}
|
|
|
406 |
else
|
|
|
407 |
{
|
|
|
408 |
// This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
|
|
|
409 |
e.style.minHeight= h - 350 + "px";
|
|
|
410 |
e.style.overflow = "auto";
|
|
|
411 |
}
|
|
|
412 |
}
|
|
|
413 |
|
| 121 |
hknight |
414 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
415 |
//
|
|
|
416 |
// MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild)
|
|
|
417 |
//
|
|
|
418 |
// pkgName eg EA_DocGen
|
|
|
419 |
// versionBase eg 1.2.3
|
|
|
420 |
// versionExt eg .cr
|
|
|
421 |
// isAutobuild true or false
|
|
|
422 |
//
|
|
|
423 |
// Returns true if version is valid, else false
|
|
|
424 |
//
|
|
|
425 |
// This function can and should be used instead of MM_validateForm to validate
|
|
|
426 |
// version numbers for new or reversioned package versions.
|
|
|
427 |
//
|
|
|
428 |
// So far, this function is used in the following situations:
|
|
|
429 |
// 1) Add new version to release (_form_new_version_page.asp)
|
|
|
430 |
// 2) Reversion existing version (_wform_rename_version.asp)
|
|
|
431 |
// 3) Add package to release (Form_add_pkg_versions.asp)
|
|
|
432 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
433 |
function MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild)
|
|
|
434 |
{
|
|
|
435 |
var errString = MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild);
|
|
|
436 |
if (errString.length > 0)
|
|
|
437 |
{
|
|
|
438 |
alert(errString);
|
|
|
439 |
return false;
|
|
|
440 |
}
|
|
|
441 |
return true;
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
445 |
//
|
|
|
446 |
// MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild)
|
|
|
447 |
//
|
|
|
448 |
// pkgName eg buildtool
|
|
|
449 |
// versionBase eg 1.2.3
|
|
|
450 |
// versionExt eg .cr
|
|
|
451 |
// isAutobuild true or false
|
|
|
452 |
//
|
|
|
453 |
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
|
|
|
454 |
//
|
|
|
455 |
// The MM_validateForm function should be modified to use this if possible, although I currently
|
|
|
456 |
// do not believe it has access to all the necessary parameter values needed.
|
|
|
457 |
//
|
|
|
458 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
459 |
function MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild)
|
|
|
460 |
{
|
|
|
461 |
var re_std_ver_format = /^\d+\.\d+\.\d+$/;
|
|
|
462 |
var re_cots_ver_format = /^[\w]+[\w\.\-]*$/; // starts with letter or digit or underscore, subsequent chars can be letters or digits or _ or . or -
|
|
|
463 |
var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/; // look for any two adjacent special characters
|
|
|
464 |
var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/; // look for any alphanumeric char
|
|
|
465 |
|
|
|
466 |
var forPkgName = "";
|
|
|
467 |
if (pkgName != null && pkgName.length > 0)
|
|
|
468 |
{
|
|
|
469 |
forPkgName = ", for package " + pkgName;
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
if(!isAutobuild)
|
|
|
473 |
{
|
|
|
474 |
if( versionBase.length == 0 )
|
|
|
475 |
{
|
|
|
476 |
return "Action failed: version number is of zero length" + forPkgName;
|
|
|
477 |
}
|
|
|
478 |
else if( versionExt != ".cots" && !re_std_ver_format.test(versionBase) )
|
|
|
479 |
{
|
|
|
480 |
return "Action failed: version is not of form (integer).(integer).(integer).(extension)" + forPkgName;
|
|
|
481 |
}
|
|
|
482 |
else if( versionExt == ".cots")
|
|
|
483 |
{
|
|
|
484 |
if( !re_cots_ver_format.test(versionBase) )
|
|
|
485 |
{
|
|
|
486 |
return "Action failed: COTS version must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed" + forPkgName;
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
if( re_cots_ver_format_exc1.test(versionBase) )
|
|
|
490 |
{
|
|
|
491 |
return "Action failed: COTS version cannot contain two adjacent special characters (underscore/dash/dot)" + forPkgName;
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
if( !re_cots_ver_format_exc2.test(versionBase) )
|
|
|
495 |
{
|
|
|
496 |
return "Action failed: COTS version must contain one or more alphanumeric characters" + forPkgName;
|
|
|
497 |
}
|
|
|
498 |
}
|
|
|
499 |
}
|
|
|
500 |
|
|
|
501 |
// everything ok - no error
|
|
|
502 |
return "";
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
|
|
|
506 |
|
| 119 |
ghuddy |
507 |
//-->
|