Action Directory / Move To File

Install

Shared by dg.account

Script

list = ["Books", "Movies - Favourites", "Movies - Unwatched", "Novels - Favourites", "Novels - Summer", "Novels - Unfavourites", "Novels - Winter", "Quotes - Emily", "Quotes"];

ui.list("Lookup", list, false, lookup);

function lookup(selectedValues) {
	if (selectedValues) {
		range = editor.getSelectedLineRange();
		line = editor.getTextInRange(range[0], range[1]);

		http.request({
			url: 'https://hooks.zapier.com/hooks/catch/1158354/93vgr8',
			data: {'filename': (selectedValues[0]), 'text': '\n' + line}
		}, function(data) {
		});

		text = editor.getText() // ; IMPORTANT: uncomment this semicolon

		if (range[1] < text.length) {
			editor.replaceTextInRange(range[0], range[1] + 1, "");
		} else {
			editor.replaceTextInRange(range[0] - 1, range[1], "");
		}
	}
}