/***************common*********************/
if(typeof(common) != 'object') {
var common = {setting: {p: '/', title: '', state: 'local'}};
}
common.ajax = {};
common.modal = {};
common.ajax.rebuilds = [];
common.loading = function(msg) {
if(typeof(msg) == 'undefined') {
msg = 'Loading...';
}
return '
' + msg + '
';
};
common.hash = function(link) {
var x = $(link).blur().attr('href');
var id = x.substring(x.indexOf('#') + 1) || '';
if(id == '') {
return false;
}
return this.goHash(id);
};
common.goHash = function(id, func) {
var h = $('#hash-' + id);
if(h.length > 0) {
var pt = parseInt($('body').css('paddingTop').replace('px', ''));
var dt = parseInt(h.attr('data-hash-top') || 0);
var st = {scrollTop: h.offset().top - pt - dt - 13};
if(typeof func == 'function') {
$("html").animate(st, 500, function() {
func();
});
} else {
$("html,body").animate(st, 500);
}
}
return false;
};
common.htmlspecialchars = function(str){
return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
};
common.rebuild_urls = [];
common.rebuild = function(selector, ie) {
s = typeof(selector) == 'undefined' ? $('.rebuild') : selector;
s.each(function(){
var url = $(this).attr('data-url') || '';
var opt = $(this).attr('data-options') || '{}';
var key = url + opt;
if(typeof(common.rebuild_urls[key]) == 'undefined') {
if(ie) {
common.rebuild_urls[key] = key;
}
$(this).removeClass('rebuild').removeAttr('data-url').removeAttr('data-options').dblclick(function(){
var self = $(this);
if(self.data('lock') == 'true') {
return false;
}
var xdata = {};
eval('xdata = ' + opt);
xdata.rebuild = Math.random().toString();
var sdata = [];
for(var i in xdata) {
sdata.push(i + '=' + xdata[i]);
}
$.ajax({type:'POST',dataType:'json',url:url,data:sdata.join('&'),success:function(json, status){
try {
if(json.status == 0) {
throw json;
}
common.ajax.complete(json);
self.data('lock', 'true').dblclick(function(){
return false;
});
return false;
} catch (e) {
self.html(' ' + e.message + '');
}
}, error: function (req, msg, e) {
//return self.dblclick();
self.html(' ' + msg + '');
return false;
}, timeout: 180000});
return false;
}).dblclick();
}
});
return false;
};
common.parseURL = function(url) {
var a = document.createElement('a');
a.href = url;
return {
source : url,
protocol : a.protocol.replace(':', ''),
host : a.hostname,
port : a.port,
query : a.search,
params : (function() {
var ret = {}, seg = a.search.replace(/^\?/, '').split('&'), len = seg.length, i = 0, s;
for (; i < len; i++) {
if (!seg[i]) {
continue;
}
s = seg[i].split('=');
ret[s[0]] = s[1];
}
return ret;
})(),
file : (a.pathname.match(/\/([^\/?#]+)$/i) || [ , '' ])[1],
hash : a.hash.replace('#', ''),
path : a.pathname.replace(/^([^\/])/, '/$1'),
relative : (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [ , '' ])[1],
segments : a.pathname.replace(/^\//, '').split('/')
};
};
common.chrome_auto_complete = function(selector) {
if(navigator.userAgent.toLowerCase().indexOf("chrome") == -1) {
return ;
}
var s = typeof(selector) == 'undefined' ? $('input') : selector.find('input');
s.each(function(){
var c = $(this);
var t = c.attr('type');
if(t == 'text' || (t == 'password' && c.attr('autocomplete') != '')) {
var n = c.attr('name');
var i = c.attr('id') || '';
c.removeAttr('name').removeAttr('id');
setTimeout(function(){
c.attr("name", n).attr("id", i);
}, 1);
}
});
};
common.modal_select2 = function(selector) {
if($.fn.select2) {
selector.find('.select2').each(function(){
var self = $(this);
if(self.attr('multiple') == 'multiple') {
self.parents('.form-control-select').first().css({'height': 'auto', 'padding': '8px 12px 0'});
}
self.select2();
});
}
};
/***************modal*********************/
common.modal.open = function(link, func, efunc, endFunc) {
if(common.modal.posting) {return false;}
var b = $(link).blur();
common.ajax.method = (b.attr('data-method') || 'POST').toUpperCase();
var c = b.attr('data-confirm') || false;
if(c && !confirm(c.replace(/\\n/ig, '\n'))) {
return false;
}
var h = b.html();
var c = b.text() == '' ? h + ' Message Box' : h;
var url = b.attr('data-url') || b.attr('href') || '';
var f1 = function(json){
$('.loading').detach();
if(typeof(func) == 'function') {
func(json);
}
};
var f2 = function() {
$(common.loading()).appendTo($('body'));
};
var f3 = function(json){
$('.loading').detach();
if(typeof(efunc) == 'function') {
efunc(json);
}
};
var opt = b.attr('data-options') || '{}';
var data = {};
eval('data = ' + opt);
data.__modal__ = c;
return common.ajax.post(url, data, f1, f2, f3, endFunc);
};
common.modal.close = function(func) {
$('.modal-mask').fadeOut('slow', function() {
$(this).detach();
});
$('.modal-wei').fadeOut('slow', function(){
if(typeof(func) == 'function') {
func();
}
$(this).detach();
$('html').removeClass('no-scroll');
});
common.modal.close_layui(func);
if(typeof(closeTalkMessage)=='function') closeTalkMessage();//存在且为函数时关闭对话框信息
return false;
};
common.modal.submit = function(btn, func, efunc, endFunc) {
if(common.ajax.posting) {return false;}
var b = $(btn).blur();
var c = b.attr('data-confirm') || false;
if(c && !confirm(c.replace(/\\n/ig, '\n'))) {
return false;
}
b.data('html', b.html());
var ishidden = b.is(':hidden');
var f = b.parents('form').first();
var u = b.attr('data-url') || f.attr('action');
var f1 = function(json){
if(ishidden) {
$('.loading').detach();
} else {
b.html(b.data('html') || 'Submit');
}
if(typeof(func) == 'function') {
func(json);
}
};
var v = b.attr('value') || b.attr('data-value') || 'submit';
var f2 = function(){
if(ishidden) {
$(common.loading()).appendTo($('body'));
} else {
b.html(' Submitting...');
}
};
var f3 = function(json){
if(ishidden) {
$('.loading').detach();
} else {
b.html(b.data('html') || 'Submit');
}
if(typeof(efunc) == 'function') {
efunc(json);
}
};
var d = [];
var k = b.attr('data-name') || b.attr('name') || 'submit';
d.push(k + '=' + encodeURIComponent(v));
var s = f.serializeArray();
for(var i in s) {
d.push(s[i]['name'] + '=' + encodeURIComponent(s[i]['value']));
}
return common.ajax.post(u, d.join('&'), f1, f2, f3, endFunc);
};
common.modal.modalSubmit = function(btn) {
if(common.ajax.posting) {return false;}
return common.modal.submit(btn, function(json){
$('.modal-content-body').html(json.modalc);
$('.modal-body').scrollTop(0);
common.chrome_auto_complete($('.modal-wei'));
common.modal_select2($('.modal-wei'));
},function(){
if(typeof(modal_submit_back_2) == 'function') {
modal_submit_back_2();
}
},function(){
if(typeof(modal_submit_back_3) == 'function') {
modal_submit_back_3();
}
});
};
common.modal.prompt = function(btn, func) {
var b = $(btn).blur();
var e = b.attr('data-allow-empty') || false;
var v = b.attr('data-value') || '';
var act = b.attr('data-action') || 'submit';
var msg = b.attr('data-message') || 'New Value';
var nv = prompt(msg.replace(/\\n/ig, '\n'), v);
if(nv == null) {
return false;
}
if(!e && (nv == '' || !nv)) {
return false;
}
var url = b.attr('data-url') || b.attr('href') || '';
var h = b.html();
var f1 = function(json){
b.html(h);
if(typeof(func) == 'function') {
func(json);
}
};
var f2 = function(){b.html(' Saving..');};
return common.ajax.post(url, {value: nv, prompt: act}, f1, f2, function(){b.html(h);});
};
common.modal.message = function(message, state, url) {
$('.modal-mask').detach();
$('.modal-wei').detach();
$('.loading').detach();
if(typeof(state) == 'undefined') {
state = true;
}
var ob = function() {return common.modal.close();};
var a = document.createElement('button');
a.setAttribute('class', 'close');
a.onclick = function() {return common.modal.close();};
a.innerHTML = '×';
var b = document.createElement('h4');
b.setAttribute('class', 'modal-title text-overflow');
b.innerHTML = ' Message';
var date = new Date();
/*var dstr = '@' + date.toLocaleString() + '
';*/
var d = document.createElement('div');
d.setAttribute('class', 'modal-content-body mbot text-' + (state ? 'success' : 'danger'));
d.innerHTML = '';/* + dstr*/;
var e = document.createElement('button');
var e2 = false;
if(state) {
if(typeof(state) == 'string' && /^confirm/i.test(state)) {
if(typeof(url) != 'string') {
e.onclick = ob;
} else {
if(state == 'confirm_mo') {
e.setAttribute('onclick', 'return common.modal.open(this)');
e.setAttribute('data-url', url);
} else {
e.onclick = function() {
window.location = url;
return true;
};
}
}
e.setAttribute('class', 'btn btn-success');
e.innerHTML = ' Yes';
var e2 = document.createElement('button');
e2.setAttribute('class', 'btn btn-default');
e2.onclick = ob;
e2.innerHTML = ' No';
} else {
if(typeof(url) != 'string') {
e.onclick = ob;
} else {
e.onclick = function() {
window.location = url;
return true;
};
}
e.setAttribute('class', 'btn btn-danger');
e.innerHTML = ' I Got It!';
}
} else {
e.setAttribute('class', 'btn btn-default');
e.onclick = ob;
e.innerHTML = ' Close';
}
var f = document.createElement('span');
f.setAttribute('class', 'pull-left');
/*f.innerHTML = '© ' + common.setting.title + '';*/
f.innerHTML = '© ' + date.toLocaleString() + '';
var g = document.createElement('span');
g.setAttribute('class', 'pull-right btn-group');
if(e2) {
g.appendChild(e2);
}
g.appendChild(e);
var mh = document.createElement('div');
mh.setAttribute('class', 'modal-header');
var mb = document.createElement('div');
mb.setAttribute('class', 'modal-body');
var mf = document.createElement('div');
mf.setAttribute('class', 'modal-footer');
mh.appendChild(a);
mh.appendChild(b);
mb.appendChild(d);
mf.appendChild(g);
mf.appendChild(f);
var mc = document.createElement('div');
mc.setAttribute('class', 'modal-content');
mc.appendChild(mh);
mc.appendChild(mb);
mc.appendChild(mf);
var md = document.createElement('div');
md.setAttribute('class', 'modal-dialog');
md.appendChild(mc);
var mm = document.createElement('div');
mm.setAttribute('class', 'modal modal-wei modal-message');
mm.appendChild(md);
document.getElementsByTagName('body')[0].appendChild(mm);
var wh = $(window).width();
var md = $('.modal-dialog');
if(md.width() + 20 > wh) {
md.css({width: (wh - 20) + 'px'});
}
common.modal.bindEvents();
};
common.modal.bindEvents = function() {
$(window).resize(function(){
var wei = $('.modal-wei');
var ww = $(window).width();
var wh = $(window).height();
var b = wei.find('.modal-dialog').first();
var x = wei.find('.modal-header').first();
var m = wei.find('.modal-body').first();
var f = wei.find('.modal-footer').first();
var bcls = wei.attr('class');
if(ww <= 767 && (!bcls || bcls.indexOf('modal-message') == -1)) {
b.css({
'margin-top': '-2px', 'margin-left': '-2px', 'margin-right': '-2px', 'margin-bottom': '-3px',
'left': '0px', 'top': '0px', 'width': (ww + 4) + 'px',
'height': (wh + 5) + 'px', 'max-width': (ww + 5) + 'px'
});
var mbh = wh - x.outerHeight() - f.outerHeight();
wei.find('.modal-content').css({'height': wh + 'px'});
wei.css({'z-index': '99'});
m.css({'height': mbh + 'px'});
x.data('x', '').unbind('mouseover').unbind('mousedown').unbind('mouseout');
} else {
var wh = $(window).outerHeight();
var mah = wh * 0.9;
if(b.outerWidth() < 320) {
b.css({width: '95%'});
}
if(b.outerHeight() > mah) {
b.css({height: mah + 'px'});
}
var h = (wh - b.outerHeight()) / 2;
var w = (ww - b.outerWidth()) / 2;
b.css({'margin-top': h + 'px', 'margin-left': w + 'px'});
var bp = parseInt($('body').css('paddingTop')) + parseInt($('body').css('paddingBottom'));
var mbh = wh - x.outerHeight() - f.outerHeight() - bp - 40;
m.css({'max-height': mbh + 'px'});
if(x.data('x') != 'x') {
x.data('x', 'x').unbind('mouseover').mouseover(function(){
$(this).css({cursor: 'move'});
}).unbind('mousedown').mousedown(function(evt){
evt.preventDefault();
var x = evt.pageX - b.offset().left;
var y = evt.pageY - b.offset().top;
b.data('x', x).data('y', y);
$(document).mouseup(function(){
$(this).unbind('mousemove');
$(this).unbind('mouseup');
}).mousemove(function(e){
e.preventDefault();
e.stopPropagation();
var x1 = e.pageX - b.data('x');
var y1 = e.pageY - b.data('y') - $(document).scrollTop();
b.css({left: x1 + 'px', top: y1 + 'px', margin: '0'});
});
}).unbind('mouseout').mouseout(function(){
$(this).css({cursor: 'default'});
}).dblclick();
}
}
var btn = false;
$('.modal-wei').find('.btn').each(function(){
if(!$(this).is(':hidden')) {
btn = $(this);
}
});
$('input').each(function(){
if($(this).is(':focus')) {
btn = $(this);
}
});
$('textarea').each(function(){
if($(this).attr('data-focus')=='focus') {
btn = $(this);
}
});
if(btn) {
btn.focus();
}
}).keyup(function(e){
if(e.keyCode == 27) {
common.modal.close();
}
}).resize();
};
common.ajax.posting = false;
common.ajax.method = 'POST';
common.ajax.post = function(url, data, sfunc, bfunc, efunc, endFunc) {
if(common.ajax.posting) {return false;}
var xdd = null;
if(typeof(data) == 'string') {
xdd = data;
} else {
var pdata = [];
for(var i in data) {
pdata.push(i + '=' + encodeURIComponent(data[i]));
}
pdata.push('r=' + Math.random().toString());
xdd = pdata.join('&');
}
$.ajax({type:common.ajax.method,dataType:'json',url:url.replace(/&/ig, '&'),data:xdd,success:function(json, state){
common.ajax.posting = false;
common.ajax.method = 'POST';
//console.log(json);
try {
if(json.status == 0) {
throw json;
}
if(typeof(sfunc) == 'function') {
sfunc(json);
}
common.ajax.complete(json);
if(json.message || json.msg) {
if(json.cssFrame || common.modal.cssFrame=='layui'){
common.modal.message_layui(json.message || json.msg, json.status, json.referer || json.url || json.refresh);
}else{
common.modal.message(json.message || json.msg, json.status, json.referer || json.url || json.refresh);
}
}
if(typeof(endFunc) == 'function') {
endFunc(json);
}
} catch (e) {
if(typeof(efunc) == 'function') {
efunc(e);
}
common.ajax.complete(json);
if(json.message || json.msg) {
if(json.cssFrame || common.modal.cssFrame=='layui'){
common.modal.message_layui(json.message || json.msg, json.status, json.referer || json.url || json.refresh);
}else{
common.modal.message(e.message || e.msg, false);
}
}
if(typeof(endFunc) == 'function') {
endFunc(json);
}
}
}, beforeSend: function(xhr) {
common.ajax.posting = true;
if(typeof(bfunc) == 'function') {
bfunc();
}
}, error: function (req, msg, e) {
common.ajax.posting = false;
if(typeof(efunc) == 'function') {
efunc(e);
}
if(common.modal.cssFrame=='layui'){
return common.modal.message_layui(req['responseText'], false);
}
return common.modal.message(req['responseText'], false);
}, timeout: 180000});
return false;
};
common.ajax.complete = function(json) {
var rebuilder = 0;
if(json.rebuild) {
if(json.replace) {
for(var id in json.rebuild) {
var reb = $('.rebuild-' + id);
rebuilder += reb.length;
reb.replaceWith(json.rebuild[id]);
}
} else if(json.append) {
for(var id in json.rebuild) {
var reb = $('.rebuild-' + id);
rebuilder += reb.length;
reb.append(json.rebuild[id]);
}
} else if(json.insertBefore) {
for(var id in json.rebuild) {
var reb = $('.rebuild-' + id);
var children = reb.children(json.insertBefore);
rebuilder += reb.length;
if(children.length == 0) {
reb.html(json.rebuild[id]);
} else {
$(json.rebuild[id]).insertBefore(reb.children().first());
}
}
} else {
for(var id in json.rebuild) {
var reb = $('.rebuild-' + id);
rebuilder += reb.length;
reb.html(json.rebuild[id]);
}
}
for(var rebi in common.ajax.rebuilds) {
try {
common.ajax.rebuilds[rebi](json);
} catch (e) {
alert(e.message);
}
}
}
if(json.rebuildInnerHTML) {
for(var id in json.rebuildInnerHTML) {
$('.rebuild-' + id).html(json.rebuildInnerHTML[id]);
}
}
if(json.rebuildAppend) {
for(var id in json.rebuildAppend) {
$('.rebuild-' + id).append(rebuildAppend.append[id]);
}
}
if(json.rebuildInsertBefore) {
for(var id in json.rebuildInsertBefore) {
var reb = $('.rebuild-' + id);
var children = reb.children();
if(children.length == 0) {
reb.html(json.rebuildInsertBefore[id]);
} else {
$(json.rebuildInsertBefore[id]).insertBefore(reb.children().first());
}
}
}
if(json.rebuildReplaceWith) {
for(var id in json.rebuildReplaceWith) {
$('.rebuild-' + id).replaceWith(json.rebuildReplaceWith[id]);
}
}
if(json.values) {
for(var id in json.values) {
$('#' + id).val(json.values[id]);
}
}
if(json.images) {
for(var id in json.images) {
$('img.' + id).attr('src', json.images[id]);
}
}
if(rebuilder > 0 && !json.noclose) {
json.close = 500;
}
if(rebuilder == 0) {
if(json.refresh) {
setTimeout(function(){
window.location.reload();
}, json.message||json.msg ? 3000 : 1000);
}
if(json.reload) {
setTimeout(function(){
window.location.reload();
}, json.reload);
}
}
if(json.url) {
var timeout = json.timeout ? json.timeout : 2000;
setTimeout(function(){
window.location = json.url.replace(/&/g, '&');
}, timeout);
}
if(json.modal) {
if(json.cssFrame || common.modal.cssFrame=='layui'){
common.modal.layui(json);
}else{
$('.modal-mask').detach();
$('.modal-wei').detach();
$('.loading').detach();
$('body').append(json.modal);
$('.modal-wei').show();
if(json.modalWidth) {
//$('.modal-dialog').css({width: json.modalWidth});
if(parseFloat(json.modalWidth) < 1 && parseFloat(json.modalWidth) > 0) {
$('.modal-dialog').css({width: ($(window).width() * parseFloat(json.modalWidth)) + 'px'});
}else{
$('.modal-dialog').css({width: parseFloat(json.modalWidth) + 'px'});
}
}
if(json.modalHeight){
if(parseFloat(json.modalHeight) < 1 && parseFloat(json.modalHeight) > 0) {
$('.modal-body').css({height: ($(window).height() * parseFloat(json.modalHeight)) + 'px'});
}else{
$('.modal-body').css({height: parseFloat(json.modalHeight) + 'px'});
}
}
$('html').addClass('no-scroll');
common.modal.bindEvents();
common.chrome_auto_complete($('.modal-wei'));
common.modal_select2($('.modal-wei'));
if(typeof(Dropzone) != 'undefined') {
wei.dropzone.init($('.modal-wei').find('.dropzone'));
}
}
}
if(json.close) {
setTimeout(function(){
common.modal.close();
}, json.close);
}
if(json.post) {
var timeout = json.post.timeout || 1000;
setTimeout(function(){
var data = {};
if(typeof(json.post.data) != 'undefined') {
data = json.post.data;
}
common.ajax.post(json.post.url, data);
}, timeout);
}
if(json.replaceState) {
window.history.replaceState(null, null, json.replaceState);
}
if(json.hash) {
if(rebuilder == 0) {
var a = common.parseURL(window.location.href);
var url = a.protocol + '://' + a.host + (a.port == 80 ? '' : ':' + a.port) + a.path;
var args = [];
for(var i in a.params) {
if(i == '_') continue;
args.push(i + '=' + a.params[i]);
}
args.push('_=' + json.hash);
window.location = url + '?' + args.join('&');
} else {
common.goHash(json.hash);
}
}
}
common.modal.layui = function(json){
modalWidth = modalHeight = 0;
if(json.modalWidth) {
if(parseFloat(json.modalWidth) < 1 && parseFloat(json.modalWidth) > 0) {
modalWidth = $(window).width() * parseFloat(json.modalWidth);
}else{
modalWidth = parseFloat(json.modalWidth);
}
}
if(json.modalHeight){
if(parseFloat(json.modalHeight) < 1 && parseFloat(json.modalHeight) > 0) {
modalHeight = $(window).height() * parseFloat(json.modalHeight);
}else{
modalHeight = parseFloat(json.modalHeight);
}
}
$area = modalWidth ? modalWidth + 'px' : 'auto';
if(modalHeight){
$area = [$area, modalHeight+'px'];
}
if(json.isHideSubmitButton){
btn = [' I Got It!'];
}else{
btn = ['Submit','Cancel'];
}
layui.use('layer', function(){
layer.open({
type: 1,
area: $area,
title: json.__modal__ ? json.__modal__ : "Message Box",
content: json.modal,
btn: btn,
btnAlign: 'c',
yes: function(index, layero){
if(json.isHideSubmitButton) {
layer.closeAll();
}else{
return common.modal.submit('.modal_submit_btn', function(){
layer.closeAll();
},common.modal.is_layui());
}
},
btn2:function(index, layero){
layer.closeAll();
},
cancel: function(){
layer.closeAll();
}
});
});
}
common.modal.is_layui = function($e){
common.modal.cssFrame = 'layui';
}
common.modal.message_layui = function(message, state, url) {
if(typeof(layer) == 'undefined') return;//前端未加载layer模块
if(typeof(state) == 'undefined') {
state = true;
}
if(state) {
if(typeof(state) == 'string' && /^confirm/i.test(state)) {
btn = ['Yes', 'No']; //可以无限个按钮
}else{
message = ' ' + message;
btn = [' I Got It!'];
}
} else {
btn = [' Close'];
message = ' ' + message + '';
}
layer.confirm(message
, {btn: btn,title:' Message'}
, function(index, layero){
//第一个按键回调
//layer.close(index); //有回调时,需手动关闭该消息框
common.modal.close_layui(index);
if(typeof(url) == 'string') {
if(state == 'confirm_mo') {
var e = document.createElement('button');
e.setAttribute('data-url', url);
return common.modal.open(e);//模态框中跳转指定頁面
}
}
if(url) {
location.reload(url);
//window.location = url;
return true;//页面中跳转指定頁面
}
}
, function(index){
//第二个按键回调
});
};
common.modal.close_layui = function(index) {
if(typeof(layer) == 'undefined') return;//前端未加载layer模块
if(typeof(index)!= 'undefined'){
layer.close(index);
}else{
layer.closeAll();
}
};
$(document).ready(function() {
common.rebuild();
});
common.rebuild_urls = [];
common.rebuild = function(selector, ie) {
s = typeof(selector) == 'undefined' ? $('.rebuild') : selector;
s.each(function(){
var url = $(this).attr('data-url') || '';
var opt = $(this).attr('data-options') || '{}';
var key = url + opt;
if(typeof(common.rebuild_urls[key]) == 'undefined') {
if(ie) {
common.rebuild_urls[key] = key;
}
$(this).removeClass('rebuild').removeAttr('data-url').removeAttr('data-options').dblclick(function(){
var self = $(this);
if(self.data('lock') == 'true') {
return false;
}
var xdata = {};
eval('xdata = ' + opt);
xdata.rebuild = Math.random().toString();
var sdata = [];
for(var i in xdata) {
sdata.push(i + '=' + xdata[i]);
}
$.ajax({type:'POST',dataType:'json',url:url,data:sdata.join('&'),success:function(json, status){
try {
if(json.status == 0) {
throw json;
}
common.ajax.complete(json);
self.data('lock', 'true').dblclick(function(){
return false;
});
return false;
} catch (e) {
self.html(' ' + e.message + '');
}
}, error: function (req, msg, e) {
//return self.dblclick();
self.html(' ' + msg + '');
return false;
}, timeout: 180000});
return false;
}).dblclick();
}
});
return false;
};
//存入cookie缓存多少分钟 默认1440分 即24小时 1天
function setCookie(name, value,times=1440) {
var exp = new Date();
exp.setTime(exp.getTime() + times * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";
}
//读取cookies缓存
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
//删除指定cookies缓存
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();
}
function in_array(search,array){
for(var i in array){
if(array[i]==search){
return true;
}
}
return false;
}
/**
*删除数组中含的某个值的元素
*/
function array_unset_value(arr,v){
$.each(arr,function(index,item){
if(item==$v){
arr.splice(index,1);
//delete arr[index];
}
});
return arr;
}
//js直接提示
function alert_confirm(msg = '', func = ''){
msg = msg ? msg : 'Are you sure to execute? This operation will not be reversible';
if(window.confirm(msg)){
return func && typeof(func) == 'function' ? func : true;
}else{
return false;
}
}