MarkItUp Markdown footnote button

Here's a simple addition to markItUp, that will prompt the user for a footnote number, a footnote text and then insert the number after the selection and the footnote text at the end of the full text. As handy extra feature, the plugin will save the previous entered footnote and not ask for further numbers during the session, but instead increment the number each time the button is pressed.

Add this to your code to set.js inside your settings object:

 {name:'Insert footnote',  
    beforeInsert: function(h) {  
        instructions = "Type in the number of the footnote:)";  
        if (!h.last_footnote) {  
            h.last_footnote = prompt(instructions);  
        } else {  
            if (!isNaN(h.last_footnote))  
                h.last_footnote = parseInt(h.last_footnote) +1;  
            else  
                h.last_footnote = prompt(instructions);  
        }  
        h.footnote_content = prompt("Type in the text of the footnote:");  
    },  
    closeWith: function(h) {  
        return '[^' + h.last_footnote + ']';  
    },  
    afterInsert: function(h) {  
        h.textarea.value += '[^' + h.last_footnote + ']: ' +  
            h.footnote_content;  
    }},

And put this icon in the set's images folder: footnote

After that be sure to modify style.css so it says something like (if 14 was the placement of the footnote button):

.markItUp .markItUpButton14 a   {  
    background-image:url(images/footnote.png);  
}