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
4 posters

    just one last change at the word counter

    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved just one last change at the word counter

    Post by Michael_vx March 28th 2014, 12:24 am

    i know i`m asking too much these days so forgive me please
    the last solved topic
    https://help.forumotion.com/t131805-something-not-right-i-just-noticed-about-word-counter
    the one more change needed is like the tags i want the code also never count images if that possible so only words and letters with out tags and images
    sorry for that too much requests
    but i must say with help.forumotion
    i found the best support 
    one more thing
    i think smilies is same as images so if images wont count smilies wont be counted too
    again
    sorry for that too much requests


    Last edited by Michael_vx on March 29th 2014, 3:06 am; edited 3 times in total (Reason for editing : Fix wrong spelling + solved)
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: just one last change at the word counter

    Post by Ange Tuteur March 28th 2014, 9:04 am

    The smiles are two or more characters so that would be a bit difficult to match and remove them all. Try this for the images though :
    Code:
       $(function(){$(function(){

     Â              var MinNumberOfChars = 50;
     Â              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 characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
     Â                 
     Â                 var sceditor = $("#text_editor_textarea").sceditor("instance");                  
     Â                 var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|/gi,'');
     Â                 var str_len = str.length;
     Â                 
     Â                 if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
     Â                 
     Â                 sceditor.keyUp(function(e) {
     Â                    str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|/gi,'');
     Â                    str_len = str.length;
     Â                    if(str_len >= MinNumberOfChars) {
     Â                       $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(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> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
     Â                       $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
     Â                    }
     Â                 });
     Â              }
     Â           })});
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: just one last change at the word counter

    Post by Michael_vx March 28th 2014, 8:34 pm

    first thanks so much for add
    2nd if most of my smiles are used to be 😄
    and not direct letters that might make it easy
    almost all of my smiles are between : Very Happy:
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: just one last change at the word counter

    Post by Ange Tuteur March 28th 2014, 9:05 pm

    emoticons that use the following text should not count :
    :emoticon:

    Replace your script with :
    Code:
       $(function(){$(function(){

                   var MinNumberOfChars = 50;
                   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 characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
                     
                      var sceditor = $("#text_editor_textarea").sceditor("instance");                 
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
                     
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                     
                      sceditor.keyUp(function(e) {
                         str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                         str_len = str.length;
                         if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(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> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                         }
                      });
                   }
                })});
    Rhino.Freak
    Rhino.Freak
    Helper
    Helper


    Male Posts : 1248
    Reputation : 104
    Language : English
    Location : Mumbai, India

    Solved Re: just one last change at the word counter

    Post by Rhino.Freak March 29th 2014, 3:04 am

    Umm.. Ange I have a request, can you put the modified codes from various topics in the main tutorial as well? coz I have temporarily removed this system and I will implement and would need to search all these threads again..
    Thanks
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: just one last change at the word counter

    Post by Michael_vx March 29th 2014, 3:05 am

    reall thanks here in help.forumotion is the best support
    solved nothing but normal letters are in the count
    i`m sure there will be nothing will be needed more
    and sorry for that too much requests
    SLGray
    SLGray
    Administrator
    Administrator


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

    Solved Re: just one last change at the word counter

    Post by SLGray March 29th 2014, 3:07 am

    Topic Solved & Archived



    just one last change at the word counter Slgray10

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

      Current date/time is September 22nd 2024, 11:33 am