1 /* This is an automatically generated file. Do not edit. */
6 " monthName: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n"
7 " shortMonthName: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n"
8 " monthPattern: /Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/,\n"
9 " dayName: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n"
10 " padZeros: function(num, places) {\n"
11 " var s = String(num)\n"
12 " while (s.length < places)\n"
16 " convertCase: function(str, cmd) {\n"
18 " case '>': return str.toUpperCase();\n"
19 " case '<': return str.toLowerCase();\n"
20 " default: return str;\n"
24 "/* display must be kept in sync with an enum in pdf_form.c */\n"
36 " u: \"Underline\",\n"
39 " transparent: [ \"T\" ],\n"
40 " black: [ \"G\", 0 ],\n"
41 " white: [ \"G\", 1 ],\n"
42 " red: [ \"RGB\", 1,0,0 ],\n"
43 " green: [ \"RGB\", 0,1,0 ],\n"
44 " blue: [ \"RGB\", 0,0,1 ],\n"
45 " cyan: [ \"CMYK\", 1,0,0,0 ],\n"
46 " magenta: [ \"CMYK\", 0,1,0,0 ],\n"
47 " yellow: [ \"CMYK\", 0,0,1,0 ],\n"
48 " dkGray: [ \"G\", 0.25 ],\n"
49 " gray: [ \"G\", 0.5 ],\n"
50 " ltGray: [ \"G\", 0.75 ],\n"
53 "util.printd = function(fmt, d)\n"
55 " var regexp = /(m+|d+|y+|H+|h+|M+|s+|t+|[^mdyHhMst]+)/g;\n"
60 " var tokens = fmt.match(regexp);\n"
61 " var length = tokens ? tokens.length : 0;\n"
62 " for (i = 0; i < length; i++)\n"
64 " switch(tokens[i])\n"
66 " case 'mmmm': res += MuPDF.monthName[d.getMonth()]; break;\n"
67 " case 'mmm': res += MuPDF.monthName[d.getMonth()].substring(0,3); break;\n"
68 " case 'mm': res += MuPDF.padZeros(d.getMonth()+1, 2); break;\n"
69 " case 'm': res += d.getMonth()+1; break;\n"
70 " case 'dddd': res += MuPDF.dayName[d.getDay()]; break;\n"
71 " case 'ddd': res += MuPDF.dayName[d.getDay()].substring(0,3); break;\n"
72 " case 'dd': res += MuPDF.padZeros(d.getDate(), 2); break;\n"
73 " case 'd': res += d.getDate(); break;\n"
74 " case 'yyyy': res += d.getFullYear(); break;\n"
75 " case 'yy': res += d.getFullYear()%100; break;\n"
76 " case 'HH': res += MuPDF.padZeros(d.getHours(), 2); break;\n"
77 " case 'H': res += d.getHours(); break;\n"
78 " case 'hh': res += MuPDF.padZeros((d.getHours()+11)%12+1, 2); break;\n"
79 " case 'h': res += (d.getHours()+11)%12+1; break;\n"
80 " case 'MM': res += MuPDF.padZeros(d.getMinutes(), 2); break;\n"
81 " case 'M': res += d.getMinutes(); break;\n"
82 " case 'ss': res += MuPDF.padZeros(d.getSeconds(), 2); break;\n"
83 " case 's': res += d.getSeconds(); break;\n"
84 " case 'tt': res += d.getHours() < 12 ? 'am' : 'pm'; break;\n"
85 " case 't': res += d.getHours() < 12 ? 'a' : 'p'; break;\n"
86 " default: res += tokens[i];\n"
91 "util.printx = function(fmt, val)\n"
97 " var length = fmt ? fmt.length : 0;\n"
98 " while (i < length)\n"
100 " switch (fmt.charAt(i))\n"
104 " if (i >= length) return res;\n"
105 " res += fmt.charAt(i);\n"
108 " m = val.match(/\\w/);\n"
109 " if (!m) return res;\n"
110 " res += MuPDF.convertCase(m[0],cs);\n"
111 " val = val.replace(/^\\W*\\w/,'');\n"
114 " m = val.match(/[A-Za-z]/);\n"
115 " if (!m) return res;\n"
116 " res += MuPDF.convertCase(m[0],cs);\n"
117 " val = val.replace(/^[^A-Za-z]*[A-Za-z]/,'');\n"
120 " m = val.match(/\\d/);\n"
121 " if (!m) return res;\n"
123 " val = val.replace(/^\\D*\\d/,'');\n"
130 " if (!val) return res;\n"
131 " res += MuPDF.convertCase(val.charAt(0),cs);\n"
132 " val = val.substring(1);\n"
137 " cs = fmt.charAt(i);\n"
140 " res += MuPDF.convertCase(fmt.charAt(i),cs);\n"
147 "util.printf = function()\n"
150 " if (arguments.length < 1)\n"
154 " var regexp = /%[^dfsx]*[dfsx]|[^%]*/g;\n"
155 " var tokens = arguments[0].match(regexp);\n"
156 " var length = tokens ? tokens.length : 0;\n"
157 " for (i = 0; i < length; i++)\n"
159 " var tok = tokens[i];\n"
160 " if (tok.match(/^%/))\n"
162 " if (arg_i < arguments.length)\n"
164 " var val = arguments[arg_i++];\n"
166 " var neg = false;\n"
167 " var decsep_re = /^,[0123]/;\n"
168 " var flags_re = /^[+ 0#]+/;\n"
169 " var width_re = /^\\d+/;\n"
170 " var prec_re = /^\\.\\d+/;\n"
171 " var conv_re = /^[dfsx]/;\n"
172 " tok = tok.replace(/^%/, \"\");\n"
173 " var decsep = tok.match(decsep_re);\n"
174 " if (decsep) decsep = decsep[0];\n"
175 " tok = tok.replace(decsep_re, \"\");\n"
176 " var flags = tok.match(flags_re);\n"
177 " if (flags) flags = flags[0];\n"
178 " tok = tok.replace(flags_re, \"\");\n"
179 " var width = tok.match(width_re);\n"
180 " if (width) width = width[0];\n"
181 " tok = tok.replace(width_re, \"\");\n"
182 " var prec = tok.match(prec_re);\n"
183 " if (prec) prec = prec[0];\n"
184 " tok = tok.replace(prec_re, \"\");\n"
185 " var conv = tok.match(conv_re);\n"
186 " if (conv) conv = conv[0];\n"
187 " prec = prec ? Number(prec.replace(/^\\./, '')) : 0;\n"
188 " var poschar = (flags && flags.match(/[+ ]/)) ? flags.match(/[+ ]/)[0] : '';\n"
189 " var pad = (flags && flags.match(/0/)) ? '0' : ' ';\n"
190 " var point = '.';\n"
196 " case ',0': thou = ','; break;\n"
197 " case ',1': break;\n"
198 " case ',2': thou = '.'; point = ','; break;\n"
199 " case ',3': point = ','; break;\n"
205 " val = Math.floor(val);\n"
206 " neg = (val < 0);\n"
209 " // Convert to hex\n"
212 " fval = '0123456789ABCDEF'.charAt(val%16) + fval;\n"
213 " val = Math.floor(val/16);\n"
216 " fval = '-' + fval;\n"
218 " fval = poschar + fval;\n"
221 " fval = String(Math.floor(val));\n"
224 " // Always pad strings with space\n"
226 " fval = String(val);\n"
229 " fval = String(val);\n"
232 " var frac = fval.match(/\\.\\d+/);\n"
236 " // Matched string includes the dot, so make it\n"
237 " // prec+1 in length\n"
238 " if (frac.length > prec+1)\n"
239 " frac = frac.substring(0, prec+1);\n"
240 " else if(frac.length < prec+1)\n"
241 " frac += new Array(prec+1-frac.length+1).join('0');\n"
242 " fval = fval.replace(/\\.\\d+/, frac);\n"
247 " if (conv.match(/[fd]/))\n"
250 " fval = poschar + fval;\n"
251 " if (point !== '.')\n"
252 " fval.replace(/\\./, point);\n"
255 " var intpart = fval.match(/\\d+/)[0];\n"
256 " intpart = new Array(2-(intpart.length+2)%3+1).join('0') + intpart;\n"
257 " intpart = intpart.match(/.../g).join(thou).replace(/^0*[,.]?/,'');\n"
258 " fval = fval.replace(/\\d+/, intpart);\n"
261 " if (width && fval.length < width)\n"
262 " fval = new Array(width - fval.length + 1).join(pad) + fval;\n"
273 "function AFMergeChange(event)\n"
275 " return event.value;\n"
277 "function AFMakeNumber(str)\n"
279 " var nums = str.match(/\\d+/g);\n"
282 " var res = nums.join('.');\n"
283 " if (str.match(/^[^0-9]*\\./))\n"
285 " return res * (str.match(/-/) ? -1.0 : 1.0);\n"
287 "function AFExtractTime(dt)\n"
289 " var ampm = dt.match(/(am|pm)/);\n"
290 " dt = dt.replace(/(am|pm)/, '');\n"
291 " var t = dt.match(/\\d{1,2}:\\d{1,2}:\\d{1,2}/);\n"
292 " dt = dt.replace(/\\d{1,2}:\\d{1,2}:\\d{1,2}/, '');\n"
295 " t = dt.match(/\\d{1,2}:\\d{1,2}/);\n"
296 " dt = dt.replace(/\\d{1,2}:\\d{1,2}/, '');\n"
298 " return [dt, t?t[0]+(ampm?ampm[0]:''):''];\n"
300 "function AFParseDateOrder(fmt)\n"
304 " // Ensure all present with those not added in default order\n"
306 " for (i = 0; i < fmt.length; i++)\n"
308 " var c = fmt.charAt(i);\n"
309 " if ('ymd'.indexOf(c) !== -1 && order.indexOf(c) === -1)\n"
314 "function AFMatchMonth(d)\n"
316 " var m = d.match(MuPDF.monthPattern);\n"
317 " return m ? MuPDF.shortMonthName.indexOf(m[0]) : null;\n"
319 "function AFParseTime(str, d)\n"
325 " var ampm = str.match(/(am|pm)/);\n"
326 " var nums = str.match(/\\d+/g);\n"
327 " var hour, min, sec;\n"
331 " switch (nums.length)\n"
334 " sec = parseInt(nums[2]);\n"
336 " hour = parseInt(nums[0]);\n"
337 " min = parseInt(nums[1]);\n"
342 " ampm = ampm && ampm[0]\n"
343 " if (ampm === 'am' && hour < 12)\n"
344 " hour = 12 + hour;\n"
345 " if (ampm === 'pm' && hour >= 12)\n"
346 " hour = 0 + hour - 12;\n"
347 " d.setHours(hour, min, sec);\n"
348 " if (d.getHours() !== hour || d.getMinutes() !== min || d.getSeconds() !== sec)\n"
352 "function AFParseDateEx(d, fmt)\n"
355 " var dt = AFExtractTime(d);\n"
356 " var nums = dt[0].match(/\\d+/g);\n"
357 " var order = AFParseDateOrder(fmt);\n"
358 " var text_month = AFMatchMonth(dt[0]);\n"
359 " var dout = new Date();\n"
360 " var year = dout.getFullYear();\n"
361 " var month = dout.getMonth();\n"
362 " var date = dout.getDate();\n"
363 " dout.setHours(12,0,0);\n"
364 " if (!nums || nums.length < 1 || nums.length > 3)\n"
366 " if (nums.length < 3 && text_month)\n"
368 " // Use the text month rather than one of the numbers\n"
369 " month = text_month;\n"
370 " order = order.replace('m','');\n"
372 " order = order.substring(0, nums.length);\n"
373 " // If year and month specified but not date then use the 1st\n"
374 " if (order === \"ym\" || (order === \"y\" && text_month))\n"
376 " for (i = 0; i < nums.length; i++)\n"
378 " switch (order.charAt(i))\n"
380 " case 'y': year = parseInt(nums[i]); break;\n"
381 " case 'm': month = parseInt(nums[i]) - 1; break;\n"
382 " case 'd': date = parseInt(nums[i]); break;\n"
387 " if (fmt.search(\"yyyy\") !== -1)\n"
390 " year = 1900 + year;\n"
391 " else if (year >= 0)\n"
392 " year = 2000 + year;\n"
394 " dout.setFullYear(year, month, date);\n"
395 " if (dout.getFullYear() !== year || dout.getMonth() !== month || dout.getDate() !== date)\n"
397 " return AFParseTime(dt[1], dout);\n"
399 "function AFDate_KeystrokeEx(fmt)\n"
401 " if (event.willCommit && !AFParseDateEx(event.value, fmt))\n"
403 " app.alert(\"The date/time entered (\"+event.value+\") does not match the format (\"+fmt+\") of the field [ \"+event.target.name+\" ]\");\n"
404 " event.rc = false;\n"
407 "function AFDate_Keystroke(index)\n"
409 " var formats = ['m/d','m/d/yy','mm/dd/yy','mm/yy','d-mmm','d-mmm-yy','dd-mm-yy','yy-mm-dd',\n"
410 " 'mmm-yy','mmmm-yy','mmm d, yyyy','mmmm d, yyyy','m/d/yy h:MM tt','m/d/yy HH:MM'];\n"
411 " AFDate_KeystrokeEx(formats[index]);\n"
413 "function AFDate_FormatEx(fmt)\n"
415 " var d = AFParseDateEx(event.value, fmt);\n"
416 " event.value = d ? util.printd(fmt, d) : \"\";\n"
418 "function AFDate_Format(index)\n"
420 " var formats = ['m/d','m/d/yy','mm/dd/yy','mm/yy','d-mmm','d-mmm-yy','dd-mm-yy','yy-mm-dd',\n"
421 " 'mmm-yy','mmmm-yy','mmm d, yyyy','mmmm d, yyyy','m/d/yy h:MM tt','m/d/yy HH:MM'];\n"
422 " AFDate_FormatEx(formats[index]);\n"
424 "function AFTime_Keystroke(index)\n"
426 " if (event.willCommit && !AFParseTime(event.value, null))\n"
428 " app.alert(\"The value entered (\"+event.value+\") does not match the format of the field [ \"+event.target.name+\" ]\");\n"
429 " event.rc = false;\n"
432 "function AFTime_FormatEx(fmt)\n"
434 " var d = AFParseTime(event.value, null);\n"
435 " event.value = d ? util.printd(fmt, d) : '';\n"
437 "function AFTime_Format(index)\n"
439 " var formats = ['HH:MM','h:MM tt','HH:MM:ss','h:MM:ss tt'];\n"
440 " AFTime_FormatEx(formats[index]);\n"
442 "function AFSpecial_KeystrokeEx(fmt)\n"
445 " var val = event.value;\n"
449 " var length = fmt ? fmt.length : 0;\n"
450 " while (i < length)\n"
452 " switch (fmt.charAt(i))\n"
456 " if (i >= length)\n"
458 " res += fmt.charAt(i);\n"
459 " if (val && val.charAt(0) === fmt.charAt(i))\n"
460 " val = val.substring(1);\n"
463 " m = val.match(/^\\w/);\n"
466 " event.rc = false;\n"
469 " res += MuPDF.convertCase(m[0],cs);\n"
470 " val = val.substring(1);\n"
473 " m = val.match(/^[A-Za-z]/);\n"
476 " event.rc = false;\n"
479 " res += MuPDF.convertCase(m[0],cs);\n"
480 " val = val.substring(1);\n"
483 " m = val.match(/^\\d/);\n"
486 " event.rc = false;\n"
490 " val = val.substring(1);\n"
499 " event.rc = false;\n"
502 " res += MuPDF.convertCase(val.charAt(0),cs);\n"
503 " val = val.substring(1);\n"
508 " cs = fmt.charAt(i);\n"
511 " res += fmt.charAt(i);\n"
512 " if (val && val.charAt(0) === fmt.charAt(i))\n"
513 " val = val.substring(1);\n"
519 " event.value = res;\n"
520 " else if (event.willCommit)\n"
521 " app.alert(\"The value entered (\"+event.value+\") does not match the format of the field [ \"+event.target.name+\" ] should be \"+fmt);\n"
523 "function AFSpecial_Keystroke(index)\n"
525 " if (event.willCommit)\n"
530 " if (!event.value.match(/^\\d{5}$/))\n"
531 " event.rc = false;\n"
534 " if (!event.value.match(/^\\d{5}[-. ]?\\d{4}$/))\n"
535 " event.rc = false;\n"
538 " if (!event.value.match(/^((\\(\\d{3}\\)|\\d{3})[-. ]?)?\\d{3}[-. ]?\\d{4}$/))\n"
539 " event.rc = false;\n"
542 " if (!event.value.match(/^\\d{3}[-. ]?\\d{2}[-. ]?\\d{4}$/))\n"
543 " event.rc = false;\n"
547 " app.alert(\"The value entered (\"+event.value+\") does not match the format of the field [ \"+event.target.name+\" ]\");\n"
550 "function AFSpecial_Format(index)\n"
556 " res = util.printx('99999', event.value);\n"
559 " res = util.printx('99999-9999', event.value);\n"
562 " res = util.printx('9999999999', event.value);\n"
563 " res = util.printx(res.length >= 10 ? '(999) 999-9999' : '999-9999', event.value);\n"
566 " res = util.printx('999-99-9999', event.value);\n"
569 " event.value = res ? res : '';\n"
571 "function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend)\n"
573 " if (sepStyle & 2)\n"
575 " if (!event.value.match(/^[+-]?\\d*[,.]?\\d*$/))\n"
576 " event.rc = false;\n"
580 " if (!event.value.match(/^[+-]?\\d*\\.?\\d*$/))\n"
581 " event.rc = false;\n"
583 " if (event.willCommit)\n"
585 " if (!event.value.match(/\\d/))\n"
586 " event.rc = false;\n"
588 " app.alert(\"The value entered (\"+event.value+\") does not match the format of the field [ \"+event.target.name+\" ]\");\n"
591 "function AFNumber_Format(nDec,sepStyle,negStyle,currStyle,strCurrency,bCurrencyPrepend)\n"
593 " var val = event.value;\n"
596 " var point = sepStyle&2 ? ',' : '.';\n"
597 " var separator = sepStyle&2 ? '.' : ',';\n"
598 " if (/^\\D*\\./.test(val))\n"
600 " var groups = val.match(/\\d+/g);\n"
603 " switch (groups.length)\n"
609 " intpart = groups[0];\n"
612 " fracpart = groups.pop();\n"
613 " intpart = groups.join('');\n"
616 " // Remove leading zeros\n"
617 " intpart = intpart.replace(/^0*/,'');\n"
620 " if ((sepStyle & 1) === 0)\n"
622 " // Add the thousands sepearators: pad to length multiple of 3 with zeros,\n"
623 " // split into 3s, join with separator, and remove the leading zeros\n"
624 " intpart = new Array(2-(intpart.length+2)%3+1).join('0') + intpart;\n"
625 " intpart = intpart.match(/.../g).join(separator).replace(/^0*/,'');\n"
629 " // Adjust fractional part to correct number of decimal places\n"
630 " fracpart += new Array(nDec+1).join('0');\n"
631 " fracpart = fracpart.substring(0,nDec);\n"
633 " intpart += point+fracpart;\n"
634 " if (bCurrencyPrepend)\n"
635 " intpart = strCurrency+intpart;\n"
637 " intpart += strCurrency;\n"
638 " if (/-/.test(val))\n"
640 " switch (negStyle)\n"
643 " intpart = '-'+intpart;\n"
649 " intpart = '('+intpart+')';\n"
654 " event.target.textColor = /-/.test(val) ? color.red : color.black;\n"
655 " event.value = intpart;\n"
657 "function AFPercent_Keystroke(nDec, sepStyle)\n"
659 " AFNumber_Keystroke(nDec, sepStyle, 0, 0, \"\", true);\n"
661 "function AFPercent_Format(nDec, sepStyle)\n"
663 " var val = AFMakeNumber(event.value);\n"
666 " event.value = '';\n"
669 " event.value = (val * 100) + '';\n"
670 " AFNumber_Format(nDec, sepStyle, 0, 0, \"%\", false);\n"
672 "function AFSimple_Calculate(op, list)\n"
687 " if (typeof list === 'string')\n"
688 " list = list.split(/ *, */);\n"
689 " for (i = 0; i < list.length; i++)\n"
691 " var field = getField(list[i]);\n"
692 " var value = Number(field.value);\n"
705 " if (i === 0 || value < res)\n"
709 " if (i === 0 || value > res)\n"
714 " if (op === 'AVG')\n"
715 " res /= list.length;\n"
716 " event.value = res;\n"
718 "function AFRange_Validate(lowerCheck, lowerLimit, upperCheck, upperLimit)\n"
720 " if (upperCheck && event.value > upperLimit)\n"
722 " event.rc = false;\n"
724 " if (lowerCheck && event.value < lowerLimit)\n"
726 " event.rc = false;\n"
730 " if (lowerCheck && upperCheck)\n"
731 " app.alert(util.printf(\"The entered value (\"+event.value+\") must be greater than or equal to %s and less than or equal to %s\", lowerLimit, upperLimit));\n"
732 " else if (lowerCheck)\n"
733 " app.alert(util.printf(\"The entered value (\"+event.value+\") must be greater than or equal to %s\", lowerLimit));\n"
735 " app.alert(util.printf(\"The entered value (\"+event.value+\") must be less than or equal to %s\", upperLimit));\n"