1_.mixin({ 2 /** 3 * Number.prototype.format(n, x, s, c) 4 * 5 * @param integer n: length of decimal 6 * @param integer x: length of whole part 7 * @param mixed s: sections delimiter 8 * @param mixed c: decimal delimiter 9 */ 10 formatPrice: function(value, n, x, d, c, s, p) { 11 var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')', 12 num = Number(value).toFixed(Math.max(0, ~~n)); 13 14 return (s && p ? s : '') + (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (d || ',')) + (s && !p ? s : ''); 15 }, 16 formatShortPrice: function (value) { 17 var price = Number(value), 18 short_price; 19 20 if (price < 1000) { 21 return price; 22 } 23 24 if (price < 10000) { 25 short_price = Math.ceil(price / 100) / 10; 26 27 return short_price + 'K'; 28 } else { 29 if (price < 1000000) { 30 short_price = Math.ceil(price / 1000); 31 32 if (short_price < 100) { 33 return String(short_price).substr(0, 2) + 'K'; 34 } 35 36 if (short_price >= 1000) { 37 return '1M'; 38 } 39 40 return short_price + 'K'; 41 } else { 42 if (price < 10000000) { 43 short_price = Math.ceil(price / 10000) / 100; 44 } else { 45 short_price = Math.ceil(price / 100000) / 10; 46 } 47 } 48 } 49 50 if (String(short_price, '.') !== -1) { 51 short_price = String(short_price).substr(0, 4); 52 } 53 54 return short_price + 'M'; 55 }, 56 sortByKey: function(rows, key, order) { 57 return (order === 'ASC') ? _.sortBy(rows, key) : _.sortBy(rows, key).reverse(); 58 }, 59 getMinByKey: function(rows, key) { 60 return _.min(rows, function(item) { 61 return item[key]; 62 }); 63 }, 64 getMaxByKey: function(rows, key) { 65 return _.max(rows, function(item) { 66 return item[key]; 67 }); 68 }, 69 getMinPriceShort: function(price) { 70 return _.formatShortPrice(_.min(price)); 71 }, 72 getMaxPriceShort: function(price) { 73 return _.formatShortPrice(_.max(price)); 74 }, 75 getMLSImage: function(mls_num, image) { 76 var base_url = '//retsimages.s3.amazonaws.com'; 77 var path = mls_num.substr(-2); 78 79 return [base_url, path, image].join("/"); 80 81 } 82});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.