Zone-FM - Cộng Đồng Forumotion Việt Nam [TUT] Select tiền tố tự động khi gửi bài
Admin
Admin
Quản Trị Viên
Bài Viết : 45
30.10.16 22:08
Admin - Quản Trị Viên
Tạo 1 file js mới .

Tile : Select Auto Prefix

Placement : In all the pages

Cho code sau vào

Code:

var prefixes = ["Thông Báo", "Làm Đẹp", "Mỹ Phẫm", "Linh Kiện", "Sim Số", "Nhà Đất", "Xe Cộ", "Dịch Vụ", "Du Lịch", "Điện Tử", "Thời Trang", "Điện Thoại"]; //danh sach cac prefix
var _pm = false; //false: cho phep prefix khi gui tin nhan
/* Topic prefixes - Copyright ©️ 2011 by Viet K - chinhphuc.info */
var chk = false;
function toMenu(a) {
  var htmlpre = '<select style="margin-right:5px" id="prefix" size="1"><option value="">(None)</option>';
  for (i in a)
  htmlpre += '<option value="' + a[i] + '">' + a[i] + '</option>';
  htmlpre += '</select>';
  return htmlpre;
}

function checkpre(ar, input) {
  for (i in ar) {
      var p = new RegExp("\\" + ar[i], "g");
      var title = input.substr(0, input.indexOf(']'));
      if (p.test(title)) return ar[i];
  }
  return "";
}
$(function () {
  if (_pm) chk = /\privmsg/.test(location.href);
  if (/\/post/.test(location.href) || chk) {
      $(toMenu(prefixes)).insertBefore("input[name=subject][type=text]");
      var mw = $("#prefix").width() + 5;
      $("input[name=subject]").css("width", $("input[name=subject]").width() - mw);
      var t = $("[name=subject]").val();
      var cur = checkpre(prefixes, t);
      if (cur != "") {
        $("[value=" + cur + "]").attr("selected", "selected");
        $("input[name=subject]").val(t.replace('[' + cur + ']', '').trim());
      }
      $("input[name=post]").click(function () {
        var sub = $("input[name=subject]").val().trim();
        if (sub != "" && $("#prefix").val() != "")
            $("input[name=subject]").val("[" + $("#prefix").val() + "] " + sub);
      });
  }
});

$(".post-entry a[href^='http://imgur.com/'][href*='/a/'],.post-entry a[href^='http://imgur.com/'][href*='/a/']").replaceWith(function(){
      return '<iframe width="100%" height="550" src="' + this.href + '" allowfullscreen="allowfullscreen" frameborder="0"></iframe>'
});

Chú Thích
code bên dưới là danh sách Prefix các bạn tùy chỉnh cho phù hợp với forum mình nhé Cười nhe răng

Code:
["Thông Báo", "Làm Đẹp", "Mỹ Phẫm", "Linh Kiện", "Sim Số", "Nhà Đất", "Xe Cộ", "Dịch Vụ", "Du Lịch", "Điện Tử", "Thời Trang", "Điện Thoại"]

help me
help me
Thành Viên
Bài Viết : 15
30.10.16 23:28
help me - Thành Viên
kaka nó đây mà www.48gio.com Cười đã quá

0


Hãy Đăng Nhập Để Gửi Bình Luận - Nếu Chưa Có Tài Khoản Đăng Ký - Click Tại Đây


 

© 2016 Spiderum Themes Cover Forumotion By @Thànhkent