changed in node tool
added: filter on notes title added: put modified note on top
This commit is contained in:
		
							parent
							
								
									d7127b3188
								
							
						
					
					
						commit
						7d551915bf
					
				| 
						 | 
					@ -9,6 +9,7 @@ var rl = readline.createInterface({
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var settings = JSON.parse(fs.readFileSync("settings.json", { encoding: "utf8", flag: "r" }));
 | 
					var settings = JSON.parse(fs.readFileSync("settings.json", { encoding: "utf8", flag: "r" }));
 | 
				
			||||||
 | 
					var filter = process.argv.length > 2 ? process.argv[2] : "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
axios.post(`${settings.url}/handler.php`,
 | 
					axios.post(`${settings.url}/handler.php`,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -24,7 +25,10 @@ axios.post(`${settings.url}/handler.php`,
 | 
				
			||||||
.then(res =>
 | 
					.then(res =>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	var notes = res.data;
 | 
						var notes = res.data;
 | 
				
			||||||
	notes.every( (note, i) =>
 | 
					
 | 
				
			||||||
 | 
						notes
 | 
				
			||||||
 | 
						.filter(n => n.title.includes(filter))
 | 
				
			||||||
 | 
						.every( (note, i) =>
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		console.log(`[${i}] ${note.title}`)
 | 
							console.log(`[${i}] ${note.title}`)
 | 
				
			||||||
		return i < settings.maxcount;
 | 
							return i < settings.maxcount;
 | 
				
			||||||
| 
						 | 
					@ -33,7 +37,7 @@ axios.post(`${settings.url}/handler.php`,
 | 
				
			||||||
	rl.prompt();
 | 
						rl.prompt();
 | 
				
			||||||
	rl.on("line", (line) =>
 | 
						rl.on("line", (line) =>
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		var note = notes[line]
 | 
							var note = notes.filter(n => n.title.includes(filter))[line];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fs.writeFileSync("note.md", note.content);
 | 
							fs.writeFileSync("note.md", note.content);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,6 +48,10 @@ axios.post(`${settings.url}/handler.php`,
 | 
				
			||||||
			if (note.content != newcontent)
 | 
								if (note.content != newcontent)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				note.content = newcontent;
 | 
									note.content = newcontent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									notes.splice(notes.indexOf(note), 1);
 | 
				
			||||||
 | 
									notes.unshift(note);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				axios.post(`${settings.url}/handler.php`,
 | 
									axios.post(`${settings.url}/handler.php`,
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					action: "push",
 | 
										action: "push",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue