
function  checkInputFloat(obj)
{
    if ( ''!=  obj.value.replace(/\d{1,}\.{0,1}\d{0,}/ , '' ))
    {
        obj.value  =  obj.value.match(/\d{1,}\.{0,1}\d{0,}/ )== null?''  :obj.value.match(/\d{1,}\.{0,1}\d{0,}/);
    }
}

function  checkInputInt(obj)
{
    if ( ''!=  obj.value.replace(/\d+/ , '' ))
    {
        obj.value  =  obj.value.match(/\d+/ )== null?''  :obj.value.match(/\d+/);
    }
}


//发布弹框
function publish(title,url,w,h){
    layer_show(title,url,w,h);
}


//获取所有选中的checkbox的值
function getCheckVals(dom){
    var vals = new Array();
    var objs = document.getElementsByName(dom);
    for (var i = objs.length - 1; i >= 0; i--) {
        if(objs[i].checked==true){
            vals.push(objs[i].value);
        }
    }
    return vals;
}


function randomn(n) {
  let res = ''
  for (; res.length < n; res += Math.random().toString(36).substr(2).toLowerCase()) {}
  return res.substr(0, n)
}


function randkey(filename){
   var ext = filename.substring(filename.lastIndexOf('.') + 1);
   var key = randomn(10) +'.'+ext;
  return key;
}


function encodeUtf8(text) {
    const code = encodeURIComponent(text);
    const bytes = [];
    for (var i = 0; i < code.length; i++) {
        const c = code.charAt(i);
        if (c === '%') {
            const hex = code.charAt(i + 1) + code.charAt(i + 2);
            const hexVal = parseInt(hex, 16);
            bytes.push(hexVal);
            i += 2;
        } else bytes.push(c.charCodeAt(0));
    }
    return bytes;
}
