diff --git a/note-stats/info.json b/note-stats/info.json new file mode 100644 index 0000000..87576f3 --- /dev/null +++ b/note-stats/info.json @@ -0,0 +1,7 @@ +{ + "name": "Note stats", + "identifier": "note-stats", + "script": "note-stats.qml", + "version": "0.0.1", + "description" : "This script shows current note statistics in a label." +} diff --git a/note-stats/note-stats.qml b/note-stats/note-stats.qml new file mode 100644 index 0000000..ed108a8 --- /dev/null +++ b/note-stats/note-stats.qml @@ -0,0 +1,29 @@ +import QtQml 2.0 +import com.qownnotes.noteapi 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 +*/ + +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 + " +
") + } + + function noteOpenedHook(note) {noteStats(note)} + function onNoteStored(note) {noteStats(note)} +}