Action
Bookends-Referenz
Posted by suavito,
Last update
over 1 year ago
- Unlisted
v1.1 – ONLY ALMOST READY FOR USE VERSION!
The Template Tag theReference holds a single reference in Bookends style (ike {Jelinek, 2022, #255414}. The reference of the text you are reading at the present time.
TheReferenceLanguage is … the language of the reference. This is important for dictating. If left empfy, dictating will use your phone’s default language.
The action starts with you inserting the page number/range.
Then you can choose to write, dictate, or scan the excerpt.
After you have done so the excerpt will get inserted in an existing draft or a new one, followed by ]ref] and the reference, including the page number/Range.
Steps
-
defineTemplateTag
name theReference
template {Jelinek, 2022, #255414}
-
defineTemplateTag
name theReferenceLanguage
template -
script
//Getting Template Tags in theReference = draft.getTemplateTag("theReference"); theReferenceLanguage = draft.getTemplateTag("theReferenceLanguage"); //Trimming of the theReference for convenience: theOpeningDelimiterLength = theReference.search(/[a-zA-Z]/); //Add error message & cancel if no reference pattern! theReferenceID = theReference.split("#")[1]; theClosingDelimiterLength = theReferenceID.length - theReferenceID.search(/[^0-9]/); theOpeningDelimiter = theReference.substring(0, theOpeningDelimiterLength); theClosingDelimiter = theReference.substring(theReference.length - theClosingDelimiterLength); theTrimmedReference = theReference.substring(theOpeningDelimiterLength, theReference.length - theClosingDelimiterLength); // Prompting the theReference: var thePrompt = Prompt.create(); thePrompt.title = theTrimmedReference; thePrompt.addTextField("thePageField", "Page(s):", "", { "keyboard": "numbersAndPunctuation", "wantsFocus": true }); thePrompt.addButton("Write"); thePrompt.addButton("Scan"); thePrompt.addButton("Dictate"); var isSelected = thePrompt.show(); if (isSelected) { var thePage = thePrompt.fieldValues["thePageField"]; var theButtonPressed = thePrompt.buttonPressed; // Inserting the reference footnote theSelection = editor.getSelectedRange(); editor.setSelectedRange((theSelection[0] + theSelection[1]), 0); editor.setSelectedText("[^ref]"); theCompleteText = editor.getText(); editor.setSelectedRange(theCompleteText.length, 0); if ((thePage != undefined) && thePage != null && (thePage != "")) { editor.setSelectedText("\n\n[^ref]:" + theOpeningDelimiter + theTrimmedReference + "@" + thePage + theClosingDelimiter); } else { editor.setSelectedText("\n\n[^ref]:" + theOpeningDelimiter + theTrimmedReference + theClosingDelimiter); } editor.setSelectedRange((theSelection[0] + theSelection[1]), 0); // Generating and inserting the excerpt theExcerpt = ""; if (theButtonPressed == "Dictate") { theExcerpt = editor.dictate(theReferenceLanguage); } if (theButtonPressed == "Scan") { theExcerpt = editor.scanDocument(); } editor.setSelectedText(theExcerpt); editor.setSelectedRange((theSelection[0] + theSelection[1]), 0); editor.activate(); editor.save; }
Options
-
After Success Default , Tags: exzerpt Notification Info Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.