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.

How can I Add Topic Prefixes

View previous topic View next topic Go down

Solved How can I Add Topic Prefixes

Post by Van-Helsing on April 5th 2014, 10:43 pm

Hi all,
How can I add this type of topic prefixes http://prntscr.com/37axjc ? My forum version is PunBB

Best Regards,
Dark-Avenger


Last edited by Dark-Avenger on April 11th 2014, 1:33 pm; edited 1 time in total

Van-Helsing
Hyperactive

Male Posts : 2197
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Sir Chivas™ on April 6th 2014, 4:48 am

Hi,

Add this script: JavaScript (ACP >> Modules >> HTML & JavaScript Management)
Code:
var prefixes = ["prefix1","prefix2","prefix3","prefix4"];
   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);
          });
      }
    });

In all places, make sure its ticked.

code provided by punBB

Sir Chivas™
Support Moderator
Support Moderator

Male Posts : 6756
Reputation : 428
Language : English, Spanish, and French
Location : || CSS || HTML || Graphics Designs || Support ||

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Van-Helsing on April 6th 2014, 10:33 am

Hi Sir Chivas,
I have found this code in few forums but the prefixes havent background colors.
I think needs futhermore css code.

Van-Helsing
Hyperactive

Male Posts : 2197
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Pizza Boi on April 6th 2014, 9:31 pm

Hi Very Happy

Did you try using the ID's declared (prefix1, 2, 3, 4, etc.) and then just add in CSS with background-color?

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Van-Helsing on April 6th 2014, 11:26 pm

@Pizza Boi wrote:Hi Very Happy

Did you try using the ID's declared (prefix1, 2, 3, 4, etc.) and then just add in CSS with background-color?

Regards,
Pizza Boi
Hi Pizza Boi Very Happy ,
I try this code in my CSS

Code:

#prefix1 {
  background: red;
}
for my first prefix but it isnt working.

Van-Helsing
Hyperactive

Male Posts : 2197
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Pizza Boi on April 7th 2014, 3:07 am

Hi Very Happy

Did you try adding additional styles such as padding, border, etc.? Try making a full style to see if the Javascript does work because if it still does not appear, they may be some bugs.

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Van-Helsing on April 7th 2014, 9:27 am

@Pizza Boi wrote:Hi Very Happy

Did you try adding additional styles such as padding, border, etc.?  Try making a full style to see if the Javascript does work because if it still does not appear, they may be some bugs.

Regards,
Pizza Boi
Hi Very Happy ,
It seems to add the prefix in the topic title at h2 I am thinking it needs some changes in JS because I can find the prefix element code. Is there a way to find prefix element?

Best Regards,
Dark-Avenger

Van-Helsing
Hyperactive

Male Posts : 2197
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Van-Helsing on April 8th 2014, 9:31 am

Bump

Van-Helsing
Hyperactive

Male Posts : 2197
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by SocialAcademy on April 8th 2014, 11:39 am

Hello @ Dark Avenger you can try this CSS

Code:
.prefix  {
background-image: url(http://i57.servimg.com/u/f57/17/68/86/50/highli10.png);
background-position: 0 -1px;
background-repeat: repeat-x;
border-radius: 3px;
color: #fff;
display: inline-block;
font-size: 9px;
font-weight: 700;
height: 15px;
line-height: 15px;
padding: 0 5px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.2);
text-transform: uppercase;
vertical-align: middle;
}



SocialAcademy
Forumember

Male Posts : 141
Reputation : 10
Language : JavaScript, CSS, Html, JQuery, C#, C++, Php, Python
Location : Forumotion

http://www.socialacademy.biz

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Pizza Boi on April 8th 2014, 11:52 am

Hi Very Happy

If you wish to do an element change, this part of changing should do the trick:

Code:
$(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);

I'm not great at RegEx but try and give it a hand and sorry if I didn't reply earlier, I was busy yesterday x.x .

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Van-Helsing on April 8th 2014, 9:56 pm

@Pizza Boi wrote:Hi Very Happy

If you wish to do an element change, this part of changing should do the trick:

Code:
$(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);

I'm not great at RegEx but try and give it a hand and sorry if I didn't reply earlier, I was busy yesterday x.x .

Regards,
Pizza Boi
Hi all,
I have change the JS into this:
Code:

var prefixes = ["Λύθηκε","Σε επεξεργασία","Πρόβλημα"];
            var _pm = false;
            var chk = false;
            function toMenu(a) {
              var htmlpre = '<select style="margin-right:5px" id="prefix" size="1"><option value="">Χαρακτηρισμός</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);
                  });
              }
            });

and I was add the CSS:
Code:

    .prefix  {
    background-image: url(http://i57.servimg.com/u/f57/17/68/86/50/highli10.png);
    background-position: 0 -1px;
    background-repeat: repeat-x;
    border-radius: 3px;
    color: #fff;
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    height: 15px;
    line-height: 15px;
    padding: 0 5px;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.2);
    text-transform: uppercase;
    vertical-align: middle;
    }
 but it still not working it adds the prefix but the CSS has no effect http://prntscr.com/387zr4 I want to have different color per prefix.

Best Regards,
Dark-Avenger

Van-Helsing
Hyperactive

Male Posts : 2197
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Pizza Boi on April 9th 2014, 6:40 pm

Hi Very Happy

I'm sorry but I do not know what else to do with it now Sad .

Really sorry I can't help much with this Sad .

Regards,
Pizza Boi

Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Van-Helsing on April 11th 2014, 1:32 pm

Hi dear all,
I have found the codes and problem has been solved.

Best Regards,
Dark-Avenger

Van-Helsing
Hyperactive

Male Posts : 2197
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: How can I Add Topic Prefixes

Post by Jophy on April 11th 2014, 1:58 pm

Garbaged, since no solution was given.

Jophy
ForumGuru

Male Posts : 17924
Reputation : 835
Language : English
Location : Somewhere

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