Duck hunt
Share code like chat box wapego | WapEgo | WapMasTer - Diễn đàn truyện - Xtseo.Xtgem.Com
* MT-A *
* Cấp bậc: mem
2015-05-12 15:26

Code này khá là chán :D. Nhưng mà do các bạn yêu thích và mến mộ nên share chơi zị thôi.
Đầu tiên để làm code like, các bạn cần chuẩn bị 2 cái shout box. Cái thứ nhất dùng để like, cái thứ 2 là shout box chính. Shout box chính các bạn có thể làm thế nào tùy ý. Làm xong thì xem tiếp hướng dẫn này. Các bước dưới đây sẽ làm với shoutbox thứ nhất. Cấm có hỏi lại :D Ở ô thứ nhất của shoutbox, các bạn chèn code sau.
<script type="text/javascript">var sc_like="",f1='<form action="main.php?id=ch_topic_h&uid=83710&back_url=/main.php" method="post" style="display:inline">',f2='<input type="hidden" name="text" value="',f3='"/>',f4='<input type="submit" value="Like" class="nobutton"/></form>';</script>{{message_list}}
Copy code


Mục đích của đoạn này chỉ là để gán các biến cần thiết thôi. Vì ở code like sẽ có các form nên việc gán như vậy sẽ không phải viết lại nhiều lần.
Chú ý: Nhớ thay 83710 thành id shuotbox thứ nhất.
Tiếp theo là code ô 2, đọc không hiểu ráng chịu nhá :)

<script type="text/javascript">var sc_like="{{message|split(';')|slice(0,100)|join(';')|raw}}"</script>
{% set stn=message|split(';')|length-1 %}
<script type="text/javascript">{% for i in 0..stn %}{% set like = message|split(';')[i] %}{% set mid = like|split(',')[0] %}
{%autoescape false%}{%if like|split(',')[1]|split('+')|length > 2%}{{'l'~mid~'='~like|split(',')[1]|split('+')|length~';u'~mid~'="'~like|split(',')[1]|split('+')|slice(0,2)|join(', ')~' và '~(like|split(',')[1]|split('+')|length-2)~' người khác";'}}{%else%}{{'l'~mid~'='~like|split(',')[1]|split('+')|length~';u'~mid~'="'~like|split(',')[1]|split('+')|slice(0,2)|join(', ')~'";'}}{%endif%}{%endautoescape%}
{% endfor %}</script>

Copy code


Chú ý: đặt số tin nhắn là 1 thôi nhá.
Cuối cùng là code like. Code này đặt ở ô 2 shoutbox chính, dùng để bấm like và hiển thị tên người like. Đặt ở bất kỳ vị trí nào bạn thích

{% set msgid=message_date|replace({':':'','-':'',' ':''})+123456789012 %}<small><script type="text/javascript">if(!(sc_like.match(/{{msgid}}/)&&u{{msgid}}.match(/{{api.u.get(api.user_id).nick}}/))){document.write(f1);if(sc_like.match(/{{msgid}}/)){sc_liked=sc_like.replace('{{msgid}},','{{msgid}},{{api.u.get(api.user_id).nick|striptags|raw}}+');document.write(f2+sc_liked+f3);}else{document.write(f2+'{{msgid}},{{api.u.get(api.user_id).nick|striptags|raw}};'+sc_like+f3)};document.write(f4)};if(l{{msgid}}>0){document.write(l{{msgid}}+' ('+u{{msgid}}+')')};</script></small>
</div>

Copy code


Chú ý: số 123456789012 là một số ngẫu nhiên để đánh lừa thị giác, bạn có thể thay bằng bất kỳ dãy số nào khác (12 chữ số).

Copy share nhớ ghi rõ nguồn: http://sharecode.wap.mu
Chia sẻ:
BBCode:

Link:
Thành viên: BOT, & 11 Khách ghé thăm!
Từ khóa: Share, code, like, chat, box, wapego,

Share code like chat box wapego