The editor's picture of this site is uploaded by this part
Seajs defines Tools module
/** * Created by zhaojunlike on 8/22/2017. */Define (function, exports, module) {/** * Screenshot Paste * @Param Selector * @param callback */Exp */Exp Orts.paaste = Function (Selector , callback) {document.queryselector (selector) .adDeventListener (Paste, Function (EV) {var data = EV.ClipboardData; var ITEMS = (Event.clipboarddata || EVEN t.originalevent.clipboarddata) .Items; for (var I in items) {var item = items [i]; // If it is the picture if (item.kind === 'file' && itempe.indexof ('iMage')> -1) {var blob = item.getasFile ( ); Var Reader = New Filereader (); After the read is completed, XHR uploads Reader.onload = Function (Event) {var base64 = event.target.Result; upload pictures // return a base64 data data VAR img = {type: item.type, kind: item.kind}; if (typeof callback === land) {callback (event.target.Result, img, event); // data uRL! Reader.readasdataURL (Blob); // Reader}});};/** * Drag the upload * @param selector * @param callback */exports.drag = function (selector, callback) {VAR ELEMENT = DOCU MENT.QUERYSELECTOR (Selector );; Drop, Function (E) {e.preventdeFault (); var files = e.datatransfer.files; for (var I = 0; i <files.Length; i ++) {// back file // file // file // Alert (drop + file [i] .name.tostring ()); VAR Reader = New FileRereader (); VAR Item = Files [i]; Reader.onload = Function (EVENT) {Var Base64 = Event.target. result; // Return to a base64 data varg = {type: item.type, name: item.name}; if (typeof callback === land) {callback (event.target.result, img, event); }}; Reader .readasdataurl (FILES [i]); // Reader} Return false;}); Element.addeventListener (DRAGENTER, FUNCTION (E) {e.stoppropagation (); ;}); Element.addeventListener (Dragover , Function (E) {e.datatransfer.dropeffect = Copy; e.stoppropagation (); e.preventDefault ();}); (E) {e.stoppropagation (); e. PreventDefault (); Return false;});} / *** analyzes the contents of the passed, to see if there is no picture on this site, analyze it and upload it to this site* / exports.parseimg = function () {}});
How to use:
// Paste up upload pictures Edtools.paSte (#Post_Content, Function (Base64, Image, Event) {$ .post ({: url ('api/uploader/upEditorimg')}, {Base: Base64}, Base64}, Base64}, Function (RET) { Layer.msg (RET.MSG); if (RET.CODE === 1) {// The picture of the new line shows the editor.insertValue (/n! [ + RET.Data.TITLE +] ( + RET.Data.Path +));}});}); // Drag the upload image Edtools.drag (#Post_Content, Function (Base64, Image, Event) {$ .post ({: URL ('API/UPLOADER/UPEDITORIMG')) } , {Base: Base64}, Function (RET) {layer.msg (ret.msg); if (RET.Code === 1) {// The picture of the new line shows the editor.insertvalue (/n! [ + Ret. data.title +] ( + Ret.data.path +);}});});
The above is all the contents of this article. I hope it will be helpful to everyone's learning. I also hope that everyone will support VEVB Wulin.com.