1Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) { 2 switch (operator) { 3 case '==': 4 return (v1 == v2) ? options.fn(this) : options.inverse(this); 5 case '===': 6 return (v1 === v2) ? options.fn(this) : options.inverse(this); 7 case '!=': 8 return (v1 != v2) ? options.fn(this) : options.inverse(this); 9 case '<': 10 return (v1 < v2) ? options.fn(this) : options.inverse(this); 11 case '<=': 12 return (v1 <= v2) ? options.fn(this) : options.inverse(this); 13 case '>': 14 return (v1 > v2) ? options.fn(this) : options.inverse(this); 15 case '>=': 16 return (v1 >= v2) ? options.fn(this) : options.inverse(this); 17 case '&&': 18 return (v1 && v2) ? options.fn(this) : options.inverse(this); 19 case '||': 20 return (v1 || v2) ? options.fn(this) : options.inverse(this); 21 default: 22 return options.inverse(this); 23 } 24}); 25 26// Deprecated since version 0.8.0 27Handlebars.registerHelper("formatDate", function(datetime, format) { 28 var DateFormats = { 29 short: "YYYY-MM-DD", 30 medium: "YYYY-MM-DD HH:mm", 31 long: "YYYY-MM-DD HH:mm:ss" 32 }; 33 34 if (moment) { 35 // can use other formats like 'lll' too 36 format = DateFormats[format] || format; 37 return moment(datetime).format(format); 38 } else { 39 return datetime; 40 } 41}); 42 43Handlebars.registerHelper("isParent", function(dateString, options) { 44 if(moment(dateString).isBefore(moment())){ 45 return options.fn(this); 46 } else { 47 return options.inverse(this); 48 } 49}); 50 51Handlebars.registerHelper('ifCondMulti', function (v1, o1, v2, mainOperator, v3, o2, v4, options) { 52 var operators = { 53 '==': function (a, b) { return a == b }, 54 '===': function (a, b) { return a === b }, 55 '!=': function (a, b) { return a != b }, 56 '!==': function (a, b) { return a !== b }, 57 '<': function (a, b) { return a < b }, 58 '<=': function (a, b) { return a <= b }, 59 '>': function (a, b) { return a > b }, 60 '>=': function (a, b) { return a >= b }, 61 '&&': function (a, b) { return a && b }, 62 '||': function (a, b) { return a || b } 63 } 64 var a1 = operators[o1](v1, v2); 65 var a2 = operators[o2](v3, v4); 66 var isTrue = operators[mainOperator](a1, a2); 67 return isTrue ? options.fn(this) : options.inverse(this); 68}); 69 70Handlebars.registerHelper('ifCondTriple', function (v1, o1, v2, mainOperator, v3, o2, v4, secondOperator, v5, o3, v6, options) { 71 var operators = { 72 '==': function (a, b) { return a == b }, 73 '===': function (a, b) { return a === b }, 74 '!=': function (a, b) { return a != b }, 75 '!==': function (a, b) { return a !== b }, 76 '<': function (a, b) { return a < b }, 77 '<=': function (a, b) { return a <= b }, 78 '>': function (a, b) { return a > b }, 79 '>=': function (a, b) { return a >= b }, 80 '&&': function (a, b) { return a && b }, 81 '||': function (a, b) { return a || b } 82 } 83 84 var a1 = operators[o1](v1, v2); 85 var a2 = operators[o2](v3, v4); 86 var a3 = operators[o3](v5, v6); 87 88 var isTrue = operators[mainOperator](a1, a2); 89 isTrue = operators[secondOperator](isTrue, a3); 90 91 return isTrue ? options.fn(this) : options.inverse(this); 92}); 93 94Handlebars.registerHelper("math", function(lvalue, operator, rvalue, options) { 95 lvalue = parseInt(lvalue); 96 rvalue = parseInt(rvalue); 97 98 return { 99 "+": lvalue + rvalue, 100 "-": lvalue - rvalue, 101 "*": lvalue * rvalue, 102 "/": lvalue / rvalue, 103 "%": lvalue % rvalue 104 }[operator]; 105}); 106 107Handlebars.registerHelper('selected', function(option, value){ 108 if (option === value) { 109 return ' selected'; 110 } else { 111 return '' 112 } 113}); 114 115Handlebars.registerHelper('toLocaleString', function(number) { 116 return number.toLocaleString(); 117}); 118 119Handlebars.registerHelper('for', function(from, to, incr, block) { 120 var accum = ''; 121 for(var i = from; i <= to; i += incr) 122 accum += block.fn(i); 123 return accum; 124}); 125 126Handlebars.registerHelper('lookup', function(obj, field) { 127 return obj && obj[field]; 128}); 129 130Handlebars.registerHelper('addCommas', function(nStr) { 131 if (!nStr) { 132 return 0; 133 } 134 nStr += ''; 135 var x = nStr.split('.'); 136 var x1 = x[0]; 137 var x2 = x.length > 1 ? '.' + x[1] : ''; 138 var rgx = /(\d+)(\d{3})/; 139 while (rgx.test(x1)) { 140 x1 = x1.replace(rgx, '$1' + ',' + '$2'); 141 } 142 return x1 + x2; 143}); 144 145Handlebars.registerHelper('fileSize', function(size) { 146 var i = size == 0 ? 0 : Math.floor( Math.log(size) / Math.log(1024) ); 147 return ( size / Math.pow(1024, i) ).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]; 148}); 149 150Handlebars.registerHelper('eachInMap', function ( map, block ) { 151 var out = ''; 152 Object.keys( map ).map(function( prop ) { 153 out += block.fn( {key: prop, value: map[ prop ]} ); 154 });
155 return out; 156} ); 157 158Handlebars.registerHelper('check', function(value, comparator) { 159 return (value === comparator) ? '' : value; 160}); 161 162Handlebars.registerHelper('notEmptyString', function(value, options) { 163 return (value !== null) && value !== '' ? options.fn(this) : options.inverse(this); 164}); 165 166Handlebars.getTemplate = function(name) { 167 if (Handlebars.templates === undefined || Handlebars.templates[name] === undefined) { 168 $.ajax({ 169 beforeSend: function (xhr) { 170 xhr.setRequestHeader("Accept","*/*"); 171 }, 172 dataType: "text", 173 url : _contextPath + '/res/js/templates/' + name + '.hbs', 174 success : function(data) { 175 if (Handlebars.templates === undefined) { 176 Handlebars.templates = {}; 177 } 178 Handlebars.templates[name] = Handlebars.compile(data); 179 }, 180 async : false 181 }); 182 } 183 184 return Handlebars.templates[name]; 185}; 186 187Handlebars.registerHelper( 'times', function( n, block ) { 188 var accum = '', 189 i = -1; 190 191 while( ++i < n ) { 192 accum += block.fn( i ); 193 } 194 195 return accum; 196}); 197 198Handlebars.registerHelper('date', function(d) { 199 return moment(d).format("MM.DD"); 200}); 201 202Handlebars.registerHelper('dateFormat', function(dateFormat, d) { 203 if (!d) return ''; 204 205 return moment(d).format(dateFormat); 206}); 207 208Handlebars.registerHelper('moneyFormat', function(money) { 209 if (!money) 210 money = 0; 211 212 return money.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); 213}); 214 215Handlebars.registerHelper('if_bigger_or_equal', function(a, b, opts) { 216 if (a >= b) { 217 return opts.fn(this); 218 } else { 219 return opts.inverse(this); 220 } 221}); 222 223Handlebars.registerHelper('breaklines', function(text) { 224 225 text = Handlebars.Utils.escapeExpression(text); 226 text = text.replace(/(\r\n|\n|\r)/gm, '<br>'); 227 text = text.replace(/(\s)/gm, ' '); 228 229 return new Handlebars.SafeString(text); 230}); 231 232Handlebars.registerHelper('getElementByIdx', function(arr, idx) { 233 if (!arr) return ''; 234 235 return arr[idx]; 236}); 237 238Handlebars.registerHelper('href', function(url, id) { 239 var basicUrl = _contextPath + url; 240 241 if (typeof id == "string") { 242 if (url.slice(-1) == '/') { 243 return basicUrl + id; 244 } else { 245 return basicUrl + "/" + id; 246 } 247 } 248 249 return basicUrl; 250}); 251 252Handlebars.registerHelper('toFixed', function(num, len) { 253 var convertStr = parseFloat(num); 254 if (num) convertStr = parseFloat(num).toFixed(len); 255 256 return convertStr; 257}); 258 259Handlebars.registerHelper('range', function(start, end) { 260 var result = []; 261 for (var i = start; i <= end; i++) { 262 result.push(i); 263 } 264 return result; 265}); 266 267Handlebars.registerHelper('eq', function(a, b) { 268 return a === b; 269}); 270 271Handlebars.registerHelper('compareMomentDate', function(date1, operator, date2, options){ 272 const m1 = moment(date1).startOf('day'); 273 const m2 = moment(date2).startOf('day'); 274 275 let result = false; 276 switch(operator){ 277 case '==' : result = m1.isSame(m2); break; 278 case '<' : result = m1.isBefore(m2); break; 279 case '>' : result = m1.isAfter(m2); break; 280 case '<=' : result = m1.isSameOrBefore(m2); break; 281 case '>=' : result = m1.isSameOrAfter(m2); break; 282 } 283 284 return result ? options.fn(this) : options.inverse(this); 285}); 286 287Handlebars.registerHelper('compareMonth', function(date1, operator, date2, options){ 288 const m1 = moment(date1); 289 const m2 = moment(date2); 290 291 if(!m1.isValid() || !m2.isValid()){ // ì ìíì§ ìì ë ì§ì¸ ê²½ì° 292 return options.inverse(this); 293 } 294 295 let result = false; 296 switch(operator){ 297 case '==' : 298 case '===' : result = m1.isSame(m2, 'month'); break; 299 case '!=' : 300 case '!==' : result = !m1.isSame(m2, 'month'); break; 301 case '<' : result = m1.isBefore(m2, 'month'); break; 302 case '>' : result = m1.isAfter(m2, 'month'); break; 303 case '<=' : result = m1.isSameOrBefore(m2, 'month'); break; 304 case '>=' : result = m1.isSameOrAfter(m2, 'month'); break; 305 default: result = false; 306 } 307 308 return result ? options.fn(this) : options.inverse(this); 309});
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.