$F = function (o) { return $("#" + o).val(); }; (function ($) { $.fn.listify = function (settings) { settings = $.extend({ hoverClass: "over", cursorType: "default", selector: "tbody tr" }, settings); $(settings.selector, this).each(function () { $(this) .css("cursor", settings.cursorType) .hover( function () { $(this).addClass(settings.hoverClass) }, function () { $(this).removeClass(settings.hoverClass) } ); }); return this; } })(jQuery) function CheckNull(text) { if (text) { return text; } return ""; } function enterClick(id) { if (event.keyCode == 13) { event.keyCode = 9; event.returnValue = false; $("#" + id).click(); } } function SubmitKeyClick(id) { evt = (evt) ? evt : ((window.event) ? window.event : "") keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode); if (keyCode == 13) { $("#" + id).click(); } } function IsCheckedList(checkName) { return $(":checkbox[name='" + checkName + "'];[checked]:").length > 0; } function SetCheckedList(checkName, checked) { $(":checkbox[name='" + checkName + "']:").each(function () { this.checked = checked; }); } function SetCheckedListIdStart(startName, checked) { $(":checkbox[id^='" + startName + "']:").each(function () { this.checked = checked; }); } function SetCheckedListByIDS(ids, checked) { var arr = ids.split(','); $.each(arr, function (i, content) { $("#" + content).attr("checked", checked); }); } function ClickCheckedListByIDS(ids, checked) { var arr = ids.split(','); $.each(arr, function (i, content) { $("#" + content).click(); }); } function SetDisabledListByIDS(ids, checked) { var disabled; if (checked) { disabled = true; } else { disabled = false; } var arr = ids.split(','); $.each(arr, function (i, content) { $("#" + content).attr("disabled", disabled); $("#" + content).attr("checked", false); }); } function GetRadioSelectedValue(name) { return $("[name='" + name + "']:checked").val(); } function GetSelectText(id) { return $("select[@id=" + id + "] option[@selected]").text(); //return $("#" + id).text(); } function GetSelectValue(id) { //return $("select[@id=" + id + "] option[@selected]").val(); return $("#" + id).val(); } function GetSelectValueobject(id) { //return $("select[@id=" + id + "] option[@selected]").val(); return $("#" + id).val(); } function SetSelect(id, value) { $("#" + id + "").val(value); } function SetSelectByIndex(id, index) { $("#" + id)[0].selectedIndex = index; } function AddSelect(id, value, text) { $("").appendTo("#" + id); } function AddSelectobject(id, value, text) { $("").appendTo("#" + id); } function AddSelectobject2(id, value, text, css, alertText, url) { $("").appendTo("#" + id); } function DeleteSelect(id, value) { $("select[@id=" + id + "] option").each(function () { if ($(this).val() == value) { $(this).remove(); } } ) } function ClearSelect(id) { $("#" + id).empty(); //清空下拉框 } function ClearSelectobject(id) { $("#" + id).empty(); //清空下拉框 } function InsertImg(src) { try { //var html = tinyMCE.get("Intro").getContent(); //var inst = tinyMCE.getInstanceById("Intro"); //inst.setContent(""); //inst.setContent(html + ''); tinyMCE.execCommand('mceInsertContent', false, ''); } catch (err) { var html = tinyMCE.get("intro").getContent(); var inst = tinyMCE.getInstanceById("intro"); inst.setContent(""); inst.setContent(html + ''); } } //图片选择器 function ImageSelector(maxNum, name, imgDiv) { if (!imgDiv) imgDiv = ''; var dlg = new $.ui.dialog({ id: 'd1', title: '\u56fe\u7247\u52a9\u624b', page: '/ImageList/?imgDiv=' + imgDiv + '&activeID=' + name + '&maxNum=' + maxNum, width: 779, height: 577, cover: true, rang: true }); dlg.ShowDialog(); } function SetImageSelector(maxNum, name, retvalue, imgDiv) { if (!retvalue) return; var imageID = $("#" + name); var divName; var tempImg; if (imgDiv) { divName = imgDiv; tempImg = '
'; } else { divName = "div" + name + "Image"; tempImg = ''; } var divImage = $("#" + divName); var strImageID = imageID.val() + ''; var strDivImage = divImage.html(); var ids = strImageID.split(','); for (var k = 0; k < ids.length; k++) { if (parseInt(ids[k]) == parseInt(retvalue[1])) return; } if (strDivImage) { strDivImage = divImage.html(); } var img = tempImg.replace(/\{0}/g, retvalue[2]).replace(/\{1}/g, retvalue[0]).replace(/\{2}/g, retvalue[1]).replace(/\{3}/g, name); strDivImage += img; divImage.html(strDivImage); if (strImageID == "") { strImageID = retvalue[1]; } else { strImageID = strImageID + ',' + retvalue[1]; } $("#" + name).val(strImageID); strImageID = strImageID + ''; if (strImageID != "" && strImageID.split(',').length == maxNum) { $("#btn" + name).attr("disabled", true); $("#btn" + name + "UploadImg").attr("disabled", true); return; } } //初始化图片选择器 function InitImageSelector(maxNum, name) { var ids = $("#" + name).val(); if (ids) { $.getJSON('/Ajax/Attachment/GetAttachmentNameAndImageNameByIds?ids=' + ids + '&rnd=' + Math.random(), function (json) { var divImage = $("#div" + name + "Image"); var imgSrcs = json.bigImageUrls.split(','); var imgIds = json.ids.split(','); var imgNames = json.names.split(','); var tempImg = ''; var imgs = ''; var i = 0; for (i = 0; i < imgSrcs.length; i++) { if (imgSrcs[i]) { imgs += tempImg.replace(/\{0}/g, imgSrcs[i]).replace(/\{1}/g, imgNames[i]).replace(/\{2}/g, imgIds[i]).replace(/\{3}/g, name); } else { imgs += tempImg.replace(/\{0}/g, '').replace(/\{1}/g, '').replace(/\{2}/g, imgIds[i]).replace(/\{3}/g, name); } } if (imgIds.length == maxNum) { $("#btn" + name).attr("disabled", true); $("#btn" + name + "UploadImg").attr("disabled", true); } divImage.html(imgs); }); } } function DialogClose() { $('#dialog').dialog('close'); } function GetDialog() { return $('#dialog'); } function delImg(name, obj) { $(obj).parent().parent().remove(); var id = $(obj).attr("attid"); delHiddenImgid(name, id); $("#btn" + name).attr("disabled", false); $("#btn" + name + "UploadImg").attr("disabled", false); } function delHiddenImgid(name, id) { var imageID = $('#' + name); var strImageID = imageID.val(); if (strImageID) { if (strImageID.indexOf(id + ',') != -1)//在中间 { strImageID = imageID.val().replace(id + ',', ''); } else if (strImageID.indexOf(',' + id) != -1)//在最后 { strImageID = imageID.val().replace(',' + id, ''); } else if (strImageID.indexOf(id) != -1)//就一个 且存在 { strImageID = ''; } else //就一个 不存在 { strImageID = imageID.val(); } } else { strImageID = id; } imageID.val(strImageID); $("#" + name).val(strImageID); return strImageID; } //文件选择器 function AttachmentSelector(isSingleSelect, name) { var dlg = new $.ui.dialog({ id: 'd1', title: '附件选择器', page: '/AttachmentList/', width: 779, height: 577, cover: true, rang: true }); dlg.ShowDialog(); } function DialogAttachClose() { $('#dialogAttach').dialog('close'); } function GetDialogAttach() { return $('#dialogAttach'); } function SetAttachmentSelector(isSingleSelect, name, retvalue) { if (!retvalue) return; var attachemetID = $("#" + name); var attachemetName = $("#" + name + "AttachmentName"); // var attachemetName = $("#AttachmentName"); var strAttachemetID = attachemetID.val(); var strAttachemetName = attachemetName.val(); if (!isSingleSelect) { if (strAttachemetID) { if (strAttachemetID.indexOf(retvalue[1] + ',') != -1) { attachemetID.val(attachemetID.val().replace(retvalue[1] + ',', '') + ',' + retvalue[1]); attachemetName.val(attachemetName.val().replace(retvalue[0] + ',', '') + ',' + retvalue[0]); } else if (strAttachemetID.indexOf(',' + retvalue[1]) != -1)//在最后 { attachemetID.val(attachemetID.val().replace(',' + retvalue[1], '') + ',' + retvalue[1]); attachemetName.val(attachemetName.val().replace(',' + retvalue[0], '') + ',' + retvalue[0]); } else if (strAttachemetID.indexOf(retvalue[1]) != -1)//就一个 且存在 { attachemetID.val(retvalue[1]); attachemetName.val(retvalue[0]); } else //就一个 不存在 { attachemetID.val(attachemetID.val() + ',' + retvalue[1]); attachemetName.val(attachemetName.val() + ',' + retvalue[0]); } } else { attachemetID.val(retvalue[1]); attachemetName.val(retvalue[0]); } } else { attachemetName.val(retvalue[0]); attachemetID.val(retvalue[1]); } } function checkStrong(sPW) { Modes = 0; for (i = 0; i < sPW.length; i++) { Modes |= CharMode(sPW.charCodeAt(i)); } return bitTotal(Modes); } function CharMode(iN) { if (iN >= 48 && iN <= 57) //数字 return 1; if (iN >= 65 && iN <= 90) //大写字母 return 2; if (iN >= 97 && iN <= 122) //小写 return 4; else return 8; //特殊字符 } function bitTotal(num) { modes = 0; for (i = 0; i < 4; i++) { if (num & 1) modes++; num >>>= 1; } return modes; } function checkPasswod() { var csint = checkStrong($(this).val()); if (csint == 0) { $('#hint').css({ 'color': '#C00' }).html('弱'); $('#s').css({ background: '#fff' }); } else if (csint == 1) { $('#hint').css({ 'color': '#C00' }).html('弱'); $('#s').css({ background: '#C00', width: '50px', height: '10px' }); } else if (csint == 2) { $('#hint').css({ 'color': '#F90' }).html('中等'); $('#s').css({ 'background': '#F90', 'width': '100px', 'height': '10px' }); } else if (csint == 3) { $('#hint').css({ 'color': '#060' }).html('强'); $('#s').css({ 'background': '#060', 'width': '150px', 'height': '10px' }); } else { $('#hint').css({ 'color': '#060' }).html('超强'); $('#s').css({ 'background': '#060', 'width': '200px', 'height': '10px' }); } } function GetModifier(table, id) { $.post("/Ajax/AdminLog/GetModifier/", { table: table, id: id }, function (json) { if (json) { $('#Modifier').text(json); $('#Modifier').css("color", "blue"); } else { $('#Modifier').text("暂无修改者!"); $('#Modifier').css("color", "blue"); } }, "json"); } function ShowModifier(table) { $("td[id]").each(function () { var td = $(this); var id = $(this).attr("id"); $.ajax({ type: "POST", url: "/Ajax/AdminLog/GetModifier/", data: "table=" + table + "&id=" + id, async: false, dataType: "json", success: function (json) { if (json) { td.text(json); td.show(); } else { td.text(""); td.show(); } } } ); }); $("td").show(); }