2017-04-26, 08:59 PM
I have this code
I add https
' +'https://'+ JSON.parse(xhr.responseText).data.link + '[/img]';
but now the form is https://http://link
how remove http://??
this is js : https://github.com/martec/myinsertbutton...ibutton.js
/* Lets build a FormData object*/
var fd = new FormData(); // I wrote about it: https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
fd.append("image", file); // Append the file
var xhr = new XMLHttpRequest(); // Create the XHR (Cross-Domain XHR FTW!!!) Thank you sooooo much imgur.com
xhr.open("POST", "https://api.imgur.com/3/image.json"); // Boooom!
xhr.onload = function() {
var code = '' +'https://'+ JSON.parse(xhr.responseText).data.link + '[/img]';
$('#message, #signature, textarea[name*="value"]').data('sceditor').insert(code);
var d = document.querySelector(".sceditor-button-imgur div.imgurup");
d.className = d.className - " imgurup";
document.querySelector('input.imgur').remove();
}
// Ok, I don't handle the errors. An exercice for the reader.
xhr.setRequestHeader('Authorization', 'Client-ID '+iclid+'');
/* And now, we send the formdata */
xhr.send(fd);
};
I add https
' +'https://'+ JSON.parse(xhr.responseText).data.link + '[/img]';
but now the form is https://http://link
how remove http://??
this is js : https://github.com/martec/myinsertbutton...ibutton.js