[TUTS] Tạo file dữ liệu avatar

  Bài viết hay nhất1
First topic message reminder :

Thử nghiệm: [You must be registered and logged in to see this link.]

So với phiên bản trước đây, code đã được tối ưu, rút gọn dữ liệu tối đa.
Nếu như trước đây, do giới hạn kích thước mà code chỉ dùng tốt với forum 3000~5000 thành viên, thì phiên bản này giới hạn đó đã tăng lên 80000~100000 thành viên.

Cụ thể:

  1. Loại bỏ các thành viên không dùng avatar.
  2. Loại bỏ protocol trong URL.
  3. Rút gọn các đường dẫn mặc định.
  4. Rút gọn 4 loại đuôi ảnh thường gặp.


Một số cải tiến:

  1. Thêm bộ đếm thời gian tải.
  2. Cấm thành viên thông thường sử dụng.
  3. Bản ghi hoạt động chi tiết.
  4. Tự tạo tệp dữ liệu khi không tìm thấy.
  5. Tải trang kế tiếp ngay khi trang trước được tải xong.
  6. Dừng tải khi gặp lỗi và tự tải lại sau 2 phút.
  7. Tự cập nhật tệp dữ liệu khi tải xong.


[You must be registered and logged in to see this image.]
Update Avatar - DEVs

[You must be registered and logged in to see this image.]
Update Avatar - Skin4FM


Hướng dẫn:


Bước 1: Tạo trang avatar obj


  • Title * :  avatar obj
  • HTML source * :
    Code:
    [{}]




Bước 2: Tạo trang HTML Update Avatar


  • Title * :  HTML Update Avatar
  • HTML source * :
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" id="min-width" lang="vi" xml:lang="vi">

    <head>
     <title>Update Avatar - version 2 | DEVs.forumvi.com</title>
     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
     <meta http-equiv="content-script-type" content="text/javascript" />
     <meta http-equiv="content-style-type" content="text/css" />
     <link rel="shortcut icon" type="image/x-icon" href="http://dl.dropboxusercontent.com/u/126946313/DEVs/devs.ico" />
     <meta name="author" content="Zzbaivong" />
     <meta name="title" content="Update Avatar - version 2 | DEVs.forumvi.com" />
     <meta name="description" content="Tạo tệp dữ liệu avatar của các thành viên có đăng bài viết" />
     <style type="text/css">
     * {
     margin: 0;
     padding: 0
     }
     body {
     background-attachment: fixed;
     background-color: transparent;
     background-image: url(http://i40.servimg.com/u/f40/17/70/81/78/83512010.jpg);
     background-position: center top;
     background-repeat: no-repeat;
     background-size: 120% auto
     }
     body * {
     -o-box-sizing: border-box;
     -moz-box-sizing: border-box;
     -webkit-box-sizing: border-box
     }
     #devs {
     float: right;
     text-indent: -9999px;
     display: block;
     width: 16px;
     height: 16px;
     background: url(http://i56.servimg.com/u/f56/18/59/49/93/l111.png) no-repeat center transparent;
     }
     .note {
     float: none;
     width: 270px;
     background: url(http://i40.servimg.com/u/f40/17/70/81/78/tip10.png) no-repeat scroll 5px center #FFFBCC;
     border: 1px solid #E6DB55;
     clear: both;
     color: #666452;
     font-size: .9em;
     position: relative;
     margin: 0 auto;
     padding: 5px 5px 5px 25px
     }
     #getavatar {
     background: none repeat scroll 0 0 padding-box #FFF;
     border: 1px solid rgba(0, 0, 0, 0.333);
     box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
     color: #000;
     left: 50%;
     margin-left: -50px;
     margin-top: -210px;
     outline: 0 none;
     position: absolute;
     top: 50%;
     width: 520px;
     padding: 40px
     }
     #getavatar button {
     background: #F5F5F5;
     border: 1px solid rgba(0, 0, 0, 0.1);
     clear: none;
     color: #444;
     cursor: pointer;
     float: none;
     font-size: 11px;
     font-weight: 700;
     height: 29px;
     line-height: 27px;
     margin-top: 10px;
     min-width: 72px;
     outline: 0 none;
     padding: 0 8px
     }
     #getavatar #start {
     background: rgb(203, 255, 207);
     }
     #getavatar #pause {
     background: rgb(255, 228, 229);
     }
     #getavatar button: hover {
     background: #999!important;
     color: #FFF;
     }
     #time,
     #page {
     padding: 0 20px 0 25px;
     width: 168px;
     display: inline-block;
     }
     #page {
     background: url(http://i57.servimg.com/u/f57/17/70/81/78/list_b10.png) no-repeat scroll left center transparent
     }
     #time {
     background: url(http://i40.servimg.com/u/f40/17/70/81/78/14578910.png) no-repeat scroll left center transparent;
     cursor: pointer
     }
     #avatarjson {
     width: 100%;
     height: 100px;
     resize: vertical;
     overflow: auto!important;
     }
     #paging {
     font-size: 12px;
     font-weight: 700;
     margin-top: 10px;
     text-align: center;
     visibility: hidden
     }
     #paging b {
     background-color: #0567AD;
     border: 1px solid #00487A;
     color: #FFF;
     text-shadow: 0 1px 0 #000;
     visibility: visible;
     padding: 3px 5px
     }
     #paging a[href="javascript:Pagination();"] {
     display: none
     }
     #paging a {
     text-decoration: none;
     background-color: #E5E5E5;
     border: 1px solid #D6D6D6;
     text-shadow: 0 1px 0 #FFF;
     visibility: visible;
     margin: 2px;
     padding: 3px 5px
     }
     .warning {
     border: 1px solid rgb(171, 218, 255);
     padding: 10px;
     text-align: justify;
     font: 12px sans-serif;
     background: rgb(239, 247, 255);
     margin: 10px 0;
     }
     .btn,
     .timepage,
     #paging,
     #avatarjson {
     display: none;
     }
     </style>
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
     <script type="text/javascript">
     //<![CDATA[ var _gaq = _gaq || []; _gaq.push(["_setAccount", "UA-26966514-1"]); _gaq.push(["_trackPageview"]); (function () { var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true; ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s) })(); //]]>
     </script>
    </head>

    <body>
     <script tyle="text/javascript">
    var page_ID = 0,
     avatar = {}, data = {}, reset = 120,
     second = 0,
     avapage,
     time, refresh, adtid,
     link = "/memberlist?change_temp&mode=posts&order=DESC",
     filter = "",
     imgfast = "";

    $("body").prepend('<div style="width: 100%; height: 100%; background: none repeat scroll 0% 0% rgb(221, 221, 221); position: absolute; top: 0px; left: 0px; opacity: 0.7;"></div><div id="getavatar"><p class="timepage"><a id="devs" target="_blank" href="http://devs.forumvi.com/">DEVs</a><span id="time">0</span><span id="page">0/0</span></p><p class="note">\u00a9 2013 Zzbaivong</p><p class="btn"><button id="reset">Làm lại</button> <button id="start">Bắt đầu</button><button style="display:none" id="pause">Tạm dừng</button></p><textarea id="avatarjson"></textarea><p id="paging"></p></div>');

    function active() {
     $(".note").css({
     "float": "right",
     "margin": "10px 0"
     });
     $(".btn,.timepage,#paging").show();
    }

    function created(a) {
     $.get("/admin/index.forum?part=modules&sub=html&extended_admin=1&tid=" + a, {
     sort_method: "page_time",
     sort_order: "DESC",
     submit: "submit"
     }, function (e) {
     page_ID = $(e).find("#pageListHtml td:contains('avatar obj'):first").next().next().find("a:last").attr("href").replace(/\S+\/h(\d+)-\S+/, "$1");
     active();
     $("#getavatar").append('<p class="warning">Tệp <strong><font color="#339933">avatar obj</font></strong> đã được tạo thành công với <strong><font color="#ff3333">page_ID</font></strong> là <strong><font color="#ff3333">' + page_ID + '</font></strong>.<br><br>Ngay bây giờ bạn có thể nhấn <font color="#333399"><strong>Bắt đầu</strong></font> để cập nhật dữ liệu.<br>Trong lúc chờ tải, bạn cần sửa lại mã <strong><font color="#ff3333">page_ID</font></strong> trong javascript của 2 tệp <font color="#9933ff"><strong>HTML Update Avatar</strong></font> và <font color="#cc6633"><strong>javascript Update Avatar</strong></font>.<br><br><i>Xem hướng dẫn chi tiết tại</i>: <a target="_blank" href="http://devs.forumvi.com/h14-avatar?pageid=' + page_ID + '">http://devs.forumvi.com/h14-avatar?pageid=' + page_ID + '</a></p>');
     console.log("page_ID = " + page_ID);
     });
    }

    function clock() {
     $("#time").text(second++)
    }

    function note(a, b) {
     $(".note").text(a);
     switch (b) {
     case "w":
     console.warn(a)
     break;
     case "e":
     console.error(a)
     break;
     default:
     console.log(a)
     }
    }

    function viTime(a) {
     var a = (new Date(a)).toString().split(/\s/);
     return a[2] + "/" + {
     Jan: "01",
     Feb: "02",
     Mar: "03",
     Apr: "04",
     May: "05",
     Jun: "06",
     Jul: "07",
     Aug: "08",
     Sep: "09",
     Oct: "10",
     Nov: "11",
     Dec: "12"
     }[a[1]] + "/" + a[3] + " " + a[4]
    }

    function getavatar(c) {
     $.get(c).done(function (a) {
     if ($(a).find("a[href^='/admin/index.forum']").length) {
     $("#paging").html($(a).find(".paging:first").html());
     $("#paging img").parent().remove();
     var page = $("#paging b").text(),
     allpage = $("#paging > *:last").text();
     if ("" == page) {
     page = 0
     };
     if ("" == allpage) {
     allpage = 0
     };
     $("#page").text(page + "/" + allpage);
     avapage = 0;
     $(a).find(".tcl.avatar-mini").each(function () {
     var b = $(this).find("img").attr("src");
     if (!new RegExp("^(" + filter + ")$").test(b) && "0" != $(this).siblings(".tc3:last").prev().text()) {
     avapage++;
     var a = $(this).find("a").attr("href").replace(/\/u(\d+)\?change_temp=/,
     "$1"),
     b = b.replace(new RegExp("https?:|//r\\d+.imgfast.net|" + imgfast, "gi"), "").replace("//illiweb.com/fa/i/avatars/", "*").replace("gallery/", "!").replace(".png", "{").replace(".gif", "}").replace(".jpg", "[").replace(".jpeg", "]");
     0 == b.indexOf(a + "-") && (b = b.replace(a + "-", "@"));
     eval("avatar[" + a + "]='" + b + "'")
     }
     });
     avatar.lastUpdate = new Date().getTime();
     $("#avatarjson").val("[" + JSON.stringify(avatar) + "]");
     note("Trang " + page + " có " + avapage + " người dùng avatar.");
     if ($("#paging b").is(":last-child") || $("#pause").is(":hidden") || "0" == $(a).find(".table .tc3:last").prev().text() || $("#paging").is(":empty")) {
     clearInterval(time);
     $("#start, #reset").show();
     $("#pause").hide();
     data = {
     title: "avatar obj",
     mode: "go_edit",
     page: page_ID,
     submit: "submit",
     html: $("#avatarjson").val()
     };
     $.post("/admin/index.forum?part=modules&sub=html&extended_admin=1&tid=" + $(a).find("a[href^='/admin/index.forum']").attr("href").replace(/\S+tid=(\w+)&change_temp=/, "$1"), data, function (b) {
     if ($(b).find(".messagebox:contains('HTML page successfully updated')").length) {
     note("Cập nhật thành công.");
     } else {
     note("Cập nhật thất bại.", "w");
     note("Cập nhật lại lần 2.");
     adtid = $(b).find("#activetab a").attr("href").replace(/\S+&tid=(\w+)/, "$1");
     $.post("/admin/index.forum?part=modules&sub=html&extended_admin=1&tid=" + adtid, data, function (b) {
     if ($(b).find(".messagebox:contains('HTML page successfully updated')").length) {
     note("Cập nhật thành công.");
     } else {
     note("Xảy ra lỗi! Dừng cập nhật tự động.", "e");
     }
     })
     }
     });
     note("Tổng số avatar: " + (Object.keys(avatar).length - 1), "w");
     if ($("#paging b").is(":last-child") || $("#paging").is(":empty")) {
     note("Hoàn thành! Tải toàn bộ avatar.")
     } else if ("0" == $(a).find(".table .tc3:last").prev().text()) {
     note("Kết thúc! Thành viên có 0 bài viết.")
     } else if ($("#pause").is(":hidden")) {
     note("[Tạm dừng] lúc " + viTime(new Date()));
     }
     } else {
     link = $("#paging b").next().attr("href");
     getavatar(link)
     };
     } else {
     note("Bạn cần quyền admin để tiếp tục.", "w");
     $(".btn,.timepage,#paging,#avatarjson").remove();
     $(".note").css({
     "float": "none",
     "margin": "0 auto"
     });
     }
     }).fail(function () {
     clearInterval(time);
     $("#start, #reset").show();
     $("#pause").hide();
     var a = reset;
     $(".note").html("Xảy ra lỗi! Cập nhật lại sau <strong id='refresh'>" + a + "</strong> giây.");
     console.warn("Xảy ra lỗi! Cập nhật lại sau " + a + " giây.");
     refresh = setInterval(function () {
     var b = a--;
     $("#refresh").text(b);
     if (0 >= b) {
     note("Tiếp tục chạy cập nhật");
     $("#start").click()
     }
     }, 1E3)
     })
    }

    $.get("/h" + page_ID + "-avatar", function (a) {
     if (a.indexOf("[") != 0) {
     note("Đường dẫn tệp dữ liệu không đúng.", "w");
     if ($(a).find("a[href^='/admin/index.forum']").length) {
     data = {
     title: "avatar obj",
     mode: "add",
     submit: "submit",
     html: "[{}]"
     };
     adtid = $(a).find("a[href^='/admin/index.forum']").attr("href").replace(/\S+&tid=(\w+)/, "$1");
     $.post("/admin/index.forum?part=modules&sub=html&extended_admin=1&tid=" + adtid, data, function (b) {
     if ($(b).find(".successbox:contains('HTML page successfully created')").length) {
     note("Tạo tệp [avatar obj] thành công");
     created(adtid)
     } else {
     note("Tạo tệp [avatar obj] thất bại", "w");
     note("Tạo lại tệp [avatar obj] lần 2.");
     adtid = $(b).find("#activetab a").attr("href").replace(/\S+&tid=(\w+)/, "$1");
     $.post("/admin/index.forum?part=modules&sub=html&extended_admin=1&tid=" + adtid, data, function (b) {
     if ($(b).find(".successbox:contains('HTML page successfully created')").length) {
     note("Tạo tệp [avatar obj] thành công.");
     created(adtid)
     } else {
     note("Xảy ra lỗi! Dừng tạo tệp [avatar obj].", "e");
     }
     });
     }
     });
     } else {
     note("Bạn cần quyền admin để tiếp tục.", "w");
     }
     } else {
     avatar = $.parseJSON(a)[0];
     if (avatar.lastUpdate != undefined) {
     note("Cập nhật cuối: " + viTime(avatar.lastUpdate));
     } else {
     note("Chưa có dữ liệu");
     }
     active();
     }
    });
    $("#start").click(function () {
     note("[Bắt đầu] lúc " + viTime(new Date()));
     time = setInterval("clock()", 1000);
     getavatar(link);
     $("#start, #reset").hide();
     $("#pause").show();
     $("#avatarjson").slideDown();
     clearInterval(refresh)
    });
    $("#reset").click(function () {
     note("[Làm lại] lúc " + viTime(new Date()));
     $("#avatarjson").slideUp();
     data = {};
     second = 0;
     link = "/memberlist?change_temp&mode=posts&order=DESC";
     $("#avatarjson").val("");
     $("#paging").empty();
     $("#time").text("0");
     $("#page").text("0/0");
     note("\u00a9 2013 Zzbaivong")
    });
    $("#pause").click(function () {
     $(this).hide().siblings().show()
    });
     </script>
    </body>

    </html>



Chỉnh sửa: Tìm trong code trên, phần javascript

page_ID: Thay 0 bằng page id của trang avatar obj tạo ở bước 1. Ví dụ:
Code:
page_ID = 7,

filter: URL avatar mặc định của diễn đàn, nếu có nhiều avatar mặc định dùng dấu gạch đứng để ngăn cách. Ví dụ:
Code:
filter = "http://i56.servimg.com/u/f56/18/59/49/93/noavat10.jpg",
...dùng nhiều avatar mặc định:
Code:
filter = "http://r15.imgfast.net/users/1513/21/33/80/avatars/gallery/defaul10.png|http://r15.imgfast.net/users/1513/21/33/80/avatars/gallery/1-5911.gif",
Xem avatar mặc định tại: ACP >> Display >> Avatars >> Avatar gallery >> Default avatar

imgfast: Đường dẫn thư mục avatar. Mỗi diễn đàn sẽ có một thư mục chứa avatar riêng trên imgfast, bạn có thể dùng bất kỳ URL avatar(được upload), lấy đoạn từ /users/ đến /avatars/. Ví dụ:
URL avatar của mình là [You must be registered and logged in to see this link.] thì nhập code như sau:
Code:
imgfast = "/users/2816/63/36/82/avatars/";

Bước 3: Tạo tệp Javascript Update Avatar


  • Title * :  Javascript Update Avatar
  • Placement : In the home page, In the sub-forums
  • Javascript Code * :
    Code:
    var page_ID = 0,
     noAvatar = "//i56.servimg.com/u/f56/18/59/49/93/noavat10.jpg",
     imgfast = "",
     avatar;

    function imgAva(a) {
     var u = a.replace(/.*\/u(\d+)(\?tt=1)?/, "$1").toString();
     a = avatar[u];
     void 0 == a && (a = noAvatar); - 1 == a.indexOf("/") && (a = imgfast + a);
     a = a.replace("@", u + "-");
     a = a.replace("*", "//illiweb.com/fa/i/avatars/");
     a = a.replace("!", "gallery/");
     a = a.replace(/\{$/, ".png");
     a = a.replace(/\}$/, ".gif");
     a = a.replace(/\[$/, ".jpg");
     a = a.replace(/\]$/, ".jpeg");
     return '<img class="statusAva" src="' + a + '" alt="avatar" onerror="this.src=\'' + noAvatar + '\';" />'
    }

    $(function () {
     $.get("/h" + page_ID + "-avatar", function (data) {
     avatar = $.parseJSON(data)[0];
     /* Viết code ở đây */
     });
    });




Tags: [You must be registered and logged in to see this link.]
  Bài viết hay nhất51
Nếu cấu trúc index_box chưa bị mất class .table .tcr thì chỉ cần chỉnh page_IDimgfast theo hướng dẫn là được.
  Bài viết hay nhất52
[You must be registered and logged in to see this link.]
Zzbaivong wrote:Nếu cấu trúc index_box chưa bị mất class .table .tcr thì chỉ cần chỉnh page_IDimgfast theo hướng dẫn là được.
Còn nếu mất rồi?
  Bài viết hay nhất53
[You must be registered and logged in to see this link.]
anhdaodaica1 wrote:[You must be registered and logged in to see this link.]
Zzbaivong wrote:Nếu cấu trúc index_box chưa bị mất class .table .tcr thì chỉ cần chỉnh page_IDimgfast theo hướng dẫn là được.
Còn nếu mất rồi?
Thay .table .tcr (dòng 23) bằng selector chứa thông tin bài viết cuối trong index_box.
  Bài viết hay nhất54
Code thật sự rất hay, nhưng trình mình còn kém quá. Làm tới đó rồi mà quay mãi vẫn ko thể hiện avatar.
Tks Baivong vì đã giải đáp những thắc mắc của mình :)
  Bài viết hay nhất55
demo?
  Bài viết hay nhất56
[You must be registered and logged in to see this link.]
Zzbaivong wrote:demo?
[You must be registered and logged in to see this link.]
  Bài viết hay nhất57
Tắt ngay cái code chặn F12 đi, chẳng có ích gì đâu, phiền phức.
Demo link dữ liệu avatar nữa.
  Bài viết hay nhất58
[You must be registered and logged in to see this link.]
Zzbaivong wrote:Tắt ngay cái code chặn F12 đi, chẳng có ích gì đâu, phiền phức.
Demo link dữ liệu avatar nữa.
[You must be registered and logged in to see this link.] - HTML Update Avatar
[You must be registered and logged in to see this link.] - avatar obj
[You must be registered and logged in to see this link.] - Javascript Update Avatar
  Bài viết hay nhất59
[You must be registered and logged in to see this link.]
anhdaodaica1 wrote:[You must be registered and logged in to see this link.]
Zzbaivong wrote:Tắt ngay cái code chặn F12 đi, chẳng có ích gì đâu, phiền phức.
Demo link dữ liệu avatar nữa.
[You must be registered and logged in to see this link.] - HTML Update Avatar
[You must be registered and logged in to see this link.] - avatar obj
[You must be registered and logged in to see this link.] - Javascript Update Avatar
Xóa file [You must be registered and logged in to see this link.] (lỗi).
Chèn vào cuối temp index_box:
Code:
<script type="text/javascript">
//<![CDATA[
var page_ID = 16,
   noAvatar = "//i56.servimg.com/u/f56/18/59/49/93/noavat10.jpg",
   imgfast = "/users/1117/20/00/30/avatars/",
   avatar;

function imgAva(a) {
   var u = a.replace(/.*\/u(\d+)(\?tt=1)?/, "$1").toString();
   a = avatar[u];
   void 0 == a && (a = noAvatar); - 1 == a.indexOf("/") && (a = imgfast + a);
   a = a.replace("@", u + "-");
   a = a.replace("*", "//illiweb.com/fa/i/avatars/");
   a = a.replace("!", "gallery/");
   a = a.replace(/\{$/, ".png");
   a = a.replace(/\}$/, ".gif");
   a = a.replace(/\[$/, ".jpg");
   a = a.replace(/\]$/, ".jpeg");
   return '<img class="statusAva" src="' + a + '" alt="avatar" onerror="this.src=\'' + noAvatar + '\';" />'
}

$(function () {
   $.get("/h" + page_ID + "-avatar", function (data) {
      avatar = $.parseJSON(data)[0];
      $(".dav1").prepend(function () {
         var user = $(this).find("a[href^='/u']");
         if (user.length) {
            return imgAva(user[0].href)
         }
      });
      $("#left a[href^='/u']").mouseover(function () {
         show_tooltip(this, imgAva(this.href))
      });
   });
});
//]]>
</script>
  Bài viết hay nhất60
[You must be registered and logged in to see this link.]
Zzbaivong wrote:[You must be registered and logged in to see this link.]
anhdaodaica1 wrote:[You must be registered and logged in to see this link.]
Zzbaivong wrote:Tắt ngay cái code chặn F12 đi, chẳng có ích gì đâu, phiền phức.
Demo link dữ liệu avatar nữa.
[You must be registered and logged in to see this link.] - HTML Update Avatar
[You must be registered and logged in to see this link.] - avatar obj
[You must be registered and logged in to see this link.] - Javascript Update Avatar
Xóa file [You must be registered and logged in to see this link.] (lỗi).
Chèn vào cuối temp index_box:
Code:
<script type="text/javascript">
//<![CDATA[
var page_ID = 16,
   noAvatar = "//i56.servimg.com/u/f56/18/59/49/93/noavat10.jpg",
   imgfast = "/users/1117/20/00/30/avatars/",
   avatar;

function imgAva(a) {
   var u = a.replace(/.*\/u(\d+)(\?tt=1)?/, "$1").toString();
   a = avatar[u];
   void 0 == a && (a = noAvatar); - 1 == a.indexOf("/") && (a = imgfast + a);
   a = a.replace("@", u + "-");
   a = a.replace("*", "//illiweb.com/fa/i/avatars/");
   a = a.replace("!", "gallery/");
   a = a.replace(/\{$/, ".png");
   a = a.replace(/\}$/, ".gif");
   a = a.replace(/\[$/, ".jpg");
   a = a.replace(/\]$/, ".jpeg");
   return '<img class="statusAva" src="' + a + '" alt="avatar" onerror="this.src=\'' + noAvatar + '\';" />'
}

$(function () {
   $.get("/h" + page_ID + "-avatar", function (data) {
      avatar = $.parseJSON(data)[0];
      $(".dav1").prepend(function () {
         var user = $(this).find("a[href^='/u']");
         if (user.length) {
            return imgAva(user[0].href)
         }
      });
      $("#left a[href^='/u']").mouseover(function () {
         show_tooltip(this, imgAva(this.href))
      });
   });
});
//]]>
</script>

Đã thành công mĩ mãn. Chân thành cảm ơn Baivong
Mình chỉ còn 1 điều thắc mắc nữa là liệu js này có gây hiện tượng request limit?
  Bài viết hay nhất61
Chắc chắn là không bị request limit :3
  Bài viết hay nhất62
Hướng dẫn tự cập nhật dữ liệu avatar, xem [You must be registered and logged in to see this link.]
  Bài viết hay nhất63
You cannot reply to topics in this forum