[ Index ] |
PHP Cross Reference of phpBB-3.3.7-deutsch |
[Summary view] [Print] [Text view]
1 /** @const */ 2 var NumericFilter = 3 { 4 /** 5 * @param {*} attrValue 6 * @return {*} 7 */ 8 filterFloat: function(attrValue) 9 { 10 return /^(?:0|-?[1-9]\d*)(?:\.\d+)?(?:e[1-9]\d*)?$/i.test(attrValue) ? attrValue : false; 11 }, 12 13 /** 14 * @param {*} attrValue 15 * @return {*} 16 */ 17 filterInt: function(attrValue) 18 { 19 return /^(?:0|-?[1-9]\d*)$/.test(attrValue) ? attrValue : false; 20 }, 21 22 /** 23 * @param {*} attrValue 24 * @param {number} min 25 * @param {number} max 26 * @param {?Logger} logger 27 * @return {number|boolean} 28 */ 29 filterRange: function(attrValue, min, max, logger) 30 { 31 if (!/^(?:0|-?[1-9]\d*)$/.test(attrValue)) 32 { 33 return false; 34 } 35 36 attrValue = parseInt(attrValue, 10); 37 38 if (attrValue < min) 39 { 40 if (logger) 41 { 42 logger.warn( 43 'Value outside of range, adjusted up to min value', 44 { 45 'attrValue' : attrValue, 46 'min' : min, 47 'max' : max 48 } 49 ); 50 } 51 52 return min; 53 } 54 55 if (attrValue > max) 56 { 57 if (logger) 58 { 59 logger.warn( 60 'Value outside of range, adjusted down to max value', 61 { 62 'attrValue' : attrValue, 63 'min' : min, 64 'max' : max 65 } 66 ); 67 } 68 69 return max; 70 } 71 72 return attrValue; 73 }, 74 75 /** 76 * @param {*} attrValue 77 * @return {*} 78 */ 79 filterUint: function(attrValue) 80 { 81 return /^(?:0|[1-9]\d*)$/.test(attrValue) ? attrValue : false; 82 } 83 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Mar 24 21:31:15 2022 | Cross-referenced by PHPXref 0.7.1 |