Action

Footnote 2

Posted by @davenicholls, Last update over 5 years ago

Prompts for the footnote text and adds both the inline element ( [^xxx] ) and footnote at the end of the draft ( [^xxx]:)

‘xxx’ is a randomly generated 3 character string.

Returns you to where you left off to continue typing.

Steps

  • script

    
    
    var p = Prompt.create();
    p.isCancellable = "true";
    p.title = "Enter the footnote text";
    p.addTextField("footnote","","",{"wantsFocus":true});
    p.addButton("Add");
    
    if (p.show()) {
    
      var content = editor.getText();
     
      do {
        var fn = Math.random().toString(36).substring(2,5);
        srch=new RegExp ("\\[\\^"+fn+"\\]")
      }
      while (content.match(srch));
      
      var selRange = editor.getSelectedRange();
      
      editor.focus();
      var inline = "[^"+fn+"]";
      var footnote = "\n[^"+fn+"]: "+p.fieldValues["footnote"];
    
      if (p.buttonPressed == "Add") {
        editor.setSelectedText(inline);
    
        content = editor.getText() + footnote;
        editor.setText(content);
        editor.setSelectedRange(selRange[0]+inline.length,0);
    
      }
    
    }

Options

  • After Success Nothing
    Notification None
    Log Level None
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.