From aa221716b1eabbc3b9a7299536079b9d93e13674 Mon Sep 17 00:00:00 2001 From: Parasomnia Date: Fri, 6 Mar 2020 17:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=B1=E5=88=87=E6=8D=A2qq?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E5=92=8Cgravatar=E5=A4=B4=E5=83=8F=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/sakura-app.js | 87 +++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/js/sakura-app.js b/js/sakura-app.js index b581098..5ccca36 100644 --- a/js/sakura-app.js +++ b/js/sakura-app.js @@ -864,53 +864,56 @@ function getqqinfo() { } var emailAddressFlag = cached.filter('#email').val(); cached.filter('#author').on('blur', function () { - var qq = cached.filter('#author').val(); - $.ajax({ - type: 'get', - url: mashiro_option.qq_api_url + '?qq=' + qq + '&_wpnonce=' + Poi.nonce, - dataType: 'json', - success: function (data) { - cached.filter('#author').val(data.name); - cached.filter('#email').val($.trim(qq) + '@qq.com'); - if (mashiro_option.qzone_autocomplete) { - cached.filter('#url').val('https://user.qzone.qq.com/' + $.trim(qq)); - } - $('div.comment-user-avatar img').attr('src', 'https://q2.qlogo.cn/headimg_dl?dst_uin=' + qq + '&spec=100'); - is_get_by_qq = true; - cached.filter('#qq').val($.trim(qq)); - if (cached.filter('#qq').val()) { - $('.qq-check').css('display', 'block'); - $('.gravatar-check').css('display', 'none'); - } - setCookie('user_author', data.name, 30); - setCookie('user_qq', qq, 30); - setCookie('is_user_qq', 'yes', 30); - setCookie('user_qq_email', qq + '@qq.com', 30); - setCookie('user_email', qq + '@qq.com', 30); - emailAddressFlag = cached.filter('#email').val(); - /***/ - $('div.comment-user-avatar img').attr('src', data.avatar); - setCookie('user_avatar', data.avatar, 30); - }, - error: function () { - cached.filter('#qq').val(''); - $('.qq-check').css('display', 'none'); - $('.gravatar-check').css('display', 'block'); - $('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80)); - setCookie('user_qq', '', 30); - setCookie('user_email', cached.filter('#email').val(), 30); - setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30); - /***/ - cached.filter('#qq,#email,#url').val(''); - if (!cached.filter('#qq').val()) { + var qq = cached.filter('#author').val(), + $reg = /^[1-9]\d{4,9}$/; + if ($reg.test(qq)) { + $.ajax({ + type: 'get', + url: mashiro_option.qq_api_url + '?qq=' + qq + '&_wpnonce=' + Poi.nonce, + dataType: 'json', + success: function (data) { + cached.filter('#author').val(data.name); + cached.filter('#email').val($.trim(qq) + '@qq.com'); + if (mashiro_option.qzone_autocomplete) { + cached.filter('#url').val('https://user.qzone.qq.com/' + $.trim(qq)); + } + $('div.comment-user-avatar img').attr('src', 'https://q2.qlogo.cn/headimg_dl?dst_uin=' + qq + '&spec=100'); + is_get_by_qq = true; + cached.filter('#qq').val($.trim(qq)); + if (cached.filter('#qq').val()) { + $('.qq-check').css('display', 'block'); + $('.gravatar-check').css('display', 'none'); + } + setCookie('user_author', data.name, 30); + setCookie('user_qq', qq, 30); + setCookie('is_user_qq', 'yes', 30); + setCookie('user_qq_email', qq + '@qq.com', 30); + setCookie('user_email', qq + '@qq.com', 30); + emailAddressFlag = cached.filter('#email').val(); + /***/ + $('div.comment-user-avatar img').attr('src', data.avatar); + setCookie('user_avatar', data.avatar, 30); + }, + error: function () { + cached.filter('#qq').val(''); $('.qq-check').css('display', 'none'); $('.gravatar-check').css('display', 'block'); - setCookie('user_qq', '', 30); $('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80)); + setCookie('user_qq', '', 30); + setCookie('user_email', cached.filter('#email').val(), 30); setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30); + /***/ + cached.filter('#qq,#email,#url').val(''); + if (!cached.filter('#qq').val()) { + $('.qq-check').css('display', 'none'); + $('.gravatar-check').css('display', 'block'); + setCookie('user_qq', '', 30); + $('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80)); + setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30); + } } - } - }); + }); + } // $.ajax({ // type: 'get', // url: mashiro_option.qq_avatar_api_url + '?type=getqqavatar&qq=' + qq,