1 | const tiny = { |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
2 | filepicker: function(title, url, suffix) { |
||
3 | return function(callback, value, meta) { |
||
4 | var height = Math.min(document.body.clientHeight - 50, 600), |
||
5 | width = Math.min(document.body.clientWidth - 20, 800); |
||
6 | tinymce.activeEditor.windowManager.openUrl({ |
||
7 | title: title, |
||
8 | url: url + meta.filetype + '/' + suffix, |
||
9 | width: width, |
||
10 | height: height, |
||
11 | onMessage: function(dialog, args) { |
||
12 | callback(args.data.url, args.data); |
||
13 | } |
||
14 | }); |
||
15 | }; |
||
16 | }, |
||
17 | image_upload_handler: function(url) { |
||
18 | return function(blobInfo, success, failure) { |
||
19 | var xhr, formData; |
||
20 | xhr = new XMLHttpRequest(); |
||
21 | xhr.withCredentials = true; |
||
22 | xhr.open('POST', url); |
||
23 | xhr.onload = function() { |
||
24 | var json; |
||
25 | if (xhr.status != 200) { |
||
26 | failure('HTTP Error: ' + xhr.status); |
||
27 | return; |
||
28 | } |
||
29 | |||
30 | json = JSON.parse(xhr.responseText); |
||
31 | |||
32 | if (!json || typeof json.location != 'string') { |
||
33 | failure('Invalid JSON: ' + xhr.responseText); |
||
34 | return; |
||
35 | } |
||
36 | |||
37 | success(json.location); |
||
38 | }; |
||
39 | |||
40 | formData = new FormData(); |
||
41 | formData.append('file', blobInfo.blob(), blobInfo.filename()); |
||
42 | xhr.send(formData); |
||
43 | }; |
||
44 | } |
||
45 | }; |
||
46 |