diff --git a/note-stats/note-stats.qml b/note-stats/note-stats.qml index ed108a8..5fb1ed3 100644 --- a/note-stats/note-stats.qml +++ b/note-stats/note-stats.qml @@ -1,29 +1,216 @@ import QtQml 2.0 -import com.qownnotes.noteapi 1.0 +import QOwnNotesTypes 1.0 -/* This script shows current note statistics in a "label": - Char(+s) = characters including spaces - Char(−s) = characters excluding spaces - Words = character groups divided by spaces - Paras = paragraphs - character groups divided by line breaks -*/ +Script { + + property string charSpaceName + property string charSpaceLeftName + property int charSpaceLeftTarget + property string charNoSpaceName + property string charNoSpaceLeftName + property int charNoSpaceLeftTarget + property string wordsName + property string wordsLeftName + property int wordsLeftTarget + property string paragraphsName + property string paragraphsLeftName + property int paragraphsLeftTarget + property string readTimeName + property int readTimeRate + + property variant settingsVariables: [ + { + "identifier": "charSpaceName", + "name": "Characters including spaces counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "Chars", + }, + { + "identifier": "charSpaceLeftName", + "name": "Characters including spaces left until target counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "", + }, + { + "identifier": "charSpaceLeftTarget", + "name": "Target number of characters including spaces", + "description": "Put number of characters including spaces to count down to", + "type": "integer", + "default": "0", + }, + { + "identifier": "charNoSpaceName", + "name": "Characters without spaces counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "", + }, + { + "identifier": "charNoSpaceLeftName", + "name": "Characters without spaces left until target counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "", + }, + { + "identifier": "charNoSpaceLeftTarget", + "name": "Target number of characters without spaces", + "description": "Put number of characters without spaces to count down to", + "type": "integer", + "default": "0", + }, + { + "identifier": "wordsName", + "name": "Words counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "Words", + }, + { + "identifier": "wordsLeftName", + "name": "Words left until target counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "", + }, + { + "identifier": "wordsLeftTarget", + "name": "Target number of words", + "description": "Put number of words to count down to", + "type": "integer", + "default": "0", + }, + { + "identifier": "paragraphsName", + "name": "Paragraphs counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "", + }, + { + "identifier": "paragraphsLeftName", + "name": "Paragraphs left until target counter name", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "", + }, + { + "identifier": "paragraphsLeftTarget", + "name": "Target number of paragraphs", + "description": "Put number of paragraphs to count down to", + "type": "integer", + "default": "0", + }, + { + "identifier": "readTimeName", + "name": "Expected time to read a note", + "description": "Put a counter name here or leave empty to disable", + "type": "string", + "default": "Reading time", + }, + { + "identifier": "readTimeRate", + "name": "Reading speed rate in words per minute", + "description": "Adjust reading time counter from declamation (120-180) to speed reading (>300)", + "type": "integer", + "default": "300", + } + ] + + function init() { script.registerLabel("note stats") } + + function sec2time(seconds) { + var hours = Math.floor(seconds / 3600) + var minutes = Math.floor((seconds - (hours * 3600)) / 60) + var seconds = seconds - (hours * 3600) - (minutes * 60) + var time = "" -QtObject { - - function init() {script.registerLabel("note stats")} - - function noteStats(note) { - script.setLabelText("note stats", - "
Char(+s) " + note.noteText.length + " - | Char(−s) " + note.noteText.match(/[^ ]/gi).length + " - | Words " + note.noteText.split(/\s+/).length + " - | Paras " + (note.noteText.match(/^.*?\S/gm) || "").length + " - |