1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
| --- aside: false date: '2023-02-18T15:53:53+08:00' title: 友情链接 type: links updated: 2023-6-3T16:33:35.746+8:0 --- <div id="qexo-friends"></div> <link href="/css/friends.css" rel="stylesheet"> <script src="/js/frends.js"></script> <script>loadQexoFriends("qexo-friends", "${SITE}")</script>
<article class="message is-info"> <div class="message-header"> 一键填充 <button class="button is-info" type="submit" onclick="onekey(event)">一键填充</button> </div> <div class="control" style="text-align: center;padding: 1.25em 1.5em;"> <textarea id="message" name="message" cols="50" rows="10" placeholder=" 一键填充友链信息格式如下: name: REAI link: https://blog.reaicc.com avatar: https://q1.qlogo.cn/g?b=qq&nk=2877406366&s=640 descr: 热爱漫无边际,生活自有分寸! siteshot: https://image.thum.io/get/width/400/crop/800/allowJPG/wait/20/noanimate/http://blog.reaicc.com " style="width: 100%; resize:none;border-radius: 4px;border: 0;font-size: 10px;"></textarea> </div> <div class="message-header"> 申请友链 <div class="field is-grouped" style="width: 190px;justify-content: space-between;"> <div class="control"> <button class="button is-info" type="submit" onclick="askFriend(event)">申请友链</button> </div> <div class="control"> <button class="button is-info" type="submit" onclick="updFriend(event)">更新友链</button> </div> </div> </div> <div class="message-body"> <div class="form-ask-friend"> <div class="field"> <label class="label">名称</label> <div class="control has-icons-left"> <input class="input" type="text" placeholder="您的站点名" id="friend-name" required> <span class="icon is-small is-left"> <i class="fas fa-signature"></i> </span> </div> </div> <div class="field"> <label class="label">链接</label> <div class="control has-icons-left"> <input class="input" type="url" placeholder="您网站首页的链接" id="friend-link" required> <span class="icon is-small is-left"> <i class="fas fa-link"></i> </span> </div> <p class="help ">请确保站点可访问!</p> </div> <div class="field"> <label class="label">图标</label> <div class="control has-icons-left"> <input class="input" type="url" placeholder="您的网站图标(尽量为正圆形)" id="friend-icon" required> <span class="icon is-small is-left"> <i class="fas fa-image"></i> </span> </div> </div> <div class="field"> <label class="label">描述</label> <div class="control has-icons-left"> <input class="input" type="text" placeholder="请用一句话介绍您的站点" id="friend-des" required> <span class="icon is-small is-left"> <i class="fas fa-info"></i> </span> </div> </div> <div class="field"> <div class="control"> <label class="checkbox"> <input type="checkbox" id="friend-check"/> 我提交的不是无意义信息 </label> </div> </div> </div> </div> </article> <script src="https://recaptcha.net/recaptcha/api.js?render=6LcMvpUkAAAAAG0fQhVsZVcBzS04dB8dZzEMiKKg"></script> <script> function onekey (event) { var textarea = document.getElementById('message'); var content = textarea.value; const regex = /(\w+):\s(.+)/g; const json = {}; let match; while ((match = regex.exec(content)) !== null) { json[match[1]] = match[2]; } $("#friend-name").val(json.name); $("#friend-link").val(json.link); $("#friend-icon").val(json.avatar); $("#friend-des").val(json.descr); console.log(json); if(Object.keys(json).length === 0){alert("填充格式错误!");}else {alert("一键填充成功,请选择申请友链,或者更新友链!");} } function TestUrl(url) { var Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; var objExp=new RegExp(Expression); if(objExp.test(url) !== true){ return false; } return true; } function askFriend (event) { let check = $("#friend-check").is(":checked"); let name = $("#friend-name").val(); let url = $("#friend-link").val(); let image = $("#friend-icon").val(); let des = $("#friend-des").val(); if(!check){ alert("请勾选\"我提交的不是无意义信息\""); return; } if(!(name&&url&&image&&des)){ alert("信息填写不完整! "); return; } if (!(TestUrl(url))){ alert("URL格式错误! 需要包含HTTP协议头! "); return; } if (!(TestUrl(image))){ alert("图片URL格式错误! 需要包含HTTP协议头! "); return; } event.target.classList.add('is-loading'); grecaptcha.ready(function() { grecaptcha.execute('你的reCaptcha 密钥', {action: 'submit'}).then(function(token) { $.ajax({ type: 'get', cache: false, url: url, dataType: "jsonp", async: false, processData: false, complete: function (data) { if(data.status==200){ let exist = false; $.ajax({ type: 'POST', dataType: "json", url: '/pub/friends/', success: function (list) { for(let i=0;i<list.data.length;i++){ if(list.data[i].url === url){ exist = true; break; } } if(exist){ alert("友链已经存在喽!"); event.target.classList.remove('is-loading'); return; }else{ $.ajax({ type: 'POST', dataType: "json", data: { "name": name, "url": url, "image": image, "description": des, "token": API密钥, "status": "显示" }, url: '/pub/add_friend/', success: function (data) { alert("友链添加成功,准备刷新页面..."); location.reload(); } }); } } });} else{ alert("URL无法连通!"); } event.target.classList.remove('is-loading'); } }); }); }); } function updFriend (event) { let check = $("#friend-check").is(":checked"); let name = $("#friend-name").val(); let url = $("#friend-link").val(); let image = $("#friend-icon").val(); let des = $("#friend-des").val(); if(!check){ alert("请勾选\"我提交的不是无意义信息\""); return; } if(!(name&&url&&image&&des)){ alert("信息填写不完整! "); return; } if (!(TestUrl(url))){ alert("URL格式错误! 需要包含HTTP协议头! "); return; } if (!(TestUrl(image))){ alert("图片URL格式错误! 需要包含HTTP协议头! "); return; } event.target.classList.add('is-loading'); grecaptcha.ready(function() { grecaptcha.execute('你的reCaptcha 密钥', {action: 'submit'}).then(function(token) { $.ajax({ type: 'get', cache: false, url: url, dataType: "jsonp", async: false, processData: false, complete: function (data) { if(data.status==200){ let exist = false; let time ; $.ajax({ type: 'POST', dataType: "json", url: '/pub/friends/', success: function (list) { for(let i=0;i<list.data.length;i++){ if(list.data[i].url === url){ exist = true; time = list.data[i].time; break; } } if(exist){ $.ajax({ type: 'POST', dataType: "json", data: { "name": name, "url": url, "image": image, "description": des, "token": API密钥, "status": "显示", "time": time }, url: '/pub/edit_friend/', success: function (data) { alert("友链更新成功,准备刷新页面..."); location.reload(); } }); }else{ alert("友链不存在呀!"); event.target.classList.remove('is-loading'); return; } } });} else{ alert("URL无法连通!"); } event.target.classList.remove('is-loading'); } }); }); }); } </script>
|