| 53 | }); |
| 54 | |
| 55 | const parseImgurResponseJSON = responseJSON => { |
| 56 | try { |
| 57 | return JSON.parse(responseJSON); |
| 58 | } catch (error) { |
| 59 | $imgur_status.text("Received an invalid JSON response from Imgur: "); |
| 60 | // .append($(E("pre")).text(responseJSON)); |
| 61 | |
| 62 | // show_error_message("Received an invalid JSON response from Imgur: ", responseJSON); |
| 63 | // show_error_message("Received an invalid JSON response from Imgur: ", responseJSON, but also error); |
| 64 | // $imgur_window.close(); |
| 65 | |
| 66 | // @TODO: DRY, including with show_error_message |
| 67 | $(E("pre")) |
| 68 | .appendTo($imgur_status) |
| 69 | .text(responseJSON) |
| 70 | .css({ |
| 71 | background: "white", |
| 72 | color: "#333", |
| 73 | fontFamily: "monospace", |
| 74 | width: "500px", |
| 75 | overflow: "auto", |
| 76 | }); |
| 77 | $(E("pre")) |
| 78 | .appendTo($imgur_status) |
| 79 | .text(error.toString()) |
| 80 | .css({ |
| 81 | background: "white", |
| 82 | color: "#333", |
| 83 | fontFamily: "monospace", |
| 84 | width: "500px", |
| 85 | overflow: "auto", |
| 86 | }); |
| 87 | $imgur_window.css({ width: "auto" }); |
| 88 | $imgur_window.center(); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | // make an HTTP request to the Imgur image upload API |
| 93 | |