DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:wordcounter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:wordcounter [2013-11-20 22:15] – [Discussion] 142.157.61.34tips:wordcounter [2022-12-19 11:46] (current) – [Discussion] 183.82.239.152
Line 80: Line 80:
 Can this be turned into a plugin that generates statistics on the number of words in the entire DokuWiki environment? I would like a feature similar to Microsoft Word's Word Counter tool so I can have some measurement of my progress. --[[mailto:steve@stevevance.net|Steven Vance]] Can this be turned into a plugin that generates statistics on the number of words in the entire DokuWiki environment? I would like a feature similar to Microsoft Word's Word Counter tool so I can have some measurement of my progress. --[[mailto:steve@stevevance.net|Steven Vance]]
  
-This does not seem to be working 2013-11-19.+I can't get any of the word count scripts to work, either as userscript.js, as a plugin, or as a greasemonkey script. Is there anything that works with "Binky?" [Kevin Dunn] 
 + 
 +>same problem as [Kevin Dunn] is there a way to run this with HRUN? or can i check somehow if userscript.js is already running with or without errors? Thanks [kbsit] 
 + 
 +Another alternative solution is using a good word count & character count tool freely available on the web, such as [[http://wordcounttools.com|Word Count Tools]] ,[[https://grammica.com/word-counter|Word Counter]] , [[http://charactercounttool.com|Character Count Tool]] or [[http://www.countingcharacters.com/|Counting Characters]].  
 +==== Issue ==== 
 +ReferenceError: findPosY is not defined 
 +=== a revised version === 
 +I changed the script to add wordcounter below the summary bar. Cause I'm a newbie on javascript, I just cut out some unresolved parts (counting for section, floating on textarea) 8-o. It works on //2014-05-05a Ponder Stibbons//
 +-- [[inbonk@gmail.com | In-Bon Kuh]] 
 + 
 +<code javascript conf/userscript.js> 
 +/** 
 + * Script to add a wordcounter below the summary bar 
 + * https://www.dokuwiki.org/tips:wordcounter 
 + * 
 + * @author Andreas Gohr <andi@splitbrain.org> 
 + * @author Lars Flintzak 
 + * @license GPL 2 
 + */ 
 + 
 +var wordcounter_timeout; 
 + 
 +function wordcounter(text){ 
 +    var list = text.split(/[^\w\-_]+/); 
 +    var len  = list.length; 
 +    if(list[len-1] == '') len--; 
 +    if(list[0] == '') len--; 
 +    if(len < 0) len=0; 
 +    return len; 
 +
 + 
 +function charcounter(text){ 
 +    var list = text.split(/[^\w\-_]+/); 
 +    var len  = text.length; 
 +    if(list[len-1] == '') len--; 
 +    if(list[0] == '') len--; 
 +    if(len < 0) len=0; 
 +    return len; 
 +
 + 
 +jQuery(function(){ 
 +    var $form = jQuery('#dw__editform');  
 +    var form = $form[0]; 
 +    if(!form) return; 
 +  
 +    var div = document.createElement('div'); 
 +    div.id = 'word__counter__output'; 
 +    div.style.color = '#0a0'; 
 +    div.style.padding = '0.2em 0.2em'; 
 + 
 +    var $summary = jQuery('.editBar .summary'); 
 +    var summary = $summary[0]; 
 +    summary.appendChild(div); 
 + 
 +    jQuery(form.elements.wikitext).keyup(function(){ 
 +        if(wordcounter_timeout) window.clearTimeout(wordcounter_timeout); 
 +        wordcounter_timeout = window.setTimeout(function(){ 
 +            var len = wordcounter(form.elements.wikitext.value); 
 +            var zei = charcounter(form.elements.wikitext.value); 
 +            div.innerHTML = 
 +                'text count: &nbsp;'+(zei)+' chars, &nbsp&nbsp;' 
 +                +(len)+' words'; 
 +        },1000); 
 +        return true; 
 +    }); 
 +}); 
 +</code>
tips/wordcounter.1384982149.txt.gz · Last modified: 2013-11-20 22:15 by 142.157.61.34

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki