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

    something not right i just noticed about word counter

    Michael_vx
    Michael_vx
    Forumember


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

    Solved something not right i just noticed about word counter

    Post by Michael_vx March 24th 2014, 11:22 pm

    1 i`m sorry for this to much requests i just noticed
    the word counter at solved topic
    https://help.forumotion.com/t131746-problem-in-add-a-word-counter-to-the-editor
    dose recognize space and the new line (Enter)
    the orginal code that dose not recognize arabic letters
    id dose not count the spaces or the new lines
    so if that possible and i say if it possible to make it never count spaces
    this will be really great if only possible
    and last thing sorry for being request many requests


    Last edited by Michael_vx on March 25th 2014, 1:50 am; edited 1 time in total (Reason for editing : fix my worng spel)
    Michael_vx
    Michael_vx
    Forumember


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

    Solved Re: something not right i just noticed about word counter

    Post by Michael_vx March 25th 2014, 3:56 am

    okay i`m guessing that is not posible Very Happy
    or its not easy as it looks
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: something not right i just noticed about word counter

    Post by Ange Tuteur March 25th 2014, 4:01 am

    Hello,

    Replace the script by :
    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/g,'');
     Â             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/g,'');
     Â                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: something not right i just noticed about word counter

    Post by Michael_vx March 25th 2014, 4:12 am

    will i guess its not possible
    look at the image
    something not right i just noticed about word counter Image
    the word is only 5 letters and the counter is counted 22 letters if i press space it will cont one more letter
    if that`s hard to do it
    then its will be no problem i will just change the 50 to any other rate i guess i don`t like to be burden to others
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: something not right i just noticed about word counter

    Post by Ange Tuteur March 25th 2014, 4:51 am

    Try this :
    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+/g,'');
     Â             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+/g,'');
     Â                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");
     Â                }
     Â             });
     Â          }
     Â       })});

    If that does not work, could you provide me a message that has that spacing ?
    Michael_vx
    Michael_vx
    Forumember


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

    Solved Re: something not right i just noticed about word counter

    Post by Michael_vx March 25th 2014, 5:01 am

    okay here is some thing


    text wrote:                
    17 spaces hould be in the uper line
    جملة بالاحرف العربية

    the WYSIWIG mode is on
    when i tried with out WYSIWIG its never count the spaces
    and the WYSIWIG mode is needed to be on so if that possible
    then i`m counting on you :Dif you don`t mind
    one thing the 3rd just arabic letters
    new add
    i find out the problem its when i use bold or center if i didn`t use it it works fine
    so i think the code must not count [b] and [b/] and [senter] and [center/] and should works fine Very Happy


    Last edited by Michael_vx on March 25th 2014, 5:14 am; edited 2 times in total (Reason for editing : add new note)
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: something not right i just noticed about word counter

    Post by Ange Tuteur March 25th 2014, 5:23 am

    Oh you don't want the tags to be counted ? This should do it :
    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+|\[.*?\]|\[\/.*?\]/g,'');
     Â             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+|\[.*?\]|\[\/.*?\]/g,'');
     Â                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");
     Â                }
     Â             });
     Â          }
     Â       })});

    That is most likely why the character count increases.
    Michael_vx
    Michael_vx
    Forumember


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

    Solved Re: something not right i just noticed about word counter

    Post by Michael_vx March 25th 2014, 5:32 am

    solved
    forgive my idiocy i didn`t know that the bold or center could the problem
    thanks again solved 100%
    i just tested
    i don`t know how to thank you really i don`t know
    thanks and 1 billion thanks
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: something not right i just noticed about word counter

    Post by Ange Tuteur March 25th 2014, 5:34 am

    You're welcome and don't worry about, the good thing is we figured out what was causing the extra characters. Wink

    Topic solved and archived

      Current date/time is November 11th 2024, 4:12 pm