1
0
Fork 0
mirror of https://github.com/marty-oehme/scripts.git synced 2024-12-22 07:58:08 +00:00

added note stats script

This commit is contained in:
Patrizio Bekerle 2017-05-16 22:52:35 +02:00
parent 1cef1ce59f
commit cd07cd2a82
No known key found for this signature in database
GPG key ID: 2E9FFD770DABE838
2 changed files with 36 additions and 0 deletions

7
note-stats/info.json Normal file
View file

@ -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 <i>label</i>."
}

29
note-stats/note-stats.qml Normal file
View file

@ -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",
"<table align=center width=90%>
<tr>
<td align=center>Char(+s) <b>" + note.noteText.length + "</b></th>
<td align=center>Char(s) <b>" + note.noteText.match(/[^ ]/gi).length + "</b></th>
<td align=center>Words <b>" + note.noteText.split(/\s+/).length + "</b></th>
<td align=center>Paras <b>" + (note.noteText.match(/^.*?\S/gm) || "").length + "</b></th>
</tr>
</table>")
}
function noteOpenedHook(note) {noteStats(note)}
function onNoteStored(note) {noteStats(note)}
}