486 lines
8.8 KiB
JavaScript
486 lines
8.8 KiB
JavaScript
$(document).ready(function(){
|
|
|
|
|
|
});
|
|
|
|
/*
|
|
设置页面tip
|
|
oid:原始id属性
|
|
oclass:原始class属性
|
|
nclass:新加class属性
|
|
显示文字
|
|
*/
|
|
function setErrorTips(oid,nclass,txt)
|
|
{
|
|
$("#"+oid).addClass(nclass);
|
|
$("#"+oid).html(txt);
|
|
}
|
|
|
|
/*
|
|
清除页面tip
|
|
oclass:原始class属性
|
|
nclass:新加class属性
|
|
显示文字
|
|
*/
|
|
function clearErrorTips(oclass,nclass)
|
|
{
|
|
$("."+oclass).each(function(){
|
|
$("."+oclass).removeClass(nclass);
|
|
$("."+oclass).html("");
|
|
});
|
|
}
|
|
|
|
var code ;
|
|
function createCode(){
|
|
code = "";
|
|
var codeLength = 4;
|
|
var selectChar = new Array(1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','j','k','l','m','n','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z');
|
|
for(var i=0;i<codeLength;i++) {
|
|
var charIndex = Math.floor(Math.random()*60);
|
|
code +=selectChar[charIndex];
|
|
}
|
|
if(code.length != codeLength){
|
|
createCode();
|
|
}
|
|
|
|
if ($("#myCanvas").length>0)
|
|
{
|
|
var c = document.getElementById("myCanvas");
|
|
c.value=code;
|
|
}
|
|
}
|
|
|
|
function validate () {
|
|
var inputCode = document.getElementById("J_codetext").value;
|
|
if(inputCode.length <= 0) {
|
|
//alert(message[3]);
|
|
return false;
|
|
}
|
|
else if(inputCode.toLowerCase() != code.toLowerCase() ) {
|
|
//alert(message[3]);
|
|
createCode();
|
|
document.getElementById("J_codetext").value = "";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
window.onload=createCode;
|
|
|
|
var oldTime=null;
|
|
|
|
/*
|
|
确认提示
|
|
*/
|
|
function tip(txt,func)
|
|
{
|
|
layer.confirm(txt, {
|
|
btn: ['确定']
|
|
}, function(index){
|
|
layer.close(index);
|
|
if (func!=""&&func!=null)
|
|
{
|
|
func();
|
|
}
|
|
});
|
|
}
|
|
|
|
/*
|
|
向后台发送数据
|
|
*/
|
|
function sendClientMsg(url,msg,func)
|
|
{
|
|
var str='';
|
|
if (msg!=""&&msg!=null)
|
|
{
|
|
for(var i in msg)
|
|
{
|
|
str+='<input type="text" name="'+i+'" value="'+msg[i]+'" style="display:none">';
|
|
}
|
|
}
|
|
if (func!=""&&func!=null)
|
|
{
|
|
str+='<input type="text" name="clientCallBackFunc" value="'+func+'" style="display:none">';
|
|
}
|
|
|
|
if ($("#form_sendMsg").length==0)
|
|
{
|
|
//$("body").wrapInner('<form id="form_sendMsg" action="" method="post" target="ifm" enctype="multipart/form-data"></form>');
|
|
//$("body").append('<form id="form_sendMsg" action="" method="post" target="ifm" enctype="multipart/form-data"></form>');
|
|
$("#msg").wrap('<form id="form_sendMsg" action="" method="post" target="ifm" enctype="multipart/form-data"></form>');
|
|
$("#form_sendMsg").append('<div id="clientMsg">'+str+'</div>');
|
|
}else
|
|
{
|
|
$("#clientMsg").remove();
|
|
//$("body").append('<iframe id="ifm" style="display:none" name="ifm"></iframe>');
|
|
$("#form_sendMsg").append('<div id="clientMsg">'+str+'</div>');
|
|
}
|
|
|
|
if ($("#ifm").length==0)
|
|
{
|
|
$("body").append('<iframe id="ifm" style="display:none" name="ifm"></iframe>');
|
|
}
|
|
|
|
$("#form_sendMsg").attr("action",url);
|
|
$("#form_sendMsg").submit();
|
|
//$("#clientMsg").html("");
|
|
//$("#ifm").remove();
|
|
}
|
|
|
|
//通信
|
|
function ajaxData(_msgtype,_url,_data,_datatype,_func)
|
|
{
|
|
$.ajax({
|
|
type:_msgtype,
|
|
url:_url,
|
|
data:_data,
|
|
//dataType:'json',
|
|
dataType:_datatype,
|
|
async:false,
|
|
success:function(msg){
|
|
if (_func!=null)
|
|
{
|
|
_func(msg);
|
|
}
|
|
},
|
|
error:function(){
|
|
alert("错误");
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
|
|
/*
|
|
刷新当前页面
|
|
*/
|
|
function refresh(msg)
|
|
{
|
|
window.location.reload();//刷新当前页面.
|
|
}
|
|
|
|
function setLayerAlert(msg)
|
|
{
|
|
layer.alert(msg, {icon: 6});
|
|
}
|
|
|
|
/*
|
|
定时器
|
|
*/
|
|
function setTime(msg)
|
|
{
|
|
oldTime=new Date();
|
|
var ins=setTimeout(function(){
|
|
var newTime=new Date();
|
|
var time=newTime.getTime()/1000-oldTime.getTime()/1000;
|
|
if (time>=1)
|
|
{
|
|
msg();
|
|
oldTime=new Date();
|
|
}
|
|
setTimeout(arguments.callee,1000);
|
|
},1000);
|
|
return ins;
|
|
};
|
|
|
|
//生成从minNum到maxNum的随机数
|
|
function randomNum(minNum,maxNum){
|
|
switch(arguments.length){
|
|
case 1:
|
|
return parseInt(Math.random()*minNum+1,10);
|
|
break;
|
|
case 2:
|
|
return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
|
|
break;
|
|
default:
|
|
return 0;
|
|
break;
|
|
}
|
|
}
|
|
|
|
/*
|
|
设置全选
|
|
*/
|
|
function setAllCheck()
|
|
{
|
|
$('.checkall').unbind('click');
|
|
$(".checkall").click(function(){
|
|
$("input[name='id[]']").each(function(){
|
|
if (this.checked) {
|
|
this.checked = false;
|
|
}
|
|
else {
|
|
this.checked = true;
|
|
}
|
|
});
|
|
})
|
|
}
|
|
|
|
/*
|
|
获取选择的广告位
|
|
*/
|
|
function getCheckBox(name)
|
|
{
|
|
var _hash={};
|
|
$("input[name='"+name+"']").each(function(){
|
|
if (this.checked==true) {
|
|
var _id=this.value;
|
|
|
|
var num=$("[name=day_"+_id+"]").val();
|
|
var bol=checkNum(num);
|
|
|
|
if (bol==true)
|
|
{
|
|
num=parseInt(num);
|
|
}
|
|
else if (bol==false)
|
|
{
|
|
num=1;
|
|
}
|
|
|
|
_hash["vacancy_"+_id]=num;
|
|
}
|
|
});
|
|
return _hash;
|
|
}
|
|
|
|
/*
|
|
加载页面
|
|
*/
|
|
function loadPage(page,fun)
|
|
{
|
|
$("#con").html("");
|
|
$("#con").load(String(page), function() {
|
|
if (fun!=null)
|
|
{
|
|
fun();
|
|
}
|
|
});
|
|
}
|
|
|
|
//上一页
|
|
function previousPage(_url,_data,_func)
|
|
{
|
|
$('.previousPage').unbind('click');
|
|
$(".previousPage").click(function (e) {
|
|
var _num=parseInt($(".currentpage").html());
|
|
if (_num>1)
|
|
{
|
|
_num=_num-1;
|
|
_data['pagecurrent']=_num;
|
|
//ajaxData(_msgtype,_url,_data,_datatype,_func);
|
|
sendClientMsg(_url,_data,_func);
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
|
|
//下一页
|
|
function nextPage(_url,_data,_func)
|
|
{
|
|
$('.nextPage').unbind('click');
|
|
$(".nextPage").click(function (e) {
|
|
var _num=parseInt($(".currentpage").html());
|
|
var _totalpage=$(".totalpage").html();
|
|
if (_num<parseInt(_totalpage))
|
|
{
|
|
_num=_num+1;
|
|
_data['pagecurrent']=_num;
|
|
//ajaxData(_msgtype,_url,_data,_datatype,_func);
|
|
sendClientMsg(_url,_data,_func);
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
|
|
//自选页
|
|
function numPage(_url,_data,_func)
|
|
{
|
|
$('.page_num').unbind('click');
|
|
$(".page_num").click(function (e) {
|
|
|
|
var _num=parseInt($.trim($("[name=my_page]").val()));
|
|
if (_num!=""&&_num!=null)
|
|
{
|
|
var _totalpage=parseInt($(".totalpage").html());
|
|
if (_num>=1&&_num<=_totalpage)
|
|
{
|
|
_data['pagecurrent']=_num;
|
|
//ajaxData(_msgtype,_url,_data,_datatype,_func);
|
|
sendClientMsg(_url,_data,_func);
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function checkInput(inputname)
|
|
{
|
|
var ins=$('[name="'+inputname+'"]');
|
|
var bool=false;
|
|
for(var i in ins)
|
|
{
|
|
if ($.trim(ins[i].value)!='')
|
|
{
|
|
bool=true;
|
|
}
|
|
|
|
}
|
|
return bool;
|
|
}
|
|
|
|
function checkCbLen(cbname)
|
|
{
|
|
return $("input[name='"+cbname+"']:checked").length;
|
|
}
|
|
|
|
function arrToStr(arr)
|
|
{
|
|
var str='';
|
|
for(var i in arr)
|
|
{
|
|
str+=arr[i]+' ';
|
|
}
|
|
return str;
|
|
}
|
|
|
|
/*
|
|
二维数组转字符串
|
|
*/
|
|
function arrToString(arr,ico1,ico2)
|
|
{
|
|
for(j = 0,len=arr.length; j < len; j++)
|
|
{
|
|
var _str=arr[j].join(ico1);
|
|
arr[j]=_str;
|
|
}
|
|
return arr.join(ico2);
|
|
}
|
|
|
|
/*
|
|
判断手机号
|
|
*/
|
|
function checkPhone(num)
|
|
{
|
|
if(!(/^1[34578]\d{9}$/.test(num)))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
判断字符串是否为纯数字或纯字母
|
|
*/
|
|
function checkRate(num)
|
|
{
|
|
var bol=true;
|
|
//var tmp=false;
|
|
var reg=/^[a-zA-Z]+$/;
|
|
if(!isNaN(num))
|
|
{
|
|
return true;
|
|
//tmp=true;
|
|
/*if (reg.test(num)==false)
|
|
{
|
|
bol=false;
|
|
}*/
|
|
}else
|
|
{
|
|
//bol=false;
|
|
if (reg.test(num)==true)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
|
|
//return reg.test(num);
|
|
}
|
|
|
|
/*
|
|
判断大于0的整数
|
|
*/
|
|
function checkNum(num)
|
|
{
|
|
//var reg=/^(([a-z]+[0-9]+)|([0-9]+[a-z]+))[a-z0-9]*$/i;
|
|
var reg = /^\+?[1-9]\d*$/;
|
|
return reg.test(num);
|
|
}
|
|
|
|
//关联数组长度
|
|
function getObjLength(obj)
|
|
{
|
|
var count=0;
|
|
for(var name in obj){
|
|
count++;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
/*
|
|
设置主导航样式
|
|
*/
|
|
function setNav(allnav,nnav,nclass,oclass)
|
|
{
|
|
$(allnav).removeClass(oclass);
|
|
nnav.addClass(nclass);
|
|
}
|
|
|
|
/*
|
|
去掉所有空格
|
|
*/
|
|
function trimAll(str,is_global)
|
|
{
|
|
var result;
|
|
result = str.replace(/(^\s+)|(\s+$)/g,"");
|
|
if(is_global.toLowerCase()=="g")
|
|
{
|
|
result = result.replace(/\s/g,"");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function createSelect(selectname,arr)
|
|
{
|
|
$(selectname).empty();
|
|
var title='<option value="">请选择</option>';
|
|
var _str='';
|
|
for(var i in arr)
|
|
{
|
|
_str+='<option value="'+arr[i].id+'">'+arr[i].name+'</option>';
|
|
}
|
|
$(selectname).append(title+_str);
|
|
}
|
|
|
|
function createTitleSelect(selectname,arr,title)
|
|
{
|
|
$(selectname).empty();
|
|
var title='<option value="">'+title+'</option>';
|
|
var _str='';
|
|
for(var i in arr)
|
|
{
|
|
_str+='<option value="'+arr[i].id+'">'+arr[i].name+'</option>';
|
|
}
|
|
$(selectname).append(title+_str);
|
|
}
|
|
|
|
function createAdSelect(selectname,arr)
|
|
{
|
|
$(selectname).empty();
|
|
var title='<option value="">请选择</option>';
|
|
var _str='';
|
|
for(var i in arr)
|
|
{
|
|
_str+='<option value="'+arr[i].id+'">'+arr[i].number+'</option>';
|
|
}
|
|
$(selectname).append(title+_str);
|
|
}
|
|
|
|
function setSelect(idname,text){
|
|
$(idname+" option").each(function (){
|
|
if($(this).text()==text){
|
|
$(this).attr('selected',true);
|
|
}
|
|
});
|
|
}
|