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.

something not right i just noticed about word counter

View previous topic View next topic Go down

Solved something not right i just noticed about word counter

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

1 i`m sorry for this to much requests i just noticed
the word counter at solved topic
http://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
Forumember

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

Back to top Go down

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

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

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

Michael_vx
Forumember

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

Back to top Go down

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

Post by Ange Tuteur on 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");
                 }
              });
           }
        })});

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

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

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

will i guess its not possible
look at the 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

Michael_vx
Forumember

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

Back to top Go down

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

Post by Ange Tuteur on 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 ?

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

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

Post by Michael_vx on 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)

Michael_vx
Forumember

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

Back to top Go down

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

Post by Ange Tuteur on 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.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

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

Post by Michael_vx on 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

Michael_vx
Forumember

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

Back to top Go down

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

Post by Ange Tuteur on 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

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

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