{"tiddlers":{"$:/plugins/telmiger/EditorCounter/EditTemplate":{"title":"$:/plugins/telmiger/EditorCounter/EditTemplate","created":"20170126185919666","creator":"Thomas Elmiger","list-before":"$:/core/ui/EditTemplate/type","modified":"20200605055914338","modifier":"Thomas Elmiger","tags":"$:/tags/EditTemplate EditorCounter","type":"text/vnd.tiddlywiki","text":"<div class=\"te-editor-counter\">\n<$reveal type=\"match\" text=\"yes\" state=\"$:/plugins/telmiger/EditorCounter/settings/characters\">\n<$editor-counter tiddler=<<currentTiddler>> colors='black:0,gray:140,green:300,indianred:800,red:1600'/> characters </$reveal>\n<$reveal type=\"match\" text=\"yes\" state=\"$:/plugins/telmiger/EditorCounter/settings/autosave\">\n<span class=\"tc-muted\"><span class=\"tc-dirty-indicator\">•</span> <$editor-counter mode=autosave savelimit={{$:/plugins/telmiger/EditorCounter/settings/autosave!!limit}}/> saved</span>\n</$reveal>\n<$reveal type=\"match\" text=\"yes\" state=\"$:/plugins/telmiger/EditorCounter/settings/characters\"> &nbsp;&nbsp; \n</$reveal>\n<$reveal type=\"match\" text=\"yes\" state=\"$:/plugins/telmiger/EditorCounter/settings/words\">\n<$editor-counter mode=word colors='black:0,gray:200,green:300,indianred:1000,red:2000'/> words &nbsp;&nbsp; \n</$reveal>\n<$reveal type=\"match\" text=\"yes\" state=\"$:/plugins/telmiger/EditorCounter/settings/autosave-pause\">\n<$checkbox tiddler=\"$:/plugins/telmiger/EditorCounter/settings/autosave\" field=\"text\" checked=\"yes\" unchecked=\"no\" default=\"no\"> Autosave</$checkbox>\n<$reveal type=\"match\" text=\"yes\" state=\"$:/plugins/telmiger/EditorCounter/settings/autosave\">\n (uncheck to pause)\n</$reveal>\n</$reveal>\n</div>\n<style>\n.te-editor-counter { margin-top: -.25rem; margin-bottom: 0.75rem; }\n</style>\n<!--\n* Show the number of characters and/or words entered in edit mode.\n* Show the number of characters at last autosave (autosave at a character difference as defined in settings).\n-->"},"$:/plugins/telmiger/EditorCounter/TitleTemplate":{"title":"$:/plugins/telmiger/EditorCounter/TitleTemplate","created":"20170213190419968","creator":"Thomas Elmiger","list-before":"$:/core/ui/EditTemplate/tags","modified":"20200605055914365","modifier":"Thomas Elmiger","tags":"$:/tags/EditTemplate EditorCounter","type":"text/vnd.tiddlywiki","text":"<$reveal type=\"match\" text=\"yes\" state=\"$:/plugins/telmiger/EditorCounter/settings/title\">\n<div class=\"te-title-counter\" title=\"Title length\">\n<$editor-counter tiddler=<<currentTiddler>> field=\"draft.title\" colors='green:20,indianred:30,red:40'/> chars\n</div>\n<style>\n.te-title-counter { position:absolute; right:1rem; margin-top:-2.25rem; padding-right:0.125rem; opacity:0.6; }\n@media (min-width: 30em) {\n.te-title-counter { right:2rem; }\n}\n@media (min-width: 42em) {\n.te-title-counter { right:4rem; }\n}\n</style>\n</$reveal>\n\n<!--\nShow the number of characters in the title\n-->"},"$:/plugins/telmiger/EditorCounter/about":{"title":"$:/plugins/telmiger/EditorCounter/about","created":"20200524222834178","modified":"20200605055914378","tags":"","type":"text/vnd.tiddlywiki","text":"The [[EditorCounter plugin|https://tid.li/tw5/plugins.html#EditorCounter]] can display counters for words and characters in the edit view. In single page wikis it can save texts automagically in the background – check the [[plugin settings|$:/plugins/telmiger/EditorCounter/settings]].\n"},"$:/plugins/telmiger/EditorCounter/counter.js":{"title":"$:/plugins/telmiger/EditorCounter/counter.js","text":"/*\\\ntitle: $:/plugins/telmiger/EditorCounter/counter.js\ntype: application/javascript\nmodule-type: widget\n\nversion: 0.6.3\n\nCount the number of words or characters in a tiddler/field/input string – Autosave while editing\n\nUsage: see the plugin’s readme.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar CounterWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nCounterWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM – reset autosave attributes\n*/\nCounterWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\t// autosave attributes\n\tthis.diffTotal = 0;\n\tthis.saveNow = false;\n\t// calculate state \n\tthis.execute();\n\tif(this.mode == \"autosave\") {\n\t\t// store the number of last saved characters\n\t\tthis.lastSavedCount = this.currentCount;\n\t\tthis.diffLastCount = this.currentCount;\n\t} \n\tvar textNode = this.document.createTextNode(this.currentCount);\n\tvar domNode = this.document.createElement(\"span\");\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\n/*\nCalculate the numbers\n*/\nCounterWidget.prototype.getLength = function(text) {\n\tvar result = 0;\n\tswitch(this.mode) {\n\t\tcase \"character\":\n\t\t\tresult = text.length.toString();\n\t\t\tbreak;\n\t\tcase \"autosave\":\n\t\t\tresult = text.length.toString();\n\t\t\t// sum up difference since last count\n\t\t\tthis.diffTotal += this.checkAutosave(result);\n\t\t\t// check saving limit\n\t\t\tthis.saveNow = (this.diffTotal >= this.saveLimit) ? true : false;\n\t\t\tbreak;\n\t\tcase \"word\":\n\t\t\tif(text.match(/\\w+/g)) {\n\t\t\t\tresult = text.match(/\\w+/g).length.toString();\n\t\t\t} else {\n\t\t\t\tresult = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault: // \"?!\"\n\t\t\tresult = \"mode undefined\";\n\t}\n\treturn result;\n}\n\n/*\nSet autosave \n*/\nCounterWidget.prototype.checkAutosave = function(textlength) {\n\t// calculate difference since last count\n\tthis.diffChars = Math.abs(textlength - this.diffLastCount);\n\t// store text length\n\tthis.diffLastCount = textlength;\n\treturn this.diffChars;\n}\n\n/*\nGet the colors as an array\n*/\nCounterWidget.prototype.getColors = function() {\n\tvar color_array1 = this.colors.split(',');\n\tvar i;\n\tcolor_array1.sort(function sortfunction(a, b){\n\t\treturn a.split(':')[1] - b.split(':')[1];\n\t});\n\tfor(i = 0; i < color_array1.length; i++) {\n\t\tthis.color_array[i] = color_array1[i].split(':')[0];\n\t\tthis.count_array[i] = color_array1[i].split(':')[1];\n\t}\n}\n\n/*\nGet the numbers\n*/\nCounterWidget.prototype.getNumber = function() {\n\t// Count letters or words as appropriate.\n\tvar result = 0;\n\tif(this.countText) {\n\t\t// text supplied as parameter \n\t\tresult = this.getLength(this.countText);\n\t} else {\n\t\tvar tiddler = this.wiki.getTiddler(this.tiddler);\n\t\tvar fieldContent = tiddler.getFieldString(this.field);\n\t\tif(fieldContent) {\n\t\t\tresult = this.getLength(fieldContent);\n\t\t} else {\n\t\t\tresult = 0;\n\t\t}\n\t}\n\treturn result;\n}\n\n/*\nCompute the internal state of the widget\n*/\nCounterWidget.prototype.execute = function() {\n\t// Get parameters from our attributes\n\tthis.mode = this.getAttribute(\"mode\",\"character\");\n\tthis.saveLimit = this.getAttribute(\"savelimit\",200);\n\tthis.tiddler = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.field = this.getAttribute(\"field\",\"text\");\n\tthis.countText = this.getAttribute(\"text\");\n\tthis.colors = this.getAttribute(\"colors\");\n\tthis.stateTiddler = this.getAttribute(\"colorState\");\n\t// Count letters or words as appropriate.\n\tthis.currentCount = this.getNumber();\n\tthis.diffChars = 0;\n\t//Find the color cut-offs, if any.\n\tif(this.colors) {\n\t\tthis.color_array = [];\n\t\tthis.count_array = [];\n\t\tvar i;\n\t\tthis.getColors();\n\n\t\t// set the color if the counter is high enough. The color with the largest value that is less than this.currentCount wins.\n\t\tfor(i = 0; i < this.color_array.length; i++) {\n\t\t\tif(Number(this.currentCount) >= Number(this.count_array[this.color_array.length - 1 - i])) {\n\t\t\t\tif(this.stateTiddler) {\n\t\t\t\t\tthis.wiki.setText(this.stateTiddler,\"text\",undefined,this.color_array[this.color_array.length -1 - i]);\n\t\t\t\t}\n\t\t\t\tthis.currentCount = '@@color:' + this.color_array[this.color_array.length -1 - i] + ';' \n\t\t\t\t\t+ this.currentCount + '@@';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(this.stateTiddler && i === this.color_array.length-1) {\n\t\t\t\tthis.wiki.setText(this.stateTiddler,\"text\",undefined,'');\n\t\t\t}\n\t\t}\n\t}\n\tvar parser = this.wiki.parseText(\"text/vnd.tiddlywiki\",this.currentCount,{parseAsInline: true});\n\tvar parseTreeNodes = parser ? parser.tree : [];\n\tthis.makeChildWidgets(parseTreeNodes);\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nCounterWidget.prototype.refresh = function(changedTiddlers) {\n\tvar refreshed = false;\n\t// Re-execute the filter to get the count\n\tthis.computeAttributes();\n\tvar oldCount = this.currentCount;\n\tthis.execute();\n\tif(this.currentCount !== oldCount && this.mode !== \"autosave\") {\n\t\t// Regenerate and rerender the widget and replace the existing DOM node\n\t\tthis.refreshSelf();\n\t\trefreshed = true;\n\t}\n\tif(this.saveNow) {\n\t\t// Trigger an autosave and refresh\n\t\t$tw.rootWidget.dispatchEvent({type: \"tm-auto-save-wiki\"});\n\t\tthis.refreshSelf();\n\t\trefreshed = true;\n\t} \n\treturn refreshed;\n};\n\nexports[\"editor-counter\"] = CounterWidget;\n\n})();\n","type":"application/javascript","module-type":"widget","created":"20170207230719552","creator":"Thomas Elmiger","modified":"20200605055914454","modifier":"Thomas Elmiger","tags":"EditorCounter"},"$:/plugins/telmiger/EditorCounter/credits":{"title":"$:/plugins/telmiger/EditorCounter/credits","created":"20170304102433909","creator":"Thomas Elmiger","modified":"20200605055914466","modifier":"Thomas Elmiger","tags":"EditorCounter","type":"text/vnd.tiddlywiki","text":"!! Credits\n\nMany thanks to Jed for his blueprint widget and demo site, originally on http://ooktech.com/jed/ExampleWikis/WordCount/ as well as to Skeeve who obviousliy contributed the original macro version Jed based his solution on.\n\n* http://ooktech.com/TiddlyWiki/\n* http://ooktech.com/TiddlyWiki/WordCount/\n\n//Powered by the fantastic TiddlyWiki community.//\n"},"$:/plugins/telmiger/EditorCounter/icon":{"title":"$:/plugins/telmiger/EditorCounter/icon","created":"20200524221551931","modified":"20200605055914501","tags":"","type":"text/vnd.tiddlywiki","text":"<svg width=\"22pt\" height=\"22pt\" viewBox=\"0 0 22 22\" xmlns=\"http://www.w3.org/2000/svg\" fill-rule=\"evenodd\" clip-rule=\"evenodd\" stroke-linejoin=\"round\" stroke-miterlimit=\"2\">\n  <path d=\"M11.1.2l9.2 5.4v10.8L11.1 22 2 16.4V5.6L11 .2z\" fill=\"#d7d7d7\" fill-rule=\"nonzero\"/>\n  <path d=\"M11.1 2a9 9 0 100 18 9 9 0 000-18zM13 5c-.6 0-1 .5-1.4.8-.3.4-.5 1-.5 1.7v1.4c0 .7-.1 1.3-.5 1.6-.3.4-.8.6-1.5.7 1 .1 1.5.5 1.8 1 .2.4.3 1 .3 1.8v.9c0 .6 0 1.1.3 1.6.3.4.8.9 1.5 1h-.4c-1.2 0-2.1-.4-2.6-1-.2-.5-.4-1.1-.4-2v-1.2c0-.6 0-1-.3-1.3-.3-.3-.8-.5-1.5-.7h-.2l.2-.2a5.5 5.5 0 001.1-.3l.5-.5.2-.5V7.9c0-.9.2-1.6.4-2 .5-.7 1.4-1.1 2.6-1.2h.4V5z\" fill=\"#e2001a\" fill-rule=\"nonzero\"/>\n</svg>"},"$:/plugins/telmiger/EditorCounter/readme":{"title":"$:/plugins/telmiger/EditorCounter/readme","created":"20170209064758307","creator":"Thomas Elmiger","modified":"20200605055914514","modifier":"Thomas Elmiger","tags":"EditorCounter","type":"text/vnd.tiddlywiki","text":"!! Count Your Texts & Autosave\n\n{{$:/plugins/telmiger/EditorCounter/about}}\n\n!!! The counters\n* In edit mode users can see stats concerning the tiddler’s text and title fields. The numbers are updated whenever they pause typing.\n* Counters for //words// and/or //characters// can be activated in the plugin settings.\n* The colours of the counters change at some predefined numbers.\n** Settings for colors and color limits are not available in the plugin configuration. <br>Workaround: edit [[the template|$:/plugins/telmiger/EditorCounter/EditTemplate]].\n\n!!! Autosave\n* When activated in the [[plugin settings|$:/plugins/telmiger/EditorCounter/settings]], //autosave// will try to save the wiki in the background during editing: whenever a predefined number of characters has been added or removed, a save is triggered.\n** As an option you can show a checkbox in the editor to pause/activate automatic saving.\n\n!!! Parameters\n\n|!Parameter |!Description |\n|colors |Optionally, define an array of color and number pairs to set minimal color limits. |\n|colorState |Optional state tiddler to save the color value. |\n|field |Calculate for the text in this field. |\n|mode |Entity to calculate: //word// or //character// or //autosave//. Defaults to \"character\". |\n|savelimit |A number of character changes after which //autosave// is performed. Default value: 200 |\n|text |Calculate this text. |\n|tiddler |Optional title of a tiddler to take the field from. Defaults to current tiddler. |\n\n!!! Widget usage\nThis plugin is based on a similar [[solution by Jed Carty|$:/plugins/telmiger/EditorCounter/credits]] – many thanks! \n\nThe widget can be used in other contexts than the plugin. The usage would be very similar to [[Jed’s examples on ooktech.com|http://ooktech.com/jed/ExampleWikis/WordCount/#%24%3A%2Fplugins%2Finmysocks%2FWordCount%2FWord%20Count%20Widget]] \n\nKnown differences: instead of `<$word-count` start with `<$editor-counter`. Default mode is //character//.\n\n!!!! Widget examples\n\n```\n<$editor-counter tiddler=SomeTiddler field=some_field mode=word/>\n<$editor-counter tiddler=SomeTiddler mode=character colors=\"blue:10,green:50,red:100\"/>\n<$editor-counter text=\"some text string\" mode=character colorState=\"$:/state/someTextColor\" colors=\"blue:10,green:50\"/>\n<$editor-counter mode=autosave savelimit=300/>\n```\n"},"$:/plugins/telmiger/EditorCounter/settings/autosave":{"title":"$:/plugins/telmiger/EditorCounter/settings/autosave","created":"20170303132537685","creator":"Thomas Elmiger","limit":"200","modified":"20200605055914542","modifier":"Thomas Elmiger","tags":"EditorCounter","type":"text/vnd.tiddlywiki","text":"no"},"$:/plugins/telmiger/EditorCounter/settings/characters":{"title":"$:/plugins/telmiger/EditorCounter/settings/characters","created":"20170208063042363","creator":"Thomas Elmiger","modified":"20200605055914567","modifier":"Thomas Elmiger","tags":"EditorCounter","type":"text/vnd.tiddlywiki","text":"yes"},"$:/plugins/telmiger/EditorCounter/settings/title":{"title":"$:/plugins/telmiger/EditorCounter/settings/title","created":"20170208211524752","creator":"Thomas Elmiger","modified":"20200605055914580","modifier":"Thomas Elmiger","tags":"EditorCounter","type":"text/vnd.tiddlywiki","text":"yes"},"$:/plugins/telmiger/EditorCounter/settings/words":{"title":"$:/plugins/telmiger/EditorCounter/settings/words","created":"20170208063040756","creator":"Thomas Elmiger","modified":"20200605055914626","modifier":"Thomas Elmiger","tags":"EditorCounter","type":"text/vnd.tiddlywiki","text":"no"},"$:/plugins/telmiger/EditorCounter/settings":{"title":"$:/plugins/telmiger/EditorCounter/settings","created":"20170208062643245","creator":"Thomas Elmiger","modified":"20200605055914527","modifier":"Thomas Elmiger","tags":"EditorCounter","type":"text/vnd.tiddlywiki","text":"!! Counter Settings\nActivate counters here. Your choice will be visible below the text field in edit mode.\n\n<$checkbox tiddler=\"$:/plugins/telmiger/EditorCounter/settings/characters\" field=\"text\" checked=\"yes\" unchecked=\"no\"> Character counter</$checkbox>\n\n<$checkbox tiddler=\"$:/plugins/telmiger/EditorCounter/settings/words\" field=\"text\" checked=\"yes\" unchecked=\"no\" default=\"no\"> Word counter</$checkbox>\n\n<$checkbox tiddler=\"$:/plugins/telmiger/EditorCounter/settings/title\" field=\"text\" checked=\"yes\" unchecked=\"no\"> Title characters counter</$checkbox>\n\n!! Autosave Settings\nAutosave will try to save your wiki in the background after adding or removing 200 characters. You can change this value below.\n\n<$checkbox tiddler=\"$:/plugins/telmiger/EditorCounter/settings/autosave\" field=\"text\" checked=\"yes\" unchecked=\"no\" default=\"no\"> Autosave</$checkbox>\n every <$edit-text tiddler=\"$:/plugins/telmiger/EditorCounter/settings/autosave\" field=\"limit\" size=\"4\"/> characters.\n\n<$checkbox tiddler=\"$:/plugins/telmiger/EditorCounter/settings/autosave-pause\" field=\"text\" checked=\"yes\" unchecked=\"no\" default=\"no\"> Show checkbox to start/pause autosave in editor</$checkbox>\n\n<br>''\n\n<$button message=\"tm-save-wiki\" param={{$:/config/SaveWikiButton/Template}} tooltip={{$:/language/Buttons/SaveWiki/Hint}} aria-label={{$:/language/Buttons/SaveWiki/Caption}} class=<<tv-config-toolbar-class>>>\n<span class=\"tc-dirty-indicator\">\n<$list filter=\"[<tv-config-toolbar-icons>prefix[yes]]\">\n{{$:/core/images/save-button}} {{$:/language/Buttons/SaveWiki/Hint}}\n</$list>\n<$list filter=\"[<tv-config-toolbar-text>prefix[yes]]\">\n<span class=\"tc-btn-text\"><$text text={{$:/language/Buttons/SaveWiki/Caption}}/></span>\n</$list>\n</span>\n</$button>\n\n''<br>\n\nNote: ''All'' characters are counted as entered in the editor, regardless if they are invisible in the result or if they produce more text based on data or transclusion."},"$:/plugins/telmiger/EditorCounter/support":{"title":"$:/plugins/telmiger/EditorCounter/support","created":"20200524222008409","modified":"20200605055914634","tags":"","type":"text/vnd.tiddlywiki","text":"{{$:/plugins/telmiger/support}}"},"$:/plugins/telmiger/support":{"title":"$:/plugins/telmiger/support","created":"20181103150753927","creator":"Thomas Elmiger","modified":"20200605055914649","modifier":"Thomas Elmiger","tags":"","type":"text/vnd.tiddlywiki","text":"!! Support the Author\n\n''Hi!'' I’m Thomas, the author of [[tid.li/tw5/plugins.html|https://tid.li/tw5/plugins.html]]. Feedback is always welcome, as well as funding for maintenance, support and new projects :)\n\n---\n\n!!! One Time Support\n\nIf using my plugins just makes you happy, consider a one time payment via ~PayPal to reward the effort:\n\nhttps://www.paypal.me/telmiger\n\n---\n\n!!! Permanent Support\n\nIf my tools make you more productive or save you time in your job or your everyday life, you can support me as a Patron: \n\nhttps://www.patreon.com/telmiger\n\n---\n\n!!! Thank You\n\nSubstantial parts of my availabe time go to the deveopment of useful plugins for [[TiddlyWiki|https://tiddlywiki.com/]]. – Many others do the same and I would like to thank them all, especially [[Jeremy Ruston|https://tiddlywiki.com/#JeremyRuston]] and all the active members of the community!\n\n//Hereby I promise to share future revenues (if any) with other developers who’s works I use or who inspired me.//\n\nIf you like my work, I would be very happy to hear from you.\n\n''Thank you very much for your support!''<br>\n//Thomas//\n\nhttps://thomas-elmiger.ch"}}}