How to use requireExactMatch method in qawolf

Best JavaScript code snippet using qawolf

PTUtil_002.js

Source:PTUtil_002.js Github

copy

Full Screen

12PTBrowserInfo = function()3{4 return this;5}6PTBrowserInfo.VERSION = '246682';7PTBrowserInfo.init = function()8{9 PTBrowserInfo.USER_AGENT = navigator.userAgent;10 PTBrowserInfo.MSIE_VERSION = PTBrowserInfo.getIEVersion();11 PTBrowserInfo.NETSCAPE_VERSION = PTBrowserInfo.getNNVersion();12 PTBrowserInfo.IS_DOM = (document.getElementById);13 PTBrowserInfo.IS_OPERA = (/opera [56789]|opera\/[56789]/i.test(PTBrowserInfo.USER_AGENT));14 PTBrowserInfo.IS_SAFARI = (/safari/i.test(PTBrowserInfo.USER_AGENT));15 PTBrowserInfo.IS_MSIE = (PTBrowserInfo.MSIE_VERSION && document.all && !PTBrowserInfo.IS_OPERA);16 PTBrowserInfo.IS_MSIE_4 = (PTBrowserInfo.MSIE_VERSION < 5.0);17 PTBrowserInfo.IS_MSIE_5 = ((PTBrowserInfo.MSIE_VERSION >= 5.0) && (PTBrowserInfo.MSIE_VERSION < 5.5));18 PTBrowserInfo.IS_MSIE_5_5 = ((PTBrowserInfo.MSIE_VERSION >= 5.5) && (PTBrowserInfo.MSIE_VERSION < 6.0));19 PTBrowserInfo.IS_MSIE_6 = ((PTBrowserInfo.MSIE_VERSION >= 6.0) && (PTBrowserInfo.MSIE_VERSION < 7.0));20 PTBrowserInfo.IS_MSIE_7 = ((PTBrowserInfo.MSIE_VERSION >= 7.0) && (PTBrowserInfo.MSIE_VERSION < 7.5));21 PTBrowserInfo.IS_NETSCAPE_4 = ((PTBrowserInfo.NETSCAPE_VERSION > 0) && (PTBrowserInfo.NETSCAPE_VERSION < 5.0));22 PTBrowserInfo.IS_NETSCAPE_6 = ((PTBrowserInfo.NETSCAPE_VERSION >= 5.0) && (PTBrowserInfo.NETSCAPE_VERSION < 7.0));23 PTBrowserInfo.IS_NETSCAPE_7 = (PTBrowserInfo.NETSCAPE_VERSION >= 7.0);24 PTBrowserInfo.IS_MOZILLA = ((!PTBrowserInfo.IS_OPERA) && (/gecko/i.test(PTBrowserInfo.USER_AGENT)));25 PTBrowserInfo.IS_NETSCAPE_DOM = (PTBrowserInfo.IS_MOZILLA || (PTBrowserInfo.NETSCAPE_VERSION >= 5.0));26 PTBrowserInfo.IS_HTTPS = (document.location.protocol.indexOf('https:') > -1);27 PTBrowserInfo.IS_XP_SP2 = (window.navigator.userAgent.indexOf('SV1') > -1);28 PTBrowserInfo.IS_NT4 = (window.navigator.userAgent.indexOf('Windows NT 4.0') > -1);29 PTBrowserInfo.isInitialized = true;30}31PTBrowserInfo.getIEVersion = function()32{33 var version = 0;34 var ua = new String(navigator.userAgent);35 if (ua.indexOf('MSIE ') > -1)36 {37 version = parseFloat(ua.substr(ua.indexOf('MSIE ') + 5));38 }39 return version;40}41PTBrowserInfo.getNNVersion = function()42{43 var version = 0;44 if(navigator.appName == 'Netscape')45 {46 version = parseFloat(navigator.appVersion);47 if(version >= 5)48 {49 if (typeof navigator.vendorSub != 'undefined')50 {51 version = parseFloat(navigator.vendorSub);52 }53 }54 }55 return version;56}57//: Initialize PTBrowserInfo once.58if (!PTBrowserInfo.isInitialized)59{60 PTBrowserInfo.init();61}62PTCommonUtil = function()63{64 return this;65}66PTCommonUtil.VERSION = '246682';67PTCommonUtil.getIEVersion = function()68{69 return PTBrowserInfo.getIEVersion();70}71PTCommonUtil.getNNVersion = function()72{73 return PTBrowserInfo.getNNVersion();74}75PTCommonUtil.getElementById = function(id)76{77 return PTDOMUtil.getElementById(id);78}79PTCommonUtil.copyObject = function(srcObj,destObj)80{81 if (!destObj)82 {83 if (srcObj.constructor) { destObj = srcObj.constructor(); }84 else { destObj = new Object(); }85 }86 var t = typeof srcObj;87 var isPrimitive = false;88 if (t == 'string') { isPrimitive = true; }89 else if (t == 'number') { isPrimitive = true; }90 else if (t == 'boolean') { isPrimitive = true; }91 if (isPrimitive) { destObj = srcObj; }92 else93 { if (srcObj && srcObj.slice && srcObj.sort && srcObj.length)94 {95 var len = srcObj.length;96 for (var a = 0; a < len; a++) { destObj[a] = srcObj[a]; }97 }98 else99 {100 for (var i in srcObj)101 {102 //: Isomorphic "SmartClient" (note the irony please) adds circular references as a by-product of103 //: extending the native Array class. We need to special case the exclusion of these, to prevent insanity.104 //: There is no need to explicitly copy 'function' objects for Arrays anyway -- they will be included105 //: automatically since we have instantiated copies via calling the 'new Array' constructor, above.106 if (srcObj.Class && (srcObj.Class == 'Array') && (typeof srcObj[i] == 'function')) { continue; }107 var t = typeof srcObj[i];108 var isPrimitive = false;109 if (t == 'string') { isPrimitive = true; }110 else if (t == 'number') { isPrimitive = true; }111 else if (t == 'boolean') { isPrimitive = true; }112 if (isPrimitive) { destObj[i] = srcObj[i]; }113 else { destObj[i] = PTCommonUtil.copyObject(srcObj[i]); }114 }115 }116 }117 return destObj;118}119PTCommonUtil.getServerFromURL = function(url)120{121 var link = document.createElement('A');122 link.href = url;123 return link.hostname;124}125PTCommonUtil.isDefined = function(obj)126{127 var type = typeof(obj);128 return (!(type == 'unknown') && !(type == 'undefined'));129}130PTCommonUtil.sortHashByKeys = function(hash,preserveFirstKey,isCaseInsensitive,doReverseSort)131{132 var keys = new Array();133 var sortedHash = new Object();134 var firstKey;135 var isNumericList = false;136 for (var key in hash) { firstKey = key; break; }137 var fkStr = new String(firstKey);138 if (!isNaN(parseInt(fkStr.charAt(0)))) { isNumericList = true; }139 for (var key in hash) { keys[keys.length] = key; }140 var sortedKeys;141 if (isNumericList)142 {143 sortedKeys = keys.sort(PTCommonUtil.sortNumeric);144 preserveFirstKey = false;145 }146 else if (doReverseSort)147 {148 if (isCaseInsensitive) { sortedKeys = keys.sort(PTCommonUtil.sortReverseCaseInsensitive); }149 else { sortedKeys = keys.sort(PTCommonUtil.sortReverse); }150 }151 else if (isCaseInsensitive)152 {153 sortedKeys = keys.sort(PTCommonUtil.sortCaseInsensitive);154 }155 else156 {157 sortedKeys = keys.sort(PTCommonUtil.sortForward);158 }159 if (preserveFirstKey) { sortedHash[firstKey] = hash[firstKey]; }160 for (var i = 0; i < sortedKeys.length; i++)161 {162 if (preserveFirstKey && (sortedKeys[i] == firstKey)) { continue; }163 sortedHash[sortedKeys[i]] = hash[sortedKeys[i]];164 }165 return sortedHash;166}167PTCommonUtil.sortNumeric = function(a,b)168{169 var numa = parseInt(a);170 var numb = parseInt(b);171 if (!isNaN(numa) && !isNaN(numb)) { return numa - numb; }172 else { return -1; }173}174PTCommonUtil.sortCaseInsensitive = function(aa,bb)175{176 var a = (new String(aa)).toLowerCase();177 var b = (new String(bb)).toLowerCase();178 if (a.valueOf() == b.valueOf()) { return 0; }179 var minLength = (a.length > b.length) ? b.length : a.length;180 var curPos = 0;181 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }182 var ac = a.charCodeAt(curPos);183 var bc = b.charCodeAt(curPos);184 if (isNaN(ac)) { return -1; }185 else if (isNaN(bc)) { return 1; }186 else { return ac - bc; }187}188PTCommonUtil.sortReverseCaseInsensitive = function(aa,bb)189{190 var a = (new String(aa)).toLowerCase();191 var b = (new String(bb)).toLowerCase();192 if (a.valueOf() == b.valueOf()) { return 0; }193 var minLength = (a.length > b.length) ? b.length : a.length;194 var curPos = 0;195 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }196 var ac = a.charCodeAt(curPos);197 var bc = b.charCodeAt(curPos);198 if (isNaN(ac)) { return 1; }199 else if (isNaN(bc)) { return -1; }200 else { return bc - ac; }201}202PTCommonUtil.sortReverse = function(aa,bb)203{204 var a = new String(aa);205 var b = new String(bb);206 if (a.valueOf() == b.valueOf()) { return 0; }207 var minLength = (a.length > b.length) ? b.length : a.length;208 var curPos = 0;209 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }210 var retValue = b.charCodeAt(curPos) - a.charCodeAt(curPos);211 if (isNaN(retValue)) { return 0; }212 else { return retValue; }213}214PTCommonUtil.sortForward = function(aa,bb)215{216 var a = new String(aa);217 var b = new String(bb);218 if (a.valueOf() == b.valueOf()) { return 0; }219 var minLength = (a.length > b.length) ? b.length : a.length;220 var curPos = 0;221 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }222 var retValue = a.charCodeAt(curPos) - b.charCodeAt(curPos);223 if (isNaN(retValue)) { return 0; }224 else { return retValue; }225}226PTCommonUtil.getValueForStyleAttribute = function(s,attr)227{228 var s = new String(s);229 var attr = new String(attr);230 var attrPos = s.indexOf(attr);231 if (attrPos == -1) { return; }232 var s = s.substr(attrPos + attr.length + 1);233 while ((s.charAt(0) == ' ') || (s.charAt(0) == ':')) { s = s.substr(1); }234 var semiPos = s.indexOf(';');235 if (semiPos == -1) { semiPos = (s.length - 1); }236 s = s.substr(0,(semiPos));237 return s;238}239PTCommonUtil.getRelativePosition = function (childDiv,parentDiv,ignoreBorders)240{241 var pos = new Object();242 pos.x = 0;243 pos.y = 0;244 if (!childDiv) { return pos; }245 if (!parentDiv) { parentDiv = document.body; }246 while (1)247 {248 if (childDiv == parentDiv) { break; }249 pos.x -= parseInt(childDiv.scrollLeft);250 pos.y -= parseInt(childDiv.scrollTop);251 var bbw = parseInt(childDiv.style.borderBottomWidth);252 var ot = childDiv.offsetTop;253 pos.y += ot + ((bbw && !ignoreBorders) ? bbw : 0);254 var blw = parseInt(childDiv.style.borderLeftWidth);255 var ol = childDiv.offsetLeft;256 pos.x += ol + ((blw && !ignoreBorders) ? blw : 0);257 if (childDiv.offsetParent) { childDiv = childDiv.offsetParent; }258 else { break; }259 }260 return pos;261}262PTCommonUtil.scrollDivIntoView = function (object,container)263{264 if (!object) { return; }265 if (!container) { container = document.body; }266 var pos = PTCommonUtil.getRelativePosition(object,container,true);267 container.scrollTop = pos.y;268}269if (!PTCommonUtil.CSSClassCache) 270{271 PTCommonUtil.CSSClassCache = new Object(); 272}273PTCommonUtil.getCSSClassStyles = function(className)274{275 var classStyles = PTCommonUtil.CSSClassCache[className];276 if (!classStyles)277 { var tmpElm = document.createElement('span');278 tmpElm.style.visibility = 'hidden';279 tmpElm.style.display = 'none';280 tmpElm.className = className;281 document.body.appendChild(tmpElm);282 if (document.all) 283 {284 PTCommonUtil.CSSClassCache[className] = tmpElm.currentStyle;285 }286 else if (document.getElementById && !document.all) 287 {288 PTCommonUtil.CSSClassCache[className] = document.defaultView.getComputedStyle(tmpElm, '');289 }290 }291 return PTCommonUtil.CSSClassCache[className]; 292}293PTCommonUtil.getCSSClassStyleProperty = function(className, propertyName)294{295 var classStyles = PTCommonUtil.getCSSClassStyles(className); 296 if (classStyles) 297 { 298 if (PTBrowserInfo.IS_NETSCAPE_DOM && PTBrowserInfo.NETSCAPE_VERSION < 7.1)299 { var convertedPropertyName = propertyName.replace(/([a-z])([A-Z])/, '$1-$2').toLowerCase();300 return classStyles.getPropertyValue(convertedPropertyName);301 }302 else303 {304 return classStyles[propertyName]; 305 }306 }307 return null;308}309PTCommonUtil.getStyleClassFromDocument = function(doc,className)310{311 var re = new RegExp('\\.' + className + '$', 'gi');312 if (doc.all) {313 for (var s = 0; s < doc.styleSheets.length; s++) {314 for (var r = 0; r < doc.styleSheets[s].rules.length; r++) {315 if (doc.styleSheets[s].rules[r].selectorText.search(re) != -1) {316 return doc.styleSheets[s].rules[r].style;317 }318 }319 }320 } else if (doc.getElementById) {321 for (var s = 0; s < doc.styleSheets.length; s++) {322 for (var r = 0; r < doc.styleSheets[s].cssRules.length; r++) {323 if (doc.styleSheets[s].cssRules[r].selectorText.search(re) != -1) {324 doc.styleSheets[s].cssRules[r].sheetIndex = s;325 doc.styleSheets[s].cssRules[r].ruleIndex = s;326 return doc.styleSheets[s].cssRules[r].style;327 }328 }329 }330 } else if (doc.layers) {331 return doc.classes[className].all;332 } else {333 return false;334 }335}336PTCommonUtil.getStyleClass = function(className)337{338 return PTCommonUtil.getStyleClassFromDocument(document,className);339}340PTCommonUtil.getStyleClassProperty = function(className,attrName)341{342 var styleClass = PTCommonUtil.getStyleClass(className);343 return (styleClass) ? styleClass[attrName] : '';344}345PTCommonUtil.getRemoteStyleClassProperty = function(doc,className,attrName)346{347 var styleClass = PTCommonUtil.getStyleClassFromDocument(doc,className);348 return (styleClass) ? styleClass[attrName] : '';349}350PTCommonUtil.parseGet = function(url)351{352 var FORM_DATA = new Object();353 var separator = ',';354 var query;355 if (url) { query = url; }356 else {357 query = '' + top.document.location.href;358 }359 query = query.substring((query.indexOf('?')) + 1);360 if (query.length < 1) { return false; } 361 var keypairs = new Object();362 var numKP = 1;363 while (query.indexOf('&') > -1) {364 keypairs[numKP] = query.substring(0,query.indexOf('&'));365 query = query.substring((query.indexOf('&')) + 1);366 numKP++;367 }368 keypairs[numKP] = query;369 for (var i in keypairs) {370 var keyName = keypairs[i].substring(0,keypairs[i].indexOf('=')); var keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1); while (keyValue.indexOf('+') > -1) {371 keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1); }372 keyValue = unescape(keyValue);373 if (FORM_DATA[keyName]) {374 FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;375 } else {376 FORM_DATA[keyName] = keyValue; }377 }378 return FORM_DATA;379}380PTCommonUtil.wait = function(ms)381{382 var Start = new Date().valueOf();383 while ((new Date().valueOf() - Start) < ms) {}384}385PTCommonUtil.alertVersion = function()386{387 var str = '';388 var controls = new Array('PTCalendarControl','PTTableControl','PTTreeControl','PTTabularLayoutManager','PTCalendarManager');389 var foundControl = false;390 for (var i = 0; i < controls.length; i++)391 {392 if (window[controls[i]]) { foundControl = controls[i]; break; }393 else if(window['' + controls[i]]) { foundControl = '' + controls[i]; break;}394 }395 if (foundControl)396 {397 var jscontrol = eval(foundControl);398 if (jscontrol.VERSION)399 {400 var version = jscontrol.VERSION;401 str += 'PTControls (v. ' + version + ')\n';402 if (window.PTControls)403 {404 for (var obj in window.PTControls)405 {406 if (obj == 'properties') { continue; }407 var o = window.PTControls[obj];408 if (o && o.objName && o.className)409 {410 var type = ' (' + o.className + ')';411 str += ' ' + o.objName + type + '\n';412 }413 }414 }415 else if(window.PTControls)416 {417 for (var obj in window.PTControls)418 {419 if (obj == 'properties') { continue; }420 var o = window.PTControls[obj];421 if (o && o.objName && o.className)422 {423 var type = ' (' + o.className + ')';424 str += ' ' + o.objName + type + '\n';425 }426 }427 }428 }429 }430 if (typeof PTDatepicker != 'undefined')431 {432 if (PTDatepicker.VERSION) { str += 'PTDatepicker (v. ' + PTDatepicker.VERSION + ')\n'; }433 }434 else if (typeof PTDatepicker != 'undefined')435 {436 if (PTDatepicker.VERSION) { str += 'PTDatepicker (v. ' + PTDatepicker.VERSION + ')\n'; }437 }438 if (typeof PTXMLWrapper != 'undefined')439 {440 if (PTXMLWrapper.VERSION) { str += 'PTXML (v. ' + PTXMLWrapper.VERSION + ')\n'; }441 }442 else if (typeof PTXMLWrapper != 'undefined')443 {444 if (PTXMLWrapper.VERSION) { str += 'PTXML (v. ' + PTXMLWrapper.VERSION + ')\n'; }445 }446 str += 'PTUtil (v. ' + PTCommonUtil.VERSION + ')\n';447 str += '\n\u00A92002-2004 Plumtree Software Inc., All Rights Reserved \n';448 if (PTCommonUtil.isDefined(window.PT_DEBUG))449 {450 str += '\nDo you want to inspect an object?\n';451 var inspect = confirm(str);452 if (inspect)453 {454 var obj = prompt('Enter the name of the object you wish to inspect: \n','');455 if (obj)456 {457 var o = eval(obj);458 if (o)459 {460 }461 else462 {463 }464 }465 }466 }467 else { alert(str); }468}469PTCommonUtil.versions = function()470{471 if (document.all)472 { if (window.event.altKey && window.event.ctrlKey && window.event.shiftKey) {473 PTCommonUtil.alertVersion();474 return false;475 }476 }477}478PTCommonUtil.setUpVersions = function()479{480 if ((typeof document != 'undefined') && (PTCommonUtil.getIEVersion() >= 5.5))481 {482 if (document.all)483 {484 if (document.body) { document.body.onmouseleave = PTCommonUtil.versions;485 } else { window.setTimeout('PTCommonUtil.setUpVersions()',500); }486 }487 }488}489PTCommonUtil.setUpVersions();490PTCommonUtil.getScripts = function()491{492 if(!document.scripts)493 {494 document.scripts = new Array();495 PTCommonUtil.addScripts(document.childNodes);496 }497 return document.scripts;498}499PTCommonUtil.addScripts = function(nodeList)500{501 for(var i = 0; i < nodeList.length; i++) { if(nodeList[i].tagName) { if(nodeList[i].tagName.toLowerCase() == 'script') document.scripts[document.scripts.length] = nodeList[i]; PTCommonUtil.addScripts(nodeList[i].childNodes); } }502}503PTCommonUtil.JSON = function () 504{505 var m = {506 '\b': '\\b',507 '\t': '\\t',508 '\n': '\\n',509 '\f': '\\f',510 '\r': '\\r',511 '"' : '\\"',512 '\\': '\\\\'513 },514 s = {515 'boolean': function (x) {516 return String(x);517 },518 number: function (x) {519 return isFinite(x) ? String(x) : 'null';520 },521 string: function (x) {522 if (/["\\\x00-\x1f]/.test(x)) {523 x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {524 var c = m[b];525 if (c) {526 return c;527 }528 c = b.charCodeAt();529 return '\\u00' +530 Math.floor(c / 16).toString(16) +531 (c % 16).toString(16);532 });533 }534 return '"' + x + '"';535 },536 object: function (x) {537 if (x) {538 var a = [], b, f, i, l, v;539 if (x instanceof Array) {540 a[0] = '[';541 l = x.length;542 for (i = 0; i < l; i += 1) {543 v = x[i];544 f = s[typeof v];545 if (f) {546 v = f(v);547 if (typeof v == 'string') {548 if (b) {549 a[a.length] = ',';550 }551 a[a.length] = v;552 b = true;553 }554 }555 }556 a[a.length] = ']';557 } else if (x instanceof Object) {558 a[0] = '{';559 for (i in x) {560 v = x[i];561 f = s[typeof v];562 if (f) {563 v = f(v);564 if (typeof v == 'string') {565 if (b) {566 a[a.length] = ',';567 }568 a.push(s.string(i), ':', v);569 b = true;570 }571 }572 }573 a[a.length] = '}';574 } else {575 return;576 }577 return a.join('');578 }579 return 'null';580 }581 };582 return {583 copyright: '(c)2005 JSON.org',584 license: 'http://www.crockford.com/JSON/license.html',585 stringify: function (v) {586 var f = s[typeof v];587 if (f) {588 v = f(v);589 if (typeof v == 'string') {590 return v;591 }592 }593 return null;594 },595 parse: function (text) {596 try {597 return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(598 text.replace(/"(\\.|[^"\\])*"/g, ''))) &&599 eval('(' + text + ')');600 } catch (e) {601 return false;602 }603 }604 };605}();606PTArrayUtil = function()607{608 return this;609}610PTArrayUtil.VERSION = '246682';611PTArrayUtil.push = function(arr,items)612{613 if (!PTArrayUtil.isArrayLike(arr))614 {615 return;616 }617 if (PTArrayUtil.isArrayLike(items))618 {619 for (var i = 0; i < items.length; i++)620 {621 arr[arr.length] = items[i];622 }623 }624 else625 {626 arr[arr.length] = items;627 }628 return arr.length;629}630PTArrayUtil.shift = function(arr)631{632 if (!PTArrayUtil.isArrayLike(arr))633 {634 return;635 }636 var returnValue = arr[0];637 for (var i = 0; i < (arr.length - 1); i++) { arr[i] = arr[i + 1]; }638 delete arr[arr.length - 1];639 arr.length--;640 return returnValue;641}642PTArrayUtil.splice = function(arr, start, deleteCount, variableNumberOfOtherArguments)643{644 if (!PTArrayUtil.isArrayLike(arr))645 {646 return;647 }648 if (!PTNumberUtil.isInteger(start) || (start < 0) || (start >= arr.length))649 {650 return;651 }652 if (!PTNumberUtil.isInteger(deleteCount) || (deleteCount < 0) || (deleteCount > arr.length))653 {654 return;655 }656 var returnValue = new Array();657 var originalLength = arr.length;658 var elemsToAdd = arguments.length - 3;659 var totalShift = elemsToAdd - deleteCount;660 for (var i = 0; i < deleteCount; i++)661 {662 var indexToRemove = start + i;663 returnValue[returnValue.length] = arr[indexToRemove];664 delete arr[indexToRemove];665 }666 if (totalShift != 0)667 {668 if (totalShift < 0)669 {670 var firstToMove = start + deleteCount;671 var lastToMove = originalLength - 1; 672 for (var i = firstToMove; i <= lastToMove; i++)673 {674 arr[i + totalShift] = arr[i];675 delete arr[i];676 }677 arr.length = arr.length + totalShift;678 }679 else if (totalShift > 0)680 {681 var firstToMove = originalLength - 1;682 var lastToMove = start + deleteCount;683 for (var i = firstToMove; i >= lastToMove; i--)684 {685 arr[i + totalShift] = arr[i];686 delete arr[i];687 }688 }689 }690 for (var i = 0; i < elemsToAdd; i++)691 {692 arr[start + i] = arguments[i+3];693 }694 return returnValue;695}696PTArrayUtil.removeElementAt = function(arr,index)697{698 if (!PTArrayUtil.isArrayLike(arr))699 {700 return;701 }702 return PTArrayUtil.splice(arr,index,1);703}704PTArrayUtil.moveElement = function(arr,sourceIndex,targetIndex)705{706 if (!PTArrayUtil.isArrayLike(arr))707 {708 return;709 }710 var elm = arr[sourceIndex];711 PTArrayUtil.removeElementAt(arr,sourceIndex);712 var len = arr.length;713 for (var i = (len - 1); i >= targetIndex; i--)714 {715 arr[i+1] = arr[i]; 716 }717 arr[targetIndex] = elm;718}719PTArrayUtil.isArrayLike = function(arr)720{721 var likeArray = (arr && arr.join && PTNumberUtil.isInteger(arr.length) && (parseInt(arr.length) >= 0));722 return (likeArray == true);723}724PTCookie = function()725{726 return this;727}728PTCookie.VERSION = '246682';729PTCookie.set = function(name,value,expires)730{731 document.cookie = name + "=" + escape(value) + ';path=/' + ((!expires) ? '' : ';expires=' + expires.toGMTString());732 return;733}734PTCookie.get = function(name)735{736 var cname = name + '=';737 if (document.cookie.length > 0) {738 begin = document.cookie.indexOf(cname);739 if (begin != -1) {740 begin += cname.length;741 end = document.cookie.indexOf(";", begin);742 if (end == -1) {end = document.cookie.length;}743 return unescape(document.cookie.substring(begin,end));744 }745 } else {746 return;747 }748}749PTCookie.expire = function(name)750{751 document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT' + ';path=/';752 return;753}754PTCookie.daysAway = function(numDays)755{756 var exp = new Date();757 var oneDay = (1000 * 60 * 60 * 24); 758 return new Date(exp.setTime(exp.getTime() + (oneDay * numDays)));759}760PTCookie.INT_30_DAYS = PTCookie.daysAway(30);761PTDOMUtil = function()762{763 return this;764}765PTDOMUtil.VERSION = '246682';766PTDOMUtil.getElementById = function(id)767{ if (!document.all) { return document.getElementById(id); }768 var elem = PTDOMUtil.ElementCache[id];769 if (!elem || !elem.innerHTML)770 {771 PTDOMUtil.ElementCache[id] = document.getElementById(id);772 }773 return PTDOMUtil.ElementCache[id];774}775if (!window.PTDOMUtil.ElementCache)776{ 777 PTDOMUtil.ElementCache = new Object(); 778}779PTDOMUtil.elementContains = function(containerElement, containedElement)780{ if (document.all) { return containerElement.contains(containedElement); }781 if (!PTDOMUtil.ElementContainsCache[containerElement]) { PTDOMUtil.ElementContainsCache[containerElement] = new Object(); }782 if (PTDOMUtil.ElementContainsCache[containerElement][containedElement]) 783 { 784 return (PTDOMUtil.ElementContainsCache[containerElement][containedElement] == 'true' ? true : false); 785 }786 if (containedElement == containerElement) 787 { 788 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'true';789 return true; 790 }791 if (containedElement == null) 792 { 793 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'false';794 return false; 795 }796 if (!containerElement.hasChildNodes) 797 { 798 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'false';799 return false; 800 }801 var childNodes = containerElement.childNodes;802 var childNodesLength = childNodes.length;803 for (var i=0; i<childNodesLength; i++)804 {805 var childNode = childNodes[i];806 if (PTDOMUtil.elementContains(childNode, containedElement)) 807 { 808 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'true';809 return true; 810 }811 }812 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'false';813 return false;814}815if (!window.PTDOMUtil.ElementContainsCache) 816{ 817 PTDOMUtil.ElementContainsCache = new Object(); 818}819PTDOMUtil.insertAdjacentElement = function(targetElement, insertWhere, elementToInsert)820{ if (document.all)821 {822 targetElement.insertAdjacentElement(insertWhere, elementToInsert);823 } else824 {825 switch (insertWhere)826 {827 case 'beforeBegin':828 targetElement.parentNode.insertBefore(elementToInsert,targetElement)829 break;830 case 'afterBegin':831 targetElement.insertBefore(elementToInsert,targetElement.firstChild);832 break;833 case 'beforeEnd':834 targetElement.appendChild(elementToInsert);835 break;836 case 'afterEnd':837 if (targetElement.nextSibling) { targetElement.parentNode.insertBefore(elementToInsert,targetElement.nextSibling); }838 else { targetElement.parentNode.appendChild(elementToInsert); }839 break;840 }841 }842}843PTDOMUtil.getOuterHTML = function(node, formatHTML, replacementTagIdMap)844{845 var sb = new PTStringBuffer();846 return PTDOMUtil.getHTML(sb, node, true, ((formatHTML) ? 0 : -1), replacementTagIdMap);847}848PTDOMUtil.getInnerHTML = function(node, formatHTML, replacementTagIdMap)849{850 var sb = new PTStringBuffer();851 var html = PTDOMUtil.getHTML(sb, node, false, (((formatHTML) ? 0 : -1)), replacementTagIdMap);852 return html;853}854PTDOMUtil.getHTML = function(sb, node, outputNode, nesting, map)855{ 856 switch (node.nodeType)857 {858 case 1: 859 case 11: 860 var closed;861 var i;862 if (outputNode)863 { 864 if(map && node.id && map[node.id])865 {866 sb.append(map[node.id]);867 return sb.toString();868 }869 closed = (!(node.hasChildNodes() || PTDOMUtil.isClosingTag(node)));870 if((nesting >= 0) && !PTDOMUtil.isTextEnclosingTag(node))871 {872 sb.append('\n');873 for(i = 0; i < nesting; i++)874 sb.append('\t');875 }876 sb.append('<' + node.tagName.toLowerCase());877 var attrs = node.attributes;878 for(i = 0; i < attrs.length; ++i)879 {880 var a = attrs.item(i);881 if(!a.specified)882 {883 continue;884 }885 var name = a.nodeName.toLowerCase();886 if(/moz/.test(name))887 {888 continue;889 }890 var value;891 if(PTBrowserInfo.IS_NETSCAPE_7 || name != "style")892 {893 if((PTBrowserInfo.IS_MSIE) && PTCommonUtil.isDefined(node[a.nodeName]))894 {895 value = node[a.nodeName];896 }897 else898 {899 value = a.nodeValue;900 }901 }902 else903 { 904 value = PTDOMUtil.cleanCSSText(node.style.cssText);905 }906 if(/moz/.test(value))907 {908 continue;909 }910 sb.append(' ' + name.toLowerCase() + '="' + value + '"');911 }912 sb.append((closed ? ' />' : '>'));913 }914 var newNesting = (!outputNode && (nesting == 0)) ? 0 : ((nesting >= 0) ? (nesting + 1) : -1);915 for (i = node.firstChild; i; i = i.nextSibling)916 {917 PTDOMUtil.getHTML(sb, i, true, newNesting, map);918 }919 if (outputNode && !closed)920 {921 if((nesting >= 0) && !PTDOMUtil.isTextEnclosingTag(node))922 {923 sb.append('\n');924 for(i = 0; i < nesting; i++)925 sb.append('\t');926 }927 sb.append('</' + node.tagName.toLowerCase() + '>');928 }929 break;930 case 3: 931 sb.append(PTDOMUtil.escapeHTML(node.data));932 break;933 case 8: 934 sb.append('<!--' + node.data + '-->');935 break; 936 }937 var html = sb.toString();938 if((html.length > 0) && (html.substring(0,1) == '\n'))939 html = html.substring(1);940 return html;941}942PTDOMUtil.escapeHTML = function(str)943{944 str = PTStringUtil.escapeHTML(str);945 var sb = new PTStringBuffer();946 for(var i = 0; i < str.length; i++)947 {948 if(str.charCodeAt(i) == 160)949 sb.append('&nbsp;');950 else951 sb.append(str.charAt(i));952 }953 return sb.toString();954}955PTDOMUtil.isClosingTag = function(el)956{957 var closingTags = ' h1 h2 h3 h4 h5 h6 script style div span tr td tbody table em strong font a ';958 var success = (closingTags.indexOf(' ' + el.tagName.toLowerCase() + ' ') != -1);959 return success;960}961PTDOMUtil.isTextEnclosingTag = function(el)962{963 var textEnclosingTags = ' th td span em font strong u a ';964 var success = (textEnclosingTags.indexOf(' ' + el.tagName.toLowerCase() + ' ') != -1);965 return success;966}967PTDOMUtil.cleanCSSText = function(css)968{969 var cssMap = {};970 var nameValuePairs = css.split(';');971 for(var i = 0; i < nameValuePairs.length; i++)972 {973 var nameValue = nameValuePairs[i].split(':');974 if(nameValue.length == 2)975 {976 var name = PTStringUtil.trimWhitespace(nameValue[0].toLowerCase(), true, true);977 var value = PTStringUtil.trimWhitespace(nameValue[1].toLowerCase(), true, true);978 cssMap[name] = value;979 }980 }981 if((cssMap['border-right'] == cssMap['border-left']) &&982 (cssMap['border-top'] == cssMap['border-bottom']) &&983 (cssMap['border-left'] == cssMap['border-bottom']))984 {985 cssMap['border'] = cssMap['border-right'];986 cssMap['border-right'] = '';987 cssMap['border-left'] = '';988 cssMap['border-top'] = '';989 cssMap['border-bottom'] = '';990 }991 var newCss = '';992 for(n in cssMap)993 {994 value = cssMap[n];995 if(value)996 newCss += n + ': ' + value + ';';997 }998 return newCss;999}1000PTDOMUtil.getElementLeft = function(elm)1001{ if (!elm) { return false; } var x = elm.offsetLeft; var elmParent = elm.offsetParent; while (elmParent != null) { 1002 if(PTBrowserInfo.IS_MSIE) 1003 {1004 if( (elmParent.tagName != "TABLE") && (elmParent.tagName != "BODY") )1005 { 1006 x += elmParent.clientLeft; 1007 }1008 }1009 else 1010 {1011 if(elmParent.tagName == "TABLE") 1012 { 1013 var parentBorder = parseInt(elmParent.border);1014 if(isNaN(parentBorder)) 1015 { 1016 var parentFrame = elmParent.getAttribute('frame');1017 if(parentFrame != null) 1018 {1019 x += 1; 1020 }1021 }1022 else if(parentBorder > 0) 1023 {1024 x += parentBorder; 1025 }1026 }1027 }1028 x += elmParent.offsetLeft;1029 elmParent = elmParent.offsetParent; 1030}1031return x;1032}1033PTDOMUtil.getElementTop = function(elm)1034{ var y = 0; while (elm != null)1035 { 1036 if(PTBrowserInfo.IS_MSIE) 1037 {1038 if( (elm.tagName != "TABLE") && (elm.tagName != "BODY") )1039 { 1040 y += elm.clientTop;1041 }1042 }1043 else 1044 {1045 if(elm.tagName == "TABLE") 1046 { 1047 var parentBorder = parseInt(elm.border);1048 if(isNaN(parentBorder)) 1049 { 1050 var parentFrame = elm.getAttribute('frame');1051 if(parentFrame != null) 1052 {1053 y += 1; 1054 }1055 }1056 else if(parentBorder > 0) 1057 {1058 y += parentBorder;1059 }1060 }1061 }1062 y += elm.offsetTop; 1063 if (elm.offsetParent && elm.offsetParent.offsetHeight && elm.offsetParent.offsetHeight < elm.offsetHeight)1064 { elm = elm.offsetParent.offsetParent; 1065 }1066 else1067 { elm = elm.offsetParent; 1068 } } 1069 return y;1070}1071PTDOMUtil.getElementWidth = function(elm)1072{ if (!elm) { return 0; } var w1 = elm.offsetWidth;1073 var w2 = 0;1074 if (window.getComputedStyle) 1075 { 1076 var w2px = window.getComputedStyle(elm,null).getPropertyValue('width'); w2px = PTStringUtil.substituteChars(w2px, { 'px' : '' });1077 w2 = parseInt(w2px);1078 }1079 return Math.max(w1,w2);1080}1081PTDOMUtil.getElementHeight = function(elm)1082{ if (!elm) { return 0; } var h1 = elm.offsetHeight;1083 var h2 = 0;1084 if (window.getComputedStyle) 1085 { 1086 var h2px = window.getComputedStyle(elm,null).getPropertyValue('height'); h2px = PTStringUtil.substituteChars(h2px, { 'px' : '' });1087 h2 = parseInt(h2px);1088 }1089 return Math.max(h1,h2);1090}1091PTDOMUtil.getWindowWidth = function()1092{1093 if (self.innerHeight) 1094 {1095 return self.innerWidth;1096 }1097 else if (document.documentElement && document.documentElement.clientHeight) {1098 return document.documentElement.clientWidth;1099 }1100 else if (document.body) 1101 {1102 return document.body.clientWidth;1103 }1104}1105PTDOMUtil.getWindowHeight = function()1106{1107 if (self.innerHeight) 1108 {1109 return self.innerHeight;1110 }1111 else if (document.documentElement && document.documentElement.clientHeight) {1112 return document.documentElement.clientHeight;1113 }1114 else if (document.body) 1115 {1116 return document.body.clientHeight;1117 }1118}1119PTDOMUtil.setElementOpacity = function(element,value)1120{1121 if (!element || !element.style) { return false; }1122 if (isNaN(value)) { return false; }1123 value = parseInt(value);1124 if ((value < 0) || (value > 100)) { return false; }1125 if (document.all)1126 { if (PTBrowserInfo.IS_NT4)1127 {1128 return false;1129 } else if (element.filters && element.filters.alpha && element.filters.alpha.opacity)1130 {1131 element.filters.alpha.opacity = value;1132 return true;1133 } else if (typeof element.style.filter == 'string')1134 {1135 element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + value + ')';1136 return true;1137 } else1138 {1139 return false;1140 }1141 } else if (typeof element.style.MozOpacity == 'string')1142 {1143 var dec = value / 100;1144 element.style.MozOpacity = '' + dec;1145 return true;1146 } else1147 {1148 return false;1149 }1150}1151PTDOMUtil.toggleVisibility = function(id)1152{1153 var elm = PTDOMUtil.getElementById(id);1154 if (elm.style.display == 'none')1155 { 1156 if (PTDOMUtil._elmDisplayCache[id] || PTDOMUtil._elmDisplayCache[id] == '') 1157 { 1158 elm.style.display = PTDOMUtil._elmDisplayCache[id]; 1159 }1160 else { elm.style.display = 'block'; }1161 }1162 else 1163 { 1164 PTDOMUtil._elmDisplayCache[id] = elm.style.display;1165 elm.style.display = 'none'; 1166 }1167}1168PTDOMUtil._elmDisplayCache = {};1169PTDate = function(datestring,date,language,dateFormat)1170{1171 this.datestring = (datestring) ? datestring : '';1172 this.date = (date) ? date : new Date();1173 this.language = (language) ? language : false;1174 this.dateFormat = (dateFormat) ? dateFormat : PTDate.defaultDateFormat;1175 return this;1176}1177PTDate.VERSION = '246682';1178PTDate.TIME_POLICY_ALLOW_TIMES = 0;1179PTDate.TIME_POLICY_REQUIRE_TIMES = 1;1180PTDate.TIME_POLICY_FORBID_TIMES = 2;1181PTDate.FORMAT_DEFAULT = 0;1182PTDate.FORMAT_SHORT = 1;1183PTDate.FORMAT_MEDIUM = 2;1184PTDate.FORMAT_LONG = 3;1185PTDate.FORMAT_FULL = 4;1186PTDate.PIVOT_DATE = 50; 1187PTDate.defaultLanguage = 'en';1188PTDate.defaultDateFormat = new String('EEE MMM d HH:mm:ss yyyy');1189PTDate.DEFAULT_LOCALE = 'en';1190PTDate.EnglishStrings = new Object();1191PTDate.EnglishStrings.monthsLong = new Array('January','February','March','April','May','June','July','August','September','October','November','December');1192PTDate.EnglishStrings.monthsShort = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');1193PTDate.EnglishStrings.daysLong = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');1194PTDate.EnglishStrings.daysShort = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');1195PTDate.EnglishStrings.daysInitial = new Array('S','M','T','W','T','F','S');1196PTDate.EnglishStrings.ampm = new Array('am','pm');1197PTDate.formatDate = function(date,dateFormat,language)1198{1199 var d = new PTDate('',date,language,dateFormat);1200 return d.format(dateFormat,d.language);1201}1202PTDate.validateDate = function(dateString, locale, alertOnFailure, timePolicy, formatList)1203{1204 return PTDateValidator.validateDate(dateString,locale,alertOnFailure,timePolicy,formatList);1205}1206PTDate.validateAndFormatDate = function(dateString, outputFormat, locale, alertOnFailure, timePolicy, formatList)1207{1208 if (!dateString) { return false; }1209 if (!outputFormat) { outputFormat = PTDate.defaultDateFormat; }1210 var validDate = PTDateValidator.validateDate(dateString,locale,alertOnFailure,timePolicy,formatList);1211 if (!validDate) { return false; }1212 var formattedDate = PTDate.formatDate(validDate,outputFormat);1213 return formattedDate;1214}1215PTDate.getNumberOfDaysInMonth = function(date)1216{1217 var m = date.getMonth();1218 if ((m == 3) || (m == 5) || (m == 8) || (m == 10)) { return 30; }1219 else if (m == 1)1220 {1221 var y = date.getFullYear();1222 if ((!(y%4) && (y%100)) || !(y%400))1223 {1224 return 29;1225 }1226 else1227 {1228 return 28;1229 }1230 }1231 else { return 31; }1232}1233PTDate.get2DigitYear = function(date)1234{1235 var y = date.getFullYear() % 100;1236 if (y < 10) { y = '0' + y; }1237 return '' + y;1238}1239PTDate.get2DigitMonth = function(date)1240{1241 var m = date.getMonth() + 1;1242 if (m < 10) { m = '0' + m; }1243 return '' + m1244}1245PTDate.get1DigitMonth = function(date)1246{1247 var m = date.getMonth() + 1;1248 return '' + m1249}1250PTDate.get2DigitDayOfMonth = function(date)1251{1252 var d = date.getDate();1253 if (d < 10) { d = '0' + d; }1254 return '' + d;1255}1256PTDate.get1DigitDayOfMonth = function(date)1257{1258 var d = date.getDate();1259 return '' + d;1260}1261PTDate.get2Digit1To12Hour = function(date)1262{1263 var h = date.getHours();1264 h = h % 12;1265 if (h == 0) { h = '12'; }1266 else if (h < 10) { h = '0' + h; }1267 return '' + h;1268}1269PTDate.get1Digit1To12Hour = function(date)1270{1271 var h = date.getHours();1272 h = h % 12;1273 if (h == 0) { h = '12'; }1274 return '' + h;1275}1276PTDate.get2Digit0To23Hour = function(date)1277{1278 var h = date.getHours();1279 if (h < 10) { h = '0' + h; }1280 return '' + h;1281}1282PTDate.get2Digit0To11Hour = function(date)1283{1284 var h = date.getHours();1285 h = h % 12;1286 if (h < 10) { h = '0' + h; }1287 return '' + h;1288}1289PTDate.get1Digit0To11Hour = function(date)1290{1291 var h = date.getHours();1292 h = h % 12;1293 return '' + h;1294}1295PTDate.get2Digit1To24Hour = function(date)1296{1297 var h = date.getHours() + 1;1298 if (h < 10) { h = '0' + h; }1299 return '' + h;1300}1301PTDate.get1Digit1To24Hour = function(date)1302{1303 var h = date.getHours() + 1;1304 return '' + h;1305}1306PTDate.get2DigitMinutes = function(date)1307{1308 var m = date.getMinutes();1309 if (m < 10) { m = '0' + m; }1310 return '' + m;1311}1312PTDate.get1DigitMinutes = function(date)1313{1314 var m = date.getMinutes();1315 return '' + m;1316}1317PTDate.get2DigitSeconds = function(date)1318{1319 var s = date.getSeconds();1320 if (s < 10) { s = '0' + s; }1321 return '' + s;1322}1323PTDate.get1DigitSeconds = function(date)1324{1325 var s = date.getSeconds();1326 return '' + s;1327}1328PTDate.get3DigitMilliseconds = function(date)1329{1330 var m = date.getMilliseconds();1331 if (m < 10) { m = '00' + m; }1332 else if (m < 100) { m = '0' + m; }1333 return '' + m;1334}1335PTDate.getAMPM = function(date,language)1336{1337 if (!language) { language = PTDate.defaultLanguage; }1338 var h = date.getHours();1339 var STR = PTDateStrings;1340 if (language == 'en') { STR = PTDate.EnglishStrings; }1341 var ampm = STR.ampm[0];1342 if (h >= 12) { ampm = STR.ampm[1]; }1343 return ampm;1344}1345PTDate.convert2DigitTo4DigitYear = function(year)1346{1347 if (year <= PTDate.PIVOT_DATE) { year += 100; }1348 year += 1900;1349 return year;1350}1351PTDate.isLeapYear = function(year)1352{1353 if (year && year.getFullYear) { var y = year.getFullYear(); }1354 else { var y = parseInt(year); }1355 return (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0));1356}1357PTDate.getFormatListForLocale = function(locale,requireExactMatch)1358{1359 locale = new String(locale);1360 if ((locale.indexOf('-') == 2) && (locale.length == 5))1361 {1362 locale = (locale.substr(0,2)).toLowerCase() + '_' + (locale.substr(3,2)).toUpperCase();1363 }1364 if (PTDate.formats[locale]) { return PTDate.formats[locale]; }1365 if (requireExactMatch) { return false; }1366 var language = locale.substring(0,2);1367 if (PTDate.formats[language]) { return PTDate.formats[language]; }1368 for (var loc in PTDate.formats)1369 {1370 if (loc.indexOf(language) > -1) { return PTDate.formats[loc]; }1371 }1372 return PTDate.formats[PTDate.DEFAULT_LOCALE];1373}1374PTDate.stripTimesFromFormat = function(format)1375{1376 format = format.replace(/a.*$/,'');1377 format = format.replace(/h.*$/i,'');1378 return format;1379}1380PTDate.prototype.format = function(dateFormat,language)1381{1382 dateFormat = (dateFormat) ? new String(dateFormat) : this.dateFormat;1383 language = (language) ? language : false;1384 var date = this.date;1385 var STR = PTDateStrings;1386 if (language == 'en') { STR = PTDate.EnglishStrings; }1387 var patternStrings = {1388 'yyyy' : date.getFullYear(),1389 'yy' : PTDate.get2DigitYear(date),1390 'MMMMM' : STR.monthsLong[date.getMonth()], 1391 'MMMM' : STR.monthsLong[date.getMonth()], // whether long form for month is 4 or 5 M's. Support both here.1392 'MMM' : STR.monthsShort[date.getMonth()],1393 'MM' : PTDate.get2DigitMonth(date),1394 'M' : PTDate.get1DigitMonth(date),1395 'EEEE' : STR.daysLong[date.getDay()],1396 'EEE' : STR.daysShort[date.getDay()], 1397 'EE' : STR.daysShort[date.getDay()], // whether short form for day is 2 or 3 E's. Support both here.1398 'E' : STR.daysInitial[date.getDay()],1399 'dd' : PTDate.get2DigitDayOfMonth(date),1400 'd' : PTDate.get1DigitDayOfMonth(date),1401 'hh' : PTDate.get2Digit1To12Hour(date),1402 'h' : PTDate.get1Digit1To12Hour(date),1403 'HH' : PTDate.get2Digit0To23Hour(date),1404 'H' : date.getHours(),1405 'KK' : PTDate.get2Digit0To11Hour(date),1406 'K' : PTDate.get1Digit0To11Hour(date),1407 'kk' : PTDate.get2Digit1To24Hour(date),1408 'k' : PTDate.get1Digit1To24Hour(date),1409 'mm' : PTDate.get2DigitMinutes(date),1410 'm' : PTDate.get1DigitMinutes(date),1411 'ss' : PTDate.get2DigitSeconds(date),1412 's' : PTDate.get1DigitSeconds(date),1413 'SSS' : PTDate.get3DigitMilliseconds(date),1414 'a' : PTDate.getAMPM(date,language),1415 'z' : '' // z gets used a lot in PTDateValidatorFormats, but we really don't want any effect from it1416 }1417 var ph = new Array();1418 var f = dateFormat;1419 while (f.indexOf('\'') != f.lastIndexOf('\''))1420 {1421 var re = new RegExp("('[^']*')");1422 var res = re.exec(f);1423 var literal = RegExp.$1;1424 var pStart = f.indexOf(literal);1425 var pEnd = pStart + literal.length;1426 var filler = '';1427 for (var i = 0; i < literal.length; i++) { filler += '-'; }1428 f = f.substring(0,pStart) + filler + f.substr(pEnd);1429 }1430 for (var pattern in patternStrings)1431 {1432 while (f.indexOf(pattern) > -1)1433 {1434 var pStart = f.indexOf(pattern);1435 var pEnd = pStart + pattern.length;1436 ph[pStart] = new Object();1437 ph[pStart].string = patternStrings[pattern];1438 ph[pStart].end = pEnd;1439 var filler = '';1440 for (var i = 0; i < pattern.length; i++) { filler += '-'; }1441 f = f.substring(0,pStart) + filler + f.substr(pEnd);1442 }1443 }1444 var convertedString = new String('');1445 var i = 0;1446 while (i < dateFormat.length)1447 {1448 if (ph[i])1449 {1450 convertedString += ph[i].string;1451 i = ph[i].end;1452 }1453 else1454 {1455 if (dateFormat.charAt(i) == '\'')1456 {1457 if (dateFormat.charAt(i+1) == '\'')1458 { convertedString += '\'';1459 i = i + 2;1460 }1461 else { i++; }1462 continue;1463 }1464 convertedString += dateFormat.charAt(i);1465 i++;1466 }1467 }1468 return PTStringUtil.trimWhitespace(convertedString,true,true);1469}1470PTDate.prototype.hasTime = function()1471{1472 return (this.datestring.indexOf(':') > -1);1473}1474PTDate.prototype.incrementMonth = function()1475{1476 var date = this.date;1477 var month = date.getMonth();1478 if (month < 11) {1479 date.setMonth(month+1);1480 }1481 else {1482 date.setMonth(0);1483 date.setFullYear(date.getFullYear()+1);1484 }1485}1486PTDate.prototype.incrementWeek = function()1487{1488 var date = this.date;1489 var hours = date.getHours();1490 date.setHours(12);1491 var week = 1000*60*60*24*7;1492 date.setTime(date.getTime()+week);1493 date.setHours(hours);1494}1495PTDate.prototype.incrementDay = function()1496{1497 var date = this.date;1498 var hours = date.getHours();1499 date.setHours(12);1500 var day = 1000*60*60*24;1501 date.setTime(date.getTime()+day);1502 date.setHours(hours);1503}1504PTDate.prototype.clone = function()1505{1506 return new PTDate(this.datestring,1507 new Date(this.date.getTime()),1508 this.language,1509 this.dateFormat);1510}1511PTDate.prototype.getNumberOfDaysInThisMonth = function()1512{1513 return PTDate.getNumberOfDaysInMonth(this.date);1514}1515PTDate.prototype.getTime = function()1516{1517 return this.date.getTime();1518}1519if (!PTDate.formats)1520{1521 PTDate.formats = new Object();1522}1523PTDate.formats['en'] = new Array(1524 'MMM d, yyyy h:mm:ss a',1525 'M/d/yyyy h:mm a',1526 'MMM d, yyyy h:mm:ss a',1527 'MMMM d, yyyy h:mm:ss a z',1528 'EEEE, MMMM d, yyyy h:mm:ss a z'1529 ); PTDate.formats['da'] = new Array(1530 'dd-MM-yy HH:mm:ss',1531 'dd-MM-yy HH:mm',1532 'dd-MM-yyyy HH:mm:ss',1533 'd. MMMM yyyy HH:mm:ss z',1534 'd. MMMM yyyy HH:mm:ss z'1535 );1536PTDate.formats['da_DK'] = new Array(1537 'dd-MM-yy HH:mm:ss',1538 'dd-MM-yy HH:mm',1539 'dd-MM-yyyy HH:mm:ss',1540 'd. MMMM yyyy HH:mm:ss z',1541 'd. MMMM yyyy HH:mm:ss z'1542 );1543PTDate.formats['fi'] = new Array(1544 'd.M.yy HH:mm:ss',1545 'd.M.yy HH:mm',1546 'd.MMM.yyyy HH:mm:ss',1547 'd. MMMM yyyy HH:mm:ss z',1548 'd. MMMM yyyy HH:mm:ss z'1549 ); PTDate.formats['fi_FI'] = new Array(1550 'dd-MM-yy HH:mm:ss',1551 'dd-MM-yy HH:mm',1552 'dd-MM-yyyy HH:mm:ss',1553 'd. MMMM yyyy HH:mm:ss z',1554 'd. MMMM yyyy HH:mm:ss z'1555 );1556PTDate.formats['no'] = new Array(1557 'dd.MM.yy HH:mm:ss',1558 'dd.MM.yy HH:mm',1559 'dd.MMM.yyyy HH:mm:ss',1560 'd. MMMM yyyy HH:mm:ss z',1561 'd. MMMM yyyy \'kl \' HH:mm z'1562 ); 1563PTDate.formats['no_NO'] = new Array(1564 'dd.MM.yy HH:mm:ss',1565 'dd.MM.yy HH:mm',1566 'dd.MMM.yyyy HH:mm:ss',1567 'd. MMMM yyyy HH:mm:ss z',1568 'd. MMMM yyyy \'kl \' HH:mm z'1569 ); 1570PTDate.formats['nb'] = new Array(1571 'dd.MM.yy HH:mm:ss',1572 'dd.MM.yy HH:mm',1573 'dd.MMM.yyyy HH:mm:ss',1574 'd. MMMM yyyy HH:mm:ss z',1575 'd. MMMM yyyy \'kl \' HH:mm z'1576 ); 1577PTDate.formats['nb_NO'] = new Array(1578 'dd.MM.yy HH:mm:ss',1579 'dd.MM.yy HH:mm',1580 'dd.MMM.yyyy HH:mm:ss',1581 'd. MMMM yyyy HH:mm:ss z',1582 'd. MMMM yyyy \'kl \' HH:mm z'1583 ); 1584PTDate.formats['nn'] = new Array(1585 'dd.MM.yy HH:mm:ss',1586 'dd.MM.yy HH:mm',1587 'dd.MMM.yyyy HH:mm:ss',1588 'd. MMMM yyyy HH:mm:ss z',1589 'd. MMMM yyyy \'kl \' HH:mm z'1590 ); 1591PTDate.formats['nn_NO'] = new Array(1592 'dd.MM.yy HH:mm:ss',1593 'dd.MM.yy HH:mm',1594 'dd.MMM.yyyy HH:mm:ss',1595 'd. MMMM yyyy HH:mm:ss z',1596 'd. MMMM yyyy \'kl \' HH:mm z'1597 ); 1598PTDate.formats['sv'] = new Array(1599 'yyyy-MM-dd HH:mm:ss',1600 'yyyy-MM-dd HH:mm',1601 'yyyy-MM-dd HH:mm:ss',1602 '\'den \' d MMMM yyyy HH:mm:ss z',1603 '\'den \' d MMMM yyyy \'kl \' HH:mm z'1604 ); 1605PTDate.formats['sv_SE'] = new Array(1606 'yyyy-MM-dd HH:mm:ss',1607 'yyyy-MM-dd HH:mm',1608 'yyyy-MM-dd HH:mm:ss',1609 '\'den \' d MMMM yyyy HH:mm:ss z',1610 '\'den \' d MMMM yyyy \'kl \' HH:mm z'1611 ); 1612PTDate.formats['tr'] = new Array(1613 'dd.MM.yy HH:mm:ss',1614 'dd.MM.yy HH:mm',1615 'dd.MMM.yyyy HH:mm:ss',1616 'dd MMMM yyyy EEEE HH:mm:ss z',1617 'dd MMMM yyyy EEEE HH:mm:ss z'1618 ); 1619PTDate.formats['tr_TR'] = new Array(1620 'dd.MM.yy HH:mm:ss',1621 'dd.MM.yy HH:mm',1622 'dd.MMM.yyyy HH:mm:ss',1623 'dd MMMM yyyy EEEE HH:mm:ss z',1624 'dd MMMM yyyy EEEE HH:mm:ss z'1625 ); 1626PTDate.formats['de'] = new Array(1627 'dd.MM.yyyy HH:mm:ss',1628 'dd.MM.yyyy HH:mm',1629 'dd.MM.yyyy HH:mm:ss',1630 'd. MMMM yyyy HH:mm:ss z',1631 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1632 );1633PTDate.formats['de_AT'] = new Array(1634 'dd.MM.yyyy HH:mm:ss',1635 'dd.MM.yyyy HH:mm',1636 'dd.MM.yyyy HH:mm:ss',1637 'dd. MMMM yyyy HH:mm:ss z',1638 'EEEE, dd. MMMM yyyy HH.mm\' Uhr \'z'1639 );1640PTDate.formats['de_CH'] = new Array(1641 'dd.MM.yyyy HH:mm:ss',1642 'dd.MM.yyyy HH:mm',1643 'dd.MM.yyyy HH:mm:ss',1644 'd. MMMM yyyy HH:mm:ss z',1645 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1646 );1647PTDate.formats['de_DE'] = new Array(1648 'dd.MM.yyyy HH:mm:ss',1649 'dd.MM.yyyy HH:mm',1650 'dd.MM.yyyy HH:mm:ss',1651 'd. MMMM yyyy HH:mm:ss z',1652 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1653 );1654PTDate.formats['de_LU'] = new Array(1655 'dd.MM.yyyy HH:mm:ss',1656 'dd.MM.yyyy HH:mm',1657 'dd.MM.yyyy HH:mm:ss',1658 'd. MMMM yyyy HH:mm:ss z',1659 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1660 );1661PTDate.formats['en_AU'] = new Array(1662 'd/MM/yyyy HH:mm:ss',1663 'd/MM/yyyy HH:mm',1664 'd/MM/yyyy HH:mm:ss',1665 'd MMMM yyyy H:mm:ss',1666 'EEEE, d MMMM yyyy hh:mm:ss a z'1667 );1668PTDate.formats['en_CA'] = new Array(1669 'd-MMM-yyyy h:mm:ss a',1670 'dd/MM/yyyy h:mm a',1671 'd-MMM-yyyy h:mm:ss a',1672 'MMMM d, yyyy h:mm:ss z a',1673 'EEEE, MMMM d, yyyy h:mm:ss \'o\'\'clock\' a z'1674 );1675PTDate.formats['en_GB'] = new Array(1676 'dd-MMM-yyyy HH:mm:ss',1677 'dd/MM/yyyy HH:mm',1678 'dd-MMM-yyyy HH:mm:ss',1679 'dd MMMM yyyy HH:mm:ss z',1680 'dd MMMM yyyy HH:mm:ss \'o\'\'clock\' z'1681 );1682PTDate.formats['en_IE'] = new Array(1683 'dd-MMM-yyyy HH:mm:ss',1684 'dd/MM/yyyy HH:mm',1685 'dd-MMM-yyyy HH:mm:ss',1686 'dd MMMM yyyy HH:mm:ss z',1687 'dd MMMM yyyy HH:mm:ss \'o\'\'clock\' z'1688 );1689PTDate.formats['en_NZ'] = new Array(1690 'd/MM/yyyy HH:mm:ss',1691 'd/MM/yyyy HH:mm',1692 'd/MM/yyyy HH:mm:ss',1693 'd MMMM yyyy H:mm:ss',1694 'EEEE, d MMMM yyyy hh:mm:ss a z'1695 );1696PTDate.formats['en_US'] = new Array(1697 'MMM d, yyyy h:mm:ss a',1698 'M/d/yyyy h:mm a',1699 'MMM d, yyyy h:mm:ss a',1700 'MMMM d, yyyy h:mm:ss a z',1701 'EEEE, MMMM d, yyyy h:mm:ss a z'1702 );1703PTDate.formats['en_ZA'] = new Array(1704 'yyyy/MM/dd hh:mm:ss',1705 'yyyy/MM/dd hh:mm',1706 'yyyy/MM/dd hh:mm:ss',1707 'dd MMMM yyyy hh:mm:ss',1708 'dd MMMM yyyy hh:mm:ss a'1709 );1710PTDate.formats['es'] = new Array(1711 'dd-MMM-yyyy H:mm:ss',1712 'd/MM/yyyy H:mm',1713 'dd-MMM-yyyy H:mm:ss',1714 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1715 'EEEE d\' de \'MMMM\' de \'yyyy HH\'H\'mm\'\' z'1716 );1717PTDate.formats['es_AR'] = new Array(1718 'dd/MM/yyyy HH:mm:ss',1719 'dd/MM/yyyy HH:mm',1720 'dd/MM/yyyy HH:mm:ss',1721 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1722 'EEEE d\' de \'MMMM\' de \'yyyy HH\'h\'\'\'mm z'1723 );1724PTDate.formats['es_BO'] = new Array(1725 'dd-MM-yyyy hh:mm:ss a',1726 'dd-MM-yyyy hh:mm a',1727 'dd-MM-yyyy hh:mm:ss a',1728 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1729 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1730 );1731PTDate.formats['es_CL'] = new Array(1732 'dd-MM-yyyy hh:mm:ss a',1733 'dd-MM-yyyy hh:mm a',1734 'dd-MM-yyyy hh:mm:ss a',1735 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1736 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1737 );1738PTDate.formats['es_CO'] = new Array(1739 'd/MM/yyyy hh:mm:ss a',1740 'd/MM/yyyy hh:mm a',1741 'd/MM/yyyy hh:mm:ss a',1742 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1743 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1744 );1745PTDate.formats['es_CR'] = new Array(1746 'dd/MM/yyyy hh:mm:ss a',1747 'dd/MM/yyyy hh:mm a',1748 'dd/MM/yyyy hh:mm:ss a',1749 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1750 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1751 );1752PTDate.formats['es_DO'] = new Array(1753 'MM/dd/yyyy hh:mm:ss a',1754 'MM/dd/yyyy hh:mm a',1755 'MM/dd/yyyy hh:mm:ss a',1756 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1757 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1758 );1759PTDate.formats['es_EC'] = new Array(1760 'dd/MM/yyyy hh:mm:ss a',1761 'dd/MM/yyyy hh:mm a',1762 'dd/MM/yyyy hh:mm:ss a',1763 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1764 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1765 );1766PTDate.formats['es_GT'] = new Array(1767 'd/MM/yyyy hh:mm:ss a',1768 'd/MM/yyyy hh:mm a',1769 'd/MM/yyyy hh:mm:ss a',1770 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1771 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1772 );1773PTDate.formats['es_HN'] = new Array(1774 'MM-dd-yyyy hh:mm:ss a',1775 'MM-dd-yyyy hh:mm a',1776 'MM-dd-yyyy hh:mm:ss a',1777 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1778 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1779 );1780PTDate.formats['es_MX'] = new Array(1781 'd/MM/yyyy hh:mm:ss a',1782 'd/MM/yyyy hh:mm a',1783 'd/MM/yyyy hh:mm:ss a',1784 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1785 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1786 );1787PTDate.formats['es_NI'] = new Array(1788 'MM-dd-yyyy hh:mm:ss a',1789 'MM-dd-yyyy hh:mm a',1790 'MM-dd-yyyy hh:mm:ss a',1791 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1792 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1793 );1794PTDate.formats['es_PA'] = new Array(1795 'MM/dd/yyyy hh:mm:ss a',1796 'MM/dd/yyyy hh:mm a',1797 'MM/dd/yyyy hh:mm:ss a',1798 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1799 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1800 );1801PTDate.formats['es_PE'] = new Array(1802 'dd/MM/yyyy hh:mm:ss a',1803 'dd/MM/yyyy hh:mm a',1804 'dd/MM/yyyy hh:mm:ss a',1805 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1806 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1807 );1808PTDate.formats['es_PR'] = new Array(1809 'MM-dd-yyyy hh:mm:ss a',1810 'MM-dd-yyyy hh:mm a',1811 'MM-dd-yyyy hh:mm:ss a',1812 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1813 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1814 );1815PTDate.formats['es_PY'] = new Array(1816 'dd/MM/yyyy hh:mm:ss a',1817 'dd/MM/yyyy hh:mm a',1818 'dd/MM/yyyy hh:mm:ss a',1819 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1820 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1821 );1822PTDate.formats['es_SV'] = new Array(1823 'MM-dd-yyyy hh:mm:ss a',1824 'MM-dd-yyyy hh:mm a',1825 'MM-dd-yyyy hh:mm:ss a',1826 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1827 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1828 );1829PTDate.formats['es_UY'] = new Array(1830 'dd/MM/yyyy hh:mm:ss a',1831 'dd/MM/yyyy hh:mm a',1832 'dd/MM/yyyy hh:mm:ss a',1833 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1834 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1835 );1836PTDate.formats['es_VE'] = new Array(1837 'dd/MM/yyyy hh:mm:ss a',1838 'dd/MM/yyyy hh:mm a',1839 'dd/MM/yyyy hh:mm:ss a',1840 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1841 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1842 );1843PTDate.formats['fr'] = new Array(1844 'd MMM yyyy HH:mm:ss',1845 'dd/MM/yyyy HH:mm',1846 'd MMM yyyy HH:mm:ss',1847 'd MMMM yyyy HH:mm:ss z',1848 'EEEE d MMMM yyyy HH\' h \'mm z'1849 );1850PTDate.formats['fr_BE'] = new Array(1851 'dd-MMM-yyyy H:mm:ss',1852 'd/MM/yyyy H:mm',1853 'dd-MMM-yyyy H:mm:ss',1854 'd MMMM yyyy H:mm:ss z',1855 'EEEE d MMMM yyyy H\' h \'mm\' min \'ss\' s \'z'1856 );1857PTDate.formats['fr_CA'] = new Array(1858 'yyyy-MM-dd HH:mm:ss',1859 'yyyy-MM-dd HH:mm',1860 'yyyy-MM-dd HH:mm:ss',1861 'd MMMM yyyy HH:mm:ss z',1862 'EEEE d MMMM yyyy H\' h \'mm z'1863 );1864PTDate.formats['fr_CH'] = new Array(1865 'd MMM yyyy HH:mm:ss',1866 'dd.MM.yyyy HH:mm',1867 'd MMM yyyy HH:mm:ss',1868 'd. MMMM yyyy HH:mm:ss z',1869 'EEEE, d. MMMM yyyy HH.mm.\' h\' z'1870 );1871PTDate.formats['fr_FR'] = new Array(1872 'd MMM yyyy HH:mm:ss',1873 'dd/MM/yyyy HH:mm',1874 'd MMM yyyy HH:mm:ss',1875 'd MMMM yyyy HH:mm:ss z',1876 'EEEE d MMMM yyyy HH\' h \'mm z'1877 );1878PTDate.formats['fr_LU'] = new Array(1879 'd MMM yyyy HH:mm:ss',1880 'dd/MM/yyyy HH:mm',1881 'd MMM yyyy HH:mm:ss',1882 'd MMMM yyyy HH:mm:ss z',1883 'EEEE d MMMM yyyy HH\' h \'mm z'1884 );1885PTDate.formats['it'] = new Array(1886 'd-MMM-yyyy H.mm.ss',1887 'dd/MM/yyyy H.mm',1888 'd-MMM-yyyy H.mm.ss',1889 'd MMMM yyyy H.mm.ss z',1890 'EEEE d MMMM yyyy H.mm.ss z'1891 );1892PTDate.formats['it_CH'] = new Array(1893 'd-MMM-yyyy HH:mm:ss',1894 'dd.MM.yyyy HH:mm',1895 'd-MMM-yyyy HH:mm:ss',1896 'd. MMMM yyyy HH:mm:ss z',1897 'EEEE, d. MMMM yyyy H.mm\' h\' z'1898 );1899PTDate.formats['it_IT'] = new Array(1900 'd-MMM-yyyy H.mm.ss',1901 'dd/MM/yyyy H.mm',1902 'd-MMM-yyyy H.mm.ss',1903 'd MMMM yyyy H.mm.ss z',1904 'EEEE d MMMM yyyy H.mm.ss z'1905 );1906PTDate.formats['ja'] = new Array(1907 'yyyy/MM/dd H:mm:ss',1908 'yyyy/MM/dd H:mm',1909 'yyyy/MM/dd H:mm:ss',1910 'yyyy/MM/dd H:mm:ss z',1911 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' H\'\u6642\'mm\'\u5206\'ss\'\u79D2\'z'1912 );1913PTDate.formats['ja_JP'] = new Array(1914 'yyyy/MM/dd H:mm:ss',1915 'yyyy/MM/dd H:mm',1916 'yyyy/MM/dd H:mm:ss',1917 'yyyy/MM/dd H:mm:ss z',1918 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' H\'\u6642\'mm\'\u5206\'ss\'\u79D2\'z'1919 );1920PTDate.formats['ko'] = new Array(1921 'yyyy-MM-dd a h:mm:ss',1922 'yyyy-MM-dd a h:mm',1923 'yyyy-MM-dd a h:mm:ss',1924 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\'',1925 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EEEE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\' z'1926 );1927PTDate.formats['ko_KR'] = new Array(1928 'yyyy-MM-dd a h:mm:ss',1929 'yyyy-MM-dd a h:mm',1930 'yyyy-MM-dd a h:mm:ss',1931 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\'',1932 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EEEE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\' z'1933 );1934PTDate.formats['nl'] = new Array(1935 'd-MMM-yyyy HH:mm:ss',1936 'd-M-yy H:mm',1937 'd-MMM-yyyy H:mm:ss',1938 'd MMMM yyyy HH:mm:ss z',1939 'EEEE d MMMM yyyy H.mm\' uur \'z'1940 );1941PTDate.formats['nl_BE'] = new Array(1942 'd-MMM-yyyy HH:mm:ss',1943 'd/MM/yy H:mm',1944 'd-MMM-yyyy H:mm:ss',1945 'd MMMM yyyy HH:mm:ss z',1946 'EEEE d MMMM yyyy H.mm\' uur \'z'1947 );1948PTDate.formats['nl_NL'] = new Array(1949 'd-MMM-yyyy HH:mm:ss',1950 'd-M-yy H:mm',1951 'd-MMM-yyyy H:mm:ss',1952 'd MMMM yyyy HH:mm:ss z',1953 'EEEE d MMMM yyyy H.mm\' uur \'z'1954 );1955PTDate.formats['pt'] = new Array(1956 'd/MMM/yyyy H:mm:ss',1957 'dd-MM-yyyy H:mm',1958 'd/MMM/yyyy H:mm:ss',1959 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1960 'EEEE, d\' de \'MMMM\' de \'yyyy HH\'H\'mm\'m\' z'1961 );1962PTDate.formats['pt_BR'] = new Array(1963 'dd/MM/yyyy HH:mm:ss',1964 'dd/MM/yyyy HH:mm',1965 'dd/MM/yyyy HH:mm:ss',1966 'd\' de \'MMMM\' de \'yyyy H\'h\'m\'min\'s\'s\' z',1967 'EEEE, d\' de \'MMMM\' de \'yyyy HH\'h\'mm\'min\'ss\'s\' z'1968 );1969PTDate.formats['pt_PT'] = new Array(1970 'd/MMM/yyyy H:mm:ss',1971 'dd-MM-yyyy H:mm',1972 'd/MMM/yyyy H:mm:ss',1973 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1974 'EEEE, d\' de \'MMMM\' de \'yyyy HH\'H\'mm\'m\' z'1975 );1976PTDate.formats['zh'] = new Array(1977 'yyyy-M-d H:mm:ss',1978 'yyyy-M-d ah:mm',1979 'yyyy-M-d H:mm:ss',1980 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u65F6\'mm\'\u5206\'ss\'\u79D2\'',1981 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' HH\'\u65F6\'mm\'\u5206\'ss\'\u79D2\' z'1982 );1983PTDate.formats['zh_CN'] = new Array(1984 'yyyy-M-d H:mm:ss',1985 'yyyy-M-d ah:mm',1986 'yyyy-M-d H:mm:ss',1987 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u65F6\'mm\'\u5206\'ss\'\u79D2\'',1988 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' HH\'\u65F6\'mm\'\u5206\'ss\'\u79D2\' z'1989 );1990PTDate.formats['zh_HK'] = new Array(1991 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh:mm:ss',1992 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ah:mm',1993 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh:mm:ss',1994 'yyyy\'\u5E74\'MM\'\u6708\'dd\'\u65E5\' EEEE ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\'',1995 'yyyy\'\u5E74\'MM\'\u6708\'dd\'\u65E5\' EEEE ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\' z'1996 );1997PTDate.formats['zh_TW'] = new Array(1998 'yyyy/M/d a hh:mm:ss',1999 'yyyy/M/d a h:mm',2000 'yyyy/M/d a hh:mm:ss',2001 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\'',2002 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\' z'2003 );2004PTDateUtil = function()2005{2006 return this;2007}2008PTDateUtil.VERSION = '246682';2009PTDateUtil.isSameDay = function (date1, date2)2010{2011 if (isNaN(date1) || isNaN(date2)) { return false; }2012 if ((date1.getFullYear() == date2.getFullYear())2013 &&2014 (date1.getMonth() == date2.getMonth())2015 &&2016 (date1.getDate() == date2.getDate()))2017 {2018 return true;2019 }2020 else { return false; }2021}2022PTDateUtil.getDaysBetweenDates = function (date1, date2)2023{2024 if (isNaN(date1) || isNaN(date2)) { return 0; }2025 date1.setHours(12);2026 date2.setHours(12);2027 var millis = Math.abs(date2.getTime() - date1.getTime());2028 return Math.round(millis / (1000 * 60 * 60 * 24));2029}2030PTDateUtil.formatTime = function(sTime, iMode)2031{2032 var err = false;2033 var regTime = /\b\d\d?\b|\b\d\d?\B|\B\d\d?\b|\B\d\d?\B/g;2034 var regAMPM = new RegExp('AM|am|Am|aM|PM|pm|Pm|pM|p.m.|p.m|P.M.|a.m.|a.m|A.M.');2035 if (sTime == '') { return false; }2036 if ((sTime.match(/\d\d?:\d/) == null) || (sTime.match(/:/) == null)) { return false; }2037 var arrTime = sTime.match(regTime);2038 var strAMPM = sTime.match(regAMPM);2039 if (!arrTime[1]) { arrTime[1] = 0; }2040 if (!arrTime[2]) { arrTime[2] = 0; }2041 if ((arrTime[0] > 23) || (arrTime[1] > 59) || (arrTime[2] > 59) || (arrTime[0] == null) || (arrTime[0] < 0) || (arrTime[1] < 0) || (arrTime[2] < 0)) { err = true; }2042 var strTempDigits;2043 if (iMode == 0)2044 {2045 if ((strAMPM == 'PM') && (arrTime[0] < 12)) { arrTime[0] += 12; }2046 else if ((strAMPM == 'AM') && (arrTime[0] == 12)) { arrTime[0] = 0; }2047 }2048 else2049 {2050 if (!strAMPM)2051 {2052 strAMPM = 'AM';2053 if (arrTime[0] > 12)2054 {2055 arrTime[0] = arrTime[0] - 12;2056 strAMPM = 'PM';2057 }2058 else if (arrTime[0] == 0)2059 {2060 arrTime[0] = 12;2061 strAMPM = 'AM';2062 }2063 }2064 }2065 for (i = 0; i < 3; i++)2066 {2067 strTempDigits = '0' + arrTime[i];2068 if (strTempDigits.length == 2) { arrTime[i] = strTempDigits; }2069 }2070 if (err)2071 {2072 alert(PTS_STR['PTU-Date-TimeFormatError']);2073 return false;2074 }2075 else2076 {2077 sTime = arrTime[0] + ':' + arrTime[1] + ':' + arrTime[2];2078 if (iMode == 1) { sTime += ' ' + strAMPM; }2079 return sTime;2080 }2081}2082PTDateUtil.validateDate = function(strDay, strMonth, strYear)2083{2084 var strInputDate = strDay + ' ' + strMonth + ' ' + strYear; var objDate = new Date(strInputDate);2085 var strDate = objDate.toGMTString();2086 var arrDate = strDate.split(' ');2087 return (arrDate[2] != strMonth);2088}2089PTDateValidator = function()2090{2091 return this;2092}2093PTDateValidator.VERSION = '246682';2094PTDateValidator.TIME_POLICY_ALLOW_TIMES = 0;2095PTDateValidator.TIME_POLICY_REQUIRE_TIMES = 1;2096PTDateValidator.TIME_POLICY_FORBID_TIMES = 2;2097PTDateValidator.formatTokens = new Array('a','d','E','h','H','k','K','m','M','s','S','y');2098PTDateValidator.punctuation = new Array(',','/',':','-','.');2099PTDateValidator.closeSubstitutes = {2100 '\u00E1' : 'a',2101 '\u00E4' : 'a',2102 '\u00E7' : 'c',2103 '\u00E9' : 'e',2104 '\u00EC' : 'i',2105 '\u00FB' : 'u',2106 '\u2013' : '-', 2107 '\u2212' : '-'2108 };2109PTDateValidator.validateDate = function(dateString, locale, alertOnFailure, timePolicy, formatList)2110{2111 if (!dateString) { return false; }2112 if (!locale) { locale = PTDate.DEFAULT_LOCALE; }2113 if (!timePolicy) { timePolicy = PTDateValidator.TIME_POLICY_ALLOW_TIMES; }2114 if (!formatList) { formatList = PTDate.getFormatListForLocale(locale); }2115 var isValidDate = false;2116 var numFormats = formatList.length;2117 var dateData = false;2118 var hash = PTDateValidator.getPunctuationHash();2119 for (var f = 0; f < numFormats; f++)2120 {2121 var format = formatList[f];2122 dateData = PTDateValidator.parseDateStringAgainstFormat(dateString,format,hash,locale);2123 if (dateData != false)2124 {2125 if (PTNumberUtil.isInteger(dateData.day) && PTNumberUtil.isInteger(dateData.month) && PTNumberUtil.isInteger(dateData.year)) { break; }2126 }2127 }2128 var date;2129 var isValidDate = false;2130 if (dateData != false)2131 { if (dateData.ampm && (dateData.ampm == 'pm'))2132 {2133 if ((dateData.hour > 0) && (dateData.hour < 12)) { dateData.hour += 12; }2134 }2135 date = new Date(dateData.year, dateData.month, dateData.day, dateData.hour, dateData.minutes, dateData.seconds);2136 if ((dateData.day == date.getDate()) &&2137 (dateData.month == date.getMonth()) &&2138 (dateData.year == date.getFullYear()))2139 {2140 isValidDate = true;2141 }2142 }2143 if (!isValidDate) { alertOnFailure = PTDateValidator.alertOnFailure(alertOnFailure,formatList,timePolicy); }2144 var isTimeValid = false;2145 if (timePolicy == PTDateValidator.TIME_POLICY_ALLOW_TIMES)2146 {2147 if ((PTNumberUtil.isInteger(dateData.hour) && PTNumberUtil.isInteger(dateData.minutes)) ||2148 (!PTNumberUtil.isInteger(dateData.hour) && !PTNumberUtil.isInteger(dateData.minutes)))2149 {2150 isTimeValid = true;2151 } else { alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy); }2152 }2153 else if (timePolicy == PTDateValidator.TIME_POLICY_REQUIRE_TIMES)2154 {2155 if (PTNumberUtil.isInteger(dateData.hour) && PTNumberUtil.isInteger(dateData.minutes))2156 {2157 isTimeValid = true;2158 } else { alertOnFailure = PTDateValidator.alertTimeRequired(alertOnFailure,formatList,timePolicy); }2159 }2160 else if (timePolicy == PTDateValidator.TIME_POLICY_FORBID_TIMES)2161 {2162 if (!PTNumberUtil.isInteger(dateData.hour) && !PTNumberUtil.isInteger(dateData.minutes))2163 {2164 isTimeValid = true;2165 } else { alertOnFailure = PTDateValidator.alertTimeForbidden(alertOnFailure,formatList,timePolicy); }2166 }2167 if (timePolicy != PTDateValidator.TIME_POLICY_FORBID_TIMES)2168 {2169 if ((dateData.hour < 0) || (dateData.hour > 23))2170 {2171 isTimeValid = false;2172 alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy);2173 }2174 else if ((dateData.minutes < 0) || (dateData.minutes > 59))2175 {2176 isTimeValid = false;2177 alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy);2178 }2179 else if ((dateData.seconds < 0) || (dateData.seconds > 59))2180 {2181 isTimeValid = false;2182 alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy);2183 }2184 }2185 var returnValue = false;2186 if (isValidDate && isTimeValid) { returnValue = date; }2187 return returnValue;2188}2189PTDateValidator.parseDateStringAgainstFormat = function(dateString, format, hash, locale)2190{2191 dateString = (new String(dateString)).replace(/\'/g,'');2192 format = format.replace(/\'\'/g,'');2193 while (1)2194 {2195 var s = format.indexOf('\'');2196 if (s == -1) { break; }2197 var e = format.substr(s + 1).indexOf('\'');2198 if (e == -1) { break; }2199 e += s + 1;2200 var literal = format.substring(s + 1,e);2201 var percent = parseInt(((s / format.length) * 100),10);2202 var matches = PTDateValidator.findAllMatches(literal, dateString, locale);2203 var bestMatch = false;2204 var bestDist = 100;2205 for (var m = 0; m < matches.length; m++)2206 {2207 var match = matches[m];2208 var dist = Math.abs(percent - match.pct);2209 if (dist < bestDist) { bestMatch = match; }2210 }2211 if (bestMatch)2212 {2213 var start = bestMatch.loc;2214 var end = start + literal.length;2215 dateString = dateString.substring(0,start) + ' ' + dateString.substr(end);2216 }2217 format = format.substring(0,s) + ' ' + format.substr(e + 1);2218 }2219 dateString = PTStringUtil.substituteChars(dateString,hash);2220 format = PTStringUtil.substituteChars(format,hash);2221 dateString = PTStringUtil.trimWhitespace(dateString,true,true);2222 format = PTStringUtil.trimWhitespace(format,true,true);2223 var i = dateString.split(/\s+/);2224 var f = format.split(/\s+/);2225 var dateData = new _dateData();2226 var numWords = Math.min(i.length,f.length);2227 for (var w = 0; w < numWords; w++)2228 { 2229 var formatToken = f[w];2230 var word = i[w];2231 dateData = PTDateValidator.validateWordByTokenType(word,formatToken,dateData,locale);2232 if (dateData == false) { return false; }2233 }2234 return dateData;2235}2236PTDateValidator.validateWordByTokenType = function(word, formatToken, dateData, locale)2237{2238 word = word.toLowerCase();2239 var foundAmpm = false;2240 var STR = PTDateStrings;2241 if (locale.indexOf('en') == 0) { STR = PTDate.EnglishStrings; }2242 if (formatToken.indexOf('a') > -1)2243 {2244 var strings = STR.ampm.length;2245 for (var s = 0; s < strings; s++)2246 {2247 var ampmString = STR.ampm[s];2248 var idx = word.indexOf(ampmString.toLowerCase());2249 if (idx > -1)2250 {2251 dateData.ampm = (s) ? 'pm' : 'am';2252 word = word.substring(0,idx) + word.substr(ampmString.length);2253 while (formatToken.indexOf('a') > -1)2254 {2255 var pos = formatToken.indexOf('a');2256 formatToken = formatToken.substring(0,pos) + formatToken.substr(pos + 1);2257 }2258 foundAmpm = true;2259 break;2260 }2261 }2262 }2263 if (formatToken.charAt(0) == 'd')2264 { if (!PTNumberUtil.isInteger(word)) { return false; }2265 var n = word;2266 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2267 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2268 if (isNaN(n)) { return false; } dateData.day = n;2269 return dateData;2270 }2271 else if (formatToken == 'E')2272 { if (PTDateValidator.isWordLike(word,STR.daysInitial,7)) { return dateData; }2273 }2274 else if (formatToken.substring(0,2) == 'EE')2275 { if (PTDateValidator.isWordLike(word,STR.daysLong.concat(STR.daysShort),7)) { return dateData; }2276 }2277 else if (formatToken.charAt(0).toLowerCase() == 'h')2278 { if (!PTNumberUtil.isInteger(word)) { return false; }2279 var n = word;2280 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2281 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2282 if (isNaN(n)) { return false; } dateData.hour = n;2283 return dateData;2284 }2285 else if (formatToken.charAt(0).toLowerCase() == 'k')2286 { if (!PTNumberUtil.isInteger(word)) { return false; }2287 var n = word;2288 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2289 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2290 if (isNaN(n)) { return false; } dateData.hour = n;2291 return dateData;2292 }2293 else if (formatToken.charAt(0) == 'm')2294 { if (!PTNumberUtil.isInteger(word)) { return false; }2295 var n = word;2296 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2297 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2298 if (isNaN(n)) { return false; } dateData.minutes = n;2299 return dateData;2300 }2301 else if ((formatToken == 'M') || (formatToken == 'MM'))2302 { if (!PTNumberUtil.isInteger(word)) { return false; }2303 var n = word;2304 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2305 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2306 if (isNaN(n)) { return false; }2307 n -= 1; dateData.month = n;2308 return dateData;2309 }2310 else if (formatToken.substring(0,3) == 'MMM')2311 { var m = PTDateValidator.isWordLike(word,STR.monthsLong.concat(STR.monthsShort),12);2312 if (m)2313 { if (parseInt(m,10) == 0) { dateData.month = 0; }2314 else { dateData.month = parseInt(PTNumberUtil.trimLeadingZeros(m),10); }2315 return dateData;2316 }2317 }2318 else if (formatToken.charAt(0) == 's')2319 {2320 var n = word;2321 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2322 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); } if (isNaN(n)) { dateData.seconds = 0; } else { dateData.seconds = n; }2323 return dateData;2324 }2325 else if (formatToken.charAt(0) == 'S')2326 { return dateData;2327 }2328 else if (formatToken.indexOf('yy') > -1)2329 { if (!PTNumberUtil.isInteger(word)) { return false; }2330 var n = parseInt(PTNumberUtil.trimLeadingZeros(word),10);2331 if (isNaN(n)) { return false; } if (n < 100)2332 {2333 n = PTDate.convert2DigitTo4DigitYear(n);2334 }2335 dateData.year = n;2336 return dateData;2337 }2338 else if (formatToken.charAt(0) == 'z')2339 { return dateData;2340 }2341 if (foundAmpm) { return dateData }2342 else { return false; }2343}2344PTDateValidator.isWordLike = function(word, matchArray, numTests)2345{2346 word = word + ''; 2347 var len = matchArray.length;2348 for (var a = 0; a < len; a++)2349 {2350 var m = (new String(matchArray[a])).toLowerCase() + ''; 2351 if (m == word) { return new String(a % numTests); }2352 if ((word.length >= 3) && (m.indexOf(word.substring(0,3)) == 0)) { return new String(a % numTests); }2353 m = PTStringUtil.substituteChars(m,PTDateValidator.closeSubstitutes);2354 if (m == word) { return new String(a % numTests); }2355 if ((word.length >= 3) && (m.indexOf(word) == 0)) { return new String(a % numTests); }2356 }2357 return false;2358}2359PTDateValidator.findAllMatches = function(pattern, string, locale)2360{2361 var results = new Array();2362 var tester = new String(string);2363 var chopped = 0;2364 var STR = PTDateStrings;2365 if (locale.indexOf('en') == 0) { STR = PTDate.EnglishStrings; }2366 while (tester.indexOf(pattern) > -1)2367 {2368 var loc = tester.indexOf(pattern);2369 var pos = loc + chopped;2370 var nogood = false;2371 var fragment = (tester.substr(tester.indexOf(pattern))).replace(/\s.*$/,'');2372 if (fragment.length > 1)2373 {2374 for (var i = 0; i < STR.monthsLong.length; i++)2375 {2376 if (STR.monthsLong[i].indexOf(fragment) > -1)2377 {2378 nogood = true;2379 break;2380 }2381 }2382 }2383 if (!nogood)2384 {2385 var r = results[results.length] = new Object();2386 r.loc = pos;2387 r.pct = Math.round((pos / string.length) * 100);2388 }2389 tester = tester.substr(loc + 1);2390 chopped += (loc + 1);2391 }2392 return results;2393}2394PTDateValidator.alertOnFailure = function(alertOnFailure, formatList, timePolicy)2395{2396 if (alertOnFailure)2397 {2398 var sb = new PTStringBuffer();2399 sb.append(PTS_STR['PTU-DateV-DateFormatError'] + '\n\n');2400 sb.append(PTS_STR['PTU-DateV-ExampleFormats'] + '\n\n');2401 var m = new Array();2402 var d = new Date();2403 var startAt = 0;2404 if (formatList[0] == formatList[2]) { startAt = 1; }2405 for (var f = startAt; f < formatList.length; f++)2406 {2407 var format = formatList[f];2408 if (timePolicy == PTDateValidator.TIME_POLICY_FORBID_TIMES) { format = PTDate.stripTimesFromFormat(format); }2409 var formattedDate = PTDate.formatDate(d,format);2410 if (m[formattedDate]) { continue; }2411 else { m[formattedDate] = true; }2412 sb.append(' ' + formattedDate + '\n');2413 }2414 sb.append('\n');2415 alert(sb.toString());2416 }2417 return false;2418}2419PTDateValidator.alertTimeFormatProblem = function(alertOnFailure, formatList, timePolicy)2420{2421 if (alertOnFailure)2422 {2423 alert(PTS_STR['PTU-DateV-TimeFormatError']);2424 return false;2425 }2426 return alertOnFailure;2427}2428PTDateValidator.alertTimeRequired = function(alertOnFailure, formatList, timePolicy)2429{2430 if (alertOnFailure)2431 {2432 alert(PTS_STR['PTU-DateV-TimeRequired']);2433 return false;2434 }2435 return alertOnFailure;2436}2437PTDateValidator.alertTimeForbidden = function(alertOnFailure, formatList, timePolicy)2438{2439 if (alertOnFailure)2440 {2441 alert(PTS_STR['PTU-DateV-TimeForbidden']);2442 return false;2443 }2444 return alertOnFailure;2445}2446PTDateValidator.getPunctuationHash = function()2447{2448 var hash = new Array();2449 var chars = PTStringUtil.whitespaceChars.concat(PTDateValidator.punctuation);2450 var len = chars.length;2451 for (var c = 0; c < len; c++) { hash[chars[c]] = ' '; }2452 return hash;2453}2454function _dateData()2455{2456 this.day = false;2457 this.month = false;2458 this.year = false;2459 this.hour = false;2460 this.minutes = false;2461 this.seconds = false;2462 this.ampm = false;2463 return this;2464}2465PTEventUtil = function()2466{2467 return this;2468}2469PTEventUtil.VERSION = '246682';2470PTEventUtil.SRC_BUTTON_LEFT = 'left';2471PTEventUtil.SRC_BUTTON_RIGHT = 'right';2472PTEventUtil.SRC_BUTTON_MIDDLE = 'middle';2473PTEventUtil.stopBubbling = function(e)2474{2475 if (!e) var e = window.event;2476 if (!e) return;2477 e.cancelBubble = true;2478 if (e.stopPropagation) e.stopPropagation();2479}2480PTEventUtil.attachEventListener = function(targetElement, eventName, listenerReference)2481{ if (document.all)2482 { if (eventName.substring(0,2) != 'on') { eventName = 'on' + eventName; }2483 targetElement.attachEvent(eventName, listenerReference);2484 } else2485 { if (eventName.substring(0,2) == 'on') { eventName = eventName.substring(2,eventName.length); }2486 targetElement.addEventListener(eventName, listenerReference, false);2487 }2488}2489PTEventUtil.detachEventListener = function(targetElement, eventName, listenerReference)2490{ if (document.all)2491 { if (eventName.substring(0,2) != 'on') { eventName = 'on' + eventName; }2492 targetElement.detachEvent(eventName, listenerReference);2493 } else2494 { if (eventName.substring(0,2) == 'on') { eventName = eventName.substring(2,eventName.length); }2495 targetElement.removeEventListener(eventName, listenerReference, false);2496 }2497}2498PTEventUtil.getSrcElement = function(e)2499{ if (document.all)2500 {2501 return e.srcElement;2502 } else2503 {2504 return e.target;2505 }2506}2507PTEventUtil.getButtonClicked = function(e)2508{2509 if (!e) { return false; }2510 if (document.all)2511 {2512 if (e.button == 1) { return PTEventUtil.SRC_BUTTON_LEFT; }2513 else if (e.button == 4) { return PTEventUtil.SRC_BUTTON_MIDDLE; }2514 else if (e.button == 2){ return PTEventUtil.SRC_BUTTON_RIGHT; }2515 else { return false; }2516 } else2517 {2518 if (e.button == 0) { return PTEventUtil.SRC_BUTTON_LEFT; }2519 else if (e.button == 1) { return PTEventUtil.SRC_BUTTON_MIDDLE; }2520 else if (e.button == 2){ return PTEventUtil.SRC_BUTTON_RIGHT; }2521 else { return false; }2522 }2523}2524PTEventUtil.getMouseOverFromElement = function(e)2525{2526 if (!e) { return false; }2527 if (document.all) { return e.fromElement; } else { return e.relatedTarget; }2528}2529PTEventUtil.getMouseOutFromElement = function(e)2530{2531 if (!e) { return false; }2532 if (document.all) { return e.fromElement; } else { return e.target; }2533}2534PTEventUtil.getMouseOverToElement = function(e)2535{2536 if (!e) { return false; }2537 if (document.all) { return e.toElement; } else { return e.target; }2538}2539PTEventUtil.getMouseOutToElement = function(e)2540{2541 if (!e) { return false; }2542 if (document.all) { return e.toElement; } else { return e.relatedTarget; }2543}2544PTEventUtil.clickElement = function(elm) 2545{ if (elm.click) { elm.click(); } else if (elm.dispatchEvent) {2546 var evt = document.createEvent('MouseEvents');2547 evt.initMouseEvent(2548 'click',2549 true,2550 true,2551 window,2552 1,2553 0,2554 0,2555 0,2556 0,2557 false,2558 false,2559 false,2560 false,2561 0,2562 null2563 );2564 elm.dispatchEvent(evt);2565}2566}2567PTEventUtil.getMouseX = function(e)2568{2569 var posx = 0;2570 if (!e) var e = window.event;2571 if (e.pageX)2572 {2573 posx = e.pageX;2574 }2575 else if (e.clientX)2576 {2577 posx = e.clientX;2578 posy = e.clientY;2579 if (PTBrowserInfo.IS_MSIE)2580 {2581 posx += document.body.scrollLeft;2582 }2583 }2584 return posx;2585}2586PTEventUtil.getMouseY = function(e)2587{2588 var posy = 0;2589 if (!e) var e = window.event;2590 if (e.pageY)2591 {2592 posy = e.pageY;2593 }2594 else if (e.clientY)2595 {2596 posy = e.clientY;2597 if (PTBrowserInfo.IS_MSIE)2598 {2599 posy += document.body.scrollTop;2600 }2601 }2602 return posy;2603}2604PTFormUtil = function() {}2605PTFormUtil.VERSION = '246682';2606PTFormUtil.getRadioValue = function(rads)2607{2608 if (!rads) { return; }2609 var val;2610 if (rads.length > 1) {2611 for (var i = 0; i < rads.length; i++) {2612 if (rads[i].checked) {2613 val = rads[i].value;2614 break;2615 }2616 }2617 } else {2618 val = rads.value;2619 }2620 return val;2621}2622PTFormUtil.setRadioValue = function(rads,val)2623{2624 if (!rads) { return false; }2625 var foundRadio = false;2626 if (rads.length > 1)2627 {2628 for (var i = 0; i < rads.length; i++)2629 {2630 if (rads[i].value == val)2631 {2632 foundRadio = true;2633 break;2634 }2635 }2636 if (foundRadio)2637 {2638 for (var i = 0; i < rads.length; i++)2639 {2640 if (rads[i].value == val) { rads[i].checked = true; }2641 else { rads[i].checked = false; }2642 }2643 }2644 }2645 else2646 {2647 foundRadio = (rads.checked = true);2648 }2649 return foundRadio;2650}2651PTFormUtil.setSelectValue = function(sel,val)2652{2653 var success = false;2654 if (!sel) { return success; }2655 if (sel.options.length < 1) { return success; }2656 for (var i = 0; i < sel.options.length; i++) {2657 var opt = sel.options[i];2658 if (opt.value && opt.value == val) {2659 sel.selectedIndex = i;2660 success = true;2661 break;2662 }2663 }2664 return success;2665}2666PTFormUtil.fillSelect = function(sel,optionsInfo)2667{2668 if (!sel) { return; }2669 if (!optionsInfo) { return; }2670 if (!optionsInfo.length) { return; }2671 var numOldOptions = sel.options.length;2672 var numNewOptions = optionsInfo.length;2673 for (var i = 0; i < numNewOptions; i++) {2674 if (!optionsInfo[i]) { continue; }2675 var curNewOption = optionsInfo[i];2676 var newOptionText = curNewOption.text;2677 var newOptionValue = curNewOption.value;2678 var newOptionIndex = numOldOptions + i;2679 sel.options[newOptionIndex] = new Option(newOptionText,newOptionValue);2680 }2681}2682PTFormUtil.clearSelect = function(sel)2683{2684 if (!sel) { return; }2685 var numOpts = sel.options.length;2686 if (numOpts == 0) { return; }2687 for (var i = (numOpts - 1); i >= 0; i--) {2688 sel.options[i] = null;2689 }2690}2691PTFormUtil.addItemToSelect = function(sel,val,txt,idx)2692{2693 if ((!idx && (idx != 0)) || (idx == -1)) {2694 idx = sel.options.length;2695 sel.options[idx] = new Option(txt,val);2696 } else {2697 var opts = sel.options;2698 var len = opts.length;2699 for (var i = len; i > idx; i--) {2700 if (!opts[i]) {2701 opts[i] = new Option(opts[i-1].text,opts[i-1].value);2702 } else {2703 opts[i].text = opts[i-1].text;2704 opts[i].value = opts[i-1].value;2705 }2706 }2707 opts[idx].text = txt;2708 opts[idx].value = val;2709 }2710 return idx;2711}2712PTFormUtil.selectMoveItemUp = function(sel)2713{2714 idx = sel.selectedIndex;2715 if (idx == -1) { return; }2716 if (idx < 1) { return; }2717 var swapText = sel.options[idx-1].text;2718 var swapVal = sel.options[idx-1].value;2719 sel.options[idx-1].text = sel.options[idx].text;2720 sel.options[idx-1].value = sel.options[idx].value;2721 sel.options[idx].text = swapText;2722 sel.options[idx].value = swapVal;2723 sel.selectedIndex = idx - 1;2724}2725PTFormUtil.selectMoveItemDown = function(sel)2726{2727 idx = sel.selectedIndex;2728 if (idx == -1) { return; }2729 if (idx >= (sel.options.length - 1)) { return; }2730 var swapText = sel.options[idx+1].text;2731 var swapVal = sel.options[idx+1].value;2732 sel.options[idx+1].text = sel.options[idx].text;2733 sel.options[idx+1].value = sel.options[idx].value;2734 sel.options[idx].text = swapText;2735 sel.options[idx].value = swapVal;2736 sel.selectedIndex = idx + 1;2737}2738PTFormUtil.focusAndSelectText = function(input)2739{2740 if (!input || !input.focus || !input.select) { return; }2741 input.focus();2742 input.select();2743}2744PTFormUtil.focusFormFieldByName = function(fieldName)2745{2746 var field = eval(fieldName);2747 if (field && field.focus) { field.focus(); }2748}2749PTFormUtil.hideAllSelects = function(elem)2750{2751 if (!elem) { elem = window.document; }2752 var selects = elem.getElementsByTagName('select');2753 var hiddenSelects = new Array();2754 for (var s = 0; s < selects.length; s++)2755 {2756 if(selects[s].style.visibility != 'hidden')2757 {2758 PTFormUtil.setSelectVisibility(selects[s],'hidden');2759 hiddenSelects[hiddenSelects.length] = selects[s];2760 }2761 }2762 return hiddenSelects;2763}2764PTFormUtil.hideSelects = function(selects)2765{2766 if(!selects) return;2767 for (var s = 0; s < selects.length; s++)2768 {2769 PTFormUtil.setSelectVisibility(selects[s],'hidden');2770 }2771}2772PTFormUtil.showAllSelects = function(elem)2773{2774 if (!elem) { elem = window.document; }2775 var selects = elem.getElementsByTagName('select');2776 var visibleSelects = new Array();2777 for (var s = 0; s < selects.length; s++)2778 {2779 if(selects[s].style.visibility == 'hidden')2780 {2781 PTFormUtil.setSelectVisibility(selects[s],'visible');2782 visibleSelects[visibleSelects.length] = selects[s];2783 }2784 }2785 return visibleSelects;2786}2787PTFormUtil.showSelects = function(selects)2788{2789 if(!selects) return;2790 for(var s = 0; s < selects.length; s++)2791 {2792 PTFormUtil.setSelectVisibility(selects[s], 'visible');2793 }2794}2795PTFormUtil.disableAllSelects = function(elem)2796{2797 if (!elem) { elem = window.document; }2798 var selects = elem.getElementsByTagName('select');2799 if (!window._selectStateCache) { window._selectStateCache = new Object(); }2800 for (var s = 0; s < selects.length; s++)2801 {2802 var sel = selects[s];2803 if (sel.id)2804 {2805 if (sel.disabled === true) { window._selectStateCache[sel.id] = true; }2806 else { window._selectStateCache[sel.id] = false; }2807 }2808 sel.disabled = true;2809 }2810}2811PTFormUtil.enableAllSelects = function(elem,useSelectStateCache)2812{2813 if (!elem) { elem = window.document; }2814 var selects = elem.getElementsByTagName('select');2815 for (var s = 0; s < selects.length; s++)2816 {2817 var sel = selects[s];2818 if (useSelectStateCache && window._selectStateCache && window._selectStateCache[sel.id]) { continue; }2819 selects[s].disabled = false;2820 }2821}2822PTFormUtil.setSelectVisibility = function(select,vis)2823{2824 if (!select) { return false; }2825 select.style.visibility = vis;2826}2827PTHashtable = function()2828{2829 this._keys = new Array();2830 this._values = new Object();2831 this._enumKeyIndex = -1;2832 return this;2833}2834PTHashtable.VERSION = '246682';2835PTHashtable.prototype.className = 'PTHashtable';2836PTHashtable.prototype.clear = function()2837{2838 this._keys = new Array();2839 this._values = new Object();2840 this._enumKeyIndex = -1;2841}2842PTHashtable.prototype.clone = function()2843{2844 var newHT = new PTHashtable();2845 var numKeys = this._keys.length;2846 for (var i = 0; i < numKeys; i++)2847 {2848 var key = this._keys[i];2849 newHT._keys[i] = key;2850 newHT._values[key] = this._values[key];2851 }2852 return newHT;2853}2854PTHashtable.prototype.contains = function(obj)2855{2856 return this.containsValue(obj);2857}2858PTHashtable.prototype.containsKey = function(key)2859{2860 var numKeys = this._keys.length;2861 for (var i = 0; i < numKeys; i++)2862 {2863 if (this._keys[i] == key) { return true; }2864 }2865 return false;2866}2867PTHashtable.prototype.containsValue = function(obj)2868{2869 var numKeys = this._keys.length;2870 for (var i = 0; i < numKeys; i++)2871 {2872 var key = this._keys[i];2873 if (this._values[key] == obj) { return true; }2874 }2875 return false;2876}2877PTHashtable.prototype.equals = function(obj)2878{2879 if (!obj) { return false; }2880 if (!obj.className) { return false; }2881 if (obj.className != 'PTHashtable') { return false; }2882 if (!obj._keys) { return false; }2883 if (!PTArrayUtil.isArrayLike(obj._keys)) { return false; }2884 if (obj._keys.length != this._keys.length) { return false; }2885 var numKeys = this._keys.length;2886 for (var i = 0; i < numKeys; i++)2887 {2888 var key = this._keys[i];2889 if (key != obj._keys[i]) { return false; }2890 if (this._values[key] != obj._values[key]) { return false; }2891 }2892 return true;2893}2894PTHashtable.prototype.get = function(key)2895{2896 return this._values[key];2897}2898PTHashtable.prototype.hasNext = function()2899{2900 var index = this._enumKeyIndex + 1;2901 return (this._keys.length > index) ? true : false;2902}2903PTHashtable.prototype.isEmpty = function()2904{2905 return (this.size() == 0) ? true : false;2906}2907PTHashtable.prototype.keys = function()2908{2909 var arr = new Array();2910 var numKeys = this._keys.length;2911 for (var i = 0; i < numKeys; i++)2912 {2913 arr[i] = this._keys[i];2914 }2915 return arr;2916}2917PTHashtable.prototype.next = function()2918{2919 this._enumKeyIndex++;2920 if (!this.hasNext()) { return; }2921 else2922 {2923 return this._values[this._keys[this._enumKeyIndex]];2924 }2925}2926PTHashtable.prototype.put = function(key,value)2927{2928 var oldValue = this._values[key];2929 if (!this.containsKey(key))2930 {2931 this._keys.push(key);2932 }2933 this._values[key] = value;2934 return oldValue;2935}2936PTHashtable.prototype.remove = function(key)2937{2938 var oldValue = this._values[key];2939 var keyIndex = -1;2940 var numKeys = this._keys.length;2941 for (var i = 0; i < numKeys; i++)2942 {2943 if (this._keys[i] == key)2944 {2945 keyIndex = i;2946 break;2947 }2948 }2949 if (keyIndex == -1) { return; }2950 this._keys.splice(keyIndex,1);2951 return oldValue;2952}2953PTHashtable.prototype.resetIterator = function()2954{2955 this._enumKeyIndex = -1;2956}2957PTHashtable.prototype.size = function()2958{2959 return this._keys.length;2960}2961PTHashtable.prototype.toArray = function()2962{2963 var arr = new Array();2964 var numKeys = this._keys.length;2965 for (var i = 0; i < numKeys; i++)2966 {2967 var key = this._keys[i];2968 var value = this._values[key];2969 var obj = new Object();2970 obj.key = key;2971 obj.value = value;2972 arr[i] = obj;2973 }2974 return arr;2975}2976PTHashtable.prototype.toString = function()2977{2978 var sb = new PTStringBuffer();2979 sb.append('{ ');2980 var numKeys = this._keys.length;2981 for (var i = 0; i < numKeys; i++)2982 {2983 var key = this._keys[i];2984 var value = this._values[key];2985 sb.append('\'' + PTStringUtil.escapeJS(key) + '\'');2986 sb.append(' : ');2987 sb.append('\'' + PTStringUtil.escapeJS(value) + '\'');2988 if (i != (numKeys - 1)) { sb.append(', '); }2989 }2990 sb.append(' }');2991 return sb.toString();2992}2993PTHashtable.prototype.values = function()2994{2995 var arr = new Array();2996 var numKeys = this._keys.length;2997 for (var i = 0; i < numKeys; i++)2998 {2999 var key = this._keys[i];3000 arr[i] = this._values[key];3001 }3002 return arr;3003}3004PTNumberFormatter = function(num)3005{3006 this.num = (num) ? num : 0;3007 this.isGrouping = true;3008 this.isCurrency = false;3009 this.currencySymbol = '';3010 this.currencySymbolBefore = true;3011 this.groupingSeparator = ',';3012 this.decimalSeparator = '.';3013 this.decimalPlaces = -1;3014 this.negativePrefix = '-';3015 this.negativeSuffix = '';3016}3017PTNumberFormatter.VERSION = '246682';3018PTNumberFormatter.prototype.INVALID = 'INVALID';3019PTNumberFormatter.prototype.formatValue = function(num)3020{3021 if (num != null) { this.num = num; }3022 if ((this.num == null) || (this.num == '') || (this.num.toString().length == 0)) { return ''; }3023 if (this.isCurrency == true)3024 {3025 var csRe1 = new RegExp(this.currencySymbol, 'gi');3026 this.num = this.num.toString().replace(csRe1,'');3027 var csRe2 = new RegExp('\\'+this.currencySymbol, 'gi');3028 this.num = this.num.toString().replace(csRe2,'');3029 }3030 var gsRe = new RegExp('\\'+this.groupingSeparator, 'g');3031 this.num = this.num.toString().replace(gsRe,'');3032 if ((this.num.toString().indexOf('(') > -1) && (this.num.toString().indexOf(')') > -1)) { if (this.num.toString().indexOf(')') != this.num.toString().lastIndexOf(')')) {3033 return this.invalidNumber();3034 }3035 if (this.num.toString().indexOf('(') != this.num.toString().lastIndexOf('(')) {3036 return this.invalidNumber();3037 } if (this.num.toString().indexOf(')') < this.num.toString().lastIndexOf('(')) {3038 return this.invalidNumber();3039 }3040 var paRe1 = new RegExp('\\(', 'g');3041 this.num = this.num.toString().replace(paRe1,'');3042 var paRe2 = new RegExp('\\)', 'g');3043 this.num = this.num.toString().replace(paRe2,''); if (this.num.toString().indexOf('-') == -1) {3044 this.num = '-' + this.num.toString();3045 }3046 }3047 if (this.num.toString().indexOf('-') != this.num.toString().lastIndexOf('-')) { return this.invalidNumber();3048 }3049 var mseRe = new RegExp('\\d\\D*-\\D*\\d', 'g');3050 if (mseRe.test(this.num.toString())) {3051 return this.invalidNumber();3052 }3053 if (this.num.toString().indexOf('-') != -1) {3054 var msRe = new RegExp('-', 'g');3055 this.num = this.num.toString().replace(msRe,'');3056 this.num = '-' + this.num.toString();3057 }3058 dsRe = new RegExp('\\'+this.decimalSeparator, 'g');3059 this.num = this.num.toString().replace(dsRe,'.');3060 if (isNaN(this.num)) {3061 return this.invalidNumber();3062 }3063 var pos;3064 var nNum = this.num; 3065 var nStr; 3066 var absNum = this.num;3067 if (absNum.toString().indexOf('-') == 0) {3068 absNum = absNum.substring(1);3069 }3070 nNum = this.getRounded(nNum);3071 nStr = this.preserveZeros(absNum);3072 dotRe = new RegExp('\\.', 'g');3073 nStr = nStr.replace(dotRe,this.decimalSeparator);3074 if (this.isGrouping) {3075 pos = nStr.indexOf(this.decimalSeparator);3076 if (pos == -1) {3077 pos = nStr.length;3078 }3079 while (pos > 0) {3080 pos -= 3;3081 if (pos <= 0) { break; }3082 nStr = nStr.substring(0,pos) + this.groupingSeparator + nStr.substring(pos, nStr.length);3083 }3084 }3085 if (this.isCurrency) {3086 if (this.currencySymbolBefore) {3087 nStr = this.currencySymbol + nStr;3088 } else {3089 nStr = nStr + this.currencySymbol;3090 }3091 }3092 nStr = (nNum < 0) ? this.negativePrefix + nStr + this.negativeSuffix : nStr; 3093 return (nStr);3094}3095PTNumberFormatter.prototype.setNumber = function(num)3096{3097 this.num = num;3098}3099PTNumberFormatter.prototype.toUnformatted = function()3100{3101 return (this.num);3102}3103PTNumberFormatter.prototype.setGrouping = function(showGroupingSeparator)3104{3105 this.isGrouping = showGroupingSeparator;3106}3107PTNumberFormatter.prototype.setGroupingSeparator = function(separator)3108{3109 this.groupingSeparator = separator;3110}3111PTNumberFormatter.prototype.setDecimalSeparator = function(separator)3112{3113 this.decimalSeparator = separator;3114}3115PTNumberFormatter.prototype.setCurrency = function(isCurrency)3116{3117 this.isCurrency = isCurrency;3118}3119PTNumberFormatter.prototype.setCurrencySymbol = function(symbol)3120{3121 this.currencySymbol = symbol;3122}3123PTNumberFormatter.prototype.setCurrencySymbolBefore = function(showSymbolBefore)3124{3125 this.currencySymbolBefore = showSymbolBefore;3126}3127PTNumberFormatter.prototype.setDecimalPlaces = function(numDecimalPlaces)3128{3129 this.decimalPlaces = numDecimalPlaces;3130}3131PTNumberFormatter.prototype.setNegativePrefix = function(symbol)3132{3133 this.negativePrefix = symbol;3134}3135PTNumberFormatter.prototype.setNegativeSuffix = function(symbol)3136{3137 this.negativeSuffix = symbol;3138}3139PTNumberFormatter.prototype.formatField = function(field)3140{3141 var formatted = this.formatValue(field.value);3142 if (formatted == this.INVALID)3143 {3144 field.value = '';3145 field.focus();3146 }3147 else { field.value = formatted; }3148}3149PTNumberFormatter.prototype.validateValue = function(number)3150{3151 var formatted = this.formatValue(number);3152 if (formatted == this.INVALID) { return false; }3153 else { return true; }3154}3155PTNumberFormatter.prototype.getRounded = function(val)3156{3157 if (this.decimalPlaces < 0) return val;3158 var factor;3159 var i;3160 factor = 1;3161 for (i=0; i<this.decimalPlaces; i++)3162 { factor *= 10; }3163 val *= factor;3164 val = Math.round(val);3165 val /= factor;3166 return (val);3167}3168PTNumberFormatter.prototype.preserveZeros = function(val)3169{3170 var i;3171 val = val + '';3172 if (this.decimalPlaces < 0) return val; 3173 var decimalPos = val.indexOf('.');3174 if (decimalPos == -1 && this.decimalPlaces > 0)3175 {3176 val += this.decimalSeparator;3177 for (i=0; i<this.decimalPlaces; i++)3178 {3179 val += '0';3180 }3181 }3182 else3183 {3184 var actualDecimals = (val.length - 1) - decimalPos;3185 var difference = this.decimalPlaces - actualDecimals;3186 for (i=0; i<difference; i++)3187 {3188 val += '0';3189 }3190 }3191 return val;3192}3193PTNumberFormatter.prototype.invalidNumber = function()3194{3195 alert(PTS_STR['PTU-Number-AlertInvNumber']);3196 return this.INVALID;3197}3198PTNumberFormatter.prototype.toFormatted = function(number)3199{3200 return this.formatValue(number);3201}3202PTNumberUtil = function() {}3203PTNumberUtil.VERSION = '246682';3204PTNumberUtil.isInteger = function(sNumber)3205{3206 sNumber = PTNumberUtil.trimLeadingZeros(sNumber); if (sNumber.length == 0)3207 {3208 return true;3209 }3210 var oString = new String(sNumber);3211 var nString = new String(parseInt(new String(sNumber)));3212 return (oString.valueOf() == nString.valueOf());3213}3214PTNumberUtil.isPositiveInteger = function(sNumber)3215{ 3216 if (!PTNumberUtil.isInteger(sNumber)) { return false; }3217 return (parseInt(sNumber) > 0);3218}3219PTNumberUtil.trimLeadingZeros = function(sNumber)3220{3221 sNumber = new String(sNumber);3222 while (sNumber.charAt(0) == '0') { sNumber = sNumber.substr(1); }3223 return sNumber;3224}3225PTStringBuffer = function(str) 3226{3227 this.i = 0;3228 this.s = new Array();3229 if (str && str.length && (str.length > 0))3230 {3231 this.s[this.i++] = str;3232 }3233 return this;3234}3235PTStringBuffer.VERSION = '246682';3236PTStringBuffer.prototype.append = function(str)3237{3238 if (this.i >= 1000 && this.i%1000 == 0) 3239 {3240 var tmp = this.s.join('');3241 this.s = new Array();3242 this.s[0] = tmp;3243 this.i = 1;3244 }3245 this.s[this.i++] = str;3246}3247PTStringBuffer.prototype.toString = function()3248{3249 return this.s.join('');3250}3251PTStringUtil = function() {}3252PTStringUtil.VERSION = '246682';3253PTStringUtil.isString = function(obj)3254{3255 if (obj == '') { return true; }3256 else if (typeof obj == 'string') { return true; }3257 else if (typeof obj == 'object')3258 {3259 if (obj.fixed && obj.link && obj.blink && obj.toUpperCase) { return true; }3260 else { return false; }3261 }3262 else { return false; }3263}3264PTStringUtil.isValidHTTPString = function(str)3265{3266 var strHTTPPartA = str.substring(0,7);3267 var strHTTPPartB = str.substring(0,8);3268 if ((strHTTPPartA != 'http://') && (strHTTPPartB != 'https://')) { return false; }3269 if (str.length < 8) { return false; }3270 if (PTStringUtil.containsWhitespace(str)) { return false; }3271 return true;3272}3273PTStringUtil.isValidUNCString = function(str, bCanBeNull)3274{3275 if (!str) { return false; }3276 if (bCanBeNull && (str == '')) { return true; }3277 if (str == '') { return false; }3278 var strUNCPart = str.substring(0,2);3279 if (strUNCPart != '\\\\' ) { return false; }3280 if (str.length < 3) { return false; }3281 return true;3282}3283PTStringUtil.containsAngleBrackets = function(str)3284{3285 var angles = /[<>]/;3286 return (angles.test(str));3287}3288PTStringUtil.containsWhitespace = function(str)3289{3290 var whitespaceChars = PTStringUtil.whitespaceChars;3291 str = new String(str);3292 for (var i = 0; i < str.length; i++) {3293 var theChar = str.charAt(i);3294 for (var j = 0; j < whitespaceChars.length; j++) {3295 var white = whitespaceChars[j];3296 if (theChar == white) {3297 return true;3298 }3299 }3300 }3301 return false;3302}3303PTStringUtil.isAllWhitespace = function(str)3304{3305 var whitespaceChars = PTStringUtil.whitespaceChars;3306 str = new String(str);3307 STRING:3308 for (var i = 0; i < str.length; i++) {3309 var theChar = str.charAt(i);3310 for (var j = 0; j < whitespaceChars.length; j++) {3311 var white = whitespaceChars[j];3312 if (theChar == white) {3313 continue STRING;3314 }3315 }3316 return false;3317 }3318 return true;3319}3320PTStringUtil.UCFirst = function(str) {3321 var firstLetter = (new String(str)).substring(0,1);3322 if (!firstLetter) { return str; }3323 else {3324 var restOfString = (new String(str)).substring(1);3325 if (!restOfString) { restOfString = ''; }3326 var ucFirst = firstLetter.toUpperCase() + restOfString;3327 return ucFirst;3328 }3329}3330PTStringUtil.stripChars = function(str,chars)3331{ 3332 if (!chars || (chars.length < 1)) { return str; }3333 str = new String(str);3334 var newStr = new String();3335 STRING:3336 for (var i = 0; i < str.length; i++) {3337 var theChar = str.charAt(i);3338 for (var j = 0; j < chars.length; j++) {3339 var strip = chars[j];3340 if (theChar == strip) {3341 continue STRING;3342 }3343 }3344 newStr += theChar;3345 }3346 return newStr;3347}3348PTStringUtil.whitespaceChars = new Array(' ','\n','\r','\t','\u00A0'); 3349PTStringUtil.trimWhitespace = function(str,trimFront,trimRear)3350{3351 if (!str) { return str; }3352 str = new String(str);3353 var whitespaceChars = PTStringUtil.whitespaceChars;3354 if (trimFront) {3355 var doTrim = true;3356 while (doTrim) {3357 var foundWhite = false;3358 for (var w = 0; w < whitespaceChars.length; w++) {3359 var c = whitespaceChars[w];3360 if (c == str.charAt(0)) {3361 foundWhite = true;3362 break;3363 }3364 }3365 if (foundWhite) {3366 str = str.substr(1);3367 } else {3368 doTrim = false;3369 }3370 }3371 }3372 if (trimRear) {3373 var doTrim = true;3374 while (doTrim) {3375 var foundWhite = false;3376 for (var w = 0; w < whitespaceChars.length; w++) {3377 var c = whitespaceChars[w];3378 if (c == str.charAt(str.length - 1)) {3379 foundWhite = true;3380 break;3381 }3382 }3383 if (foundWhite) {3384 str = str.substring(0, (str.length - 1));3385 } else {3386 doTrim = false;3387 }3388 }3389 }3390 return str;3391}3392PTStringUtil.escapeHTML = function(str,doLineBreakConversion,doWhitespaceConversion)3393{3394 str = new String(str);3395 if (document.getElementById)3396 {3397 var nextChar = new RegExp('"','g');3398 str = str.replace(nextChar, '&quot;');3399 var nextChar = new RegExp('<','g');3400 str = str.replace(nextChar, '&lt;');3401 var nextChar = new RegExp('>','g');3402 str = str.replace(nextChar, '&gt;');3403 if (doLineBreakConversion)3404 {3405 var nextChar = new RegExp('\n','g');3406 str = str.replace(nextChar, '<br>');3407 }3408 if (doWhitespaceConversion)3409 {3410 var nextChar = new RegExp('\\s','g');3411 str = str.replace(nextChar, '&nbsp;');3412 }3413 var newStr = str;3414 }3415 else3416 {3417 var escapes = {3418 '"' : '&quot;',3419 '<' : '&lt;',3420 '>' : '&gt;'3421 }3422 var newStr = new String();3423 STRING:3424 for (var i = 0; i < str.length; i++) {3425 var theChar = str.charAt(i);3426 for (var j in escapes) {3427 var esc = escapes[j];3428 if (theChar == j) {3429 newStr += esc;3430 continue STRING;3431 }3432 }3433 newStr += theChar;3434 }3435 }3436 return newStr;3437}3438PTStringUtil.unescapeHTML = function(str)3439{3440 str = new String(str);3441 var escQuote = new RegExp('&quot;','gi');3442 str = str.replace(escQuote,'"');3443 var escLeftAngle = new RegExp('&lt;','gi');3444 str = str.replace(escLeftAngle,'<');3445 var escLeftAngle = new RegExp('&gt;','gi');3446 str = str.replace(escLeftAngle,'>');3447 return str;3448}3449PTStringUtil.removeHTML = function(str)3450{3451 str = new String(str);3452 str = str.replace( new RegExp('&nbsp;','g') ,' ');3453 while ((str.indexOf('<') > -1) && (str.indexOf('>') > str.indexOf('<')))3454 {3455 var start = str.indexOf('<');3456 var end = str.indexOf('>');3457 str = str.substr(0,start) + str.substring(end + 1,str.length);3458 }3459 return str;3460}3461PTStringUtil.getInnerText = function(elem)3462{3463 var str;3464 if (PTBrowserInfo.IS_MSIE) { str = elem.innerText; }3465 else { str = PTStringUtil.removeHTML(elem.innerHTML); }3466 return str;3467}3468PTStringUtil.escapeJS = function(str)3469{3470 str = new String(str);3471 if (document.getElementById)3472 {3473 var nextChar = new RegExp('\\\\','g');3474 str = str.replace(nextChar, '\\\\');3475 var nextChar = new RegExp('\n','g');3476 str = str.replace(nextChar, '\\n');3477 var nextChar = new RegExp('\'','g');3478 str = str.replace(nextChar, '\\\'');3479 var newStr = str;3480 }3481 else3482 {3483 var escapes = {3484 '\n' : '\\n',3485 '\'' : '\\\'',3486 '\\' : '\\\\'3487 } 3488 var newStr = new String('');3489 STRING:3490 for (var i = 0; i < str.length; i++) {3491 var theChar = str.charAt(i);3492 for (var j in escapes) {3493 var esc = escapes[j];3494 if (theChar == j) {3495 newStr += esc;3496 continue STRING;3497 }3498 }3499 newStr += theChar;3500 }3501 }3502 return newStr;3503}3504PTStringUtil.encodeURL = function(str,URLEncodeSingleQuotes)3505{3506 if (str == null)3507 return null;3508 if (PTBrowserInfo.IS_NETSCAPE_DOM || PTBrowserInfo.IS_SAFARI || (PTBrowserInfo.IS_MSIE && PTBrowserInfo.MSIE_VERSION >= 5.5))3509 {3510 var encoded = encodeURIComponent(str);3511 if (URLEncodeSingleQuotes)3512 {3513 encoded = encoded.replace(/\'/g,'%27');3514 }3515 return encoded;3516 }3517 var theString = new String(str);3518 var encoded = new PTStringBuffer();3519 for (var i = 0; i < theString.length; i++ ) 3520 {3521 var theChar = theString.charAt(i);3522 var charCode = theChar.charCodeAt(0); if(((charCode > 47)&&(charCode < 58))||3523 ((charCode > 64)&&(charCode < 91))||3524 ((charCode > 96)&&(charCode < 123)))3525 {3526 encoded.append(String.fromCharCode(charCode));3527 } else if ((charCode <= 47)||3528 ((charCode >= 58)&&(charCode <= 64))||3529 ((charCode >= 91)&&(charCode <= 96))||3530 ((charCode >= 123)&&(charCode <= 127)))3531 {3532 var hex = charCode.toString(16);3533 var len = hex.length;3534 switch(len){3535 case 0:3536 hex = '00';3537 break;3538 case 1:3539 hex = '0'+hex;3540 case 2:3541 break;3542 defalt:3543 hex = hex.substring((len-2), len);3544 break;3545 }3546 encoded.append('%'+hex);3547 } else if ((charCode>127) && (charCode<2048))3548 {3549 encoded.append('%' + ((charCode>>6)|192).toString(16).toUpperCase());3550 encoded.append('%' + ((charCode&63)|128).toString(16).toUpperCase());3551 } else3552 {3553 var c1 = (charCode>>12)|224;3554 var c2 = ((charCode>>6)&63)|128;3555 var c3 = (charCode&63)|128;3556 encoded.append('%' + ((charCode>>12)|224).toString(16).toUpperCase());3557 encoded.append('%' + (((charCode>>6)&63)|128).toString(16).toUpperCase());3558 encoded.append('%' + ((charCode&63)|128).toString(16).toUpperCase());3559 }3560 }3561 var returnString = encoded.toString();3562 if (URLEncodeSingleQuotes)3563 {3564 returnString = returnString.replace(/\'/g,'%27');3565 }3566 return returnString;3567}3568PTStringUtil.substituteChars = function(str,hash)3569{3570 str = new String(str);3571 var newStr = new String();3572 STRING:3573 for (var i = 0; i < str.length; i++) {3574 var theChar = str.charAt(i);3575 for (var h in hash) {3576 var subs = hash[h];3577 if (theChar == h) {3578 newStr += subs;3579 continue STRING;3580 }3581 }3582 newStr += theChar;3583 }3584 return newStr;3585}3586PTStringUtil.lineBreakToBR = function(str)3587{3588 str = new String(str);3589 var br = /\n/g;3590 str = str.replace(br,'<br>');3591 return str;3592}3593PTWindowUtil = function()3594{3595 return this;3596}3597PTWindowUtil.VERSION = '246682';3598PTWindowUtil.defaultWidth = 650;3599PTWindowUtil.defaultHeight = 450;3600PTWindowUtil.helpWindowName = 'PTRoboHelp';3601PTWindowUtil.openWindow = function(URL,name,height,width,isFullChrome)3602{3603 var isNN4 = (document.layers);3604 if (!name) { name = 'PTWindow' + (new Date()).getTime(); }3605 var winWidth = (width) ? width : PTWindowUtil.defaultWidth;3606 var winHeight = (height) ? height : PTWindowUtil.defaultHeight;3607 var scrWidth = (isNN4) ? screen.width : screen.availWidth;3608 var scrHeight = (isNN4) ? screen.height : screen.availHeight;3609 var leftPosVal = parseInt(scrWidth/2) - parseInt(winWidth/2);3610 var topPosVal = parseInt(scrHeight/2) - parseInt(winHeight/2);3611 var leftPos = (isNN4) ? 'screenX=' + leftPosVal : 'left=' + leftPosVal;3612 var topPos = (isNN4) ? 'screenY=' + topPosVal : 'top=' + topPosVal;3613 var winProps = 'width=' + winWidth + ',height=' + winHeight + ',' + leftPos + ',' + topPos + ',resizable=1';3614 if (PTNumberUtil.isInteger(isFullChrome))3615 {3616 if (isFullChrome == 1) { winProps += ',scrollbars=1,status=0,toolbar=0,menubar=0,location=0'; }3617 }3618 else if (isFullChrome == true)3619 {3620 winProps += ',scrollbars=1,status=1,toolbar=1,menubar=1,location=1';3621 }3622 else3623 {3624 winProps += ',scrollbars=0,status=0,toolbar=0,menubar=0,location=0';3625 }3626 var winOpenedWindow = window.open(URL,name,winProps);3627 winOpenedWindow.focus();3628 return winOpenedWindow;3629}3630PTWindowUtil.openHelpWindow = function(URL,height,width,isFullChrome)3631{3632 return PTWindowUtil.openWindow(URL,PTWindowUtil.helpWindowName,height,width,isFullChrome);3633}3634function OpenSizedWindow(URL,name,height,width,isFullChrome)3635{3636 return PTWindowUtil.openWindow(URL,name,height,width,isFullChrome);...

Full Screen

Full Screen

PTUtil.js

Source:PTUtil.js Github

copy

Full Screen

12PTBrowserInfo = function()3{4 return this;5}6PTBrowserInfo.VERSION = '246682';7PTBrowserInfo.init = function()8{9 PTBrowserInfo.USER_AGENT = navigator.userAgent;10 PTBrowserInfo.MSIE_VERSION = PTBrowserInfo.getIEVersion();11 PTBrowserInfo.NETSCAPE_VERSION = PTBrowserInfo.getNNVersion();12 PTBrowserInfo.IS_DOM = (document.getElementById);13 PTBrowserInfo.IS_OPERA = (/opera [56789]|opera\/[56789]/i.test(PTBrowserInfo.USER_AGENT));14 PTBrowserInfo.IS_SAFARI = (/safari/i.test(PTBrowserInfo.USER_AGENT));15 PTBrowserInfo.IS_MSIE = (PTBrowserInfo.MSIE_VERSION && document.all && !PTBrowserInfo.IS_OPERA);16 PTBrowserInfo.IS_MSIE_4 = (PTBrowserInfo.MSIE_VERSION < 5.0);17 PTBrowserInfo.IS_MSIE_5 = ((PTBrowserInfo.MSIE_VERSION >= 5.0) && (PTBrowserInfo.MSIE_VERSION < 5.5));18 PTBrowserInfo.IS_MSIE_5_5 = ((PTBrowserInfo.MSIE_VERSION >= 5.5) && (PTBrowserInfo.MSIE_VERSION < 6.0));19 PTBrowserInfo.IS_MSIE_6 = ((PTBrowserInfo.MSIE_VERSION >= 6.0) && (PTBrowserInfo.MSIE_VERSION < 7.0));20 PTBrowserInfo.IS_MSIE_7 = ((PTBrowserInfo.MSIE_VERSION >= 7.0) && (PTBrowserInfo.MSIE_VERSION < 7.5));21 PTBrowserInfo.IS_NETSCAPE_4 = ((PTBrowserInfo.NETSCAPE_VERSION > 0) && (PTBrowserInfo.NETSCAPE_VERSION < 5.0));22 PTBrowserInfo.IS_NETSCAPE_6 = ((PTBrowserInfo.NETSCAPE_VERSION >= 5.0) && (PTBrowserInfo.NETSCAPE_VERSION < 7.0));23 PTBrowserInfo.IS_NETSCAPE_7 = (PTBrowserInfo.NETSCAPE_VERSION >= 7.0);24 PTBrowserInfo.IS_MOZILLA = ((!PTBrowserInfo.IS_OPERA) && (/gecko/i.test(PTBrowserInfo.USER_AGENT)));25 PTBrowserInfo.IS_NETSCAPE_DOM = (PTBrowserInfo.IS_MOZILLA || (PTBrowserInfo.NETSCAPE_VERSION >= 5.0));26 PTBrowserInfo.IS_HTTPS = (document.location.protocol.indexOf('https:') > -1);27 PTBrowserInfo.IS_XP_SP2 = (window.navigator.userAgent.indexOf('SV1') > -1);28 PTBrowserInfo.IS_NT4 = (window.navigator.userAgent.indexOf('Windows NT 4.0') > -1);29 PTBrowserInfo.isInitialized = true;30}31PTBrowserInfo.getIEVersion = function()32{33 var version = 0;34 var ua = new String(navigator.userAgent);35 if (ua.indexOf('MSIE ') > -1)36 {37 version = parseFloat(ua.substr(ua.indexOf('MSIE ') + 5));38 }39 return version;40}41PTBrowserInfo.getNNVersion = function()42{43 var version = 0;44 if(navigator.appName == 'Netscape')45 {46 version = parseFloat(navigator.appVersion);47 if(version >= 5)48 {49 if (typeof navigator.vendorSub != 'undefined')50 {51 version = parseFloat(navigator.vendorSub);52 }53 }54 }55 return version;56}57//: Initialize PTBrowserInfo once.58if (!PTBrowserInfo.isInitialized)59{60 PTBrowserInfo.init();61}62PTCommonUtil = function()63{64 return this;65}66PTCommonUtil.VERSION = '246682';67PTCommonUtil.getIEVersion = function()68{69 return PTBrowserInfo.getIEVersion();70}71PTCommonUtil.getNNVersion = function()72{73 return PTBrowserInfo.getNNVersion();74}75PTCommonUtil.getElementById = function(id)76{77 return PTDOMUtil.getElementById(id);78}79PTCommonUtil.copyObject = function(srcObj,destObj)80{81 if (!destObj)82 {83 if (srcObj.constructor) { destObj = srcObj.constructor(); }84 else { destObj = new Object(); }85 }86 var t = typeof srcObj;87 var isPrimitive = false;88 if (t == 'string') { isPrimitive = true; }89 else if (t == 'number') { isPrimitive = true; }90 else if (t == 'boolean') { isPrimitive = true; }91 if (isPrimitive) { destObj = srcObj; }92 else93 { if (srcObj && srcObj.slice && srcObj.sort && srcObj.length)94 {95 var len = srcObj.length;96 for (var a = 0; a < len; a++) { destObj[a] = srcObj[a]; }97 }98 else99 {100 for (var i in srcObj)101 {102 //: Isomorphic "SmartClient" (note the irony please) adds circular references as a by-product of103 //: extending the native Array class. We need to special case the exclusion of these, to prevent insanity.104 //: There is no need to explicitly copy 'function' objects for Arrays anyway -- they will be included105 //: automatically since we have instantiated copies via calling the 'new Array' constructor, above.106 if (srcObj.Class && (srcObj.Class == 'Array') && (typeof srcObj[i] == 'function')) { continue; }107 var t = typeof srcObj[i];108 var isPrimitive = false;109 if (t == 'string') { isPrimitive = true; }110 else if (t == 'number') { isPrimitive = true; }111 else if (t == 'boolean') { isPrimitive = true; }112 if (isPrimitive) { destObj[i] = srcObj[i]; }113 else { destObj[i] = PTCommonUtil.copyObject(srcObj[i]); }114 }115 }116 }117 return destObj;118}119PTCommonUtil.getServerFromURL = function(url)120{121 var link = document.createElement('A');122 link.href = url;123 return link.hostname;124}125PTCommonUtil.isDefined = function(obj)126{127 var type = typeof(obj);128 return (!(type == 'unknown') && !(type == 'undefined'));129}130PTCommonUtil.sortHashByKeys = function(hash,preserveFirstKey,isCaseInsensitive,doReverseSort)131{132 var keys = new Array();133 var sortedHash = new Object();134 var firstKey;135 var isNumericList = false;136 for (var key in hash) { firstKey = key; break; }137 var fkStr = new String(firstKey);138 if (!isNaN(parseInt(fkStr.charAt(0)))) { isNumericList = true; }139 for (var key in hash) { keys[keys.length] = key; }140 var sortedKeys;141 if (isNumericList)142 {143 sortedKeys = keys.sort(PTCommonUtil.sortNumeric);144 preserveFirstKey = false;145 }146 else if (doReverseSort)147 {148 if (isCaseInsensitive) { sortedKeys = keys.sort(PTCommonUtil.sortReverseCaseInsensitive); }149 else { sortedKeys = keys.sort(PTCommonUtil.sortReverse); }150 }151 else if (isCaseInsensitive)152 {153 sortedKeys = keys.sort(PTCommonUtil.sortCaseInsensitive);154 }155 else156 {157 sortedKeys = keys.sort(PTCommonUtil.sortForward);158 }159 if (preserveFirstKey) { sortedHash[firstKey] = hash[firstKey]; }160 for (var i = 0; i < sortedKeys.length; i++)161 {162 if (preserveFirstKey && (sortedKeys[i] == firstKey)) { continue; }163 sortedHash[sortedKeys[i]] = hash[sortedKeys[i]];164 }165 return sortedHash;166}167PTCommonUtil.sortNumeric = function(a,b)168{169 var numa = parseInt(a);170 var numb = parseInt(b);171 if (!isNaN(numa) && !isNaN(numb)) { return numa - numb; }172 else { return -1; }173}174PTCommonUtil.sortCaseInsensitive = function(aa,bb)175{176 var a = (new String(aa)).toLowerCase();177 var b = (new String(bb)).toLowerCase();178 if (a.valueOf() == b.valueOf()) { return 0; }179 var minLength = (a.length > b.length) ? b.length : a.length;180 var curPos = 0;181 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }182 var ac = a.charCodeAt(curPos);183 var bc = b.charCodeAt(curPos);184 if (isNaN(ac)) { return -1; }185 else if (isNaN(bc)) { return 1; }186 else { return ac - bc; }187}188PTCommonUtil.sortReverseCaseInsensitive = function(aa,bb)189{190 var a = (new String(aa)).toLowerCase();191 var b = (new String(bb)).toLowerCase();192 if (a.valueOf() == b.valueOf()) { return 0; }193 var minLength = (a.length > b.length) ? b.length : a.length;194 var curPos = 0;195 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }196 var ac = a.charCodeAt(curPos);197 var bc = b.charCodeAt(curPos);198 if (isNaN(ac)) { return 1; }199 else if (isNaN(bc)) { return -1; }200 else { return bc - ac; }201}202PTCommonUtil.sortReverse = function(aa,bb)203{204 var a = new String(aa);205 var b = new String(bb);206 if (a.valueOf() == b.valueOf()) { return 0; }207 var minLength = (a.length > b.length) ? b.length : a.length;208 var curPos = 0;209 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }210 var retValue = b.charCodeAt(curPos) - a.charCodeAt(curPos);211 if (isNaN(retValue)) { return 0; }212 else { return retValue; }213}214PTCommonUtil.sortForward = function(aa,bb)215{216 var a = new String(aa);217 var b = new String(bb);218 if (a.valueOf() == b.valueOf()) { return 0; }219 var minLength = (a.length > b.length) ? b.length : a.length;220 var curPos = 0;221 while ((curPos < minLength) && (a.charCodeAt(curPos) == b.charCodeAt(curPos))) { curPos++; }222 var retValue = a.charCodeAt(curPos) - b.charCodeAt(curPos);223 if (isNaN(retValue)) { return 0; }224 else { return retValue; }225}226PTCommonUtil.getValueForStyleAttribute = function(s,attr)227{228 var s = new String(s);229 var attr = new String(attr);230 var attrPos = s.indexOf(attr);231 if (attrPos == -1) { return; }232 var s = s.substr(attrPos + attr.length + 1);233 while ((s.charAt(0) == ' ') || (s.charAt(0) == ':')) { s = s.substr(1); }234 var semiPos = s.indexOf(';');235 if (semiPos == -1) { semiPos = (s.length - 1); }236 s = s.substr(0,(semiPos));237 return s;238}239PTCommonUtil.getRelativePosition = function (childDiv,parentDiv,ignoreBorders)240{241 var pos = new Object();242 pos.x = 0;243 pos.y = 0;244 if (!childDiv) { return pos; }245 if (!parentDiv) { parentDiv = document.body; }246 while (1)247 {248 if (childDiv == parentDiv) { break; }249 pos.x -= parseInt(childDiv.scrollLeft);250 pos.y -= parseInt(childDiv.scrollTop);251 var bbw = parseInt(childDiv.style.borderBottomWidth);252 var ot = childDiv.offsetTop;253 pos.y += ot + ((bbw && !ignoreBorders) ? bbw : 0);254 var blw = parseInt(childDiv.style.borderLeftWidth);255 var ol = childDiv.offsetLeft;256 pos.x += ol + ((blw && !ignoreBorders) ? blw : 0);257 if (childDiv.offsetParent) { childDiv = childDiv.offsetParent; }258 else { break; }259 }260 return pos;261}262PTCommonUtil.scrollDivIntoView = function (object,container)263{264 if (!object) { return; }265 if (!container) { container = document.body; }266 var pos = PTCommonUtil.getRelativePosition(object,container,true);267 container.scrollTop = pos.y;268}269if (!PTCommonUtil.CSSClassCache) 270{271 PTCommonUtil.CSSClassCache = new Object(); 272}273PTCommonUtil.getCSSClassStyles = function(className)274{275 var classStyles = PTCommonUtil.CSSClassCache[className];276 if (!classStyles)277 { var tmpElm = document.createElement('span');278 tmpElm.style.visibility = 'hidden';279 tmpElm.style.display = 'none';280 tmpElm.className = className;281 document.body.appendChild(tmpElm);282 if (document.all) 283 {284 PTCommonUtil.CSSClassCache[className] = tmpElm.currentStyle;285 }286 else if (document.getElementById && !document.all) 287 {288 PTCommonUtil.CSSClassCache[className] = document.defaultView.getComputedStyle(tmpElm, '');289 }290 }291 return PTCommonUtil.CSSClassCache[className]; 292}293PTCommonUtil.getCSSClassStyleProperty = function(className, propertyName)294{295 var classStyles = PTCommonUtil.getCSSClassStyles(className); 296 if (classStyles) 297 { 298 if (PTBrowserInfo.IS_NETSCAPE_DOM && PTBrowserInfo.NETSCAPE_VERSION < 7.1)299 { var convertedPropertyName = propertyName.replace(/([a-z])([A-Z])/, '$1-$2').toLowerCase();300 return classStyles.getPropertyValue(convertedPropertyName);301 }302 else303 {304 return classStyles[propertyName]; 305 }306 }307 return null;308}309PTCommonUtil.getStyleClassFromDocument = function(doc,className)310{311 var re = new RegExp('\\.' + className + '$', 'gi');312 if (doc.all) {313 for (var s = 0; s < doc.styleSheets.length; s++) {314 for (var r = 0; r < doc.styleSheets[s].rules.length; r++) {315 if (doc.styleSheets[s].rules[r].selectorText.search(re) != -1) {316 return doc.styleSheets[s].rules[r].style;317 }318 }319 }320 } else if (doc.getElementById) {321 for (var s = 0; s < doc.styleSheets.length; s++) {322 for (var r = 0; r < doc.styleSheets[s].cssRules.length; r++) {323 if (doc.styleSheets[s].cssRules[r].selectorText.search(re) != -1) {324 doc.styleSheets[s].cssRules[r].sheetIndex = s;325 doc.styleSheets[s].cssRules[r].ruleIndex = s;326 return doc.styleSheets[s].cssRules[r].style;327 }328 }329 }330 } else if (doc.layers) {331 return doc.classes[className].all;332 } else {333 return false;334 }335}336PTCommonUtil.getStyleClass = function(className)337{338 return PTCommonUtil.getStyleClassFromDocument(document,className);339}340PTCommonUtil.getStyleClassProperty = function(className,attrName)341{342 var styleClass = PTCommonUtil.getStyleClass(className);343 return (styleClass) ? styleClass[attrName] : '';344}345PTCommonUtil.getRemoteStyleClassProperty = function(doc,className,attrName)346{347 var styleClass = PTCommonUtil.getStyleClassFromDocument(doc,className);348 return (styleClass) ? styleClass[attrName] : '';349}350PTCommonUtil.parseGet = function(url)351{352 var FORM_DATA = new Object();353 var separator = ',';354 var query;355 if (url) { query = url; }356 else {357 query = '' + top.document.location.href;358 }359 query = query.substring((query.indexOf('?')) + 1);360 if (query.length < 1) { return false; } 361 var keypairs = new Object();362 var numKP = 1;363 while (query.indexOf('&') > -1) {364 keypairs[numKP] = query.substring(0,query.indexOf('&'));365 query = query.substring((query.indexOf('&')) + 1);366 numKP++;367 }368 keypairs[numKP] = query;369 for (var i in keypairs) {370 var keyName = keypairs[i].substring(0,keypairs[i].indexOf('=')); var keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1); while (keyValue.indexOf('+') > -1) {371 keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1); }372 keyValue = unescape(keyValue);373 if (FORM_DATA[keyName]) {374 FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;375 } else {376 FORM_DATA[keyName] = keyValue; }377 }378 return FORM_DATA;379}380PTCommonUtil.wait = function(ms)381{382 var Start = new Date().valueOf();383 while ((new Date().valueOf() - Start) < ms) {}384}385PTCommonUtil.alertVersion = function()386{387 var str = '';388 var controls = new Array('PTCalendarControl','PTTableControl','PTTreeControl','PTTabularLayoutManager','PTCalendarManager');389 var foundControl = false;390 for (var i = 0; i < controls.length; i++)391 {392 if (window[controls[i]]) { foundControl = controls[i]; break; }393 else if(window['' + controls[i]]) { foundControl = '' + controls[i]; break;}394 }395 if (foundControl)396 {397 var jscontrol = eval(foundControl);398 if (jscontrol.VERSION)399 {400 var version = jscontrol.VERSION;401 str += 'PTControls (v. ' + version + ')\n';402 if (window.PTControls)403 {404 for (var obj in window.PTControls)405 {406 if (obj == 'properties') { continue; }407 var o = window.PTControls[obj];408 if (o && o.objName && o.className)409 {410 var type = ' (' + o.className + ')';411 str += ' ' + o.objName + type + '\n';412 }413 }414 }415 else if(window.PTControls)416 {417 for (var obj in window.PTControls)418 {419 if (obj == 'properties') { continue; }420 var o = window.PTControls[obj];421 if (o && o.objName && o.className)422 {423 var type = ' (' + o.className + ')';424 str += ' ' + o.objName + type + '\n';425 }426 }427 }428 }429 }430 if (typeof PTDatepicker != 'undefined')431 {432 if (PTDatepicker.VERSION) { str += 'PTDatepicker (v. ' + PTDatepicker.VERSION + ')\n'; }433 }434 else if (typeof PTDatepicker != 'undefined')435 {436 if (PTDatepicker.VERSION) { str += 'PTDatepicker (v. ' + PTDatepicker.VERSION + ')\n'; }437 }438 if (typeof PTXMLWrapper != 'undefined')439 {440 if (PTXMLWrapper.VERSION) { str += 'PTXML (v. ' + PTXMLWrapper.VERSION + ')\n'; }441 }442 else if (typeof PTXMLWrapper != 'undefined')443 {444 if (PTXMLWrapper.VERSION) { str += 'PTXML (v. ' + PTXMLWrapper.VERSION + ')\n'; }445 }446 str += 'PTUtil (v. ' + PTCommonUtil.VERSION + ')\n';447 str += '\n\u00A92002-2004 Plumtree Software Inc., All Rights Reserved \n';448 if (PTCommonUtil.isDefined(window.PT_DEBUG))449 {450 str += '\nDo you want to inspect an object?\n';451 var inspect = confirm(str);452 if (inspect)453 {454 var obj = prompt('Enter the name of the object you wish to inspect: \n','');455 if (obj)456 {457 var o = eval(obj);458 if (o)459 {460 }461 else462 {463 }464 }465 }466 }467 else { alert(str); }468}469PTCommonUtil.versions = function()470{471 if (document.all)472 { if (window.event.altKey && window.event.ctrlKey && window.event.shiftKey) {473 PTCommonUtil.alertVersion();474 return false;475 }476 }477}478PTCommonUtil.setUpVersions = function()479{480 if ((typeof document != 'undefined') && (PTCommonUtil.getIEVersion() >= 5.5))481 {482 if (document.all)483 {484 if (document.body) { document.body.onmouseleave = PTCommonUtil.versions;485 } else { window.setTimeout('PTCommonUtil.setUpVersions()',500); }486 }487 }488}489PTCommonUtil.setUpVersions();490PTCommonUtil.getScripts = function()491{492 if(!document.scripts)493 {494 document.scripts = new Array();495 PTCommonUtil.addScripts(document.childNodes);496 }497 return document.scripts;498}499PTCommonUtil.addScripts = function(nodeList)500{501 for(var i = 0; i < nodeList.length; i++) { if(nodeList[i].tagName) { if(nodeList[i].tagName.toLowerCase() == 'script') document.scripts[document.scripts.length] = nodeList[i]; PTCommonUtil.addScripts(nodeList[i].childNodes); } }502}503PTCommonUtil.JSON = function () 504{505 var m = {506 '\b': '\\b',507 '\t': '\\t',508 '\n': '\\n',509 '\f': '\\f',510 '\r': '\\r',511 '"' : '\\"',512 '\\': '\\\\'513 },514 s = {515 'boolean': function (x) {516 return String(x);517 },518 number: function (x) {519 return isFinite(x) ? String(x) : 'null';520 },521 string: function (x) {522 if (/["\\\x00-\x1f]/.test(x)) {523 x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {524 var c = m[b];525 if (c) {526 return c;527 }528 c = b.charCodeAt();529 return '\\u00' +530 Math.floor(c / 16).toString(16) +531 (c % 16).toString(16);532 });533 }534 return '"' + x + '"';535 },536 object: function (x) {537 if (x) {538 var a = [], b, f, i, l, v;539 if (x instanceof Array) {540 a[0] = '[';541 l = x.length;542 for (i = 0; i < l; i += 1) {543 v = x[i];544 f = s[typeof v];545 if (f) {546 v = f(v);547 if (typeof v == 'string') {548 if (b) {549 a[a.length] = ',';550 }551 a[a.length] = v;552 b = true;553 }554 }555 }556 a[a.length] = ']';557 } else if (x instanceof Object) {558 a[0] = '{';559 for (i in x) {560 v = x[i];561 f = s[typeof v];562 if (f) {563 v = f(v);564 if (typeof v == 'string') {565 if (b) {566 a[a.length] = ',';567 }568 a.push(s.string(i), ':', v);569 b = true;570 }571 }572 }573 a[a.length] = '}';574 } else {575 return;576 }577 return a.join('');578 }579 return 'null';580 }581 };582 return {583 copyright: '(c)2005 JSON.org',584 license: 'http://www.crockford.com/JSON/license.html',585 stringify: function (v) {586 var f = s[typeof v];587 if (f) {588 v = f(v);589 if (typeof v == 'string') {590 return v;591 }592 }593 return null;594 },595 parse: function (text) {596 try {597 return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(598 text.replace(/"(\\.|[^"\\])*"/g, ''))) &&599 eval('(' + text + ')');600 } catch (e) {601 return false;602 }603 }604 };605}();606PTArrayUtil = function()607{608 return this;609}610PTArrayUtil.VERSION = '246682';611PTArrayUtil.push = function(arr,items)612{613 if (!PTArrayUtil.isArrayLike(arr))614 {615 return;616 }617 if (PTArrayUtil.isArrayLike(items))618 {619 for (var i = 0; i < items.length; i++)620 {621 arr[arr.length] = items[i];622 }623 }624 else625 {626 arr[arr.length] = items;627 }628 return arr.length;629}630PTArrayUtil.shift = function(arr)631{632 if (!PTArrayUtil.isArrayLike(arr))633 {634 return;635 }636 var returnValue = arr[0];637 for (var i = 0; i < (arr.length - 1); i++) { arr[i] = arr[i + 1]; }638 delete arr[arr.length - 1];639 arr.length--;640 return returnValue;641}642PTArrayUtil.splice = function(arr, start, deleteCount, variableNumberOfOtherArguments)643{644 if (!PTArrayUtil.isArrayLike(arr))645 {646 return;647 }648 if (!PTNumberUtil.isInteger(start) || (start < 0) || (start >= arr.length))649 {650 return;651 }652 if (!PTNumberUtil.isInteger(deleteCount) || (deleteCount < 0) || (deleteCount > arr.length))653 {654 return;655 }656 var returnValue = new Array();657 var originalLength = arr.length;658 var elemsToAdd = arguments.length - 3;659 var totalShift = elemsToAdd - deleteCount;660 for (var i = 0; i < deleteCount; i++)661 {662 var indexToRemove = start + i;663 returnValue[returnValue.length] = arr[indexToRemove];664 delete arr[indexToRemove];665 }666 if (totalShift != 0)667 {668 if (totalShift < 0)669 {670 var firstToMove = start + deleteCount;671 var lastToMove = originalLength - 1; 672 for (var i = firstToMove; i <= lastToMove; i++)673 {674 arr[i + totalShift] = arr[i];675 delete arr[i];676 }677 arr.length = arr.length + totalShift;678 }679 else if (totalShift > 0)680 {681 var firstToMove = originalLength - 1;682 var lastToMove = start + deleteCount;683 for (var i = firstToMove; i >= lastToMove; i--)684 {685 arr[i + totalShift] = arr[i];686 delete arr[i];687 }688 }689 }690 for (var i = 0; i < elemsToAdd; i++)691 {692 arr[start + i] = arguments[i+3];693 }694 return returnValue;695}696PTArrayUtil.removeElementAt = function(arr,index)697{698 if (!PTArrayUtil.isArrayLike(arr))699 {700 return;701 }702 return PTArrayUtil.splice(arr,index,1);703}704PTArrayUtil.moveElement = function(arr,sourceIndex,targetIndex)705{706 if (!PTArrayUtil.isArrayLike(arr))707 {708 return;709 }710 var elm = arr[sourceIndex];711 PTArrayUtil.removeElementAt(arr,sourceIndex);712 var len = arr.length;713 for (var i = (len - 1); i >= targetIndex; i--)714 {715 arr[i+1] = arr[i]; 716 }717 arr[targetIndex] = elm;718}719PTArrayUtil.isArrayLike = function(arr)720{721 var likeArray = (arr && arr.join && PTNumberUtil.isInteger(arr.length) && (parseInt(arr.length) >= 0));722 return (likeArray == true);723}724PTCookie = function()725{726 return this;727}728PTCookie.VERSION = '246682';729PTCookie.set = function(name,value,expires)730{731 document.cookie = name + "=" + escape(value) + ';path=/' + ((!expires) ? '' : ';expires=' + expires.toGMTString());732 return;733}734PTCookie.get = function(name)735{736 var cname = name + '=';737 if (document.cookie.length > 0) {738 begin = document.cookie.indexOf(cname);739 if (begin != -1) {740 begin += cname.length;741 end = document.cookie.indexOf(";", begin);742 if (end == -1) {end = document.cookie.length;}743 return unescape(document.cookie.substring(begin,end));744 }745 } else {746 return;747 }748}749PTCookie.expire = function(name)750{751 document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT' + ';path=/';752 return;753}754PTCookie.daysAway = function(numDays)755{756 var exp = new Date();757 var oneDay = (1000 * 60 * 60 * 24); 758 return new Date(exp.setTime(exp.getTime() + (oneDay * numDays)));759}760PTCookie.INT_30_DAYS = PTCookie.daysAway(30);761PTDOMUtil = function()762{763 return this;764}765PTDOMUtil.VERSION = '246682';766PTDOMUtil.getElementById = function(id)767{ if (!document.all) { return document.getElementById(id); }768 var elem = PTDOMUtil.ElementCache[id];769 if (!elem || !elem.innerHTML)770 {771 PTDOMUtil.ElementCache[id] = document.getElementById(id);772 }773 return PTDOMUtil.ElementCache[id];774}775if (!window.PTDOMUtil.ElementCache)776{ 777 PTDOMUtil.ElementCache = new Object(); 778}779PTDOMUtil.elementContains = function(containerElement, containedElement)780{ if (document.all) { return containerElement.contains(containedElement); }781 if (!PTDOMUtil.ElementContainsCache[containerElement]) { PTDOMUtil.ElementContainsCache[containerElement] = new Object(); }782 if (PTDOMUtil.ElementContainsCache[containerElement][containedElement]) 783 { 784 return (PTDOMUtil.ElementContainsCache[containerElement][containedElement] == 'true' ? true : false); 785 }786 if (containedElement == containerElement) 787 { 788 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'true';789 return true; 790 }791 if (containedElement == null) 792 { 793 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'false';794 return false; 795 }796 if (!containerElement.hasChildNodes) 797 { 798 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'false';799 return false; 800 }801 var childNodes = containerElement.childNodes;802 var childNodesLength = childNodes.length;803 for (var i=0; i<childNodesLength; i++)804 {805 var childNode = childNodes[i];806 if (PTDOMUtil.elementContains(childNode, containedElement)) 807 { 808 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'true';809 return true; 810 }811 }812 PTDOMUtil.ElementContainsCache[containerElement][containedElement] = 'false';813 return false;814}815if (!window.PTDOMUtil.ElementContainsCache) 816{ 817 PTDOMUtil.ElementContainsCache = new Object(); 818}819PTDOMUtil.insertAdjacentElement = function(targetElement, insertWhere, elementToInsert)820{ if (document.all)821 {822 targetElement.insertAdjacentElement(insertWhere, elementToInsert);823 } else824 {825 switch (insertWhere)826 {827 case 'beforeBegin':828 targetElement.parentNode.insertBefore(elementToInsert,targetElement)829 break;830 case 'afterBegin':831 targetElement.insertBefore(elementToInsert,targetElement.firstChild);832 break;833 case 'beforeEnd':834 targetElement.appendChild(elementToInsert);835 break;836 case 'afterEnd':837 if (targetElement.nextSibling) { targetElement.parentNode.insertBefore(elementToInsert,targetElement.nextSibling); }838 else { targetElement.parentNode.appendChild(elementToInsert); }839 break;840 }841 }842}843PTDOMUtil.getOuterHTML = function(node, formatHTML, replacementTagIdMap)844{845 var sb = new PTStringBuffer();846 return PTDOMUtil.getHTML(sb, node, true, ((formatHTML) ? 0 : -1), replacementTagIdMap);847}848PTDOMUtil.getInnerHTML = function(node, formatHTML, replacementTagIdMap)849{850 var sb = new PTStringBuffer();851 var html = PTDOMUtil.getHTML(sb, node, false, (((formatHTML) ? 0 : -1)), replacementTagIdMap);852 return html;853}854PTDOMUtil.getHTML = function(sb, node, outputNode, nesting, map)855{ 856 switch (node.nodeType)857 {858 case 1: 859 case 11: 860 var closed;861 var i;862 if (outputNode)863 { 864 if(map && node.id && map[node.id])865 {866 sb.append(map[node.id]);867 return sb.toString();868 }869 closed = (!(node.hasChildNodes() || PTDOMUtil.isClosingTag(node)));870 if((nesting >= 0) && !PTDOMUtil.isTextEnclosingTag(node))871 {872 sb.append('\n');873 for(i = 0; i < nesting; i++)874 sb.append('\t');875 }876 sb.append('<' + node.tagName.toLowerCase());877 var attrs = node.attributes;878 for(i = 0; i < attrs.length; ++i)879 {880 var a = attrs.item(i);881 if(!a.specified)882 {883 continue;884 }885 var name = a.nodeName.toLowerCase();886 if(/moz/.test(name))887 {888 continue;889 }890 var value;891 if(PTBrowserInfo.IS_NETSCAPE_7 || name != "style")892 {893 if((PTBrowserInfo.IS_MSIE) && PTCommonUtil.isDefined(node[a.nodeName]))894 {895 value = node[a.nodeName];896 }897 else898 {899 value = a.nodeValue;900 }901 }902 else903 { 904 value = PTDOMUtil.cleanCSSText(node.style.cssText);905 }906 if(/moz/.test(value))907 {908 continue;909 }910 sb.append(' ' + name.toLowerCase() + '="' + value + '"');911 }912 sb.append((closed ? ' />' : '>'));913 }914 var newNesting = (!outputNode && (nesting == 0)) ? 0 : ((nesting >= 0) ? (nesting + 1) : -1);915 for (i = node.firstChild; i; i = i.nextSibling)916 {917 PTDOMUtil.getHTML(sb, i, true, newNesting, map);918 }919 if (outputNode && !closed)920 {921 if((nesting >= 0) && !PTDOMUtil.isTextEnclosingTag(node))922 {923 sb.append('\n');924 for(i = 0; i < nesting; i++)925 sb.append('\t');926 }927 sb.append('</' + node.tagName.toLowerCase() + '>');928 }929 break;930 case 3: 931 sb.append(PTDOMUtil.escapeHTML(node.data));932 break;933 case 8: 934 sb.append('<!--' + node.data + '-->');935 break; 936 }937 var html = sb.toString();938 if((html.length > 0) && (html.substring(0,1) == '\n'))939 html = html.substring(1);940 return html;941}942PTDOMUtil.escapeHTML = function(str)943{944 str = PTStringUtil.escapeHTML(str);945 var sb = new PTStringBuffer();946 for(var i = 0; i < str.length; i++)947 {948 if(str.charCodeAt(i) == 160)949 sb.append('&nbsp;');950 else951 sb.append(str.charAt(i));952 }953 return sb.toString();954}955PTDOMUtil.isClosingTag = function(el)956{957 var closingTags = ' h1 h2 h3 h4 h5 h6 script style div span tr td tbody table em strong font a ';958 var success = (closingTags.indexOf(' ' + el.tagName.toLowerCase() + ' ') != -1);959 return success;960}961PTDOMUtil.isTextEnclosingTag = function(el)962{963 var textEnclosingTags = ' th td span em font strong u a ';964 var success = (textEnclosingTags.indexOf(' ' + el.tagName.toLowerCase() + ' ') != -1);965 return success;966}967PTDOMUtil.cleanCSSText = function(css)968{969 var cssMap = {};970 var nameValuePairs = css.split(';');971 for(var i = 0; i < nameValuePairs.length; i++)972 {973 var nameValue = nameValuePairs[i].split(':');974 if(nameValue.length == 2)975 {976 var name = PTStringUtil.trimWhitespace(nameValue[0].toLowerCase(), true, true);977 var value = PTStringUtil.trimWhitespace(nameValue[1].toLowerCase(), true, true);978 cssMap[name] = value;979 }980 }981 if((cssMap['border-right'] == cssMap['border-left']) &&982 (cssMap['border-top'] == cssMap['border-bottom']) &&983 (cssMap['border-left'] == cssMap['border-bottom']))984 {985 cssMap['border'] = cssMap['border-right'];986 cssMap['border-right'] = '';987 cssMap['border-left'] = '';988 cssMap['border-top'] = '';989 cssMap['border-bottom'] = '';990 }991 var newCss = '';992 for(n in cssMap)993 {994 value = cssMap[n];995 if(value)996 newCss += n + ': ' + value + ';';997 }998 return newCss;999}1000PTDOMUtil.getElementLeft = function(elm)1001{ if (!elm) { return false; } var x = elm.offsetLeft; var elmParent = elm.offsetParent; while (elmParent != null) { 1002 if(PTBrowserInfo.IS_MSIE) 1003 {1004 if( (elmParent.tagName != "TABLE") && (elmParent.tagName != "BODY") )1005 { 1006 x += elmParent.clientLeft; 1007 }1008 }1009 else 1010 {1011 if(elmParent.tagName == "TABLE") 1012 { 1013 var parentBorder = parseInt(elmParent.border);1014 if(isNaN(parentBorder)) 1015 { 1016 var parentFrame = elmParent.getAttribute('frame');1017 if(parentFrame != null) 1018 {1019 x += 1; 1020 }1021 }1022 else if(parentBorder > 0) 1023 {1024 x += parentBorder; 1025 }1026 }1027 }1028 x += elmParent.offsetLeft;1029 elmParent = elmParent.offsetParent; 1030}1031return x;1032}1033PTDOMUtil.getElementTop = function(elm)1034{ var y = 0; while (elm != null)1035 { 1036 if(PTBrowserInfo.IS_MSIE) 1037 {1038 if( (elm.tagName != "TABLE") && (elm.tagName != "BODY") )1039 { 1040 y += elm.clientTop;1041 }1042 }1043 else 1044 {1045 if(elm.tagName == "TABLE") 1046 { 1047 var parentBorder = parseInt(elm.border);1048 if(isNaN(parentBorder)) 1049 { 1050 var parentFrame = elm.getAttribute('frame');1051 if(parentFrame != null) 1052 {1053 y += 1; 1054 }1055 }1056 else if(parentBorder > 0) 1057 {1058 y += parentBorder;1059 }1060 }1061 }1062 y += elm.offsetTop; 1063 if (elm.offsetParent && elm.offsetParent.offsetHeight && elm.offsetParent.offsetHeight < elm.offsetHeight)1064 { elm = elm.offsetParent.offsetParent; 1065 }1066 else1067 { elm = elm.offsetParent; 1068 } } 1069 return y;1070}1071PTDOMUtil.getElementWidth = function(elm)1072{ if (!elm) { return 0; } var w1 = elm.offsetWidth;1073 var w2 = 0;1074 if (window.getComputedStyle) 1075 { 1076 var w2px = window.getComputedStyle(elm,null).getPropertyValue('width'); w2px = PTStringUtil.substituteChars(w2px, { 'px' : '' });1077 w2 = parseInt(w2px);1078 }1079 return Math.max(w1,w2);1080}1081PTDOMUtil.getElementHeight = function(elm)1082{ if (!elm) { return 0; } var h1 = elm.offsetHeight;1083 var h2 = 0;1084 if (window.getComputedStyle) 1085 { 1086 var h2px = window.getComputedStyle(elm,null).getPropertyValue('height'); h2px = PTStringUtil.substituteChars(h2px, { 'px' : '' });1087 h2 = parseInt(h2px);1088 }1089 return Math.max(h1,h2);1090}1091PTDOMUtil.getWindowWidth = function()1092{1093 if (self.innerHeight) 1094 {1095 return self.innerWidth;1096 }1097 else if (document.documentElement && document.documentElement.clientHeight) {1098 return document.documentElement.clientWidth;1099 }1100 else if (document.body) 1101 {1102 return document.body.clientWidth;1103 }1104}1105PTDOMUtil.getWindowHeight = function()1106{1107 if (self.innerHeight) 1108 {1109 return self.innerHeight;1110 }1111 else if (document.documentElement && document.documentElement.clientHeight) {1112 return document.documentElement.clientHeight;1113 }1114 else if (document.body) 1115 {1116 return document.body.clientHeight;1117 }1118}1119PTDOMUtil.setElementOpacity = function(element,value)1120{1121 if (!element || !element.style) { return false; }1122 if (isNaN(value)) { return false; }1123 value = parseInt(value);1124 if ((value < 0) || (value > 100)) { return false; }1125 if (document.all)1126 { if (PTBrowserInfo.IS_NT4)1127 {1128 return false;1129 } else if (element.filters && element.filters.alpha && element.filters.alpha.opacity)1130 {1131 element.filters.alpha.opacity = value;1132 return true;1133 } else if (typeof element.style.filter == 'string')1134 {1135 element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + value + ')';1136 return true;1137 } else1138 {1139 return false;1140 }1141 } else if (typeof element.style.MozOpacity == 'string')1142 {1143 var dec = value / 100;1144 element.style.MozOpacity = '' + dec;1145 return true;1146 } else1147 {1148 return false;1149 }1150}1151PTDOMUtil.toggleVisibility = function(id)1152{1153 var elm = PTDOMUtil.getElementById(id);1154 if (elm.style.display == 'none')1155 { 1156 if (PTDOMUtil._elmDisplayCache[id] || PTDOMUtil._elmDisplayCache[id] == '') 1157 { 1158 elm.style.display = PTDOMUtil._elmDisplayCache[id]; 1159 }1160 else { elm.style.display = 'block'; }1161 }1162 else 1163 { 1164 PTDOMUtil._elmDisplayCache[id] = elm.style.display;1165 elm.style.display = 'none'; 1166 }1167}1168PTDOMUtil._elmDisplayCache = {};1169PTDate = function(datestring,date,language,dateFormat)1170{1171 this.datestring = (datestring) ? datestring : '';1172 this.date = (date) ? date : new Date();1173 this.language = (language) ? language : false;1174 this.dateFormat = (dateFormat) ? dateFormat : PTDate.defaultDateFormat;1175 return this;1176}1177PTDate.VERSION = '246682';1178PTDate.TIME_POLICY_ALLOW_TIMES = 0;1179PTDate.TIME_POLICY_REQUIRE_TIMES = 1;1180PTDate.TIME_POLICY_FORBID_TIMES = 2;1181PTDate.FORMAT_DEFAULT = 0;1182PTDate.FORMAT_SHORT = 1;1183PTDate.FORMAT_MEDIUM = 2;1184PTDate.FORMAT_LONG = 3;1185PTDate.FORMAT_FULL = 4;1186PTDate.PIVOT_DATE = 50; 1187PTDate.defaultLanguage = 'en';1188PTDate.defaultDateFormat = new String('EEE MMM d HH:mm:ss yyyy');1189PTDate.DEFAULT_LOCALE = 'en';1190PTDate.EnglishStrings = new Object();1191PTDate.EnglishStrings.monthsLong = new Array('January','February','March','April','May','June','July','August','September','October','November','December');1192PTDate.EnglishStrings.monthsShort = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');1193PTDate.EnglishStrings.daysLong = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');1194PTDate.EnglishStrings.daysShort = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');1195PTDate.EnglishStrings.daysInitial = new Array('S','M','T','W','T','F','S');1196PTDate.EnglishStrings.ampm = new Array('am','pm');1197PTDate.formatDate = function(date,dateFormat,language)1198{1199 var d = new PTDate('',date,language,dateFormat);1200 return d.format(dateFormat,d.language);1201}1202PTDate.validateDate = function(dateString, locale, alertOnFailure, timePolicy, formatList)1203{1204 return PTDateValidator.validateDate(dateString,locale,alertOnFailure,timePolicy,formatList);1205}1206PTDate.validateAndFormatDate = function(dateString, outputFormat, locale, alertOnFailure, timePolicy, formatList)1207{1208 if (!dateString) { return false; }1209 if (!outputFormat) { outputFormat = PTDate.defaultDateFormat; }1210 var validDate = PTDateValidator.validateDate(dateString,locale,alertOnFailure,timePolicy,formatList);1211 if (!validDate) { return false; }1212 var formattedDate = PTDate.formatDate(validDate,outputFormat);1213 return formattedDate;1214}1215PTDate.getNumberOfDaysInMonth = function(date)1216{1217 var m = date.getMonth();1218 if ((m == 3) || (m == 5) || (m == 8) || (m == 10)) { return 30; }1219 else if (m == 1)1220 {1221 var y = date.getFullYear();1222 if ((!(y%4) && (y%100)) || !(y%400))1223 {1224 return 29;1225 }1226 else1227 {1228 return 28;1229 }1230 }1231 else { return 31; }1232}1233PTDate.get2DigitYear = function(date)1234{1235 var y = date.getFullYear() % 100;1236 if (y < 10) { y = '0' + y; }1237 return '' + y;1238}1239PTDate.get2DigitMonth = function(date)1240{1241 var m = date.getMonth() + 1;1242 if (m < 10) { m = '0' + m; }1243 return '' + m1244}1245PTDate.get1DigitMonth = function(date)1246{1247 var m = date.getMonth() + 1;1248 return '' + m1249}1250PTDate.get2DigitDayOfMonth = function(date)1251{1252 var d = date.getDate();1253 if (d < 10) { d = '0' + d; }1254 return '' + d;1255}1256PTDate.get1DigitDayOfMonth = function(date)1257{1258 var d = date.getDate();1259 return '' + d;1260}1261PTDate.get2Digit1To12Hour = function(date)1262{1263 var h = date.getHours();1264 h = h % 12;1265 if (h == 0) { h = '12'; }1266 else if (h < 10) { h = '0' + h; }1267 return '' + h;1268}1269PTDate.get1Digit1To12Hour = function(date)1270{1271 var h = date.getHours();1272 h = h % 12;1273 if (h == 0) { h = '12'; }1274 return '' + h;1275}1276PTDate.get2Digit0To23Hour = function(date)1277{1278 var h = date.getHours();1279 if (h < 10) { h = '0' + h; }1280 return '' + h;1281}1282PTDate.get2Digit0To11Hour = function(date)1283{1284 var h = date.getHours();1285 h = h % 12;1286 if (h < 10) { h = '0' + h; }1287 return '' + h;1288}1289PTDate.get1Digit0To11Hour = function(date)1290{1291 var h = date.getHours();1292 h = h % 12;1293 return '' + h;1294}1295PTDate.get2Digit1To24Hour = function(date)1296{1297 var h = date.getHours() + 1;1298 if (h < 10) { h = '0' + h; }1299 return '' + h;1300}1301PTDate.get1Digit1To24Hour = function(date)1302{1303 var h = date.getHours() + 1;1304 return '' + h;1305}1306PTDate.get2DigitMinutes = function(date)1307{1308 var m = date.getMinutes();1309 if (m < 10) { m = '0' + m; }1310 return '' + m;1311}1312PTDate.get1DigitMinutes = function(date)1313{1314 var m = date.getMinutes();1315 return '' + m;1316}1317PTDate.get2DigitSeconds = function(date)1318{1319 var s = date.getSeconds();1320 if (s < 10) { s = '0' + s; }1321 return '' + s;1322}1323PTDate.get1DigitSeconds = function(date)1324{1325 var s = date.getSeconds();1326 return '' + s;1327}1328PTDate.get3DigitMilliseconds = function(date)1329{1330 var m = date.getMilliseconds();1331 if (m < 10) { m = '00' + m; }1332 else if (m < 100) { m = '0' + m; }1333 return '' + m;1334}1335PTDate.getAMPM = function(date,language)1336{1337 if (!language) { language = PTDate.defaultLanguage; }1338 var h = date.getHours();1339 var STR = PTDateStrings;1340 if (language == 'en') { STR = PTDate.EnglishStrings; }1341 var ampm = STR.ampm[0];1342 if (h >= 12) { ampm = STR.ampm[1]; }1343 return ampm;1344}1345PTDate.convert2DigitTo4DigitYear = function(year)1346{1347 if (year <= PTDate.PIVOT_DATE) { year += 100; }1348 year += 1900;1349 return year;1350}1351PTDate.isLeapYear = function(year)1352{1353 if (year && year.getFullYear) { var y = year.getFullYear(); }1354 else { var y = parseInt(year); }1355 return (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0));1356}1357PTDate.getFormatListForLocale = function(locale,requireExactMatch)1358{1359 locale = new String(locale);1360 if ((locale.indexOf('-') == 2) && (locale.length == 5))1361 {1362 locale = (locale.substr(0,2)).toLowerCase() + '_' + (locale.substr(3,2)).toUpperCase();1363 }1364 if (PTDate.formats[locale]) { return PTDate.formats[locale]; }1365 if (requireExactMatch) { return false; }1366 var language = locale.substring(0,2);1367 if (PTDate.formats[language]) { return PTDate.formats[language]; }1368 for (var loc in PTDate.formats)1369 {1370 if (loc.indexOf(language) > -1) { return PTDate.formats[loc]; }1371 }1372 return PTDate.formats[PTDate.DEFAULT_LOCALE];1373}1374PTDate.stripTimesFromFormat = function(format)1375{1376 format = format.replace(/a.*$/,'');1377 format = format.replace(/h.*$/i,'');1378 return format;1379}1380PTDate.prototype.format = function(dateFormat,language)1381{1382 dateFormat = (dateFormat) ? new String(dateFormat) : this.dateFormat;1383 language = (language) ? language : false;1384 var date = this.date;1385 var STR = PTDateStrings;1386 if (language == 'en') { STR = PTDate.EnglishStrings; }1387 var patternStrings = {1388 'yyyy' : date.getFullYear(),1389 'yy' : PTDate.get2DigitYear(date),1390 'MMMMM' : STR.monthsLong[date.getMonth()], 1391 'MMMM' : STR.monthsLong[date.getMonth()], // whether long form for month is 4 or 5 M's. Support both here.1392 'MMM' : STR.monthsShort[date.getMonth()],1393 'MM' : PTDate.get2DigitMonth(date),1394 'M' : PTDate.get1DigitMonth(date),1395 'EEEE' : STR.daysLong[date.getDay()],1396 'EEE' : STR.daysShort[date.getDay()], 1397 'EE' : STR.daysShort[date.getDay()], // whether short form for day is 2 or 3 E's. Support both here.1398 'E' : STR.daysInitial[date.getDay()],1399 'dd' : PTDate.get2DigitDayOfMonth(date),1400 'd' : PTDate.get1DigitDayOfMonth(date),1401 'hh' : PTDate.get2Digit1To12Hour(date),1402 'h' : PTDate.get1Digit1To12Hour(date),1403 'HH' : PTDate.get2Digit0To23Hour(date),1404 'H' : date.getHours(),1405 'KK' : PTDate.get2Digit0To11Hour(date),1406 'K' : PTDate.get1Digit0To11Hour(date),1407 'kk' : PTDate.get2Digit1To24Hour(date),1408 'k' : PTDate.get1Digit1To24Hour(date),1409 'mm' : PTDate.get2DigitMinutes(date),1410 'm' : PTDate.get1DigitMinutes(date),1411 'ss' : PTDate.get2DigitSeconds(date),1412 's' : PTDate.get1DigitSeconds(date),1413 'SSS' : PTDate.get3DigitMilliseconds(date),1414 'a' : PTDate.getAMPM(date,language),1415 'z' : '' // z gets used a lot in PTDateValidatorFormats, but we really don't want any effect from it1416 }1417 var ph = new Array();1418 var f = dateFormat;1419 while (f.indexOf('\'') != f.lastIndexOf('\''))1420 {1421 var re = new RegExp("('[^']*')");1422 var res = re.exec(f);1423 var literal = RegExp.$1;1424 var pStart = f.indexOf(literal);1425 var pEnd = pStart + literal.length;1426 var filler = '';1427 for (var i = 0; i < literal.length; i++) { filler += '-'; }1428 f = f.substring(0,pStart) + filler + f.substr(pEnd);1429 }1430 for (var pattern in patternStrings)1431 {1432 while (f.indexOf(pattern) > -1)1433 {1434 var pStart = f.indexOf(pattern);1435 var pEnd = pStart + pattern.length;1436 ph[pStart] = new Object();1437 ph[pStart].string = patternStrings[pattern];1438 ph[pStart].end = pEnd;1439 var filler = '';1440 for (var i = 0; i < pattern.length; i++) { filler += '-'; }1441 f = f.substring(0,pStart) + filler + f.substr(pEnd);1442 }1443 }1444 var convertedString = new String('');1445 var i = 0;1446 while (i < dateFormat.length)1447 {1448 if (ph[i])1449 {1450 convertedString += ph[i].string;1451 i = ph[i].end;1452 }1453 else1454 {1455 if (dateFormat.charAt(i) == '\'')1456 {1457 if (dateFormat.charAt(i+1) == '\'')1458 { convertedString += '\'';1459 i = i + 2;1460 }1461 else { i++; }1462 continue;1463 }1464 convertedString += dateFormat.charAt(i);1465 i++;1466 }1467 }1468 return PTStringUtil.trimWhitespace(convertedString,true,true);1469}1470PTDate.prototype.hasTime = function()1471{1472 return (this.datestring.indexOf(':') > -1);1473}1474PTDate.prototype.incrementMonth = function()1475{1476 var date = this.date;1477 var month = date.getMonth();1478 if (month < 11) {1479 date.setMonth(month+1);1480 }1481 else {1482 date.setMonth(0);1483 date.setFullYear(date.getFullYear()+1);1484 }1485}1486PTDate.prototype.incrementWeek = function()1487{1488 var date = this.date;1489 var hours = date.getHours();1490 date.setHours(12);1491 var week = 1000*60*60*24*7;1492 date.setTime(date.getTime()+week);1493 date.setHours(hours);1494}1495PTDate.prototype.incrementDay = function()1496{1497 var date = this.date;1498 var hours = date.getHours();1499 date.setHours(12);1500 var day = 1000*60*60*24;1501 date.setTime(date.getTime()+day);1502 date.setHours(hours);1503}1504PTDate.prototype.clone = function()1505{1506 return new PTDate(this.datestring,1507 new Date(this.date.getTime()),1508 this.language,1509 this.dateFormat);1510}1511PTDate.prototype.getNumberOfDaysInThisMonth = function()1512{1513 return PTDate.getNumberOfDaysInMonth(this.date);1514}1515PTDate.prototype.getTime = function()1516{1517 return this.date.getTime();1518}1519if (!PTDate.formats)1520{1521 PTDate.formats = new Object();1522}1523PTDate.formats['en'] = new Array(1524 'MMM d, yyyy h:mm:ss a',1525 'M/d/yyyy h:mm a',1526 'MMM d, yyyy h:mm:ss a',1527 'MMMM d, yyyy h:mm:ss a z',1528 'EEEE, MMMM d, yyyy h:mm:ss a z'1529 ); PTDate.formats['da'] = new Array(1530 'dd-MM-yy HH:mm:ss',1531 'dd-MM-yy HH:mm',1532 'dd-MM-yyyy HH:mm:ss',1533 'd. MMMM yyyy HH:mm:ss z',1534 'd. MMMM yyyy HH:mm:ss z'1535 );1536PTDate.formats['da_DK'] = new Array(1537 'dd-MM-yy HH:mm:ss',1538 'dd-MM-yy HH:mm',1539 'dd-MM-yyyy HH:mm:ss',1540 'd. MMMM yyyy HH:mm:ss z',1541 'd. MMMM yyyy HH:mm:ss z'1542 );1543PTDate.formats['fi'] = new Array(1544 'd.M.yy HH:mm:ss',1545 'd.M.yy HH:mm',1546 'd.MMM.yyyy HH:mm:ss',1547 'd. MMMM yyyy HH:mm:ss z',1548 'd. MMMM yyyy HH:mm:ss z'1549 ); PTDate.formats['fi_FI'] = new Array(1550 'dd-MM-yy HH:mm:ss',1551 'dd-MM-yy HH:mm',1552 'dd-MM-yyyy HH:mm:ss',1553 'd. MMMM yyyy HH:mm:ss z',1554 'd. MMMM yyyy HH:mm:ss z'1555 );1556PTDate.formats['no'] = new Array(1557 'dd.MM.yy HH:mm:ss',1558 'dd.MM.yy HH:mm',1559 'dd.MMM.yyyy HH:mm:ss',1560 'd. MMMM yyyy HH:mm:ss z',1561 'd. MMMM yyyy \'kl \' HH:mm z'1562 ); 1563PTDate.formats['no_NO'] = new Array(1564 'dd.MM.yy HH:mm:ss',1565 'dd.MM.yy HH:mm',1566 'dd.MMM.yyyy HH:mm:ss',1567 'd. MMMM yyyy HH:mm:ss z',1568 'd. MMMM yyyy \'kl \' HH:mm z'1569 ); 1570PTDate.formats['nb'] = new Array(1571 'dd.MM.yy HH:mm:ss',1572 'dd.MM.yy HH:mm',1573 'dd.MMM.yyyy HH:mm:ss',1574 'd. MMMM yyyy HH:mm:ss z',1575 'd. MMMM yyyy \'kl \' HH:mm z'1576 ); 1577PTDate.formats['nb_NO'] = new Array(1578 'dd.MM.yy HH:mm:ss',1579 'dd.MM.yy HH:mm',1580 'dd.MMM.yyyy HH:mm:ss',1581 'd. MMMM yyyy HH:mm:ss z',1582 'd. MMMM yyyy \'kl \' HH:mm z'1583 ); 1584PTDate.formats['nn'] = new Array(1585 'dd.MM.yy HH:mm:ss',1586 'dd.MM.yy HH:mm',1587 'dd.MMM.yyyy HH:mm:ss',1588 'd. MMMM yyyy HH:mm:ss z',1589 'd. MMMM yyyy \'kl \' HH:mm z'1590 ); 1591PTDate.formats['nn_NO'] = new Array(1592 'dd.MM.yy HH:mm:ss',1593 'dd.MM.yy HH:mm',1594 'dd.MMM.yyyy HH:mm:ss',1595 'd. MMMM yyyy HH:mm:ss z',1596 'd. MMMM yyyy \'kl \' HH:mm z'1597 ); 1598PTDate.formats['sv'] = new Array(1599 'yyyy-MM-dd HH:mm:ss',1600 'yyyy-MM-dd HH:mm',1601 'yyyy-MM-dd HH:mm:ss',1602 '\'den \' d MMMM yyyy HH:mm:ss z',1603 '\'den \' d MMMM yyyy \'kl \' HH:mm z'1604 ); 1605PTDate.formats['sv_SE'] = new Array(1606 'yyyy-MM-dd HH:mm:ss',1607 'yyyy-MM-dd HH:mm',1608 'yyyy-MM-dd HH:mm:ss',1609 '\'den \' d MMMM yyyy HH:mm:ss z',1610 '\'den \' d MMMM yyyy \'kl \' HH:mm z'1611 ); 1612PTDate.formats['tr'] = new Array(1613 'dd.MM.yy HH:mm:ss',1614 'dd.MM.yy HH:mm',1615 'dd.MMM.yyyy HH:mm:ss',1616 'dd MMMM yyyy EEEE HH:mm:ss z',1617 'dd MMMM yyyy EEEE HH:mm:ss z'1618 ); 1619PTDate.formats['tr_TR'] = new Array(1620 'dd.MM.yy HH:mm:ss',1621 'dd.MM.yy HH:mm',1622 'dd.MMM.yyyy HH:mm:ss',1623 'dd MMMM yyyy EEEE HH:mm:ss z',1624 'dd MMMM yyyy EEEE HH:mm:ss z'1625 ); 1626PTDate.formats['de'] = new Array(1627 'dd.MM.yyyy HH:mm:ss',1628 'dd.MM.yyyy HH:mm',1629 'dd.MM.yyyy HH:mm:ss',1630 'd. MMMM yyyy HH:mm:ss z',1631 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1632 );1633PTDate.formats['de_AT'] = new Array(1634 'dd.MM.yyyy HH:mm:ss',1635 'dd.MM.yyyy HH:mm',1636 'dd.MM.yyyy HH:mm:ss',1637 'dd. MMMM yyyy HH:mm:ss z',1638 'EEEE, dd. MMMM yyyy HH.mm\' Uhr \'z'1639 );1640PTDate.formats['de_CH'] = new Array(1641 'dd.MM.yyyy HH:mm:ss',1642 'dd.MM.yyyy HH:mm',1643 'dd.MM.yyyy HH:mm:ss',1644 'd. MMMM yyyy HH:mm:ss z',1645 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1646 );1647PTDate.formats['de_DE'] = new Array(1648 'dd.MM.yyyy HH:mm:ss',1649 'dd.MM.yyyy HH:mm',1650 'dd.MM.yyyy HH:mm:ss',1651 'd. MMMM yyyy HH:mm:ss z',1652 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1653 );1654PTDate.formats['de_LU'] = new Array(1655 'dd.MM.yyyy HH:mm:ss',1656 'dd.MM.yyyy HH:mm',1657 'dd.MM.yyyy HH:mm:ss',1658 'd. MMMM yyyy HH:mm:ss z',1659 'EEEE, d. MMMM yyyy H.mm\' Uhr \'z'1660 );1661PTDate.formats['en_AU'] = new Array(1662 'd/MM/yyyy HH:mm:ss',1663 'd/MM/yyyy HH:mm',1664 'd/MM/yyyy HH:mm:ss',1665 'd MMMM yyyy H:mm:ss',1666 'EEEE, d MMMM yyyy hh:mm:ss a z'1667 );1668PTDate.formats['en_CA'] = new Array(1669 'd-MMM-yyyy h:mm:ss a',1670 'dd/MM/yyyy h:mm a',1671 'd-MMM-yyyy h:mm:ss a',1672 'MMMM d, yyyy h:mm:ss z a',1673 'EEEE, MMMM d, yyyy h:mm:ss \'o\'\'clock\' a z'1674 );1675PTDate.formats['en_GB'] = new Array(1676 'dd-MMM-yyyy HH:mm:ss',1677 'dd/MM/yyyy HH:mm',1678 'dd-MMM-yyyy HH:mm:ss',1679 'dd MMMM yyyy HH:mm:ss z',1680 'dd MMMM yyyy HH:mm:ss \'o\'\'clock\' z'1681 );1682PTDate.formats['en_IE'] = new Array(1683 'dd-MMM-yyyy HH:mm:ss',1684 'dd/MM/yyyy HH:mm',1685 'dd-MMM-yyyy HH:mm:ss',1686 'dd MMMM yyyy HH:mm:ss z',1687 'dd MMMM yyyy HH:mm:ss \'o\'\'clock\' z'1688 );1689PTDate.formats['en_NZ'] = new Array(1690 'd/MM/yyyy HH:mm:ss',1691 'd/MM/yyyy HH:mm',1692 'd/MM/yyyy HH:mm:ss',1693 'd MMMM yyyy H:mm:ss',1694 'EEEE, d MMMM yyyy hh:mm:ss a z'1695 );1696PTDate.formats['en_US'] = new Array(1697 'MMM d, yyyy h:mm:ss a',1698 'M/d/yyyy h:mm a',1699 'MMM d, yyyy h:mm:ss a',1700 'MMMM d, yyyy h:mm:ss a z',1701 'EEEE, MMMM d, yyyy h:mm:ss a z'1702 );1703PTDate.formats['en_ZA'] = new Array(1704 'yyyy/MM/dd hh:mm:ss',1705 'yyyy/MM/dd hh:mm',1706 'yyyy/MM/dd hh:mm:ss',1707 'dd MMMM yyyy hh:mm:ss',1708 'dd MMMM yyyy hh:mm:ss a'1709 );1710PTDate.formats['es'] = new Array(1711 'dd-MMM-yyyy H:mm:ss',1712 'd/MM/yyyy H:mm',1713 'dd-MMM-yyyy H:mm:ss',1714 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1715 'EEEE d\' de \'MMMM\' de \'yyyy HH\'H\'mm\'\' z'1716 );1717PTDate.formats['es_AR'] = new Array(1718 'dd/MM/yyyy HH:mm:ss',1719 'dd/MM/yyyy HH:mm',1720 'dd/MM/yyyy HH:mm:ss',1721 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1722 'EEEE d\' de \'MMMM\' de \'yyyy HH\'h\'\'\'mm z'1723 );1724PTDate.formats['es_BO'] = new Array(1725 'dd-MM-yyyy hh:mm:ss a',1726 'dd-MM-yyyy hh:mm a',1727 'dd-MM-yyyy hh:mm:ss a',1728 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1729 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1730 );1731PTDate.formats['es_CL'] = new Array(1732 'dd-MM-yyyy hh:mm:ss a',1733 'dd-MM-yyyy hh:mm a',1734 'dd-MM-yyyy hh:mm:ss a',1735 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1736 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1737 );1738PTDate.formats['es_CO'] = new Array(1739 'd/MM/yyyy hh:mm:ss a',1740 'd/MM/yyyy hh:mm a',1741 'd/MM/yyyy hh:mm:ss a',1742 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1743 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1744 );1745PTDate.formats['es_CR'] = new Array(1746 'dd/MM/yyyy hh:mm:ss a',1747 'dd/MM/yyyy hh:mm a',1748 'dd/MM/yyyy hh:mm:ss a',1749 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1750 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1751 );1752PTDate.formats['es_DO'] = new Array(1753 'MM/dd/yyyy hh:mm:ss a',1754 'MM/dd/yyyy hh:mm a',1755 'MM/dd/yyyy hh:mm:ss a',1756 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1757 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1758 );1759PTDate.formats['es_EC'] = new Array(1760 'dd/MM/yyyy hh:mm:ss a',1761 'dd/MM/yyyy hh:mm a',1762 'dd/MM/yyyy hh:mm:ss a',1763 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1764 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1765 );1766PTDate.formats['es_GT'] = new Array(1767 'd/MM/yyyy hh:mm:ss a',1768 'd/MM/yyyy hh:mm a',1769 'd/MM/yyyy hh:mm:ss a',1770 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1771 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1772 );1773PTDate.formats['es_HN'] = new Array(1774 'MM-dd-yyyy hh:mm:ss a',1775 'MM-dd-yyyy hh:mm a',1776 'MM-dd-yyyy hh:mm:ss a',1777 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1778 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1779 );1780PTDate.formats['es_MX'] = new Array(1781 'd/MM/yyyy hh:mm:ss a',1782 'd/MM/yyyy hh:mm a',1783 'd/MM/yyyy hh:mm:ss a',1784 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1785 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1786 );1787PTDate.formats['es_NI'] = new Array(1788 'MM-dd-yyyy hh:mm:ss a',1789 'MM-dd-yyyy hh:mm a',1790 'MM-dd-yyyy hh:mm:ss a',1791 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1792 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1793 );1794PTDate.formats['es_PA'] = new Array(1795 'MM/dd/yyyy hh:mm:ss a',1796 'MM/dd/yyyy hh:mm a',1797 'MM/dd/yyyy hh:mm:ss a',1798 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1799 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1800 );1801PTDate.formats['es_PE'] = new Array(1802 'dd/MM/yyyy hh:mm:ss a',1803 'dd/MM/yyyy hh:mm a',1804 'dd/MM/yyyy hh:mm:ss a',1805 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1806 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1807 );1808PTDate.formats['es_PR'] = new Array(1809 'MM-dd-yyyy hh:mm:ss a',1810 'MM-dd-yyyy hh:mm a',1811 'MM-dd-yyyy hh:mm:ss a',1812 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1813 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1814 );1815PTDate.formats['es_PY'] = new Array(1816 'dd/MM/yyyy hh:mm:ss a',1817 'dd/MM/yyyy hh:mm a',1818 'dd/MM/yyyy hh:mm:ss a',1819 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1820 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1821 );1822PTDate.formats['es_SV'] = new Array(1823 'MM-dd-yyyy hh:mm:ss a',1824 'MM-dd-yyyy hh:mm a',1825 'MM-dd-yyyy hh:mm:ss a',1826 'dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1827 'EEEE dd\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1828 );1829PTDate.formats['es_UY'] = new Array(1830 'dd/MM/yyyy hh:mm:ss a',1831 'dd/MM/yyyy hh:mm a',1832 'dd/MM/yyyy hh:mm:ss a',1833 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1834 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1835 );1836PTDate.formats['es_VE'] = new Array(1837 'dd/MM/yyyy hh:mm:ss a',1838 'dd/MM/yyyy hh:mm a',1839 'dd/MM/yyyy hh:mm:ss a',1840 'd\' de \'MMMM\' de \'yyyy hh:mm:ss a z',1841 'EEEE d\' de \'MMMM\' de \'yyyy hh:mm:ss a z'1842 );1843PTDate.formats['fr'] = new Array(1844 'd MMM yyyy HH:mm:ss',1845 'dd/MM/yyyy HH:mm',1846 'd MMM yyyy HH:mm:ss',1847 'd MMMM yyyy HH:mm:ss z',1848 'EEEE d MMMM yyyy HH\' h \'mm z'1849 );1850PTDate.formats['fr_BE'] = new Array(1851 'dd-MMM-yyyy H:mm:ss',1852 'd/MM/yyyy H:mm',1853 'dd-MMM-yyyy H:mm:ss',1854 'd MMMM yyyy H:mm:ss z',1855 'EEEE d MMMM yyyy H\' h \'mm\' min \'ss\' s \'z'1856 );1857PTDate.formats['fr_CA'] = new Array(1858 'yyyy-MM-dd HH:mm:ss',1859 'yyyy-MM-dd HH:mm',1860 'yyyy-MM-dd HH:mm:ss',1861 'd MMMM yyyy HH:mm:ss z',1862 'EEEE d MMMM yyyy H\' h \'mm z'1863 );1864PTDate.formats['fr_CH'] = new Array(1865 'd MMM yyyy HH:mm:ss',1866 'dd.MM.yyyy HH:mm',1867 'd MMM yyyy HH:mm:ss',1868 'd. MMMM yyyy HH:mm:ss z',1869 'EEEE, d. MMMM yyyy HH.mm.\' h\' z'1870 );1871PTDate.formats['fr_FR'] = new Array(1872 'd MMM yyyy HH:mm:ss',1873 'dd/MM/yyyy HH:mm',1874 'd MMM yyyy HH:mm:ss',1875 'd MMMM yyyy HH:mm:ss z',1876 'EEEE d MMMM yyyy HH\' h \'mm z'1877 );1878PTDate.formats['fr_LU'] = new Array(1879 'd MMM yyyy HH:mm:ss',1880 'dd/MM/yyyy HH:mm',1881 'd MMM yyyy HH:mm:ss',1882 'd MMMM yyyy HH:mm:ss z',1883 'EEEE d MMMM yyyy HH\' h \'mm z'1884 );1885PTDate.formats['it'] = new Array(1886 'd-MMM-yyyy H.mm.ss',1887 'dd/MM/yyyy H.mm',1888 'd-MMM-yyyy H.mm.ss',1889 'd MMMM yyyy H.mm.ss z',1890 'EEEE d MMMM yyyy H.mm.ss z'1891 );1892PTDate.formats['it_CH'] = new Array(1893 'd-MMM-yyyy HH:mm:ss',1894 'dd.MM.yyyy HH:mm',1895 'd-MMM-yyyy HH:mm:ss',1896 'd. MMMM yyyy HH:mm:ss z',1897 'EEEE, d. MMMM yyyy H.mm\' h\' z'1898 );1899PTDate.formats['it_IT'] = new Array(1900 'd-MMM-yyyy H.mm.ss',1901 'dd/MM/yyyy H.mm',1902 'd-MMM-yyyy H.mm.ss',1903 'd MMMM yyyy H.mm.ss z',1904 'EEEE d MMMM yyyy H.mm.ss z'1905 );1906PTDate.formats['ja'] = new Array(1907 'yyyy/MM/dd H:mm:ss',1908 'yyyy/MM/dd H:mm',1909 'yyyy/MM/dd H:mm:ss',1910 'yyyy/MM/dd H:mm:ss z',1911 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' H\'\u6642\'mm\'\u5206\'ss\'\u79D2\'z'1912 );1913PTDate.formats['ja_JP'] = new Array(1914 'yyyy/MM/dd H:mm:ss',1915 'yyyy/MM/dd H:mm',1916 'yyyy/MM/dd H:mm:ss',1917 'yyyy/MM/dd H:mm:ss z',1918 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' H\'\u6642\'mm\'\u5206\'ss\'\u79D2\'z'1919 );1920PTDate.formats['ko'] = new Array(1921 'yyyy-MM-dd a h:mm:ss',1922 'yyyy-MM-dd a h:mm',1923 'yyyy-MM-dd a h:mm:ss',1924 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\'',1925 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EEEE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\' z'1926 );1927PTDate.formats['ko_KR'] = new Array(1928 'yyyy-MM-dd a h:mm:ss',1929 'yyyy-MM-dd a h:mm',1930 'yyyy-MM-dd a h:mm:ss',1931 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\'',1932 'yyyy\'\uB144\' M\'\uC6D4\' d\'\uC77C\' EEEE a hh\'\uC2DC\'mm\'\uBD84\'ss\'\uCD08\' z'1933 );1934PTDate.formats['nl'] = new Array(1935 'd-MMM-yyyy HH:mm:ss',1936 'd-M-yy H:mm',1937 'd-MMM-yyyy H:mm:ss',1938 'd MMMM yyyy HH:mm:ss z',1939 'EEEE d MMMM yyyy H.mm\' uur \'z'1940 );1941PTDate.formats['nl_BE'] = new Array(1942 'd-MMM-yyyy HH:mm:ss',1943 'd/MM/yy H:mm',1944 'd-MMM-yyyy H:mm:ss',1945 'd MMMM yyyy HH:mm:ss z',1946 'EEEE d MMMM yyyy H.mm\' uur \'z'1947 );1948PTDate.formats['nl_NL'] = new Array(1949 'd-MMM-yyyy HH:mm:ss',1950 'd-M-yy H:mm',1951 'd-MMM-yyyy H:mm:ss',1952 'd MMMM yyyy HH:mm:ss z',1953 'EEEE d MMMM yyyy H.mm\' uur \'z'1954 );1955PTDate.formats['pt'] = new Array(1956 'd/MMM/yyyy H:mm:ss',1957 'dd-MM-yyyy H:mm',1958 'd/MMM/yyyy H:mm:ss',1959 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1960 'EEEE, d\' de \'MMMM\' de \'yyyy HH\'H\'mm\'m\' z'1961 );1962PTDate.formats['pt_BR'] = new Array(1963 'dd/MM/yyyy HH:mm:ss',1964 'dd/MM/yyyy HH:mm',1965 'dd/MM/yyyy HH:mm:ss',1966 'd\' de \'MMMM\' de \'yyyy H\'h\'m\'min\'s\'s\' z',1967 'EEEE, d\' de \'MMMM\' de \'yyyy HH\'h\'mm\'min\'ss\'s\' z'1968 );1969PTDate.formats['pt_PT'] = new Array(1970 'd/MMM/yyyy H:mm:ss',1971 'dd-MM-yyyy H:mm',1972 'd/MMM/yyyy H:mm:ss',1973 'd\' de \'MMMM\' de \'yyyy H:mm:ss z',1974 'EEEE, d\' de \'MMMM\' de \'yyyy HH\'H\'mm\'m\' z'1975 );1976PTDate.formats['zh'] = new Array(1977 'yyyy-M-d H:mm:ss',1978 'yyyy-M-d ah:mm',1979 'yyyy-M-d H:mm:ss',1980 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u65F6\'mm\'\u5206\'ss\'\u79D2\'',1981 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' HH\'\u65F6\'mm\'\u5206\'ss\'\u79D2\' z'1982 );1983PTDate.formats['zh_CN'] = new Array(1984 'yyyy-M-d H:mm:ss',1985 'yyyy-M-d ah:mm',1986 'yyyy-M-d H:mm:ss',1987 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u65F6\'mm\'\u5206\'ss\'\u79D2\'',1988 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' HH\'\u65F6\'mm\'\u5206\'ss\'\u79D2\' z'1989 );1990PTDate.formats['zh_HK'] = new Array(1991 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh:mm:ss',1992 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ah:mm',1993 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh:mm:ss',1994 'yyyy\'\u5E74\'MM\'\u6708\'dd\'\u65E5\' EEEE ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\'',1995 'yyyy\'\u5E74\'MM\'\u6708\'dd\'\u65E5\' EEEE ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\' z'1996 );1997PTDate.formats['zh_TW'] = new Array(1998 'yyyy/M/d a hh:mm:ss',1999 'yyyy/M/d a h:mm',2000 'yyyy/M/d a hh:mm:ss',2001 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\'',2002 'yyyy\'\u5E74\'M\'\u6708\'d\'\u65E5\' ahh\'\u6642\'mm\'\u5206\'ss\'\u79D2\' z'2003 );2004PTDateUtil = function()2005{2006 return this;2007}2008PTDateUtil.VERSION = '246682';2009PTDateUtil.isSameDay = function (date1, date2)2010{2011 if (isNaN(date1) || isNaN(date2)) { return false; }2012 if ((date1.getFullYear() == date2.getFullYear())2013 &&2014 (date1.getMonth() == date2.getMonth())2015 &&2016 (date1.getDate() == date2.getDate()))2017 {2018 return true;2019 }2020 else { return false; }2021}2022PTDateUtil.getDaysBetweenDates = function (date1, date2)2023{2024 if (isNaN(date1) || isNaN(date2)) { return 0; }2025 date1.setHours(12);2026 date2.setHours(12);2027 var millis = Math.abs(date2.getTime() - date1.getTime());2028 return Math.round(millis / (1000 * 60 * 60 * 24));2029}2030PTDateUtil.formatTime = function(sTime, iMode)2031{2032 var err = false;2033 var regTime = /\b\d\d?\b|\b\d\d?\B|\B\d\d?\b|\B\d\d?\B/g;2034 var regAMPM = new RegExp('AM|am|Am|aM|PM|pm|Pm|pM|p.m.|p.m|P.M.|a.m.|a.m|A.M.');2035 if (sTime == '') { return false; }2036 if ((sTime.match(/\d\d?:\d/) == null) || (sTime.match(/:/) == null)) { return false; }2037 var arrTime = sTime.match(regTime);2038 var strAMPM = sTime.match(regAMPM);2039 if (!arrTime[1]) { arrTime[1] = 0; }2040 if (!arrTime[2]) { arrTime[2] = 0; }2041 if ((arrTime[0] > 23) || (arrTime[1] > 59) || (arrTime[2] > 59) || (arrTime[0] == null) || (arrTime[0] < 0) || (arrTime[1] < 0) || (arrTime[2] < 0)) { err = true; }2042 var strTempDigits;2043 if (iMode == 0)2044 {2045 if ((strAMPM == 'PM') && (arrTime[0] < 12)) { arrTime[0] += 12; }2046 else if ((strAMPM == 'AM') && (arrTime[0] == 12)) { arrTime[0] = 0; }2047 }2048 else2049 {2050 if (!strAMPM)2051 {2052 strAMPM = 'AM';2053 if (arrTime[0] > 12)2054 {2055 arrTime[0] = arrTime[0] - 12;2056 strAMPM = 'PM';2057 }2058 else if (arrTime[0] == 0)2059 {2060 arrTime[0] = 12;2061 strAMPM = 'AM';2062 }2063 }2064 }2065 for (i = 0; i < 3; i++)2066 {2067 strTempDigits = '0' + arrTime[i];2068 if (strTempDigits.length == 2) { arrTime[i] = strTempDigits; }2069 }2070 if (err)2071 {2072 alert(PTS_STR['PTU-Date-TimeFormatError']);2073 return false;2074 }2075 else2076 {2077 sTime = arrTime[0] + ':' + arrTime[1] + ':' + arrTime[2];2078 if (iMode == 1) { sTime += ' ' + strAMPM; }2079 return sTime;2080 }2081}2082PTDateUtil.validateDate = function(strDay, strMonth, strYear)2083{2084 var strInputDate = strDay + ' ' + strMonth + ' ' + strYear; var objDate = new Date(strInputDate);2085 var strDate = objDate.toGMTString();2086 var arrDate = strDate.split(' ');2087 return (arrDate[2] != strMonth);2088}2089PTDateValidator = function()2090{2091 return this;2092}2093PTDateValidator.VERSION = '246682';2094PTDateValidator.TIME_POLICY_ALLOW_TIMES = 0;2095PTDateValidator.TIME_POLICY_REQUIRE_TIMES = 1;2096PTDateValidator.TIME_POLICY_FORBID_TIMES = 2;2097PTDateValidator.formatTokens = new Array('a','d','E','h','H','k','K','m','M','s','S','y');2098PTDateValidator.punctuation = new Array(',','/',':','-','.');2099PTDateValidator.closeSubstitutes = {2100 '\u00E1' : 'a',2101 '\u00E4' : 'a',2102 '\u00E7' : 'c',2103 '\u00E9' : 'e',2104 '\u00EC' : 'i',2105 '\u00FB' : 'u',2106 '\u2013' : '-', 2107 '\u2212' : '-'2108 };2109PTDateValidator.validateDate = function(dateString, locale, alertOnFailure, timePolicy, formatList)2110{2111 if (!dateString) { return false; }2112 if (!locale) { locale = PTDate.DEFAULT_LOCALE; }2113 if (!timePolicy) { timePolicy = PTDateValidator.TIME_POLICY_ALLOW_TIMES; }2114 if (!formatList) { formatList = PTDate.getFormatListForLocale(locale); }2115 var isValidDate = false;2116 var numFormats = formatList.length;2117 var dateData = false;2118 var hash = PTDateValidator.getPunctuationHash();2119 for (var f = 0; f < numFormats; f++)2120 {2121 var format = formatList[f];2122 dateData = PTDateValidator.parseDateStringAgainstFormat(dateString,format,hash,locale);2123 if (dateData != false)2124 {2125 if (PTNumberUtil.isInteger(dateData.day) && PTNumberUtil.isInteger(dateData.month) && PTNumberUtil.isInteger(dateData.year)) { break; }2126 }2127 }2128 var date;2129 var isValidDate = false;2130 if (dateData != false)2131 { if (dateData.ampm && (dateData.ampm == 'pm'))2132 {2133 if ((dateData.hour > 0) && (dateData.hour < 12)) { dateData.hour += 12; }2134 }2135 date = new Date(dateData.year, dateData.month, dateData.day, dateData.hour, dateData.minutes, dateData.seconds);2136 if ((dateData.day == date.getDate()) &&2137 (dateData.month == date.getMonth()) &&2138 (dateData.year == date.getFullYear()))2139 {2140 isValidDate = true;2141 }2142 }2143 if (!isValidDate) { alertOnFailure = PTDateValidator.alertOnFailure(alertOnFailure,formatList,timePolicy); }2144 var isTimeValid = false;2145 if (timePolicy == PTDateValidator.TIME_POLICY_ALLOW_TIMES)2146 {2147 if ((PTNumberUtil.isInteger(dateData.hour) && PTNumberUtil.isInteger(dateData.minutes)) ||2148 (!PTNumberUtil.isInteger(dateData.hour) && !PTNumberUtil.isInteger(dateData.minutes)))2149 {2150 isTimeValid = true;2151 } else { alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy); }2152 }2153 else if (timePolicy == PTDateValidator.TIME_POLICY_REQUIRE_TIMES)2154 {2155 if (PTNumberUtil.isInteger(dateData.hour) && PTNumberUtil.isInteger(dateData.minutes))2156 {2157 isTimeValid = true;2158 } else { alertOnFailure = PTDateValidator.alertTimeRequired(alertOnFailure,formatList,timePolicy); }2159 }2160 else if (timePolicy == PTDateValidator.TIME_POLICY_FORBID_TIMES)2161 {2162 if (!PTNumberUtil.isInteger(dateData.hour) && !PTNumberUtil.isInteger(dateData.minutes))2163 {2164 isTimeValid = true;2165 } else { alertOnFailure = PTDateValidator.alertTimeForbidden(alertOnFailure,formatList,timePolicy); }2166 }2167 if (timePolicy != PTDateValidator.TIME_POLICY_FORBID_TIMES)2168 {2169 if ((dateData.hour < 0) || (dateData.hour > 23))2170 {2171 isTimeValid = false;2172 alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy);2173 }2174 else if ((dateData.minutes < 0) || (dateData.minutes > 59))2175 {2176 isTimeValid = false;2177 alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy);2178 }2179 else if ((dateData.seconds < 0) || (dateData.seconds > 59))2180 {2181 isTimeValid = false;2182 alertOnFailure = PTDateValidator.alertTimeFormatProblem(alertOnFailure,formatList,timePolicy);2183 }2184 }2185 var returnValue = false;2186 if (isValidDate && isTimeValid) { returnValue = date; }2187 return returnValue;2188}2189PTDateValidator.parseDateStringAgainstFormat = function(dateString, format, hash, locale)2190{2191 dateString = (new String(dateString)).replace(/\'/g,'');2192 format = format.replace(/\'\'/g,'');2193 while (1)2194 {2195 var s = format.indexOf('\'');2196 if (s == -1) { break; }2197 var e = format.substr(s + 1).indexOf('\'');2198 if (e == -1) { break; }2199 e += s + 1;2200 var literal = format.substring(s + 1,e);2201 var percent = parseInt(((s / format.length) * 100),10);2202 var matches = PTDateValidator.findAllMatches(literal, dateString, locale);2203 var bestMatch = false;2204 var bestDist = 100;2205 for (var m = 0; m < matches.length; m++)2206 {2207 var match = matches[m];2208 var dist = Math.abs(percent - match.pct);2209 if (dist < bestDist) { bestMatch = match; }2210 }2211 if (bestMatch)2212 {2213 var start = bestMatch.loc;2214 var end = start + literal.length;2215 dateString = dateString.substring(0,start) + ' ' + dateString.substr(end);2216 }2217 format = format.substring(0,s) + ' ' + format.substr(e + 1);2218 }2219 dateString = PTStringUtil.substituteChars(dateString,hash);2220 format = PTStringUtil.substituteChars(format,hash);2221 dateString = PTStringUtil.trimWhitespace(dateString,true,true);2222 format = PTStringUtil.trimWhitespace(format,true,true);2223 var i = dateString.split(/\s+/);2224 var f = format.split(/\s+/);2225 var dateData = new _dateData();2226 var numWords = Math.min(i.length,f.length);2227 for (var w = 0; w < numWords; w++)2228 { 2229 var formatToken = f[w];2230 var word = i[w];2231 dateData = PTDateValidator.validateWordByTokenType(word,formatToken,dateData,locale);2232 if (dateData == false) { return false; }2233 }2234 return dateData;2235}2236PTDateValidator.validateWordByTokenType = function(word, formatToken, dateData, locale)2237{2238 word = word.toLowerCase();2239 var foundAmpm = false;2240 var STR = PTDateStrings;2241 if (locale.indexOf('en') == 0) { STR = PTDate.EnglishStrings; }2242 if (formatToken.indexOf('a') > -1)2243 {2244 var strings = STR.ampm.length;2245 for (var s = 0; s < strings; s++)2246 {2247 var ampmString = STR.ampm[s];2248 var idx = word.indexOf(ampmString.toLowerCase());2249 if (idx > -1)2250 {2251 dateData.ampm = (s) ? 'pm' : 'am';2252 word = word.substring(0,idx) + word.substr(ampmString.length);2253 while (formatToken.indexOf('a') > -1)2254 {2255 var pos = formatToken.indexOf('a');2256 formatToken = formatToken.substring(0,pos) + formatToken.substr(pos + 1);2257 }2258 foundAmpm = true;2259 break;2260 }2261 }2262 }2263 if (formatToken.charAt(0) == 'd')2264 { if (!PTNumberUtil.isInteger(word)) { return false; }2265 var n = word;2266 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2267 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2268 if (isNaN(n)) { return false; } dateData.day = n;2269 return dateData;2270 }2271 else if (formatToken == 'E')2272 { if (PTDateValidator.isWordLike(word,STR.daysInitial,7)) { return dateData; }2273 }2274 else if (formatToken.substring(0,2) == 'EE')2275 { if (PTDateValidator.isWordLike(word,STR.daysLong.concat(STR.daysShort),7)) { return dateData; }2276 }2277 else if (formatToken.charAt(0).toLowerCase() == 'h')2278 { if (!PTNumberUtil.isInteger(word)) { return false; }2279 var n = word;2280 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2281 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2282 if (isNaN(n)) { return false; } dateData.hour = n;2283 return dateData;2284 }2285 else if (formatToken.charAt(0).toLowerCase() == 'k')2286 { if (!PTNumberUtil.isInteger(word)) { return false; }2287 var n = word;2288 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2289 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2290 if (isNaN(n)) { return false; } dateData.hour = n;2291 return dateData;2292 }2293 else if (formatToken.charAt(0) == 'm')2294 { if (!PTNumberUtil.isInteger(word)) { return false; }2295 var n = word;2296 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2297 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2298 if (isNaN(n)) { return false; } dateData.minutes = n;2299 return dateData;2300 }2301 else if ((formatToken == 'M') || (formatToken == 'MM'))2302 { if (!PTNumberUtil.isInteger(word)) { return false; }2303 var n = word;2304 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2305 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); }2306 if (isNaN(n)) { return false; }2307 n -= 1; dateData.month = n;2308 return dateData;2309 }2310 else if (formatToken.substring(0,3) == 'MMM')2311 { var m = PTDateValidator.isWordLike(word,STR.monthsLong.concat(STR.monthsShort),12);2312 if (m)2313 { if (parseInt(m,10) == 0) { dateData.month = 0; }2314 else { dateData.month = parseInt(PTNumberUtil.trimLeadingZeros(m),10); }2315 return dateData;2316 }2317 }2318 else if (formatToken.charAt(0) == 's')2319 {2320 var n = word;2321 if (parseInt(n,10) == 0) { n = parseInt(n,10); }2322 else { n = parseInt(PTNumberUtil.trimLeadingZeros(word),10); } if (isNaN(n)) { dateData.seconds = 0; } else { dateData.seconds = n; }2323 return dateData;2324 }2325 else if (formatToken.charAt(0) == 'S')2326 { return dateData;2327 }2328 else if (formatToken.indexOf('yy') > -1)2329 { if (!PTNumberUtil.isInteger(word)) { return false; }2330 var n = parseInt(PTNumberUtil.trimLeadingZeros(word),10);2331 if (isNaN(n)) { return false; } if (n < 100)2332 {2333 n = PTDate.convert2DigitTo4DigitYear(n);2334 }2335 dateData.year = n;2336 return dateData;2337 }2338 else if (formatToken.charAt(0) == 'z')2339 { return dateData;2340 }2341 if (foundAmpm) { return dateData }2342 else { return false; }2343}2344PTDateValidator.isWordLike = function(word, matchArray, numTests)2345{2346 word = word + ''; 2347 var len = matchArray.length;2348 for (var a = 0; a < len; a++)2349 {2350 var m = (new String(matchArray[a])).toLowerCase() + ''; 2351 if (m == word) { return new String(a % numTests); }2352 if ((word.length >= 3) && (m.indexOf(word.substring(0,3)) == 0)) { return new String(a % numTests); }2353 m = PTStringUtil.substituteChars(m,PTDateValidator.closeSubstitutes);2354 if (m == word) { return new String(a % numTests); }2355 if ((word.length >= 3) && (m.indexOf(word) == 0)) { return new String(a % numTests); }2356 }2357 return false;2358}2359PTDateValidator.findAllMatches = function(pattern, string, locale)2360{2361 var results = new Array();2362 var tester = new String(string);2363 var chopped = 0;2364 var STR = PTDateStrings;2365 if (locale.indexOf('en') == 0) { STR = PTDate.EnglishStrings; }2366 while (tester.indexOf(pattern) > -1)2367 {2368 var loc = tester.indexOf(pattern);2369 var pos = loc + chopped;2370 var nogood = false;2371 var fragment = (tester.substr(tester.indexOf(pattern))).replace(/\s.*$/,'');2372 if (fragment.length > 1)2373 {2374 for (var i = 0; i < STR.monthsLong.length; i++)2375 {2376 if (STR.monthsLong[i].indexOf(fragment) > -1)2377 {2378 nogood = true;2379 break;2380 }2381 }2382 }2383 if (!nogood)2384 {2385 var r = results[results.length] = new Object();2386 r.loc = pos;2387 r.pct = Math.round((pos / string.length) * 100);2388 }2389 tester = tester.substr(loc + 1);2390 chopped += (loc + 1);2391 }2392 return results;2393}2394PTDateValidator.alertOnFailure = function(alertOnFailure, formatList, timePolicy)2395{2396 if (alertOnFailure)2397 {2398 var sb = new PTStringBuffer();2399 sb.append(PTS_STR['PTU-DateV-DateFormatError'] + '\n\n');2400 sb.append(PTS_STR['PTU-DateV-ExampleFormats'] + '\n\n');2401 var m = new Array();2402 var d = new Date();2403 var startAt = 0;2404 if (formatList[0] == formatList[2]) { startAt = 1; }2405 for (var f = startAt; f < formatList.length; f++)2406 {2407 var format = formatList[f];2408 if (timePolicy == PTDateValidator.TIME_POLICY_FORBID_TIMES) { format = PTDate.stripTimesFromFormat(format); }2409 var formattedDate = PTDate.formatDate(d,format);2410 if (m[formattedDate]) { continue; }2411 else { m[formattedDate] = true; }2412 sb.append(' ' + formattedDate + '\n');2413 }2414 sb.append('\n');2415 alert(sb.toString());2416 }2417 return false;2418}2419PTDateValidator.alertTimeFormatProblem = function(alertOnFailure, formatList, timePolicy)2420{2421 if (alertOnFailure)2422 {2423 alert(PTS_STR['PTU-DateV-TimeFormatError']);2424 return false;2425 }2426 return alertOnFailure;2427}2428PTDateValidator.alertTimeRequired = function(alertOnFailure, formatList, timePolicy)2429{2430 if (alertOnFailure)2431 {2432 alert(PTS_STR['PTU-DateV-TimeRequired']);2433 return false;2434 }2435 return alertOnFailure;2436}2437PTDateValidator.alertTimeForbidden = function(alertOnFailure, formatList, timePolicy)2438{2439 if (alertOnFailure)2440 {2441 alert(PTS_STR['PTU-DateV-TimeForbidden']);2442 return false;2443 }2444 return alertOnFailure;2445}2446PTDateValidator.getPunctuationHash = function()2447{2448 var hash = new Array();2449 var chars = PTStringUtil.whitespaceChars.concat(PTDateValidator.punctuation);2450 var len = chars.length;2451 for (var c = 0; c < len; c++) { hash[chars[c]] = ' '; }2452 return hash;2453}2454function _dateData()2455{2456 this.day = false;2457 this.month = false;2458 this.year = false;2459 this.hour = false;2460 this.minutes = false;2461 this.seconds = false;2462 this.ampm = false;2463 return this;2464}2465PTEventUtil = function()2466{2467 return this;2468}2469PTEventUtil.VERSION = '246682';2470PTEventUtil.SRC_BUTTON_LEFT = 'left';2471PTEventUtil.SRC_BUTTON_RIGHT = 'right';2472PTEventUtil.SRC_BUTTON_MIDDLE = 'middle';2473PTEventUtil.stopBubbling = function(e)2474{2475 if (!e) var e = window.event;2476 if (!e) return;2477 e.cancelBubble = true;2478 if (e.stopPropagation) e.stopPropagation();2479}2480PTEventUtil.attachEventListener = function(targetElement, eventName, listenerReference)2481{ if (document.all)2482 { if (eventName.substring(0,2) != 'on') { eventName = 'on' + eventName; }2483 targetElement.attachEvent(eventName, listenerReference);2484 } else2485 { if (eventName.substring(0,2) == 'on') { eventName = eventName.substring(2,eventName.length); }2486 targetElement.addEventListener(eventName, listenerReference, false);2487 }2488}2489PTEventUtil.detachEventListener = function(targetElement, eventName, listenerReference)2490{ if (document.all)2491 { if (eventName.substring(0,2) != 'on') { eventName = 'on' + eventName; }2492 targetElement.detachEvent(eventName, listenerReference);2493 } else2494 { if (eventName.substring(0,2) == 'on') { eventName = eventName.substring(2,eventName.length); }2495 targetElement.removeEventListener(eventName, listenerReference, false);2496 }2497}2498PTEventUtil.getSrcElement = function(e)2499{ if (document.all)2500 {2501 return e.srcElement;2502 } else2503 {2504 return e.target;2505 }2506}2507PTEventUtil.getButtonClicked = function(e)2508{2509 if (!e) { return false; }2510 if (document.all)2511 {2512 if (e.button == 1) { return PTEventUtil.SRC_BUTTON_LEFT; }2513 else if (e.button == 4) { return PTEventUtil.SRC_BUTTON_MIDDLE; }2514 else if (e.button == 2){ return PTEventUtil.SRC_BUTTON_RIGHT; }2515 else { return false; }2516 } else2517 {2518 if (e.button == 0) { return PTEventUtil.SRC_BUTTON_LEFT; }2519 else if (e.button == 1) { return PTEventUtil.SRC_BUTTON_MIDDLE; }2520 else if (e.button == 2){ return PTEventUtil.SRC_BUTTON_RIGHT; }2521 else { return false; }2522 }2523}2524PTEventUtil.getMouseOverFromElement = function(e)2525{2526 if (!e) { return false; }2527 if (document.all) { return e.fromElement; } else { return e.relatedTarget; }2528}2529PTEventUtil.getMouseOutFromElement = function(e)2530{2531 if (!e) { return false; }2532 if (document.all) { return e.fromElement; } else { return e.target; }2533}2534PTEventUtil.getMouseOverToElement = function(e)2535{2536 if (!e) { return false; }2537 if (document.all) { return e.toElement; } else { return e.target; }2538}2539PTEventUtil.getMouseOutToElement = function(e)2540{2541 if (!e) { return false; }2542 if (document.all) { return e.toElement; } else { return e.relatedTarget; }2543}2544PTEventUtil.clickElement = function(elm) 2545{ if (elm.click) { elm.click(); } else if (elm.dispatchEvent) {2546 var evt = document.createEvent('MouseEvents');2547 evt.initMouseEvent(2548 'click',2549 true,2550 true,2551 window,2552 1,2553 0,2554 0,2555 0,2556 0,2557 false,2558 false,2559 false,2560 false,2561 0,2562 null2563 );2564 elm.dispatchEvent(evt);2565}2566}2567PTEventUtil.getMouseX = function(e)2568{2569 var posx = 0;2570 if (!e) var e = window.event;2571 if (e.pageX)2572 {2573 posx = e.pageX;2574 }2575 else if (e.clientX)2576 {2577 posx = e.clientX;2578 posy = e.clientY;2579 if (PTBrowserInfo.IS_MSIE)2580 {2581 posx += document.body.scrollLeft;2582 }2583 }2584 return posx;2585}2586PTEventUtil.getMouseY = function(e)2587{2588 var posy = 0;2589 if (!e) var e = window.event;2590 if (e.pageY)2591 {2592 posy = e.pageY;2593 }2594 else if (e.clientY)2595 {2596 posy = e.clientY;2597 if (PTBrowserInfo.IS_MSIE)2598 {2599 posy += document.body.scrollTop;2600 }2601 }2602 return posy;2603}2604PTFormUtil = function() {}2605PTFormUtil.VERSION = '246682';2606PTFormUtil.getRadioValue = function(rads)2607{2608 if (!rads) { return; }2609 var val;2610 if (rads.length > 1) {2611 for (var i = 0; i < rads.length; i++) {2612 if (rads[i].checked) {2613 val = rads[i].value;2614 break;2615 }2616 }2617 } else {2618 val = rads.value;2619 }2620 return val;2621}2622PTFormUtil.setRadioValue = function(rads,val)2623{2624 if (!rads) { return false; }2625 var foundRadio = false;2626 if (rads.length > 1)2627 {2628 for (var i = 0; i < rads.length; i++)2629 {2630 if (rads[i].value == val)2631 {2632 foundRadio = true;2633 break;2634 }2635 }2636 if (foundRadio)2637 {2638 for (var i = 0; i < rads.length; i++)2639 {2640 if (rads[i].value == val) { rads[i].checked = true; }2641 else { rads[i].checked = false; }2642 }2643 }2644 }2645 else2646 {2647 foundRadio = (rads.checked = true);2648 }2649 return foundRadio;2650}2651PTFormUtil.setSelectValue = function(sel,val)2652{2653 var success = false;2654 if (!sel) { return success; }2655 if (sel.options.length < 1) { return success; }2656 for (var i = 0; i < sel.options.length; i++) {2657 var opt = sel.options[i];2658 if (opt.value && opt.value == val) {2659 sel.selectedIndex = i;2660 success = true;2661 break;2662 }2663 }2664 return success;2665}2666PTFormUtil.fillSelect = function(sel,optionsInfo)2667{2668 if (!sel) { return; }2669 if (!optionsInfo) { return; }2670 if (!optionsInfo.length) { return; }2671 var numOldOptions = sel.options.length;2672 var numNewOptions = optionsInfo.length;2673 for (var i = 0; i < numNewOptions; i++) {2674 if (!optionsInfo[i]) { continue; }2675 var curNewOption = optionsInfo[i];2676 var newOptionText = curNewOption.text;2677 var newOptionValue = curNewOption.value;2678 var newOptionIndex = numOldOptions + i;2679 sel.options[newOptionIndex] = new Option(newOptionText,newOptionValue);2680 }2681}2682PTFormUtil.clearSelect = function(sel)2683{2684 if (!sel) { return; }2685 var numOpts = sel.options.length;2686 if (numOpts == 0) { return; }2687 for (var i = (numOpts - 1); i >= 0; i--) {2688 sel.options[i] = null;2689 }2690}2691PTFormUtil.addItemToSelect = function(sel,val,txt,idx)2692{2693 if ((!idx && (idx != 0)) || (idx == -1)) {2694 idx = sel.options.length;2695 sel.options[idx] = new Option(txt,val);2696 } else {2697 var opts = sel.options;2698 var len = opts.length;2699 for (var i = len; i > idx; i--) {2700 if (!opts[i]) {2701 opts[i] = new Option(opts[i-1].text,opts[i-1].value);2702 } else {2703 opts[i].text = opts[i-1].text;2704 opts[i].value = opts[i-1].value;2705 }2706 }2707 opts[idx].text = txt;2708 opts[idx].value = val;2709 }2710 return idx;2711}2712PTFormUtil.selectMoveItemUp = function(sel)2713{2714 idx = sel.selectedIndex;2715 if (idx == -1) { return; }2716 if (idx < 1) { return; }2717 var swapText = sel.options[idx-1].text;2718 var swapVal = sel.options[idx-1].value;2719 sel.options[idx-1].text = sel.options[idx].text;2720 sel.options[idx-1].value = sel.options[idx].value;2721 sel.options[idx].text = swapText;2722 sel.options[idx].value = swapVal;2723 sel.selectedIndex = idx - 1;2724}2725PTFormUtil.selectMoveItemDown = function(sel)2726{2727 idx = sel.selectedIndex;2728 if (idx == -1) { return; }2729 if (idx >= (sel.options.length - 1)) { return; }2730 var swapText = sel.options[idx+1].text;2731 var swapVal = sel.options[idx+1].value;2732 sel.options[idx+1].text = sel.options[idx].text;2733 sel.options[idx+1].value = sel.options[idx].value;2734 sel.options[idx].text = swapText;2735 sel.options[idx].value = swapVal;2736 sel.selectedIndex = idx + 1;2737}2738PTFormUtil.focusAndSelectText = function(input)2739{2740 if (!input || !input.focus || !input.select) { return; }2741 input.focus();2742 input.select();2743}2744PTFormUtil.focusFormFieldByName = function(fieldName)2745{2746 var field = eval(fieldName);2747 if (field && field.focus) { field.focus(); }2748}2749PTFormUtil.hideAllSelects = function(elem)2750{2751 if (!elem) { elem = window.document; }2752 var selects = elem.getElementsByTagName('select');2753 var hiddenSelects = new Array();2754 for (var s = 0; s < selects.length; s++)2755 {2756 if(selects[s].style.visibility != 'hidden')2757 {2758 PTFormUtil.setSelectVisibility(selects[s],'hidden');2759 hiddenSelects[hiddenSelects.length] = selects[s];2760 }2761 }2762 return hiddenSelects;2763}2764PTFormUtil.hideSelects = function(selects)2765{2766 if(!selects) return;2767 for (var s = 0; s < selects.length; s++)2768 {2769 PTFormUtil.setSelectVisibility(selects[s],'hidden');2770 }2771}2772PTFormUtil.showAllSelects = function(elem)2773{2774 if (!elem) { elem = window.document; }2775 var selects = elem.getElementsByTagName('select');2776 var visibleSelects = new Array();2777 for (var s = 0; s < selects.length; s++)2778 {2779 if(selects[s].style.visibility == 'hidden')2780 {2781 PTFormUtil.setSelectVisibility(selects[s],'visible');2782 visibleSelects[visibleSelects.length] = selects[s];2783 }2784 }2785 return visibleSelects;2786}2787PTFormUtil.showSelects = function(selects)2788{2789 if(!selects) return;2790 for(var s = 0; s < selects.length; s++)2791 {2792 PTFormUtil.setSelectVisibility(selects[s], 'visible');2793 }2794}2795PTFormUtil.disableAllSelects = function(elem)2796{2797 if (!elem) { elem = window.document; }2798 var selects = elem.getElementsByTagName('select');2799 if (!window._selectStateCache) { window._selectStateCache = new Object(); }2800 for (var s = 0; s < selects.length; s++)2801 {2802 var sel = selects[s];2803 if (sel.id)2804 {2805 if (sel.disabled === true) { window._selectStateCache[sel.id] = true; }2806 else { window._selectStateCache[sel.id] = false; }2807 }2808 sel.disabled = true;2809 }2810}2811PTFormUtil.enableAllSelects = function(elem,useSelectStateCache)2812{2813 if (!elem) { elem = window.document; }2814 var selects = elem.getElementsByTagName('select');2815 for (var s = 0; s < selects.length; s++)2816 {2817 var sel = selects[s];2818 if (useSelectStateCache && window._selectStateCache && window._selectStateCache[sel.id]) { continue; }2819 selects[s].disabled = false;2820 }2821}2822PTFormUtil.setSelectVisibility = function(select,vis)2823{2824 if (!select) { return false; }2825 select.style.visibility = vis;2826}2827PTHashtable = function()2828{2829 this._keys = new Array();2830 this._values = new Object();2831 this._enumKeyIndex = -1;2832 return this;2833}2834PTHashtable.VERSION = '246682';2835PTHashtable.prototype.className = 'PTHashtable';2836PTHashtable.prototype.clear = function()2837{2838 this._keys = new Array();2839 this._values = new Object();2840 this._enumKeyIndex = -1;2841}2842PTHashtable.prototype.clone = function()2843{2844 var newHT = new PTHashtable();2845 var numKeys = this._keys.length;2846 for (var i = 0; i < numKeys; i++)2847 {2848 var key = this._keys[i];2849 newHT._keys[i] = key;2850 newHT._values[key] = this._values[key];2851 }2852 return newHT;2853}2854PTHashtable.prototype.contains = function(obj)2855{2856 return this.containsValue(obj);2857}2858PTHashtable.prototype.containsKey = function(key)2859{2860 var numKeys = this._keys.length;2861 for (var i = 0; i < numKeys; i++)2862 {2863 if (this._keys[i] == key) { return true; }2864 }2865 return false;2866}2867PTHashtable.prototype.containsValue = function(obj)2868{2869 var numKeys = this._keys.length;2870 for (var i = 0; i < numKeys; i++)2871 {2872 var key = this._keys[i];2873 if (this._values[key] == obj) { return true; }2874 }2875 return false;2876}2877PTHashtable.prototype.equals = function(obj)2878{2879 if (!obj) { return false; }2880 if (!obj.className) { return false; }2881 if (obj.className != 'PTHashtable') { return false; }2882 if (!obj._keys) { return false; }2883 if (!PTArrayUtil.isArrayLike(obj._keys)) { return false; }2884 if (obj._keys.length != this._keys.length) { return false; }2885 var numKeys = this._keys.length;2886 for (var i = 0; i < numKeys; i++)2887 {2888 var key = this._keys[i];2889 if (key != obj._keys[i]) { return false; }2890 if (this._values[key] != obj._values[key]) { return false; }2891 }2892 return true;2893}2894PTHashtable.prototype.get = function(key)2895{2896 return this._values[key];2897}2898PTHashtable.prototype.hasNext = function()2899{2900 var index = this._enumKeyIndex + 1;2901 return (this._keys.length > index) ? true : false;2902}2903PTHashtable.prototype.isEmpty = function()2904{2905 return (this.size() == 0) ? true : false;2906}2907PTHashtable.prototype.keys = function()2908{2909 var arr = new Array();2910 var numKeys = this._keys.length;2911 for (var i = 0; i < numKeys; i++)2912 {2913 arr[i] = this._keys[i];2914 }2915 return arr;2916}2917PTHashtable.prototype.next = function()2918{2919 this._enumKeyIndex++;2920 if (!this.hasNext()) { return; }2921 else2922 {2923 return this._values[this._keys[this._enumKeyIndex]];2924 }2925}2926PTHashtable.prototype.put = function(key,value)2927{2928 var oldValue = this._values[key];2929 if (!this.containsKey(key))2930 {2931 this._keys.push(key);2932 }2933 this._values[key] = value;2934 return oldValue;2935}2936PTHashtable.prototype.remove = function(key)2937{2938 var oldValue = this._values[key];2939 var keyIndex = -1;2940 var numKeys = this._keys.length;2941 for (var i = 0; i < numKeys; i++)2942 {2943 if (this._keys[i] == key)2944 {2945 keyIndex = i;2946 break;2947 }2948 }2949 if (keyIndex == -1) { return; }2950 this._keys.splice(keyIndex,1);2951 return oldValue;2952}2953PTHashtable.prototype.resetIterator = function()2954{2955 this._enumKeyIndex = -1;2956}2957PTHashtable.prototype.size = function()2958{2959 return this._keys.length;2960}2961PTHashtable.prototype.toArray = function()2962{2963 var arr = new Array();2964 var numKeys = this._keys.length;2965 for (var i = 0; i < numKeys; i++)2966 {2967 var key = this._keys[i];2968 var value = this._values[key];2969 var obj = new Object();2970 obj.key = key;2971 obj.value = value;2972 arr[i] = obj;2973 }2974 return arr;2975}2976PTHashtable.prototype.toString = function()2977{2978 var sb = new PTStringBuffer();2979 sb.append('{ ');2980 var numKeys = this._keys.length;2981 for (var i = 0; i < numKeys; i++)2982 {2983 var key = this._keys[i];2984 var value = this._values[key];2985 sb.append('\'' + PTStringUtil.escapeJS(key) + '\'');2986 sb.append(' : ');2987 sb.append('\'' + PTStringUtil.escapeJS(value) + '\'');2988 if (i != (numKeys - 1)) { sb.append(', '); }2989 }2990 sb.append(' }');2991 return sb.toString();2992}2993PTHashtable.prototype.values = function()2994{2995 var arr = new Array();2996 var numKeys = this._keys.length;2997 for (var i = 0; i < numKeys; i++)2998 {2999 var key = this._keys[i];3000 arr[i] = this._values[key];3001 }3002 return arr;3003}3004PTNumberFormatter = function(num)3005{3006 this.num = (num) ? num : 0;3007 this.isGrouping = true;3008 this.isCurrency = false;3009 this.currencySymbol = '';3010 this.currencySymbolBefore = true;3011 this.groupingSeparator = ',';3012 this.decimalSeparator = '.';3013 this.decimalPlaces = -1;3014 this.negativePrefix = '-';3015 this.negativeSuffix = '';3016}3017PTNumberFormatter.VERSION = '246682';3018PTNumberFormatter.prototype.INVALID = 'INVALID';3019PTNumberFormatter.prototype.formatValue = function(num)3020{3021 if (num != null) { this.num = num; }3022 if ((this.num == null) || (this.num == '') || (this.num.toString().length == 0)) { return ''; }3023 if (this.isCurrency == true)3024 {3025 var csRe1 = new RegExp(this.currencySymbol, 'gi');3026 this.num = this.num.toString().replace(csRe1,'');3027 var csRe2 = new RegExp('\\'+this.currencySymbol, 'gi');3028 this.num = this.num.toString().replace(csRe2,'');3029 }3030 var gsRe = new RegExp('\\'+this.groupingSeparator, 'g');3031 this.num = this.num.toString().replace(gsRe,'');3032 if ((this.num.toString().indexOf('(') > -1) && (this.num.toString().indexOf(')') > -1)) { if (this.num.toString().indexOf(')') != this.num.toString().lastIndexOf(')')) {3033 return this.invalidNumber();3034 }3035 if (this.num.toString().indexOf('(') != this.num.toString().lastIndexOf('(')) {3036 return this.invalidNumber();3037 } if (this.num.toString().indexOf(')') < this.num.toString().lastIndexOf('(')) {3038 return this.invalidNumber();3039 }3040 var paRe1 = new RegExp('\\(', 'g');3041 this.num = this.num.toString().replace(paRe1,'');3042 var paRe2 = new RegExp('\\)', 'g');3043 this.num = this.num.toString().replace(paRe2,''); if (this.num.toString().indexOf('-') == -1) {3044 this.num = '-' + this.num.toString();3045 }3046 }3047 if (this.num.toString().indexOf('-') != this.num.toString().lastIndexOf('-')) { return this.invalidNumber();3048 }3049 var mseRe = new RegExp('\\d\\D*-\\D*\\d', 'g');3050 if (mseRe.test(this.num.toString())) {3051 return this.invalidNumber();3052 }3053 if (this.num.toString().indexOf('-') != -1) {3054 var msRe = new RegExp('-', 'g');3055 this.num = this.num.toString().replace(msRe,'');3056 this.num = '-' + this.num.toString();3057 }3058 dsRe = new RegExp('\\'+this.decimalSeparator, 'g');3059 this.num = this.num.toString().replace(dsRe,'.');3060 if (isNaN(this.num)) {3061 return this.invalidNumber();3062 }3063 var pos;3064 var nNum = this.num; 3065 var nStr; 3066 var absNum = this.num;3067 if (absNum.toString().indexOf('-') == 0) {3068 absNum = absNum.substring(1);3069 }3070 nNum = this.getRounded(nNum);3071 nStr = this.preserveZeros(absNum);3072 dotRe = new RegExp('\\.', 'g');3073 nStr = nStr.replace(dotRe,this.decimalSeparator);3074 if (this.isGrouping) {3075 pos = nStr.indexOf(this.decimalSeparator);3076 if (pos == -1) {3077 pos = nStr.length;3078 }3079 while (pos > 0) {3080 pos -= 3;3081 if (pos <= 0) { break; }3082 nStr = nStr.substring(0,pos) + this.groupingSeparator + nStr.substring(pos, nStr.length);3083 }3084 }3085 if (this.isCurrency) {3086 if (this.currencySymbolBefore) {3087 nStr = this.currencySymbol + nStr;3088 } else {3089 nStr = nStr + this.currencySymbol;3090 }3091 }3092 nStr = (nNum < 0) ? this.negativePrefix + nStr + this.negativeSuffix : nStr; 3093 return (nStr);3094}3095PTNumberFormatter.prototype.setNumber = function(num)3096{3097 this.num = num;3098}3099PTNumberFormatter.prototype.toUnformatted = function()3100{3101 return (this.num);3102}3103PTNumberFormatter.prototype.setGrouping = function(showGroupingSeparator)3104{3105 this.isGrouping = showGroupingSeparator;3106}3107PTNumberFormatter.prototype.setGroupingSeparator = function(separator)3108{3109 this.groupingSeparator = separator;3110}3111PTNumberFormatter.prototype.setDecimalSeparator = function(separator)3112{3113 this.decimalSeparator = separator;3114}3115PTNumberFormatter.prototype.setCurrency = function(isCurrency)3116{3117 this.isCurrency = isCurrency;3118}3119PTNumberFormatter.prototype.setCurrencySymbol = function(symbol)3120{3121 this.currencySymbol = symbol;3122}3123PTNumberFormatter.prototype.setCurrencySymbolBefore = function(showSymbolBefore)3124{3125 this.currencySymbolBefore = showSymbolBefore;3126}3127PTNumberFormatter.prototype.setDecimalPlaces = function(numDecimalPlaces)3128{3129 this.decimalPlaces = numDecimalPlaces;3130}3131PTNumberFormatter.prototype.setNegativePrefix = function(symbol)3132{3133 this.negativePrefix = symbol;3134}3135PTNumberFormatter.prototype.setNegativeSuffix = function(symbol)3136{3137 this.negativeSuffix = symbol;3138}3139PTNumberFormatter.prototype.formatField = function(field)3140{3141 var formatted = this.formatValue(field.value);3142 if (formatted == this.INVALID)3143 {3144 field.value = '';3145 field.focus();3146 }3147 else { field.value = formatted; }3148}3149PTNumberFormatter.prototype.validateValue = function(number)3150{3151 var formatted = this.formatValue(number);3152 if (formatted == this.INVALID) { return false; }3153 else { return true; }3154}3155PTNumberFormatter.prototype.getRounded = function(val)3156{3157 if (this.decimalPlaces < 0) return val;3158 var factor;3159 var i;3160 factor = 1;3161 for (i=0; i<this.decimalPlaces; i++)3162 { factor *= 10; }3163 val *= factor;3164 val = Math.round(val);3165 val /= factor;3166 return (val);3167}3168PTNumberFormatter.prototype.preserveZeros = function(val)3169{3170 var i;3171 val = val + '';3172 if (this.decimalPlaces < 0) return val; 3173 var decimalPos = val.indexOf('.');3174 if (decimalPos == -1 && this.decimalPlaces > 0)3175 {3176 val += this.decimalSeparator;3177 for (i=0; i<this.decimalPlaces; i++)3178 {3179 val += '0';3180 }3181 }3182 else3183 {3184 var actualDecimals = (val.length - 1) - decimalPos;3185 var difference = this.decimalPlaces - actualDecimals;3186 for (i=0; i<difference; i++)3187 {3188 val += '0';3189 }3190 }3191 return val;3192}3193PTNumberFormatter.prototype.invalidNumber = function()3194{3195 alert(PTS_STR['PTU-Number-AlertInvNumber']);3196 return this.INVALID;3197}3198PTNumberFormatter.prototype.toFormatted = function(number)3199{3200 return this.formatValue(number);3201}3202PTNumberUtil = function() {}3203PTNumberUtil.VERSION = '246682';3204PTNumberUtil.isInteger = function(sNumber)3205{3206 sNumber = PTNumberUtil.trimLeadingZeros(sNumber); if (sNumber.length == 0)3207 {3208 return true;3209 }3210 var oString = new String(sNumber);3211 var nString = new String(parseInt(new String(sNumber)));3212 return (oString.valueOf() == nString.valueOf());3213}3214PTNumberUtil.isPositiveInteger = function(sNumber)3215{ 3216 if (!PTNumberUtil.isInteger(sNumber)) { return false; }3217 return (parseInt(sNumber) > 0);3218}3219PTNumberUtil.trimLeadingZeros = function(sNumber)3220{3221 sNumber = new String(sNumber);3222 while (sNumber.charAt(0) == '0') { sNumber = sNumber.substr(1); }3223 return sNumber;3224}3225PTStringBuffer = function(str) 3226{3227 this.i = 0;3228 this.s = new Array();3229 if (str && str.length && (str.length > 0))3230 {3231 this.s[this.i++] = str;3232 }3233 return this;3234}3235PTStringBuffer.VERSION = '246682';3236PTStringBuffer.prototype.append = function(str)3237{3238 if (this.i >= 1000 && this.i%1000 == 0) 3239 {3240 var tmp = this.s.join('');3241 this.s = new Array();3242 this.s[0] = tmp;3243 this.i = 1;3244 }3245 this.s[this.i++] = str;3246}3247PTStringBuffer.prototype.toString = function()3248{3249 return this.s.join('');3250}3251PTStringUtil = function() {}3252PTStringUtil.VERSION = '246682';3253PTStringUtil.isString = function(obj)3254{3255 if (obj == '') { return true; }3256 else if (typeof obj == 'string') { return true; }3257 else if (typeof obj == 'object')3258 {3259 if (obj.fixed && obj.link && obj.blink && obj.toUpperCase) { return true; }3260 else { return false; }3261 }3262 else { return false; }3263}3264PTStringUtil.isValidHTTPString = function(str)3265{3266 var strHTTPPartA = str.substring(0,7);3267 var strHTTPPartB = str.substring(0,8);3268 if ((strHTTPPartA != 'http://') && (strHTTPPartB != 'https://')) { return false; }3269 if (str.length < 8) { return false; }3270 if (PTStringUtil.containsWhitespace(str)) { return false; }3271 return true;3272}3273PTStringUtil.isValidUNCString = function(str, bCanBeNull)3274{3275 if (!str) { return false; }3276 if (bCanBeNull && (str == '')) { return true; }3277 if (str == '') { return false; }3278 var strUNCPart = str.substring(0,2);3279 if (strUNCPart != '\\\\' ) { return false; }3280 if (str.length < 3) { return false; }3281 return true;3282}3283PTStringUtil.containsAngleBrackets = function(str)3284{3285 var angles = /[<>]/;3286 return (angles.test(str));3287}3288PTStringUtil.containsWhitespace = function(str)3289{3290 var whitespaceChars = PTStringUtil.whitespaceChars;3291 str = new String(str);3292 for (var i = 0; i < str.length; i++) {3293 var theChar = str.charAt(i);3294 for (var j = 0; j < whitespaceChars.length; j++) {3295 var white = whitespaceChars[j];3296 if (theChar == white) {3297 return true;3298 }3299 }3300 }3301 return false;3302}3303PTStringUtil.isAllWhitespace = function(str)3304{3305 var whitespaceChars = PTStringUtil.whitespaceChars;3306 str = new String(str);3307 STRING:3308 for (var i = 0; i < str.length; i++) {3309 var theChar = str.charAt(i);3310 for (var j = 0; j < whitespaceChars.length; j++) {3311 var white = whitespaceChars[j];3312 if (theChar == white) {3313 continue STRING;3314 }3315 }3316 return false;3317 }3318 return true;3319}3320PTStringUtil.UCFirst = function(str) {3321 var firstLetter = (new String(str)).substring(0,1);3322 if (!firstLetter) { return str; }3323 else {3324 var restOfString = (new String(str)).substring(1);3325 if (!restOfString) { restOfString = ''; }3326 var ucFirst = firstLetter.toUpperCase() + restOfString;3327 return ucFirst;3328 }3329}3330PTStringUtil.stripChars = function(str,chars)3331{ 3332 if (!chars || (chars.length < 1)) { return str; }3333 str = new String(str);3334 var newStr = new String();3335 STRING:3336 for (var i = 0; i < str.length; i++) {3337 var theChar = str.charAt(i);3338 for (var j = 0; j < chars.length; j++) {3339 var strip = chars[j];3340 if (theChar == strip) {3341 continue STRING;3342 }3343 }3344 newStr += theChar;3345 }3346 return newStr;3347}3348PTStringUtil.whitespaceChars = new Array(' ','\n','\r','\t','\u00A0'); 3349PTStringUtil.trimWhitespace = function(str,trimFront,trimRear)3350{3351 if (!str) { return str; }3352 str = new String(str);3353 var whitespaceChars = PTStringUtil.whitespaceChars;3354 if (trimFront) {3355 var doTrim = true;3356 while (doTrim) {3357 var foundWhite = false;3358 for (var w = 0; w < whitespaceChars.length; w++) {3359 var c = whitespaceChars[w];3360 if (c == str.charAt(0)) {3361 foundWhite = true;3362 break;3363 }3364 }3365 if (foundWhite) {3366 str = str.substr(1);3367 } else {3368 doTrim = false;3369 }3370 }3371 }3372 if (trimRear) {3373 var doTrim = true;3374 while (doTrim) {3375 var foundWhite = false;3376 for (var w = 0; w < whitespaceChars.length; w++) {3377 var c = whitespaceChars[w];3378 if (c == str.charAt(str.length - 1)) {3379 foundWhite = true;3380 break;3381 }3382 }3383 if (foundWhite) {3384 str = str.substring(0, (str.length - 1));3385 } else {3386 doTrim = false;3387 }3388 }3389 }3390 return str;3391}3392PTStringUtil.escapeHTML = function(str,doLineBreakConversion,doWhitespaceConversion)3393{3394 str = new String(str);3395 if (document.getElementById)3396 {3397 var nextChar = new RegExp('"','g');3398 str = str.replace(nextChar, '&quot;');3399 var nextChar = new RegExp('<','g');3400 str = str.replace(nextChar, '&lt;');3401 var nextChar = new RegExp('>','g');3402 str = str.replace(nextChar, '&gt;');3403 if (doLineBreakConversion)3404 {3405 var nextChar = new RegExp('\n','g');3406 str = str.replace(nextChar, '<br>');3407 }3408 if (doWhitespaceConversion)3409 {3410 var nextChar = new RegExp('\\s','g');3411 str = str.replace(nextChar, '&nbsp;');3412 }3413 var newStr = str;3414 }3415 else3416 {3417 var escapes = {3418 '"' : '&quot;',3419 '<' : '&lt;',3420 '>' : '&gt;'3421 }3422 var newStr = new String();3423 STRING:3424 for (var i = 0; i < str.length; i++) {3425 var theChar = str.charAt(i);3426 for (var j in escapes) {3427 var esc = escapes[j];3428 if (theChar == j) {3429 newStr += esc;3430 continue STRING;3431 }3432 }3433 newStr += theChar;3434 }3435 }3436 return newStr;3437}3438PTStringUtil.unescapeHTML = function(str)3439{3440 str = new String(str);3441 var escQuote = new RegExp('&quot;','gi');3442 str = str.replace(escQuote,'"');3443 var escLeftAngle = new RegExp('&lt;','gi');3444 str = str.replace(escLeftAngle,'<');3445 var escLeftAngle = new RegExp('&gt;','gi');3446 str = str.replace(escLeftAngle,'>');3447 return str;3448}3449PTStringUtil.removeHTML = function(str)3450{3451 str = new String(str);3452 str = str.replace( new RegExp('&nbsp;','g') ,' ');3453 while ((str.indexOf('<') > -1) && (str.indexOf('>') > str.indexOf('<')))3454 {3455 var start = str.indexOf('<');3456 var end = str.indexOf('>');3457 str = str.substr(0,start) + str.substring(end + 1,str.length);3458 }3459 return str;3460}3461PTStringUtil.getInnerText = function(elem)3462{3463 var str;3464 if (PTBrowserInfo.IS_MSIE) { str = elem.innerText; }3465 else { str = PTStringUtil.removeHTML(elem.innerHTML); }3466 return str;3467}3468PTStringUtil.escapeJS = function(str)3469{3470 str = new String(str);3471 if (document.getElementById)3472 {3473 var nextChar = new RegExp('\\\\','g');3474 str = str.replace(nextChar, '\\\\');3475 var nextChar = new RegExp('\n','g');3476 str = str.replace(nextChar, '\\n');3477 var nextChar = new RegExp('\'','g');3478 str = str.replace(nextChar, '\\\'');3479 var newStr = str;3480 }3481 else3482 {3483 var escapes = {3484 '\n' : '\\n',3485 '\'' : '\\\'',3486 '\\' : '\\\\'3487 } 3488 var newStr = new String('');3489 STRING:3490 for (var i = 0; i < str.length; i++) {3491 var theChar = str.charAt(i);3492 for (var j in escapes) {3493 var esc = escapes[j];3494 if (theChar == j) {3495 newStr += esc;3496 continue STRING;3497 }3498 }3499 newStr += theChar;3500 }3501 }3502 return newStr;3503}3504PTStringUtil.encodeURL = function(str,URLEncodeSingleQuotes)3505{3506 if (str == null)3507 return null;3508 if (PTBrowserInfo.IS_NETSCAPE_DOM || PTBrowserInfo.IS_SAFARI || (PTBrowserInfo.IS_MSIE && PTBrowserInfo.MSIE_VERSION >= 5.5))3509 {3510 var encoded = encodeURIComponent(str);3511 if (URLEncodeSingleQuotes)3512 {3513 encoded = encoded.replace(/\'/g,'%27');3514 }3515 return encoded;3516 }3517 var theString = new String(str);3518 var encoded = new PTStringBuffer();3519 for (var i = 0; i < theString.length; i++ ) 3520 {3521 var theChar = theString.charAt(i);3522 var charCode = theChar.charCodeAt(0); if(((charCode > 47)&&(charCode < 58))||3523 ((charCode > 64)&&(charCode < 91))||3524 ((charCode > 96)&&(charCode < 123)))3525 {3526 encoded.append(String.fromCharCode(charCode));3527 } else if ((charCode <= 47)||3528 ((charCode >= 58)&&(charCode <= 64))||3529 ((charCode >= 91)&&(charCode <= 96))||3530 ((charCode >= 123)&&(charCode <= 127)))3531 {3532 var hex = charCode.toString(16);3533 var len = hex.length;3534 switch(len){3535 case 0:3536 hex = '00';3537 break;3538 case 1:3539 hex = '0'+hex;3540 case 2:3541 break;3542 defalt:3543 hex = hex.substring((len-2), len);3544 break;3545 }3546 encoded.append('%'+hex);3547 } else if ((charCode>127) && (charCode<2048))3548 {3549 encoded.append('%' + ((charCode>>6)|192).toString(16).toUpperCase());3550 encoded.append('%' + ((charCode&63)|128).toString(16).toUpperCase());3551 } else3552 {3553 var c1 = (charCode>>12)|224;3554 var c2 = ((charCode>>6)&63)|128;3555 var c3 = (charCode&63)|128;3556 encoded.append('%' + ((charCode>>12)|224).toString(16).toUpperCase());3557 encoded.append('%' + (((charCode>>6)&63)|128).toString(16).toUpperCase());3558 encoded.append('%' + ((charCode&63)|128).toString(16).toUpperCase());3559 }3560 }3561 var returnString = encoded.toString();3562 if (URLEncodeSingleQuotes)3563 {3564 returnString = returnString.replace(/\'/g,'%27');3565 }3566 return returnString;3567}3568PTStringUtil.substituteChars = function(str,hash)3569{3570 str = new String(str);3571 var newStr = new String();3572 STRING:3573 for (var i = 0; i < str.length; i++) {3574 var theChar = str.charAt(i);3575 for (var h in hash) {3576 var subs = hash[h];3577 if (theChar == h) {3578 newStr += subs;3579 continue STRING;3580 }3581 }3582 newStr += theChar;3583 }3584 return newStr;3585}3586PTStringUtil.lineBreakToBR = function(str)3587{3588 str = new String(str);3589 var br = /\n/g;3590 str = str.replace(br,'<br>');3591 return str;3592}3593PTWindowUtil = function()3594{3595 return this;3596}3597PTWindowUtil.VERSION = '246682';3598PTWindowUtil.defaultWidth = 650;3599PTWindowUtil.defaultHeight = 450;3600PTWindowUtil.helpWindowName = 'PTRoboHelp';3601PTWindowUtil.openWindow = function(URL,name,height,width,isFullChrome)3602{3603 var isNN4 = (document.layers);3604 if (!name) { name = 'PTWindow' + (new Date()).getTime(); }3605 var winWidth = (width) ? width : PTWindowUtil.defaultWidth;3606 var winHeight = (height) ? height : PTWindowUtil.defaultHeight;3607 var scrWidth = (isNN4) ? screen.width : screen.availWidth;3608 var scrHeight = (isNN4) ? screen.height : screen.availHeight;3609 var leftPosVal = parseInt(scrWidth/2) - parseInt(winWidth/2);3610 var topPosVal = parseInt(scrHeight/2) - parseInt(winHeight/2);3611 var leftPos = (isNN4) ? 'screenX=' + leftPosVal : 'left=' + leftPosVal;3612 var topPos = (isNN4) ? 'screenY=' + topPosVal : 'top=' + topPosVal;3613 var winProps = 'width=' + winWidth + ',height=' + winHeight + ',' + leftPos + ',' + topPos + ',resizable=1';3614 if (PTNumberUtil.isInteger(isFullChrome))3615 {3616 if (isFullChrome == 1) { winProps += ',scrollbars=1,status=0,toolbar=0,menubar=0,location=0'; }3617 }3618 else if (isFullChrome == true)3619 {3620 winProps += ',scrollbars=1,status=1,toolbar=1,menubar=1,location=1';3621 }3622 else3623 {3624 winProps += ',scrollbars=0,status=0,toolbar=0,menubar=0,location=0';3625 }3626 var winOpenedWindow = window.open(URL,name,winProps);3627 winOpenedWindow.focus();3628 return winOpenedWindow;3629}3630PTWindowUtil.openHelpWindow = function(URL,height,width,isFullChrome)3631{3632 return PTWindowUtil.openWindow(URL,PTWindowUtil.helpWindowName,height,width,isFullChrome);3633}3634function OpenSizedWindow(URL,name,height,width,isFullChrome)3635{3636 return PTWindowUtil.openWindow(URL,name,height,width,isFullChrome);...

Full Screen

Full Screen

generateCueSets.ts

Source:generateCueSets.ts Github

copy

Full Screen

...48 yield* twoTargetCueSets.map(buildCueSet) as any;49 // yield 3 target cue sets50 const threeTargetCues = combine(targetCues, 3);51 yield* threeTargetCues.map(buildCueSet) as any;52 const exactMatchOnly = requireExactMatch(target);53 const descendants = Array.from(target.querySelectorAll("*"));54 if (target.shadowRoot) {55 descendants.push(...target.shadowRoot.querySelectorAll("*"));56 }57 let level = 1;58 let ancestor = getParentElement(target);59 while (level - 1 < descendants.length || ancestor) {60 // yield ancestor + target cue sets61 if (ancestor) {62 // @ts-ignore63 yield* generateRelativeCueSets({64 exactMatchOnly,65 // negative so it is sorted higher when combined into a selector66 level: level * -1,...

Full Screen

Full Screen

isElementMatch.ts

Source:isElementMatch.ts Github

copy

Full Screen

...17 return false;18}19export function isElementMatch(element: HTMLElement, target: HTMLElement, cache: Map<HTMLElement, Rect>): boolean {20 if (element === target) return true;21 if (requireExactMatch(target)) return false;22 // check the middle of the element is within the target23 let targetRect = cache.get(target);24 if (!targetRect) {25 targetRect = target.getBoundingClientRect();26 cache.set(target, targetRect);27 }28 let elementRect = cache.get(element);29 if (!elementRect) {30 elementRect = element.getBoundingClientRect();31 cache.set(element, elementRect);32 }33 if (!isWithin(elementRect, targetRect)) return false;34 return false;35}36/**37 * Check the middle point of other is within the container.38 * Since that is what will be clicked on.39 */40export function isWithin(other: Rect, container: Rect): boolean {41 const middle = {42 x: other.x + other.width / 2,43 y: other.y + other.height / 2,44 };45 return container.x <= middle.x && middle.x <= container.x + container.width && container.y <= middle.y && middle.y <= container.y + container.height;46}47export function requireExactMatch(target: HTMLElement): boolean {48 // do not allow position match for iframes49 if (target.tagName === "IFRAME") return true;50 // do not allow position match if the element is fillable51 if (isFillable(getDescriptor(target))) return true;52 return false;...

Full Screen

Full Screen

routeHelpers.ts

Source:routeHelpers.ts Github

copy

Full Screen

1import { PathMatch, matchPath } from "react-router-dom";2// https://github.com/remix-run/react-router/blob/f16c5490dfa75f15dcfb86d2a981a7c58a9d1a33/packages/react-router/index.tsx#L13693const joinPaths = (paths: string[]): string => paths.join("/").replace(/\/\/+/g, "/");4export function concatPaths(parent: string, current: string) {5 const jointPaths = joinPaths([parent, current]);6 return jointPaths;7}8//isActive logic from NavLink: https://github.com/remix-run/react-router/blob/7668662895337af01f0a8eb22788e0e6b2f5e344/packages/react-router-dom/index.tsx#L3249export function isPathActiveForLocation(pathName: string, locationPathname: string) {10 return (11 locationPathname === pathName ||12 (locationPathname.startsWith(pathName) && locationPathname.charAt(pathName.length) === "/")13 );14}15// eslint-disable-next-line @typescript-eslint/no-unused-vars16//use matchPath to resolve params on the path: https://github.com/remix-run/react-router/issues/5870#issuecomment-39419433817export function matchPatternInPath(18 pathPattern: string,19 locationPathname: string,20 requireExactMatch: boolean = false21): PathMatch<string> | null {22 return matchPath(23 {24 path: pathPattern,25 end: requireExactMatch,26 },27 locationPathname28 );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require("qawolf");2const selectors = require("./selectors/test.json");3describe("test", () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await launch();8 page = await browser.newPage();9 });10 afterAll(() => browser.close());11 it("test", async () => {12 await page.click(selectors["qawolf_input_1"]);13 await page.type(selectors["qawolf_input_1"], "hello world");14 await page.click(selectors["qawolf_button_1"]);15 });16});17{18 "qawolf_input_1": "input[type=\"text\"]:nth-of-type(1)",19 "qawolf_button_1": "input[type=\"submit\"]:nth-of-type(1)"20}21{22 "qawolf_input_1": "input[type=\"text\"]:nth-of-type(1)",23 "qawolf_button_1": "input[type=\"submit\"]:nth-of-type(1)"24}25{26 "qawolf_input_1": "input[type=\"text\"]:nth-of-type(1)",27 "qawolf_button_1": "input[type=\"submit\"]:nth-of-type(1)"28}29{30 "qawolf_input_1": "input[type=\"text\"]:nth-of-type(1)",31 "qawolf_button_1": "input[type=\"submit\"]:nth-of-type(1)"32}33{34 "qawolf_input_1": "input[type=\"text\"]:nth-of-type(1)",35 "qawolf_button_1": "input[type=\"submit\"]:nth-of-type(1)"36}37{38 "qawolf_input_1": "input[type=\"text\"]:nth-of-type(1)",39 "qawolf_button_1": "input[type=\"submit\"]:nth-of-type(1)"40}41{42 "qawolf_input_1": "input[type=\"text\"]:nth-of-type(1)",

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch, requireExactMatch } = require("qawolf");2const { chromium } = require("playwright");3requireExactMatch();4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.click('input[aria-label="Search"]');9 await page.fill('input[aria-label="Search"]', "qawolf");10 await page.press('input[aria-label="Search"]', "Enter");11 await page.click("text=Get started");12 await browser.close();13})();14requireExactMatch(false);15requireExactMatch(true);16requireExactMatch(false);17requireExactMatch(true);18requireExactMatch(false);19requireExactMatch(true);20requireExactMatch(false);21requireExactMatch(true);22requireExactMatch(false);23requireExactMatch(true);24requireExactMatch(false);25requireExactMatch(true);26requireExactMatch(false);27requireExactMatch(true);28requireExactMatch(false);29requireExactMatch(true);30requireExactMatch(false);31requireExactMatch(true);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch, openBrowser, goto, write, click, closeBrowser, requireExactMatch } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await write("Taiko", into("Search"));6 await click("Google Search");7 await requireExactMatch("Taiko");8 } catch (error) {9 console.error(error);10 } finally {11 await closeBrowser();12 }13})();14const { launch, openBrowser, goto, write, click, closeBrowser, requireExactMatch } = require('taiko');15(async () => {16 try {17 await openBrowser();18 await write("Taiko", into("Search"));19 await click("Google Search");20 await requireExactMatch("Taiko");21 } catch (error) {22 console.error(error);23 } finally {24 await closeBrowser();25 }26})();27const { launch, openBrowser, goto, write, click, closeBrowser, requireExactMatch } = require('taiko');28(async () => {29 try {30 await openBrowser();31 await write("Taiko", into("Search"));32 await click("Google Search");33 await requireExactMatch("Taiko");34 } catch (error) {35 console.error(error);36 } finally {37 await closeBrowser();38 }39})();40const { launch, openBrowser, goto, write, click, closeBrowser, requireExactMatch } = require('taiko');41(async () => {42 try {43 await openBrowser();44 await write("Taiko", into("Search"));45 await click("Google Search");46 await requireExactMatch("Taiko");47 } catch (error) {48 console.error(error);49 } finally {50 await closeBrowser();51 }52})();53const { launch, openBrowser, goto, write, click, closeBrowser, requireExactMatch } = require('taiko');

Full Screen

Using AI Code Generation

copy

Full Screen

1requireExactMatch = require('qawolf').requireExactMatch;2requireExactMatch(true);3const { launch } = require('qawolf');4const browser = await launch();5const context = await browser.newContext();6const page = await context.newPage();7requireExactMatch(true);8requireExactMatch(false);9await browser.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const { chromium } = require("playwright");3const browser = await chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6await page.waitFor("input[name=q]");7await qawolf.requireExactMatch(page, "input[name=q]", "Hello");8await browser.close();9const qawolf = require("qawolf");10const { chromium } = require("playwright");11const browser = await chromium.launch();12const context = await browser.newContext();13const page = await context.newPage();14await page.waitFor("input[name=q]");15await qawolf.requireExactMatch(page, "input[name=q]", "Hello");16await browser.close();17const qawolf = require("qawolf");18const { chromium } = require("playwright");19const browser = await chromium.launch();20const context = await browser.newContext();21const page = await context.newPage();22await page.waitFor("input[name=q]");23await qawolf.requireExactMatch(page, "input[name=q]",

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful