common_util.js 641 B

1234567891011121314151617181920
  1. /**
  2. * Created by CSL on 2017-06-06.
  3. * public functions for web.
  4. */
  5. // 忽略大小写判断字符串是否和参数指定的字符串相同
  6. String.prototype.sameText = function (str) {
  7. return this.toLowerCase() == str.toLowerCase();
  8. };
  9. // 忽略大小写判断字符串是否有参数指定的子串
  10. String.prototype.hasSubStr = function (str) {
  11. return this.toLowerCase().indexOf(str.toLowerCase()) > -1;
  12. };
  13. // 树结点计算时,取费会出现值为NaN的情况,导致往父节点汇总(递归相加)会出现错误。
  14. function parseFloatPlus(value){
  15. let rst = parseFloat(value);
  16. return isNaN(rst) ? 0 : rst;
  17. };