Simple shortcut replacement

Hi, here you go: https://actions.getdrafts.com/a/1VS

Personally I use the Share Action with this script (I didn‘t share it because its not very well developed baut ist works:) ):

var p = Prompt.create();
p.title = "Share draft:";
p.message = "Select an option or cancel if you need the draft later.";
var buttonArray = ["iMessage","WhatsApp","Clipboard","E-Mail"];

for(str in buttonArray)
{
	p.addButton(buttonArray[str]);
}

//p.addButton
//p.addButton("iMessage");
//p.addButton("Clipboard");

var didSelect = p.show();

if(didSelect == true)
{
	var selection = p.buttonPressed;
	
	if (selection == "iMessage")
	{
		var msg = Message.create();
 		msg.body = draft.content;
		var result = msg.send();
		if (result == true)
		{
			app.displaySuccessMessage("successfully sent iMessage");
		} else
		{
			app.displayWarningMessage("did not sent the iMessage");
		}
		
	} else if (selection == "Clipboard")
	{
		app.setClipboard(draft.content);
	} else if (selection == "E-Mail")
	{
		var mail = Mail.create();
		var mailP = Prompt.create();
		mailP.title = "E-Mail Subject";
		mailP.message = "select subject for your E-Mail";

		mailP.addButton("use custom subject");
		mailP.addTextField("custom subject","custom subject","");
		mailP.addButton("use title of draft");		
		var titleIsSubject = 0;
		var mailPdidSelect = mailP.show();
		if(mailPdidSelect == true)
		{
			var mailPselection = mailP.buttonPressed;
			var subject;
			if(mailPselection == "use title of draft")
			{
				subject = draft.title;
				titleIsSubject = 1;
			} else if (mailPselection == "use custom subject")
			{
				subject = mailP.fieldValues["custom subject"];
			}
			mail.subject = subject;
			
		}
		
		if(titleIsSubject == 1)
		{
			mail.body = draft.processTemplate("[[body]]");
		} else
		{
			mail.body = draft.content;
		}
		var result = mail.send();
		
	} else if (selection == "WhatsApp") {
		if (device.model == "iPhone") {
			app.openURL("whatsapp://send?text=" + encodeURI(draft.content));
		} else {
			alert("WhatsApp is only possible on iPhone");
			context.fail("Share via WhatsApp is not possible on" + device.model + ".");
		}
		
	}
	
}
2 Likes