The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
3 posters

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

    KrissuKissu
    KrissuKissu
    Forumember


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

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

    Post by KrissuKissu 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.com/ - (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.
    Ace 1
    Ace 1
    Helper
    Helper


    Male Posts : 843
    Reputation : 64
    Language : English - French?
    Location : Druid Hill Park

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

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

    You're talking about this character counter?

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

    I'm kinda confused on what you actually want
    KrissuKissu
    KrissuKissu
    Forumember


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

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

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

    https://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.
    Ace 1
    Ace 1
    Helper
    Helper


    Male Posts : 843
    Reputation : 64
    Language : English - French?
    Location : Druid Hill Park

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

    Post by Ace 1 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.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

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

    Post by SLGray 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



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

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


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

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

    Post by KrissuKissu 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.com/ - 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)
    Ace 1
    Ace 1
    Helper
    Helper


    Male Posts : 843
    Reputation : 64
    Language : English - French?
    Location : Druid Hill Park

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

    Post by Ace 1 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.

      Current date/time is September 23rd 2024, 5:18 am