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.

just one last change at the word counter

4 posters

Go down

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)
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

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");
                     }
                  });
               }
            })});
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

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:
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

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");
                     }
                  });
               }
            })});
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

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
Rhino.Freak
Rhino.Freak
Helper
Helper

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

http://freetest.forumotion.net/

Back to top Go down

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
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

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.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51489
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum