首页 新闻 会员 周边 捐助

nodejs随笔

0
[已关闭问题] 关闭于 2015-05-06 10:39

发邮件

###
* 发送邮件给项目创建者
###
exports.sendEmailToTeamCreater = (req,res)->
  oSearchQuery = req.body
  # 项目id
  projectId = oSearchQuery.id
  team = oSearchQuery.team
  product = oSearchQuery.product
  version = oSearchQuery.version
  # 邮件接收者
  receiver = oSearchQuery.author
  #邮件发送者
  sendUserName = (req.session.user.hw_name).toLowerCase()
  sendUserName = sendUserName.replace(" ","_")
  titleName = sendUserName.split("_")[0]
  # 邮件内容
  sendContent = "<p style='font-weight:bold;color:#195d84;font-size:16px;'>
  "+titleName+"申请"+product+"产品,"+version+"版本,"+team+\
  "项目组权限,点击下边对应连接即可添加:</p>"
  sendContent += "<br/>
  <p style='font-weight:bold;color:#195d84;font-size:16px;'>
  添加项目信息查看权限:
  http://rnd-udeck/addPermissionThroughEmail/"\
  +sendUserName+"/"+projectId+"/query/setAuth</p>"
  sendContent += "<br/>
  <p style='font-weight:bold;color:#195d84;font-size:16px;'>
  添加项目信息管理权限:
  http://rnd-udeck/addPermissionThroughEmail/"\
  +sendUserName+"/"+projectId+"/modify/setAuth</p>"
  sendEmail(receiver,sendContent)
  res.send {err:false}
  

###
  * 开始发送邮件
  * @param {[string]}, people [邮件接收者]
  * @param {[string]}, sendContent [邮件内容]
###
sendEmail = (people,sendContent) ->
  #添加邮件开关
  # if config.sendEmail is '1'
  #   people = config.toUser
  # people = "cwx222119"
  data = querystring.stringify({
    'toUser':people,
    'sub':'添加项目组权限',
    'msg':sendContent
  })
  options =
    hostname:config.ip
    port:config.port
    path:config.path
    method:config.method
    headers:{
      'Content-Type': 'application/x-www-form-urlencoded',
      'Content-Length': data.length
    }
  # 开始发送邮件
  req = http.request(options,(res)->
    status = res.statusCode
    res.setEncoding('utf8')
    res.on('data',(chunk)->
      console.log('BODY' + chunk)
    )
  )
  req.on('error',(e)->
    console.log('problem with request: ' + e.message)
  )
  req.write(data)
  req.end()
Klaus.Fenng的主页 Klaus.Fenng | 初学一级 | 园豆:199
提问于:2015-05-06 09:59
< >
分享
所有回答(1)
0
function parseDate(str) {
    var results;
    if (typeof str === "string") {
        results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
        if (results && results.length > 3) {
            return new Date(parseInt(results[1], 10), parseInt(results[2], 10) - 1, parseInt(results[3], 10));
        }
        results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
        if (results && results.length > 6) {
            return new Date(parseInt(results[1], 10), parseInt(results[2], 10) - 1, parseInt(results[3], 10), parseInt(results[4], 10), parseInt(results[5], 10), parseInt(results[6], 10));
        }
        results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
        if (results && results.length > 7) {
            return new Date(parseInt(results[1], 10), parseInt(results[2], 10) - 1, parseInt(results[3], 10), parseInt(results[4], 10), parseInt(results[5], 10), parseInt(results[6], 10), parseInt(results[7], 10));
        }
    }
    return null;
}

function format_time(time_in_seconds) {
    var hour, min, sec, strhour, strmin, strsec, timeformat;
    hour = _.str.sprintf("%d", parseInt(time_in_seconds) / 3600);
    min = _.str.sprintf("%d", (time_in_seconds % 3600) / 60);
    sec = _.str.sprintf("%d", time_in_seconds % 60);
    strhour = hour;
    strmin = _.str.pad("" + min, 2, "0");
    strsec = _.str.pad("" + sec, 2, "0");
    timeformat = _.str.sprintf("%s:%s:%s", strhour, strmin, strsec);
    return timeformat;
}
Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:13
function formatDateToStr(date, desStr){
    var d, h, m, min, sDay, sHour, sMin, sMonth, sSec, sTime, sec, y;
    //date = new Date();
    if(!_.isEmpty(desStr)){
        if (desStr === '最近一周') {
            date.setDate(date.getDate() - 7);
        } else if (desStr === '最近两周') {
            date.setDate(date.getDate() - 14);
        } else if (desStr === '最近一个月') {
            date.setMonth(date.getMonth() - 1);
        } else if (desStr === '最近三个月') {
            date.setMonth(date.getMonth() - 3);
        } else if (desStr.indexOf(',')>-1){
            return desStr;
        } else{
            return ''
        }
    }

    y = date.getFullYear();
    m = date.getMonth() + 1;
    d = date.getDate();
    h = date.getHours();
    min = date.getMinutes();
    sec = date.getSeconds();
    sMonth = _.str.pad("" + m, 2, "0");
    sDay = _.str.pad("" + d, 2, "0");
    sHour = _.str.pad("" + h, 2, "0");
    sMin = _.str.pad("" + min, 2, "0");
    sSec = _.str.pad("" + sec, 2, "0");
    sTime = _.str.sprintf("%s-%s-%s %s:%s:%s", y, sMonth, sDay, sHour, sMin, sSec);
    return sTime;
}

function getPeriodStr(type,time){
    var res = '最近两周';
    if (type === '0') {
        res = '最近一周';
    } else if (type === '1') {
        res = '最近两周';
    } else if (type === '2') {
        res = '最近一个月';
    } else if (type === '3') {
        res = '最近三个月';
    } else if (type === '4') {
        res = '全部';
    } else if (type === '5'){
        res = $.trim(time);
    }
    return res;
}

 

支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:14

@Klaus.Fenng: 

function htmlLinebreaktoBr(str) {
    return String(str).replace(/\n/g, '<br>');
}

function htmlEscape(str) {
    return String(str)
            .replace(/&/g, '&amp;')
            .replace(/"/g, '&quot;')
            .replace(/'/g, '&#39;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/\n/g, '<br>');
}

function fnDownload(sUrl,oParams) {
    // 获得url和data
    if(sUrl && oParams) {
        // 把参数组装成 form的  input
        var inputs = '';
        var param;
        var i;
        for(i in oParams) {
            param = oParams[i];
            inputs += '<input type="hidden" name="'+ param['name'] +'" value="'+ param['value'] +'" />';
        }
        $('<form action="'+ sUrl +'" method="post">'+inputs+'</form>').appendTo('body').submit().remove();
    };
}

function month(mon){
    arr = ['Jan','Feb','Mar','Apr','May','Jun','July','Aug','Sep','Oct','Nov','Dec']
    return arr[mon-1]
}
var console = console || {log:function(){}, error: function(){}};

function formatParam(aParam){
    var oParam = {};
    if(aParam && typeof(aParam) === 'object'){
        for(var i = 0; i<aParam.length; i++){
            oParam[aParam[i].name] = aParam[i].value;
        }
    }
    return oParam;
}
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:14

@Klaus.Fenng: 

function strTrim(str){
    var result = str.replace(/(^\s*)|(\s*$)/g, "");
    return result;
}

function mainPageHeight(){
    $(top.document).find("#contentIframe").height($("body").height());
}
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:18

@Klaus.Fenng: 

function urlConvert(str){
    return str.replace(/\//g,"");
}

function toPage(obj) {
    var toUrl;
    if($.type(obj) == "string"){
        toUrl = obj;
    }else{
        toUrl = urlConvert($(obj).attr("page"))
    }
    window.location.href = "index.html?page="+encodeURI (toUrl);
}

function resetPageHeight(isReturn){
    var height;
    var isShowSub = $("#mainIframe ~ #modal").css("display")=="none"?false:true;
    var modalFrame = $(window.parent.document).find("#modal-iframe");
    var mainIframe = $(window.document).find("#mainIframe");
    if(!isReturn){
        if(isShowSub&&modalFrame.length==0 && mainIframe.length != 0){
            return
        }else{
            height = $("body").height();
        }

    }else{
        height = $(window.parent.document.body).height();
    }

    if(undefined!=modalFrame){
        modalFrame.height(height+10);
    }
    if(height < 600){
        height = 600;
    }

    $(top.document).find("#contentIframe").height(height+50);
}

function initSubPage(){
    if($("#modal-iframe").length==1){
        if(top.subPage!=""){
            window.modalEle.show(top.subPage.replace(/\|\|/g,"&"))
            resetPageHeight();
        }
    }
}
function initPage(){
    //加载子页
    if(top.subPage!=""){
        initSubPage();
        initBreadCrumb();

    }else{
        initMainPage();
    }
}
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:19

@Klaus.Fenng: 

function delayGet(duge,callback){
    var result;
    delayInter = window.setInterval(function(){
        if(eval(duge)){
            callback(eval(duge));
            window.clearInterval(delayInter)
        }
    },200)
}

function urlSplit(url){
    reg = /(http|https)\:\/\/([\w . \- \_]+)\:*(\d+|)(\/.+)/
    result = url.match(reg)
    return {protocol:result[1],domain:result[2],port:result[3],path:result[4]}
}

function getI18nextLanguage(){
    var nameEQ = "i18next=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) === 0)
            return c.substring(nameEQ.length,c.length);
    }
    return null;
}
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:20

@Klaus.Fenng: 

  getListInfo: function(areaEdit,proEdit,verEdit){
    $('#area').chosen({});
    $('#product').chosen({});
    $('#version').chosen({});
    var option = {name:'area'};
    $('#area').trigger("liszt:updated");
    this.getAreaInfos(option,'area',areaEdit,function(){
      $('#area').trigger("liszt:updated");
    });
    var option2 = {name:'product'};
    this.getProductInfos(option2,'product',proEdit,function(){
      $('#product').trigger("liszt:updated");
    });
    var option3 = {name:'version'};
    this.getVersionInfos(option3,'version',verEdit,function(){
      $('#version').trigger("liszt:updated");
    });
    resetPageHeight();
  },
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:23

@Klaus.Fenng: 

getAreaInfos: function(option,renderId,areaEdit,callback){
    var url = '/api/userver/getAreaInfos';
    var me = this;
    $.post(url,option,function(datas){
      if(!$.isEmptyObject(datas)){
        var sortData = datas.sort();
        var dataLen = sortData.length;
        if(dataLen > 0){
          var options = '';
          for(var i=0;i<dataLen;i++){
            var flag = false;
              for (var j = 0; j<areaEdit.length; j++) {
                if(sortData[i] == areaEdit[j]){
                  flag =true;
                  break;
                }
              }
            if(flag){
              options += '<option class="addoption" selected>'+sortData[i]+'</option>';
            }else{
              options += '<option class="addoption">'+sortData[i]+'</option>';
            }
          }
          me.removeOption(renderId);
          $('#'+renderId).append(options);
        }
        if(typeof callback === 'function'){
          callback();
        }
      }
    })
  }
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:31

@Klaus.Fenng: 

addAllSysPermission:function(){
    var domain = '';
    var users = [];
    var query = {};
    domain = this.$('#domain').textext()[0].hiddenInput().val();
    users = JSON.parse(domain);
    var perm_ids = [];
    var areaData = [];
    var proData = [];
    var verData = [];
    this.perms.forEach(function(typePerms){
      _.map(typePerms.attributes.perms,function(perm){
        if($('#ckb-' + perm.perm._id).is(':checked')){
          perm_ids.push(perm.perm._id);
        }
      });
    });
    var areaSel = this.$('#area').find("option:selected");
    var proSel = this.$('#product').find("option:selected");
    var verSel = this.$('#version').find("option:selected");
    for(var i=0;i<areaSel.length;i++){
      areaData.push(areaSel[i].text);
    }
    for(var j=0;j<proSel.length;j++){
      proData.push(proSel[j].text);
    }
    for(var k=0;k<verSel.length;k++){
      verData.push(verSel[k].text);
    }
    if(users.length<=0) {
      var account = $.t("ns.system:accountInfo");
      this.$alertBox.html(_.template($('#AlertTpl').html(),
        {type: 'error', message: account}));
      return;
    }
    if(_.isEmpty(perm_ids)&&_.isEmpty(areaData)&&_.isEmpty(proData)&&_.isEmpty(verData)){
      var option = $.t("ns.system:permission_option");
      this.$alertBox.html(_.template($('#AlertTpl').html(),
        {type: 'error', message: option}));
      return;
    }
    query.users = users;
    query.perm_ids = perm_ids;
    query.areaData = areaData;
    query.proData = proData;
    query.verData = verData;

    var me = this;
    $.post('/api/admin/dashboard/system/permission/addAllPermission',
    query,function(data){
      var type = 'error';
      if(data.err){
        type = 'error';
      }else{
        type = 'success';
        me.$el.empty();
        window.systemRouter.syspermissions.fetch({reset: true});
        window.systemRouter.navigate('', {trigger: true});
      }
      resetPageHeight();
      me.$alertBox.html(_.template($('#AlertTpl').html(),
      {type: type, message: data.msg}));
    },'json');
  }
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:33

@Klaus.Fenng: 

cancelAllSysPermission:function(){
    this.$alertBox.empty();
    this.$el.empty();
    window.systemRouter.navigate('', {trigger: true});
  },

  showErrors: function(errors) {
    _.each(errors, function(error){
      var groupField = this.$('#' + error.name);
      groupField.addClass('error');
      groupField.next('.help-inline').text(error.message);
    }, this);
  },

  hideErrors: function() {
    this.$('.group-field').removeClass('error');
    this.$('.help-inline').text('');
  },

  _fnGetAuthInfo: function(userName,callback) {
    $.post('/api/admin/dashboard/system/countpermission/edit',
      {query:userName},function(data){
        return callback(data);
      }
    );
  }
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-06 10:37

@Klaus.Fenng: 

js解析xml

 1 ;
 2 (function (window) {
 3     //text为传入的xml文件
 4     function ConfigXML(text) {
 5         try //Internet Explorer
 6         {
 7             xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 8             //关闭异步加载,这样可确保在文档完整加载之前,解析器不会继续执行脚本
 9             xmlDoc.async = "false";
10             xmlDoc.loadXML(text);
11         }
12         catch (e) {
13             try //Firefox, Mozilla, Opera, etc.
14             {
15                 parser = new DOMParser();
16                 xmlDoc = parser.parseFromString(text, "text/xml");
17             }
18             catch (e1) {
19                 alert(e1.message)
20             }
21         }
22         this.xmlDoc = xmlDoc;
23         this.xmlText = text;
24         return this;
25     }
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:53

@Klaus.Fenng: 

 1 /**
 2      * 获取描述文件对象
 3      * @returns {string|*} xmlDoc
 4      */
 5     ConfigXML.prototype.getXmlDoc = function () {
 6         return this.xmlDoc;
 7     };
 8 
 9     /**
10      * 获取节点所有属性集合
11      * @param xmlNode 节点信息
12      * @param nodeName 节点名
13      */
14     ConfigXML.prototype.getJsonAttributes = function (xmlNode) {
15         var attrJson = {},
16             attrList = xmlNode.attributes;
17         for (var i in attrList) {
18             var nodeValue = attrList[i].nodeValue;
19             //对value为数组的特殊处理,若为数组字符,返回数组
20             if (attrList[i].nodeName == 'value' && nodeValue.indexOf('^') != -1) {
21                 var valueArray = nodeValue.split("^");
22                 attrJson[attrList[i].nodeName] = valueArray.splice(0, valueArray.length - 1);
23             }
24             else {
25                 attrJson[attrList[i].nodeName] = nodeValue;
26             }
27         }
28         if (attrJson.width == undefined) {
29             attrJson.width = "100%";
30         }
31         return  attrJson;
32     }
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:53

@Klaus.Fenng: 

 1 /**
 2      * 根据节点名获取节点内容
 3      * @param xmlNode 节点XML
 4      * @param attrName 属性名
 5      * @returns {*} 属性值
 6      */
 7     ConfigXML.prototype.getNodeInfo = function (xmlNode, nodeName) {
 8         //如果节点存在该属性值,直接返回
 9         if (xmlNode) {
10             return xmlNode.getElementsByTagName(nodeName);
11         }
12         return "";
13     };
14 
15     /**
16      *  返回xml的jquery对象
17      *  @returns {*|jQuery|HTMLElement}
18      */
19     ConfigXML.prototype.getJQueryDom = function () {
20         return $(this.xmlText);
21     }
22 
23 
24     window.ConfigXML = ConfigXML;
25 })(window);
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:54

@Klaus.Fenng: 校验

;( function( window ) {
    // 初始化 new时调用
    function Check(){
        return this;
    }
    Check.prototype = {
        notnull : function(inputName,str){
            var value = str.split(Constants.LIST_VALUE_SPLIT);
            if(value instanceof Array){
                var len = value.length
                if(value.length > 1){
                    len -= 1
                }
                for(var i=0; i< len; i++) {
                    if (null == value[i] || value[i].trim() == "") {
                        alert(inputName + $.t("ns.sci:check.notNull"))
                        return false;
                    }
                }
            }else{
                if (null == value || value.trim() == "") {
                    alert(inputName +$.t("ns.sci:check.notNull"))
                    return false;
                }
            }
            return true;
        },
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:57

@Klaus.Fenng: 

 1 reg : function (inputName,str, regStr){
 2             var result = str.test(regStr);
 3             if(!result){
 4                 alert(inputName +$.t("ns.sci:check.valiFail"))
 5                 return false
 6             }
 7             return true;
 8         },
 9         //校验是否为数字,由于可能是数组以^分割,循环判断
10         number : function(inputName,str){
11             var value = str.split(Constants.LIST_VALUE_SPLIT);
12             var reg = /^([1-9]\d*|0)$/;
13             if(value instanceof Array){
14                 for(var i=0; i< value.length;i++){
15                     if(value[i] && !reg.test(value[i])){
16                         alert(inputName +$.t("ns.sci:check.mustNumber"));
17                         return false;
18                     }
19                 }
20             }else{
21                 if(value && !reg.test(value)){
22                     alert(inputName +$.t("ns.sci:check.mustNumber"));
23                     return false;
24                 }
25             }
26             return true;
27         },
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:58

@Klaus.Fenng: 

 1 ip : function(inputName,value) {
 2             var reg=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
 3             if(value.indexOf('^') != -1){
 4                 alert(inputName +  $.t("ns.sci:check.unique"));
 5                 return false;
 6             }else{
 7                 if(value && !reg.test(value)){
 8                     alert(inputName + $.t("ns.sci:check.mustIp"));
 9                     return false;
10                 }
11             }
12             return true;
13         },
14         port : function(inputName,value) {
15             if(value instanceof Array){
16                 for(var i=0; i< value.length;i++){
17                     if(isNaN(value[i]) || value[i]<1 || value[i]>65535){
18                         alert(inputName +$.t("ns.sci:check.mustIn"));
19                         return false;
20                     }
21                 }
22             }else{
23                 if(isNaN(value) || value<1 || value>65535){
24                     alert(inputName +$.t("ns.sci:check.mustIn"));
25                     return false;
26                 }
27             }
28             return true;
29         },
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:58

@Klaus.Fenng: 

 1 noChinese : function(inputName,str){
 2             var pattern = /([\\u4E00-\\u9FA5]|[\\uFE30-\\uFFA0])+$/gi;
 3             if(pattern.test(str)){
 4                 return true;
 5             }
 6             alert(inputName +$.t("ns.sci:check.notChinese"));
 7             return false;
 8         },
 9         //计算字符串的长度,一个汉字两个字符
10         realLength : function(str) {
11             return this.replace(/[^\\x00-\\xff]/g,"**").length;
12         },
13         //只包含数字字母下划线
14         noSpecialChar : function(inputName,value){
15             var valid=/^\w*$/,
16                 values = value.split(Constants.LIST_VALUE_SPLIT);
17             if(values instanceof Array) {
18                 for(var i=0; i< values.length;i++){
19                     if(values[i] && !valid.test(values[i])){
20                         alert(inputName +$.t("ns.sci:check.containS"));
21                         return false;
22                     }
23                 }
24             }else{
25                 if(values && !valid.test(values)){
26                     alert(inputName +$.t("ns.sci:check.containS"));
27                     return false;
28                 }
29             }
30 
31             return true;
32         },
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:59

@Klaus.Fenng: 

 1 normalChar : function(inputName,values){
 2             var valid=/^[^#%^!……¥]+$/;
 3             if(values instanceof Array) {
 4                 for(var i=0; i< values.length;i++){
 5                     if(values[i] && !valid.test(values[i])){
 6                         alert(inputName +$.t("ns.sci:check.containS"))
 7                         return false;
 8                     }
 9                 }
10             }else{
11                 if(values && !valid.test(values)){
12                     alert(inputName +$.t("ns.sci:check.containS"))
13                     return false;
14                 }
15             }
16 
17             return true;
18         },
19         //只包含数字字母下划线,且不为空
20         noSpecialCharRequire : function(inputName, value){
21             var valid=/^\w*$/,
22                 values = value.split(Constants.LIST_VALUE_SPLIT);
23             if(values instanceof Array) {
24                 for(var i=0; i< values.length;i++){
25                     if(!valid.test(values[i])){
26                         alert(inputName +$.t("ns.sci:check.notSnotNull"))
27                         return false;
28                     }
29                 }
30             }else{
31                 if(!valid.test(values)){
32                     alert(inputName +$.t("ns.sci:check.notSnotNull"))
33                     return false;
34                 }
35             }
36             return false;
37         },
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 15:59

@Klaus.Fenng: 

 1 unique : function(node){
 2             var name  = node.getAttribute('name'),
 3                 pNode = $(node).parents()[1],
 4                 //解决list_change的数据不是存放在一起的
 5                 nodes = $(pNode).find('field[name="'+name+'"][value][value != ""]'),
 6                 // 用于存放已经输入的值
 7                 datas = {};
 8             for(var i = 0; i < nodes.length; i ++){
 9                 // 表格类型的多个值存放在一起
10                 var values = nodes[i].getAttribute('value').split('^');
11                 for(var j = 0; j < values.length; j ++){
12                     var value = values[j];
13                     if(!value){
14                         continue;
15                     }
16                     // 若存在则表示已经存在了
17                     if(datas[value]){
18                         alert(name +$.t("ns.sci:check.mustUnique"))
19                         return false;
20                     }else{
21                         datas[value] = 1;
22                     }
23                 }
24             }
25             return true;
26         }
27     };
28     window.Check = Check;
29 })( window );
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 16:00

@Klaus.Fenng: 

 1 function listChangeNotNull(name){
 2     var jqConfigDom = configXml.getJQueryDom(),
 3         node = jqConfigDom.find('field[name="'+name+'"]')[0];
 4     if(node.getElementsByTagName('fields').length > 0){
 5         return true;
 6     }else{
 7         alert(name +$.t("ns.sci:check.notNull"))
 8         return false;
 9     }
10 }
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 16:00

@Klaus.Fenng: 

通用控件

 1 ;( function( window ) {
 2   // 初始化 new时调用
 3   function PasswordType(){
 4     return this;
 5   }
 6   PasswordType.prototype = {
 7       getHtml: function (options) {
 8           var option = configXml.getJsonAttributes(options);
 9           var results;
10           if (option.value instanceof Array) {
11               results = [];
12               for (var i = 0; i < option.value.length; i++) {
13                   var attr = {
14                       name: option.name,
15                       value: option.value[i]
16                   };
17                   var dom = $('<td></td>');
18                   dom.append(this.getDom(option, attr));
19                   results.push(dom);
20               }
21               return results;
22           } else {
23               results = $('<div class="' + Constants.CSS_FIELD_LABEL + '"></div>');
24               results.append(option.label);
25               var attr = {
26                   value: option.value,
27                   name: option.name
28               };
29               results.after(this.getDom(option, attr));
30               var contentDiv = $("<div class='" + Constants.CSS_FIELD_COMM + "' style='width:" + option.width + ";'></div>").append(results);
31               if(option.require === 'false'){
32                   contentDiv.attr('id', option.name + 'Node');
33                   contentDiv.addClass('hide');
34               }
35               return contentDiv;
36           }
37       },
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 16:07

@Klaus.Fenng: 

1 getDom: function (option, attr) {
2           var cDom;
3           cDom = $('<div class="' + Constants.CSS_FIELD_CONTENT + '"><input name="'+option.name+'" type="password"/></div>');
4           cDom.find("input").attr(attr);
5           return cDom;
6       }
7   };
8   window.PasswordType = PasswordType;
9 })( window );
支持(0) 反对(0) Klaus.Fenng | 园豆:199 (初学一级) | 2015-05-08 16:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册