// public plugin var public = {}; if (jQuery)(function () { $.extend($.fn, { public: function () { var func = arguments [0]; arguments[0] = this; return eval('public.' + func).apply(this, arguments); } }); })(jQuery); /** * set language */ public.setLanguage = function (lan) { $('.lang').each(function (n, c) { var ec = $(c); var msg; var languageElements; var languageElement=ec.attr('lang'); if(languageElement !== undefined){ languageElements=languageElement.split(' '); for(var i=0;i<languageElements.length;i++){ msg = ec.attr(languageElements[i]); if (msg && msg.length > 4 && msg.substr(0, 4) == 'Msg.') { console.log(eval('(' + msg + ')')); ec.attr(languageElements[i], eval('(' + msg + ')')); } } } msg = ec.html(); if (msg && msg.length > 4 && msg.substr(0, 4) == 'Msg.') ec.html(eval('(' + msg + ')')); }); $ ('. lang'). show (); }; /*##################Global functions############################*/ // Separate the numbers with commas every three digits function FormatNum(str){ var str = '' + str; var newStr = ""; var count = 0; if(str.indexOf(".")==-1){ for(var i=str.length-1;i>=0;i--){ if(count % 3 == 0 && count != 0){ newStr = str.charAt(i) + "," + newStr; }else{ newStr = str.charAt(i) + newStr; } count++; } //str = newStr + ".00"; //automatically fill two decimal places str = newStr; } else { for(var i = str.indexOf(".")-1;i>=0;i--){ if(count % 3 == 0 && count != 0){ newStr = str.charAt(i) + "," + newStr; }else{ newStr = str.charAt(i) + newStr; //Concatenate characters one by one } count++; } str = newStr + (str + "00").substr((str + "00").indexOf("."),3); } return str; } /*@description: Get the day of the week * @param: On the basis of the current day of the week, how many days to add, if it is empty, it means the day of the week * */ function getWeek(param){ var param = param == undefined? 0: param; var date = new Date(); var day = date.getDay(); var week=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; var add=parseInt((day+param))%7; return week[add]; } /*@description: Get year month day * @param: On the basis of the current date, how many days will be added in the future, if it is empty, it means the current day * */ function getYMD (param) { var param = param == undefined? 0: param; var seperator1 = "-"; var date = new Date(); date.setDate(date.getDate()+param); var year = date.getFullYear(); var month = parseInt(date.getMonth() + 1); month = month<10?'0'+month:month; var strDate = parseInt(date.getDate()); strDate = strDate <10? '0' + strDate: strDate; var strdate = year + seperator1 + month + seperator1 + strDate; console.log(strdate) //var week=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'] return strdate; } /*@description: Get the current time yyyy-mm-dd hh:mm:ss * */ function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var seperator2 = ":"; var year = date.getFullYear(); var month = date.getMonth() + 1; var second = date.getSeconds(); var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } console.log(second); if (second <= 9) { second = "0" + second; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + date.getMinutes() + seperator2 + second; return currentdate; }
public.js
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326866555&siteId=291194637
Ranking