(body, onStatus, onNoUrl)
| 679 | }); |
| 680 | } |
| 681 | function niNotifyUploadSuccessToEditor(body, onStatus, onNoUrl) { |
| 682 | onStatus = onStatus || function () {}; |
| 683 | var urls = collectUrls(body, []); |
| 684 | var seen = {}; |
| 685 | var uniq = []; |
| 686 | urls.forEach(function (u) { |
| 687 | if (!seen[u]) { |
| 688 | seen[u] = true; |
| 689 | uniq.push(u); |
| 690 | } |
| 691 | }); |
| 692 | var mainUrl = uniq[0] || ''; |
| 693 | if (mainUrl) { |
| 694 | var mdSnippet = formatSnippet('md', mainUrl); |
| 695 | if (!insertIntoForumEditor(mdSnippet + '\n')) { |
| 696 | copyText( |
| 697 | mdSnippet, |
| 698 | function () { |
| 699 | onStatus('已复制 MD 格式'); |
| 700 | }, |
| 701 | function () { |
| 702 | onStatus('复制失败', true); |
| 703 | } |
| 704 | ); |
| 705 | } |
| 706 | } else { |
| 707 | if (typeof onNoUrl === 'function') onNoUrl(body); |
| 708 | else onStatus('上传成功(响应中无图片链接)', true); |
| 709 | } |
| 710 | } |
| 711 | var NS_NI_UPLOAD_PROG_STYLE_ID = 'ns-ni-upload-prog-styles'; |
| 712 | function niEnsureUploadProgressStyles() { |
| 713 | if (document.getElementById(NS_NI_UPLOAD_PROG_STYLE_ID)) return; |
no test coverage detected