1 | function loadQexoFriends(id, url) {
|
2 | var uri = url + "/pub/friends/";
|
3 | var loadStyle = '<div class="qexo_loading"><div class="qexo_part"><div style="display: flex; justify-content: center"><div class="qexo_loader"><div class="qexo_inner one"></div><div class="qexo_inner two"></div><div class="qexo_inner three"></div></div></div></div><p style="text-align: center; display: block">友链加载中...</p></div>';
|
4 | document.getElementById(id).className = "qexo-friends";
|
5 | document.getElementById(id).innerHTML = loadStyle;
|
6 | var ajax;
|
7 | try {
|
8 |
|
9 | ajax = new XMLHttpRequest();
|
10 | } catch (e) {
|
11 |
|
12 | try {
|
13 | ajax = new ActiveXObject("Msxml2.XMLHTTP");
|
14 | } catch (e) {
|
15 | try {
|
16 | ajax = new ActiveXObject("Microsoft.XMLHTTP");
|
17 | } catch (e) {
|
18 | alert("糟糕,你的浏览器不能上传文件!");
|
19 | return false;
|
20 | }
|
21 | }
|
22 | }
|
23 | ajax.open("get", uri, true);
|
24 | ajax.setRequestHeader("Content-Type", "text/plain");
|
25 | ajax.onreadystatechange = function () {
|
26 | if (ajax.readyState == 4) {
|
27 | if (ajax.status == 200) {
|
28 | var res = JSON.parse(ajax.response);
|
29 | if (res["status"]) {
|
30 | var friends = res["data"];
|
31 | document.getElementById(id).innerHTML = "";
|
32 | for (let i = 0; i < friends.length; i++) {
|
33 | document.getElementById(id).innerHTML += '<p><a target="_blank" href="' + friends[i]["url"] + '" title="' + friends[i]["name"] + '" class="qexo-friendurl"></p><div class="qexo-frienddiv"><div class="qexo-frienddivleft"><img class="qexo-myfriend" src="' + friends[i]["image"] + '"></div><div class="qexo-frienddivright"><span style="font-weight: bold;">' + friends[i]["name"] + '</span><br>' + friends[i]["description"] + '</div></div></a>';
|
34 | }
|
35 | } else {
|
36 | console.log(res["data"]["msg"]);
|
37 | }
|
38 | } else {
|
39 | console.log("友链获取失败! 网络错误");
|
40 | }
|
41 | }
|
42 | };
|
43 | ajax.send(null);
|
44 | }
|