|
|
Forum moderator: bigblog |
uCoz Community For Webmasters Custom Solutions Help! I need Word Count Script for the File Catalog Entry/Ed |
Help! I need Word Count Script for the File Catalog Entry/Ed |
I need a word count script.
I know bigblog knows some script for word count of the File Catalog Entry Adding/Editing page. Word count changes on the fly as the user types words. Please help me. Post edited by khen - Wednesday, 2016-09-14, 12:36 PM
|
khen, insert the following code after the $BODY$ tag:
Code <script type="text/javascript"> $(document).ready(function(){$("#edttmessage").after("<div class=\"wordCount\">The text has <b>0</b> words.</div>");}); $(function() { var count = {}; $("#message").keyup(function() { var all = this.value.match(/\b/g); count[this.id] = all ? all.length / 2 : 0; var output = 0; $.each(count, function(k, v) { output += v; }); $('.wordCount b').text(output) }).keyup(); }); </script> Please, note that this code will only work with the HTML or BB Code editor of the entry full text. If you want it to work with the editor of the entry brief text, use the following code: Code <script type="text/javascript"> $(document).ready(function(){$("#edttbrief").after("<div class=\"wordCount\">The text has <b>0</b> words.</div>");}); $(function() { var count = {}; $("#brief").keyup(function() { var all = this.value.match(/\b/g); count[this.id] = all ? all.length / 2 : 0; var output = 0; $.each(count, function(k, v) { output += v; }); $('.wordCount b').text(output) }).keyup(); }); </script> If you want to use it for both, this code will fit your needs: Code <script type="text/javascript"> $(document).ready(function(){$("#edttmessage").after("<div class=\"wordCount\">The text has <b>0</b> words.</div>");}); $(document).ready(function(){$("#edttbrief").after("<div class=\"wordCountBrief\">The text has <b>0</b> words.</div>");}); $(function() { var count = {}; $("#message").keyup(function() { var all = this.value.match(/\b/g); count[this.id] = all ? all.length / 2 : 0; var output = 0; $.each(count, function(k, v) { output += v; }); $('.wordCount b').text(output) }).keyup(); }); $(function() { var count = {}; $("#brief").keyup(function() { var all = this.value.match(/\b/g); count[this.id] = all ? all.length / 2 : 0; var output = 0; $.each(count, function(k, v) { output += v; }); $('.wordCountBrief b').text(output) }).keyup(); }); </script> hey i'm joe and i do not work for the company anymore, please contact other staff or tech support
icon by ch-chau sometimes i lurk here |
bigblog, thanks to you man. You're such a blessing. But is there a way to make it work using the Visual Editor? Because I'm using the Visual Editor.
|
khen, since the visual editor is loaded through an HTML frame, I'm afraid, it's not possible to retrieve any property of its content.
hey i'm joe and i do not work for the company anymore, please contact other staff or tech support
icon by ch-chau sometimes i lurk here |
bigblog, ah. ok. I get it. Thanks to you bigblog. I really appreciate your help.
|
| |||
| |||