The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Prefix Coding for Admin/Mod Only

View previous topic View next topic Go down

Solved Prefix Coding for Admin/Mod Only

Post by Babybok on August 4th 2017, 11:33 am

Good day, So I have this problem if it is possible that the use of prefix is for Admin and Mod's only. Anyone can help or code me with this problem? cause I've this Admin/Mod Warning button that only Admin/Mod can use and I think my problem is possible also to code it for admin/mod only.


Here is the code.
Code:
var prefixes = ["Form", "In Progress", "Request", "Suggestion", "Notice", "Information", "Tutorial", "Guide"];
var _pm = false;
 
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)
      })
  }
});


code of the admin/mod warning

Code:
$(function() {
  var modButton = true, admButton = true,
  modImage = 'http://i39.servimg.com/u/f39/18/21/41/30/bouton11.png',
  admImage = 'http://i39.servimg.com/u/f39/18/21/41/30/bouton10.png';

  if (_userdata.user_level != 0 && modButton === true) {
    $("#text_editor_textarea").before("<img src='"+modImage+"' title='Moderator warning' id='mod-b'/>");
    $('#mod-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('[mod]','[/mod]')});
  }
  if (_userdata.user_level === 1 && admButton === true) {
    $("#text_editor_textarea").before("<img src='"+admImage+"' title='Admin warning' id='adm-b'/>");
    $('#adm-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('[adm]','[/adm]')});
  }
  $('div.postbody div').each(function () {
    if ($(this).text().indexOf('[adm]') != -1) $(this).html($(this).html().replace(/\[adm\](.+?)\[\/adm\]/gi, '<div class="adm_mess"><div class="titl">Administrator Warning</div><div>$1 </div></div>'));
    if ($(this).text().indexOf('[mod]') != -1) $(this).html($(this).html().replace(/\[mod\](.+?)\[\/mod\]/gi, '<div class="mod_mess"><div class="titl">Moderator Warning</div><div>$1 </div></div>'));
  }); 
});


Hope anyone can help me. thanks!


Last edited by Babybok on August 10th 2017, 11:32 am; edited 1 time in total
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 4th 2017, 4:09 pm

Use this code:
Code:
 if(!_userdata. user_level){      var prefixes = ["Form", "In Progress", "Request", "Suggestion", "Notice", "Information", "Tutorial", "Guide"];
        var _pm = false;
       
        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)
              })
          }
        });
};
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 5th 2017, 6:56 am

Wolfuryo wrote:Use this code:
Code:
 if(!_userdata. user_level){      var prefixes = ["Form", "In Progress", "Request", "Suggestion", "Notice", "Information", "Tutorial", "Guide"];
        var _pm = false;
       
        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)
              })
          }
        });
};

Hello good day, thanks for the fast reply, but when I replace this code to the code that I have in my Javascript section it didn't worked, the prefix was gone as well as the prefix css. @Wolfuryo
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 5th 2017, 7:36 am

Code:
        if(_userdata. user_level){      var prefixes = ["Form", "In Progress", "Request", "Suggestion", "Notice", "Information", "Tutorial", "Guide"];
                var _pm = false;
             
                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)
                      })
                  }
                });
        };

Made a small mistake in the code. See if this works.
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 5th 2017, 8:11 am

Wolfuryo wrote:
Code:
        if(_userdata. user_level){      var prefixes = ["Form", "In Progress", "Request", "Suggestion", "Notice", "Information", "Tutorial", "Guide"];
                var _pm = false;
             
                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)
                      })
                  }
                });
        };

Made a small mistake in the code. See if this works.

Still not working :'(

Anyways here my forum address : forums.mo-rpg.com
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 5th 2017, 9:53 am

Try this. There was an extra space in the code.
Code:
 if(_userdata.user_level){      var prefixes = ["Form", "In Progress", "Request", "Suggestion", "Notice", "Information", "Tutorial", "Guide"];
                var _pm = false;
           
                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)
                      })
                  }
                });
        };
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 5th 2017, 10:37 am

Wolfuryo wrote:Try this. There was an extra space in the code.
Code:
 if(_userdata.user_level){      var prefixes = ["Form", "In Progress", "Request", "Suggestion", "Notice", "Information", "Tutorial", "Guide"];
                var _pm = false;
           
                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)
                      })
                  }
                });
        };

Hello thanks for your help but the code you gave still not working.. Sad
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 5th 2017, 12:09 pm

So, what do you exactly want? If you want the code to only be executed for mods and admins, than that's exactly what the code I gave you does.
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Draxion on August 5th 2017, 4:25 pm

Why not try this?
Code:
if (_userdata["user_level"] == 1 || _userdata["user_level"] == 2) {
  var prefixes = [
    "Form",
    "In Progress",
    "Request",
    "Suggestion",
    "Notice",
    "Information",
    "Tutorial",
    "Guide"
  ];
  var _pm = false;

  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);
      });
    }
  });
}


NEVER provide your founder's account or email
Please provide forum's URL when dealing with design and appearance issues
Don't forget to mark the topic as when the issue is resolved. This helps the staff greatly.
PM Support is prohibited!
TOS | General Rules | FAQ | Tricks & Tips | Latest Updates | Introduce Yourself

avatar
Draxion
Support Moderator
Support Moderator

Male Posts : 1797
Reputation : 225
Language : English
Location : USA

http://www.draxionsgameden.com/

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 5th 2017, 10:46 pm

Wolfuryo wrote:So, what do you exactly want? If you want the code to only be executed for mods and admins, than that's exactly what the code I gave you does.

yeah I want mod and admins only to use the prefix, but it does not support in my forum.
I've tried it many times, but it still doesn't work and some of my javascript have been disabled with that code.

Draxion wrote:Why not try this?
Code:
if (_userdata["user_level"] == 1 || _userdata["user_level"] == 2) {
  var prefixes = [
    "Form",
    "In Progress",
    "Request",
    "Suggestion",
    "Notice",
    "Information",
    "Tutorial",
    "Guide"
  ];
  var _pm = false;

  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);
      });
    }
  });
}

Thanks for this code, but still doesn't support in my forum

anyways, my forum is Invision.
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 7th 2017, 5:48 am

Bump! Even in my PHPBB2 forum the code doesn't work.. help please @Draxion @Wolfuryo
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 7th 2017, 2:40 pm

Hi again,

I'm not the author of those scripts so I have no idea why they don't work. I could look through them to find the error, but it would be easier for me if I create a code from scratch. Just to clarify, the code should add a list of prefixes in the topic posting page. When the user clicks one of them, the prefix is inserted in the title of the post, right? I'll wait for you answer than I'll start working on the code.
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 7th 2017, 3:06 pm

Wolfuryo wrote:Hi again,

I'm not the author of those scripts so I have no idea why they don't work. I could look through them to find the error, but it would be easier for me if I create a code from scratch. Just to clarify, the code should add a list of prefixes in the topic posting page. When the user clicks one of them, the prefix is inserted in the title of the post, right? I'll wait for you answer than I'll start working on the code.

Yes sir, you are correct but only MODS/ADMINS can use it. Here is what I have now in my forum


I hope that will be the same when you code it from scratch. thank you very much sir, I appreciated your fast reply and help.
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 8th 2017, 3:30 pm

Bumo! @Wolfuryo
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 9th 2017, 6:34 am

Code:
$(function(){
/*Coded by Wolfuryo. Use at your own risk. This notice must be kept in place*/
var prefixes=["prefix1", "prefix2"];
if(/post/.test(location.pathname) && $("label:contains('Title of the topic')") && _userdata.user_level){
var t=$(".posting-subject"), h="", len=prefixes.length, i=0;
for(i;i<len;i++){
h+="<option>"+prefixes[i]+"</option>";
}
h="<select id='pref'>"+h+"</select>";
t.after(h);
$("#pref>option").click(function(){
var t=$(".posting-subject");
if(/\[.+\]/.test(t.val())){
t.val(t.val().replace(/\[.+\]/, "["+this.innerHTML+"]"));
} else {
t.val("["+this.innerHTML+"]"+t.val());
}
})
}
})

To add or edit prefixes, you have to do modifications here:
Code:
var prefixes=["prefix1", "prefix2"];
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 9th 2017, 7:10 am

Hi, good day @Wolfuryo Thanks for the help, I appreciate it. but it is still not working, yeah it is working in the creation of topic but when you post it the prefix doesn't appear

Creation of Topic


When posting it (There is no prefix appearing)


avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 9th 2017, 7:24 am

By default there's no prefix selected, you have to click on the box saying prefix 1 and select something from it.
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 9th 2017, 7:30 am

I have selected prefix 1 and prefix 2 but still nothing happened. :'(
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Justice™ on August 9th 2017, 7:40 am

I tested on your forum and my code is working. Delete all the other codes that have to do with prefixes, there's no need for 3 codes that try to do the same thing and all of them failing.
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 9th 2017, 8:02 am

Wolfuryo wrote:I tested on your forum and my code is working. Delete all the other codes that have to do with prefixes, there's no need for 3 codes that try to do the same thing and all of them failing.

I have no other prefix codes, just the css and 1 js to support the CSS Code and the code you gave.
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by Babybok on August 10th 2017, 11:30 am

Oh I think this is solved, I've added a code in the previous code I got' copying from the code of admin/mod warning. So I think yeah this is done already. Thanks to @Wolfuryo for the help and idea and also to @Draxion for the contribute! cheers mates!


This is the code I've used.
Code:
$(function(){   
     if (_userdata.user_level) {
   var prefixes = ["Prefix1", "Prefix2"];
     var _pm = false;
   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)
         })
     }
   });
});
avatar
Babybok
Forumember

Male Posts : 188
Reputation : 2
Language : Filipino, English
Location : Philippines

http://rl-rp.board.st

Back to top Go down

Solved Re: Prefix Coding for Admin/Mod Only

Post by brandon_g on August 10th 2017, 1:26 pm

Topic solved & archived ~ brandon_g
Please read our forum rules: ESF General Rules


Remember to mark your topic when a solution is found.
avatar
brandon_g
Support Moderator
Support Moderator

Male Posts : 5983
Reputation : 549
Language : English
Location : USA

http://broadcastingduo.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum