moodle_local_treestudyplan/amd/build/downloader.min.js

3 lines
No EOL
1.1 KiB
JavaScript

define("local_treestudyplan/downloader",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.download=function(filename,text,type){null==type&&(type="text/plain");var pom=document.createElement("a");if(pom.setAttribute("href","data:"+type+";charset=utf-8,"+encodeURIComponent(text)),pom.setAttribute("download",filename),document.createEvent){var event=document.createEvent("MouseEvents");event.initEvent("click",!0,!0),pom.dispatchEvent(event)}else pom.click()},_exports.upload=function(onready,accept){var input=document.createElement("input");input.type="file",Array.isArray(accept)?accept.count>0&&(input.accept=accept.join(", ")):void 0!==accept&&(input.accept=accept);if(input.onchange=function(){var files=Array.from(input.files);if(files.length>0){var file=files[0],reader=new FileReader;reader.onload=function(e){var contents=e.target.result;onready instanceof Function&&onready(file,contents)},reader.readAsText(file)}},document.createEvent){var event=document.createEvent("MouseEvents");event.initEvent("click",!0,!0),input.dispatchEvent(event)}else input.click()}}));
//# sourceMappingURL=downloader.min.js.map