[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ất26
[You must be registered and logged in to see this link.]
Admin wrote:Mình ghi rõ ràng: Bây giờ, ngay tại bài viết này, tức là mình chỉ cho bạn thấy tác dụng của hàm imgAva ở DEVs, còn 4rum bạn chưa cài thì làm thế nào mà nó chạy được?
dạ, e làm hết các bước rồi, còn mỗi bước sử dụng, nhưng chắc là trong cái bước sử dụng đó trước đó e fải thêm gì gì vào đó trong temp thì mới hoạt động đc, chắc e k đủ trình xài cái này ùi :(
sr ad, để e xóa cmt :)
  Bài viết hay nhất27
Cập nhật:

  • Sửa lỗi yêu cầu quyền admin, nguyên nhân là do diễn đàn sử dụng Temporary themes.
  • Thêm code ví dụ sử dụng avatar trong index_body và latest topics cho diễn đàn có cấu trúc mặc định.
  Bài viết hay nhất28
code chạy tốt...Admin cho mình hỏi...khi thành viên cập nhật avatar mới thì nó tự load ra index ko hay là mình phải chạy trang html updeat thế...
  Bài viết hay nhất29
[You must be registered and logged in to see this link.]
hanphong wrote:code chạy tốt...Admin cho mình hỏi...khi thành viên cập nhật avatar mới thì nó tự load ra index ko hay là mình phải chạy trang html updeat thế...
fai chạy html nhé :)
  Bài viết hay nhất30
e làm đc rồi, nhưng đang làm thì nó bảo cần quyền admin để tiếp tục :(( (p/s : đã làm theo bản update của ad rồi)
  Bài viết hay nhất31
Gửi nick admin xem thử.
  Bài viết hay nhất32
[You must be registered and logged in to see this link.]
Admin wrote:Gửi nick admin xem thử.
e hui ui fo, a f5 di
  Bài viết hay nhất33
Cập nhật: Sửa lỗi yêu cầu quyền admin trường hợp chỉ có 1 trang dữ liệu.
  Bài viết hay nhất34
bị như này là sao ạ
Cập nhật lại lần 2.
ấn vaò bawrt đầu để tiếp tục thì toàn hiện : Kết thúc! Thành viên có 0 bài viết.

cứ như thế T_T
  Bài viết hay nhất35
Vì code này không lấy avatar của thành viên không viết bài, nếu tìm thấy thành viên 0 bài viết nó sẽ dừng lại.
  Bài viết hay nhất36
[You must be registered and logged in to see this link.]
Admin wrote:Vì code này không lấy avatar của thành viên không viết bài, nếu tìm thấy thành viên 0 bài viết nó sẽ dừng lại.

vậy có cách nào khác ko bác .
chả nhẽ đến đó thì nó lại thôi
  Bài viết hay nhất37
Thật ra thành viên mà không viết bài thì cũng hầu như chẳng dùng avatar, có tải tiếp cũng thêm vài avatar là cùng.
Nếu bạn muốn dùng thì xóa code sau:

Dòng 257
Code:
 || "0" == $(a).find(".table .tc3:last").prev().text()

Dòng 286, 287
Code:
} 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.")

Ps: Nhấn F12 >> Console để xem chi tiết quá trình tải
  Bài viết hay nhất38
[You must be registered and logged in to see this link.]
Admin wrote:Thật ra thành viên mà không viết bài thì cũng hầu như chẳng dùng avatar, có tải tiếp cũng thêm vài avatar là cùng.
Nếu bạn muốn dùng thì xóa code sau:

Dòng 257
Code:
 || "0" == $(a).find(".table .tc3:last").prev().text()

Dòng 286, 287
Code:
} 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.")

Ps: Nhấn F12 >> Console để xem chi tiết quá trình tải

xóa cả 2 code trên hả bác
  Bài viết hay nhất39
uhm, xóa hết.
  Bài viết hay nhất40
mấy lần đều bị T_T
[You must be registered and logged in to see this link.]
  Bài viết hay nhất41
Làm lại từ đầu thử xem, lỗi đó là do không tìm thấy admin link.
  Bài viết hay nhất42
đã làm lại 2 lần nhưng vẫn ra kết quả thế T_T
đây là code ạ
Code:
<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><script tyle="text/javascript">
var page_ID = 82,
  avatar = {}, data = {}, reset = 120,
  second = 0,
  avapage,
  time, refresh, adtid,
  link = "/memberlist?change_temp&mode=posts&order=DESC",
  filter = "http://www.cntt-k3.com/users/2015/12/67/35/avatars/gallery/user_n10.png",
  imgfast = "/users/2015/12/67/35/avatars/";
 
$("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") || $("#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 ($("#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>
  Bài viết hay nhất43
Vẫn dùng SCEditor ah! Mất body mà sao code vẫn chạy nhỉ?
Xem bài này để xóa SCEditor: [You must be registered and logged in to see this link.]
  Bài viết hay nhất44
[You must be registered and logged in to see this link.]
Admin wrote:Vẫn dùng SCEditor ah! Mất body mà sao code vẫn chạy nhỉ?
Xem bài này để xóa SCEditor: [You must be registered and logged in to see this link.]


ủa e dùng rồi mà bac

js loại bỏ SCEditor trên e add lên forum rồi mà
  Bài viết hay nhất45
Nó là js nhưng không dùng như js thường, xem bài này nhé: [You must be registered and logged in to see this link.]
  Bài viết hay nhất46
[You must be registered and logged in to see this link.]
Admin wrote:Nó là js nhưng không dùng như js thường, xem bài này nhé: [You must be registered and logged in to see this link.]


à ^^ lâu ko vô FM nên ko biết
để ẻ thử xem :D có gì e làm phiền bác sau :P
  Bài viết hay nhất47
[You must be registered and logged in to see this image.]
Cho hỏi mình làm như vậy đã đúng chưa?
Nếu đúng rồi thì làm sao để hiện avatar ngoài index_box?
  Bài viết hay nhất48
[You must be registered and logged in to see this link.]
anhdaodaica1 wrote:
[You must be registered and logged in to see this image.]
Cho hỏi mình làm như vậy đã đúng chưa?
Nếu đúng rồi thì làm sao để hiện avatar ngoài index_box?
nếu đã cập nhập thành công nghĩa là đúng rồi - còn hiện avatar ra ngoài index_box thì bạn xem cái cách sữ dụng ở hướng dẫn :)
  Bài viết hay nhất49
Chỉnh lại tham số imgfast
Code:
imgfast = "/users/1117/20/00/30/avatars/";
  Bài viết hay nhất50
[You must be registered and logged in to see this link.]
anhoang_qn wrote:[You must be registered and logged in to see this link.]
anhdaodaica1 wrote:
[You must be registered and logged in to see this image.]
Cho hỏi mình làm như vậy đã đúng chưa?
Nếu đúng rồi thì làm sao để hiện avatar ngoài index_box?
nếu đã cập nhập thành công nghĩa là đúng rồi - còn hiện avatar ra ngoài index_box thì bạn xem cái cách sữ dụng ở hướng dẫn :)

Là chèn đoạn này vào index_box?

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];
      $(".table .tcr").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))
      });
  });
});

Nhưng chèn class gì vào nơi muốn hiện avatar?





[You must be registered and logged in to see this link.]
Zzbaivong wrote:Chỉnh lại tham số imgfast
Code:
imgfast = "/users/1117/20/00/30/avatars/";

Bằng cái gì vậy Baivong? mà chỉnh lại trong trang HTML Update Avatar hả?
  Bài viết hay nhất51
You cannot reply to topics in this forum