|
Server : nginx/1.18.0 System : Linux iZrj9edhd5u5pfsek09o1jZ 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 User : www ( 1000) PHP Version : 5.6.40 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /mnt/web/www.neatabattery.com/public/static/admin/js/ |
function go(url){
window.location = url;
}
/**
* 格式化数字
* @param num 数字
* @param ext 保留多少位小数
* @returns {*}
*/
function number_format(num, ext){
if(ext < 0){
return num;
}
num = Number(num);
if(isNaN(num)){
num = 0;
}
var _str = num.toString();
var _arr = _str.split('.');
var _int = _arr[0];
var _flt = _arr[1];
if(_str.indexOf('.') == -1){
/* 找不到小数点,则添加 */
if(ext == 0){
return _str;
}
var _tmp = '';
for(var i = 0; i < ext; i++){
_tmp += '0';
}
_str = _str + '.' + _tmp;
}else{
if(_flt.length == ext){
return _str;
}
/* 找得到小数点,则截取 */
if(_flt.length > ext){
_str = _str.substr(0, _str.length - (_flt.length - ext));
if(ext == 0){
_str = _int;
}
}else{
for(var i = 0; i < ext - _flt.length; i++){
_str += '0';
}
}
}
return _str;
}
/**
* 设置用户输入数字合法性
* @param name 表单name
* @param min 范围最小值
* @param max 范围最大值
* @param keep 保留多少位小数 可不填
* @param def 不在范围返回的默认值 可不填
*/
function checkInputNum(name,min,max,keep,def){
var input = $('input[name='+name+']');
var inputVal = parseInt(input.val());
var a = parseInt(arguments[3]) ? parseInt(arguments[3]) : 0;//设置第四个参数的默认值
var b = parseInt(arguments[4]) ? parseInt(arguments[4]) : '';//设置第四个参数的默认值
if(isNaN(inputVal)){
input.val('');
}else{
if(inputVal < min || inputVal > max){
if(a > 0){
input.val(number_format(b,a));
}else{
input.val(b);
}
}else{
if(a > 0){
input.val(number_format(inputVal, a));
}else{
input.val(inputVal);
}
}
}
}
//图片垂直水平缩放裁切显示
(function($){
$.fn.VMiddleImg = function(options) {
var defaults={
"width":null,
"height":null
};
var opts = $.extend({},defaults,options);
return $(this).each(function() {
var $this = $(this);
var objHeight = $this.height(); //图片高度
var objWidth = $this.width(); //图片宽度
var parentHeight = opts.height||$this.parent().height(); //图片父容器高度
var parentWidth = opts.width||$this.parent().width(); //图片父容器宽度
var ratio = objHeight / objWidth;
if (objHeight > parentHeight && objWidth > parentWidth) {
if (objHeight > objWidth) { //赋值宽高
$this.width(parentWidth);
$this.height(parentWidth * ratio);
} else {
$this.height(parentHeight);
$this.width(parentHeight / ratio);
}
objHeight = $this.height(); //重新获取宽高
objWidth = $this.width();
if (objHeight > objWidth) {
$this.css("top", (parentHeight - objHeight) / 2);
//定义top属性
} else {
//定义left属性
$this.css("left", (parentWidth - objWidth) / 2);
}
}
else {
if (objWidth > parentWidth) {
$this.css("left", (parentWidth - objWidth) / 2);
}
$this.css("top", (parentHeight - objHeight) / 2);
}
});
};
})(jQuery);
function trim(str) {
return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}
/* 显示Ajax表单 */
function ajax_form(id, title, url, width, model)
{
if (!width) width = 480;
if (!model) model = 1;
var d = DialogManager.create(id);
d.setTitle(title);
d.setContents('ajax', url);
d.setWidth(width);
d.show('center',model);
return d;
}
//显示一个内容为自定义HTML内容的消息
function html_form(id, title, _html, width, model) {
if (!width) width = 480;
if (!model) model = 0;
var d = DialogManager.create(id);
d.setTitle(title);
d.setContents(_html);
d.setWidth(width);
d.show('center',model);
return d;
}
/*
* 为低版本IE添加placeholder效果
*
* 使用范例:
* [html]
* <input id="captcha" name="captcha" type="text" placeholder="验证码" value="" >
* [javascrpt]
* $("#captcha").nc_placeholder();
*
* 生效后提交表单时,placeholder的内容会被提交到服务器,提交前需要把值清空
* 范例:
* $('[data-placeholder="placeholder"]').val("");
* $("#form").submit();
*
*/
(function($) {
$.fn.nc_placeholder = function() {
var isPlaceholder = 'placeholder' in document.createElement('input');
return this.each(function() {
if(!isPlaceholder) {
$el = $(this);
$el.focus(function() {
if($el.attr("placeholder") === $el.val()) {
$el.val("");
$el.attr("data-placeholder", "");
}
}).blur(function() {
if($el.val() === "") {
$el.val($el.attr("placeholder"));
$el.attr("data-placeholder", "placeholder");
}
}).blur();
}
});
};
})(jQuery);
function setCookie(name,value,days){
var exp=new Date();
exp.setTime(exp.getTime() + days*24*60*60*1000);
var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString() +"path=/";
}
function getCookie(name){
var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr!=null){
return unescape(arr[2]);
return null;
}
}
function delCookie(name){
var exp=new Date();
exp.setTime(exp.getTime()-1);
var cval=getCookie(name);
if(cval!=null){
document.cookie=name+"="+cval+";expires="+exp.toGMTString() +"path=/";
}
}