$(document).ready(function() { new AjaxUpload('#uploadImageFile', { action: '/files/new', name: 'FileData', data: { 'FileData.Name': 'FakeName', 'IsAjax': 'true' }, hoverClass: "", responseType: 'xml', onComplete: function(file, response) { var processedData = Core.AjaxManager.processXml(response); if (processedData.data.IsSuccess) { var state = new Attacklab.TextareaState(); if (!state) { return; } var chunk = state.getChunks(); var makeLinkMarkdown = function(link) { if (link !== null) { chunk.startTag = chunk.endTag = ""; var linkDef = " [999]: " + link; var num = Attacklab.Command.addLinkDef(chunk, linkDef); chunk.startTag = "!["; chunk.endTag = "][" + num + "]"; if (!chunk.selection) { chunk.selection = "alt text"; } } }; makeLinkMarkdown(processedData.data.Path); if (chunk) { state.setChunks(chunk); } state.restore(); } } }); new AjaxUpload('#uploadFile', { action: '/files/new', name: 'FileData', data: { 'FileData.Name': 'FakeName', 'IsAjax': 'true' }, hoverClass: "hover", responseType: 'xml', onComplete: function(file, response) { var processedData = Core.AjaxManager.processXml(response); if (processedData.data.IsSuccess) { var state = new Attacklab.TextareaState(); if (!state) { return; } var chunk = state.getChunks(); var makeLinkMarkdown = function(link) { if (link !== null) { chunk.startTag = chunk.endTag = ""; chunk.startTag = "\n\n["; chunk.endTag = "]\n\n"; chunk.selection = "f#" + processedData.data.FileId; } }; makeLinkMarkdown(processedData.data.Path); if (chunk) { state.setChunks(chunk); } state.restore(); } } }); });