//*HySoft.VIPSystem后台管理页JS函数,Jquery扩展 //*作者:一些事情 //*时间:2012年02月20日 //=============================切换验证码====================================== function ToggleCode(obj, codeurl) { $(obj).attr("src", codeurl + "?time=" + Math.random()); } //表格隔行变色 $(function () { $(".msgtable tr:nth-child(odd)").addClass("tr_odd_bg"); //隔行变色 $(".msgtable tr").hover( function () { $(this).addClass("tr_hover_col"); }, function () { $(this).removeClass("tr_hover_col"); } ); }); //==========================页面加载时JS函数结束=============================== //===========================系统管理JS函数开始================================ //Tab控制函数 function tabs(tabId, tabNum) { //设置点击后的切换样式 $(tabId + " .tab_nav li").removeClass("selected"); $(tabId + " .tab_nav li").eq(tabNum).addClass("selected"); //根据参数决定显示内容 $(tabId + " .tab_con").hide(); $(tabId + " .tab_con").eq(tabNum).show(); } //可以自动关闭的提示 function jsprint(msgtitle, url, msgcss, callback) { $("#msgprint").remove(); var cssname = ""; switch (msgcss) { case "Success": cssname = "pcent success"; break; case "Error": cssname = "pcent error"; break; default: cssname = "pcent warning"; break; } var str = "
" + msgtitle + "
"; $("body").append(str); $("#msgprint").show(); var itemiframe = "#framecenter .l-tab-content .l-tab-content-item"; var curriframe = ""; $(itemiframe).each(function () { if ($(this).css("display") != "none") { curriframe = $(itemiframe).index($(this)); return false; } }); if (url == "back" && curriframe != "") { frames[curriframe].history.back(-1); } else if (url != "" && curriframe != "") { frames[curriframe].location.href = url; } //3秒后清除提示 setTimeout(function () { $("#msgprint").fadeOut(500); //如果动画结束则删除节点 if (!$("#msgprint").is(":animated")) { $("#msgprint").remove(); } }, 3000); //执行回调函数 if (typeof (callback) == "function") callback(); } //全选取消按钮函数,调用样式如: function checkAll(chkobj){ if($(chkobj).find("span b").text()=="全选") { $(chkobj).find("span b").text("取消"); $(".checkall input").attr("checked", true); }else{ $(chkobj).find("span b").text("全选"); $(".checkall input").attr("checked", false); } } //全选取消按钮函数,调用样式如: function checkAllByName(chkobj) { if ($(chkobj).find("span b").text() == "全选") { $(chkobj).find("span b").text("取消"); $("input[name=checkall]").attr("checked", true); } else { $(chkobj).find("span b").text("全选"); $("input[name=checkall]").attr("checked", false); } } //执行回传函数 function ExePostBack(objId, objmsg) { if ($(".checkall input:checked").size() < 1) { $.ligerDialog.warn("对不起,请选中您要操作的记录!"); return false; } var msg = "删除记录后不可恢复,您确定吗?"; if (arguments.length == 2) { msg = objmsg; } $.ligerDialog.confirm(msg, "提示信息", function (result) { if (result) { __doPostBack(objId, ''); } }); return false; } //关闭提示窗口 function CloseTip(objId) { $("#" + objId).hide(); } //打开Dialog窗口 function openDialog(tit, sendUrl, w, h) { if (arguments.length == 3) { $.ligerDialog.open({ title: tit, url: sendUrl, width: w, isResize: true }); } else if (arguments.length == 4) { $.ligerDialog.open({ title: tit, url: sendUrl, width: w, height: h, isResize: true }); } else { $.ligerDialog.open({ title: tit, url: sendUrl, isResize: true }); } } //只允许输入数字 function checkNumber(e) { if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) { //FF if (!((e.which >= 48 && e.which <= 57) || (e.which >= 96 && e.which <= 105) || (e.which == 8) || (e.which == 46))) return false; } else { if (!((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode == 8) || (event.keyCode == 46))) event.returnValue = false; } } //===========================系统管理JS函数结束================================ //================上传文件JS函数开始,需和jquery.form.js一起使用=============== //文件上传 function Upload(action, repath, uppath, iswater, isthumbnail, filepath) { var sendUrl = "../../tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath; //判断是否打水印 if(arguments.length == 4){ sendUrl = "../../tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath + "&IsWater=" + iswater; } //判断是否生成宿略图 if (arguments.length == 5) { sendUrl = "../../tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath + "&IsWater=" + iswater + "&IsThumbnail=" + isthumbnail; } //自定义上传路径 if (arguments.length == 6) { sendUrl = filepath + "tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath + "&IsWater=" + iswater + "&IsThumbnail=" + isthumbnail; } //开始提交 $("#form1").ajaxSubmit({ beforeSubmit: function(formData, jqForm, options){ //隐藏上传按钮 $("#"+repath).nextAll(".files").eq(0).hide(); //显示LOADING图片 $("#"+repath).nextAll(".uploading").eq(0).show(); }, success: function(data, textStatus) { if (data.msg == 1) { $("#"+repath).val(data.msgbox); } else { $.ligerDialog.alert(data.msgbox, '提示', "warm"); } $("#"+repath).nextAll(".files").eq(0).show(); $("#"+repath).nextAll(".uploading").eq(0).hide(); }, error: function(data, status, e) { $.ligerDialog.alert("上传失败,错误信息:" + e, '提示', "error"); $("#"+repath).nextAll(".files").eq(0).show(); $("#"+repath).nextAll(".uploading").eq(0).hide(); }, url: sendUrl, type: "post", dataType: "json", timeout: 600000 }); }; //附件上传 function AttachUpload(repath, uppath) { var submitUrl = "../../tools/upload_ajax.ashx?action=AttachFile&UpFilePath=" + uppath; //开始提交 $("#form1").ajaxSubmit({ beforeSubmit: function (formData, jqForm, options) { //隐藏上传按钮 $("#" + uppath).parent().hide(); //显示LOADING图片 $("#" + uppath).parent().nextAll(".uploading").eq(0).show(); }, success: function (data, textStatus) { if (data.msg == 1) { var listBox = $("#" + repath + " ul"); var newLi = '
  • ' + '' + '' + '   ' + '标题:' + '附件:' + data.mstitle + '' + '人气:0' + '正在更新...' + '
  • '; listBox.append(newLi); } else { alert(data.msgbox); } $("#" + uppath).parent().show(); $("#" + uppath).parent().nextAll(".uploading").eq(0).hide(); }, error: function (data, status, e) { alert("上传失败,错误信息:" + e); $("#" + uppath).parent().show(); $("#" + uppath).parent().nextAll(".uploading").eq(0).hide(); }, url: submitUrl, type: "post", dataType: "json", timeout: 600000 }); }; //更新附件上传 function AttachUpdate(repath, uppath) { var btnOldName = $(uppath).attr("name"); var btnNewName = "NewFileUpdate"; $(uppath).attr("name", btnNewName); var submitUrl = "../../tools/upload_ajax.ashx?action=AttachFile&UpFilePath=" + btnNewName; //开始提交 $("#form1").ajaxSubmit({ beforeSubmit: function (formData, jqForm, options) { //隐藏上传按钮 $(uppath).parent().hide(); //显示LOADING图片 $(uppath).parent().nextAll(".uploading").eq(0).show(); }, success: function (data, textStatus) { if (data.msg == 1) { var ArrFileName = $(uppath).parent().prevAll("input[name='" + repath + "']").val().split("|"); $(uppath).parent().prevAll("input[name='" + repath + "']").val(ArrFileName[0] + "|" + data.mstitle + "|" + data.msgbox); $(uppath).parent().nextAll(".title").html("附件:" + data.mstitle); } else { alert(data.msgbox); } $(uppath).parent().show(); $(uppath).parent().nextAll(".uploading").eq(0).hide(); $(uppath).attr("name", btnOldName); }, error: function (data, status, e) { alert("上传失败,错误信息:" + e); $(uppath).parent().show(); $(uppath).parent().nextAll(".uploading").eq(0).hide(); $(uppath).attr("name", btnOldName); }, url: submitUrl, type: "post", dataType: "json", timeout: 600000 }); }; //===========================上传文件JS函数结束================================ //#region 获取url参数 function GetUrlQuerying() { var args = new Object(); var query = location.search.substring(1); // Get query string var pairs = query.split("&"); // Break at ampersand for (var i = 0; i < pairs.length; i++) { var pos = pairs[i].indexOf('='); // Look for "name=value" if (pos == -1) continue; // If not found, skip var argname = pairs[i].substring(0, pos); // Extract the name var value = pairs[i].substring(pos + 1); // Extract the value try { value = decodeURIComponent(value); // Decode it, if needed } catch (e) { value = unescape(value); } args[argname] = value; // Store as a property } return args; // Return the object } //#endregion