PageSourceSearch

https://www.pur11med.com/themes/template/blog1/static/js/conmon.js

js pur11med.com collected 2026-10-08 20:01:48 UTC 4,732 bytes, 174 lines download raw bytes

1layui.use(['layer','laydate','form'],function(){
2    var layer = layui.layer;  //layer初始化
3})
4function submitLogin() {
5    let username = $('#username').val();
6    let password = $('#password').val();
7    let url = $('.login-ajax-form').attr('action')
8    if (!username) {
9        layer.msg('请输入账号');
10        return false;
11    }
12    if (!password) {
13        layer.msg('请输入密码');
14        return false;
15    }
16    $.ajax({
17        type: "POST",
18        url: url,
19        data: {username: username, password: password},
20
21        dataType: "json",
22        success: function (data) {
23            if (data.code == 200) {
24                location.href = data.data.url
25            } else {
26                layer.msg(data.message);
27            }
28        },
29        error: function () {
30            layer.msg("请求失败");
31        }
32    });
33}
34
35/**
36 * 错误信息
37 * @param msg 提示信息
38 * @param obj  插入节点
39 * @param redObj  红框元素
40 */
41function showMsg(msg, obj, redObj) {
42    $(obj).after("<label class='m-error'>" + msg + "</label>");
43    if (redObj) {
44        $(redObj).addClass("red-border");
45
46        if($(redObj).attr("type") == 'hidden'){
47            $(redObj).siblings(".select-p").addClass("red-border")
48        }
49    }
50}
51
52/**
53 * 清除错误提示
54 * @param obj  清除插入节点
55 * @param redObj  清除红框元素
56 */
57function removeErrorMsg(obj, redObj) {
58    $(obj).next("label").remove();
59    if ($(redObj)) {
60        $(redObj).removeClass("red-border");
61    } else {
62        $(obj).removeClass("red-border");
63    }
64}
65
66
67function widthCheck(e,len) {
68    removeErrorMsg($(e), $(e))
69    let temp = 0
70    for (let i = 0; i < $(e).val().length; i++) {
71        if (/[\u4e00-\u9fa5]/.test($(e).val()[i])) {
72            temp += 2
73        } else {
74            temp++
75        }
76        if (temp > len) {
77            $(e).val($(e).val().substr(0, i))
78        }
79    }
80}
81
82
83$(".submit").on("click", function () {
84    let form = $(this).closest(".ajax-form");
85    let url = $(form).attr("action");
86    let formData = new FormData($(form)[0]);
87    if (checkForm(form)) {
88        // 提交表单
89        request(url,formData).then(function(res){
90            if (res.code == 200) {
91                layer.msg(res.message, {
92                    time: 2000,
93                    icon: 1,
94                    skin: "show-toast-01",
95                    end: function end() {
96                        location.reload();
97                    },
98                });
99            } else {
100                layer.msg(res.message);
101            }
102        })
103    }
104});
105// let checkFormType=[]
106function checkForm(form){
107    let checkFormType=true
108    $(form).find(".check-input").each(function (index,item){
109        if($(item).attr("rules")){
110            removeErrorMsg($(item).closest('.item'), $(item))
111            let rules=JSON.parse($(item).attr("rules"))
112            rules.map((rulesItem) => {
113
114                if (rulesItem.type && rulesItem.type == 'email' && $(item).val().indexOf('@') < 0) {
115                    removeErrorMsg($(item).closest('.item'), $(item))
116                    showMsg(rulesItem.message, $(item).closest('.item'), $(item))
117                    checkFormType=false
118                }
119                if (rulesItem.required && !$(item).val().trim()) {
120                    removeErrorMsg($(item).closest('.item'), $(item))
121                    showMsg(rulesItem.message, $(item).closest('.item'), $(item))
122                    checkFormType=false
123                }
124            })
125        }
126    })
127    return checkFormType
128}
129
130const currying = (fn, arr = []) => {
131    let len = fn.length;
132    return (...args) => {
133        let concatArgs = [...arr, ...args];
134        if (concatArgs.length < len) {
135            return currying(fn, concatArgs)
136        } else {
137            return fn(...concatArgs)
138        }
139    }
140}
141const isType = (typing, value) => {
142    //判断数据类型
143    return Object.prototype.toString.call(value) == `[object ${typing}]`
144}
145let util = {}
146let typeArr = ['String', 'Number', 'Null', 'Undefined', 'FormData']
147typeArr.map((typing, index) => {
148    util[`is${typing}`] = currying(isType, [typing])
149})
150
151async function request(url, data, ajaxType = "POST"){
152    let resData
153    $.ajax({
154        type: ajaxType,
155        url: url,
156        contentType: util.isFormData(data) ? false : "application/x-www-form-urlencoded",
157        processData: util.isFormData(data) ? false : true,
158        data: data,
159        dataType: "json",
160        async: false,
161        success: function (data) {
162            resData = data
163        },
164        error: function () {
165        },
166        beforeSend: function () {
167
168        },
169        complete: function () {
170
171        }
172    });
173    return resData
174}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.