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 to make word counter to work for just not in all categories.

View previous topic View next topic Go down

How to make word counter to work for just not in all categories.

Post by KrissuKissu on August 20th 2016, 6:56 pm

Hey!

So I need to help on the problem what is stated in the title.
I have the code but I don't want it to be everywhere, just few of them i wanna take out.

Is there any way I can do it?

http://themagicwithin.forumotion.co/ - (I wanna take Welcome Center and Character Creation out, there we don't need it)

EDIT: Okay I know now you need to add this:
if ($('a.nav[href^="/c3-"]').length == 0) return;

But It doesn't seem to work for me for some reason.

KrissuKissu
Forumember

Female Posts : 31
Reputation : 2
Language : English/Estonian

http://themagicwithin.forumotion.co/

Back to top Go down

Re: How to make word counter to work for just not in all categories.

Post by Ace 1 on August 23rd 2016, 3:18 pm

You're talking about this character counter?

http://help.forumotion.com/t141556-character-counter

I'm kinda confused on what you actually want

Ace 1
Forumember

Male Posts : 693
Reputation : 38
Language : my css ready java yo scripts boi
Location : Druid Hill Park smoking indo

http://genocideclan.forumotion.com

Back to top Go down

Re: How to make word counter to work for just not in all categories.

Post by KrissuKissu on August 24th 2016, 5:21 am

http://help.forumotion.com/t131191-add-a-word-counter-to-the-editor - i was talking about this. Razz
Just i wonder how to make it work only some categories. I wound somewhere the code what you need add but it didn't seem to work there for me.

KrissuKissu
Forumember

Female Posts : 31
Reputation : 2
Language : English/Estonian

http://themagicwithin.forumotion.co/

Back to top Go down

Re: How to make word counter to work for just not in all categories.

Post by Ace 1 on August 24th 2016, 3:56 pm

Omg @KrissuKissu I've been wanting to do this for a while and you just gave me inspiration. It doesn't matter what version you're running, this should work Wink

Replace the counter code with this:

Code:
$(function() {
    var fmpath = url_newposts.split('where=').pop();
    if ( fmpath == 'f1')
        wordCounter();
});

function wordCounter(){
  $(function(){
 
      var MinNumberOfWords = 5;
      var LetterCountPerWord = 3;
      var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
      var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png"; 
 
    if($("#text_editor_textarea").length != 0){
          $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");     
          $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum words to send a message: " + MinNumberOfWords + " (at least " + LetterCountPerWord + " letters)</div><div id='div_minchars_info'></div></div>");
         
          var sceditor = $("#text_editor_textarea").sceditor("instance");                 
          var str = sceditor.val();
          var regex = new RegExp('\\w{' + LetterCountPerWord + ',}\\b', 'g');
          var str_arr = str.match(regex);
          var str_len = str_arr == null ? 0 : str_arr.length;
         
          if(str_len >= MinNumberOfWords) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
         
          sceditor.keyUp(function(e) {
            str = sceditor.val();
            str_arr = str.match(regex);
            str_len = str_arr == null ? 0 : str_arr.length;
            if(str_len >= MinNumberOfWords) {
                $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> word(s). You can now send the message <img src='" + ico_compl  + "' />"); 
            $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
            }else{
                $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> word(s). You need " + (MinNumberOfWords - str_len) + " word(s) to send this message <img src='" + ico_incompl  + "' />");
                $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
            }
          });
      }
  })
}

And if you look at line 3, the
Code:
f1
is the forum id of the forum where you want the code to work.

Ace 1
Forumember

Male Posts : 693
Reputation : 38
Language : my css ready java yo scripts boi
Location : Druid Hill Park smoking indo

http://genocideclan.forumotion.com

Back to top Go down

Re: How to make word counter to work for just not in all categories.

Post by SLGray on August 24th 2016, 9:25 pm

The topic was posted in the wrong section, so I have moved it to the correct section.
Please read our forum rules: ESF General Rules


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 35667
Reputation : 2375
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

Re: How to make word counter to work for just not in all categories.

Post by KrissuKissu on August 27th 2016, 11:42 am

The point is I don't want it to be just in one forum. On this site: http://themagicwithin.forumotion.co/ - I want this code to work from Hogwarts category to Other Location of the World. (We don't need it for Character Creation category, Imprtant Information and OOC one)

KrissuKissu
Forumember

Female Posts : 31
Reputation : 2
Language : English/Estonian

http://themagicwithin.forumotion.co/

Back to top Go down

Re: How to make word counter to work for just not in all categories.

Post by Ace 1 on August 28th 2016, 3:30 pm

Ohh @KrissuKissu so you don't want it to work for certain forums. In that case just change line 3 of my code up there to this:

Code:
if ( fmpath != 'f1' )

If you have more than one forum you don't want it to appear in then use this:

Code:
if ( fmpath != 'f1' || fmpath != 'f2' )

Code:
f1
and
Code:
f2
are the forum ids where you don't want the counter to work.

Ace 1
Forumember

Male Posts : 693
Reputation : 38
Language : my css ready java yo scripts boi
Location : Druid Hill Park smoking indo

http://genocideclan.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