From 1b43f9647c42c4e34044ed52024ed5b20b8f8718 Mon Sep 17 00:00:00 2001 From: Focus Chen Date: Sun, 2 Oct 2022 12:03:28 +0100 Subject: [PATCH] Prioritise avatar loading --- assets/js/function.js | 28 ------------- merger.html | 97 ++++++++++++++++++++++++++++++------------- 2 files changed, 69 insertions(+), 56 deletions(-) diff --git a/assets/js/function.js b/assets/js/function.js index c9be287..fdc460c 100644 --- a/assets/js/function.js +++ b/assets/js/function.js @@ -9,36 +9,8 @@ var client; var selected; var scale = window.devicePixelRatio; // Change scale to 1 on retina screens to see blurry canvas -profile_error = 0; - -if (typeof profile === "undefined" || profile === null || profile === "") { - profile_error = 1; -} -else if (profile.includes('@') && !profile.includes('http')) { // Verify if value entered is a email - var email = profile.split("@") - var suffix = email[1]; - if (suffix.includes('.')) { // Verify if the email entered is valid - var profile_url = gravatar_url + md5(profile) + "?s=96"; - var profile_lg = profile_url.replace("96", "500"); // Set a large version - } - else { - console.log("%c Email address invaild, please entre a vaild email or image url! ", "color: red"); // Error message if email entered is invalid - console.log("%c Email 无效,请输入有效 Email 或者图片 url ", "color: red"); - profile_error = 1; - } -} -else { - profile_url = profile_lg = profile; // If email is not entered, use whatever value entered (presumably a url) -} - -if (profile_error > 0) { - profile_url = profile_lg = 'https://ae01.alicdn.com/kf/Udaba9d58fade4a3e921c0ceba62db2b7n.png'; // Set a default avatar in case profile image is undefined -} - -document.getElementById("i").style.background = "url('" + profile_lg + "') no-repeat center/cover"; // Set center picture $("#favicon").attr("href", profile_url); // Set page icon - var userLang = navigator.language || navigator.userLanguage; if (multilingual !== false) { if (/zh-CN|zh-cn|zh-Hans|zh-hans|cn/i.test(userLang)) { diff --git a/merger.html b/merger.html index d420719..b47abc2 100644 --- a/merger.html +++ b/merger.html @@ -64,64 +64,105 @@ var qrcodeapi = "https://api.moedog.org/qr/?p=15&url="; // Please note that the API has to support HTTPS connection otherwise will not be loaded var gravatar_url = "https://www.gravatar.com/avatar/"; // You can set your preferred gravatar source (mirror) here; stay default if you cannot decide which source you'd prefer // var gravatar_url = "https://gravatar.loli.net/avatar/"; // A Gravatar source provided by css.loli.net; stabler, relatively slower (in China) - +
-

-

+

+

+ +
- - - -