File: onsave-setup_journal_notebook.js

package info (click to toggle)
nixnote2 2.1.6%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,916 kB
  • sloc: cpp: 79,037; java: 1,096; sh: 275; ansic: 10; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 849 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* 
   This is a sample exit. It is called when a note's contents 
   are saved. It just looks for a note that starts 
   with a day of the week, followed by month, day & year. For 
   example, "Monday, January 2, 2017". If this string is 
   found at the beginning of a note it is assigned to the 
   "Journal" notebook. 
*/
var dateCreated = new Date(note.getCreatedDate("yyyy-MM-dd"));

var contents = note.getContentsPlainText().split(" ");
var dow = contents[0];
if (dow === "Monday," || dow === "Tuesday," || dow === "Wednesday" || dow === "Thursday," ||
    dow === "Friday," || dow === "Saturday," || dow === "Sunday,") {
    var month = contents[1];
    var day = contents[2];
    var year = contents[3];
    day = day.substring(0,day.length-1);
    var newDate = new Date(month + " " +day + " " + year);
    note.setNotebook("Journal");
}