From b908343a12e7b323a9907c4f7802b3292df5cd54 Mon Sep 17 00:00:00 2001 From: kanadeko Date: Sat, 14 Jan 2017 06:16:47 -0300 Subject: [PATCH] Removed unused files --- .DS_Store | Bin 10244 -> 6148 bytes README.md | 2 +- public/.DS_Store | Bin 8196 -> 8196 bytes public/index.html | 65 +-------------------------- public/js/envResolver.js | 83 ---------------------------------- public/js/pureupload.min.js | 1 - public/js/queueRenderer.js | 87 ------------------------------------ public/js/upload.js | 56 +++++++++++++++++++++++ 8 files changed, 59 insertions(+), 235 deletions(-) delete mode 100644 public/js/envResolver.js delete mode 100755 public/js/pureupload.min.js delete mode 100644 public/js/queueRenderer.js create mode 100644 public/js/upload.js diff --git a/.DS_Store b/.DS_Store index e7e02f687353b2fe2b799630ce208aadad547b6a..b5ffce1ccffd85e918e3889913eba55036db4449 100644 GIT binary patch delta 223 zcmZn(XfcprU|?W$DortDU=RQ@Ie-{MGjUE#6q~50D9Qwq2a9DgBqx;@7bNB6Cv8kz z&N$gXg+-E$p@5;3A&DV}0ZA69=E z3MR&8wY35*930Y`rjEXm1+`s^7B5-4Z25}AM<-he%QGIEd_zKhW6E)s#q1m$g3Le@ ofk1#8NVtOBwlVQL^JIP%N08$|u44hwK$n7C4;I@T&ohS^0P3nSUjP6A literal 10244 zcmeHMU2GIp6h3DubY@%OwzRS=f}7R~k`?;Hj}3p@c11`bG_<7@3hV67*bdCjY<6b5 z{5AH?pI|gG8Z`p`^7m*Y@kxU*>Wd~465+u_qrUiNc+emZo;!E8&ThN%q?kA}nS1WN z=bU@aeDlrRy>|fsdkbm@KnwsRy0~QZRLpU3J-=ohA+P5Fl1TnwjCTxXtZZ(UWzZ2I z5FijB5FijB5FqehL4f9Len@pf24#RifIxu23WP>#|ldsTQ0J!1Z%|o$f$0epyScs>@CI_5^C) z;*NEY0SioUAWzbuQ=^()9=*1|x}`6dv$sz1A*+q)%j_e5i%8-x$$On zzFf}rtfiiFrasGb6y4PFKG(4k-Bhh&uT?Nr zdu&jQH=?V~M2a;J8`mW0`~c2`$AI*#zHCYI=7ylCg|J*0fWsA)^?Xf}uEC zk700Qd%vR{b9n85ZRMRl*D%Fc!PfR_WT#JRNwOx_Mvl*(oTFQ&y-&;ABwG{h;-=)w z_07>0t*ajG+_?GreG3<{aAUY>WRe4EXv0O0@u*^FG*i{h@dJds>F7`CT3&7lZIXvf zC94UqC6T2vyCRLL6mqwvavRmvM3zLBOVUB!-*ih1%A-dLvJ0#XGk4%dD5S{D78>9w|%lm0_GD{iSqPsh?Nn&40 zhk5K>itX&lX(ol=vUMAyta_{6r6i4Vj~-RkRH-$w$^(k=pD;_I1=hi47=TfFk&AE| zUV&HPZMX~{z(?>Yd<9>_H*gKUh40}9_z`}BU*R_V0e4Ws25iJ8Y{n?I;zRf_uEaR5 z#|`)xcH=hOfjhAuci|8o!o#Rw8jqrb1uWt*d^4*%51*S5-&NUS&h(khl!8-L4YZuE7oX z4t|DT;5P)K*g}lp3VaY-h+=KH2G?Q-cH%nRf?F|xJ=jMC+l_m00QcfS93!Hoh-ycO zYFRWfhsW^*p28`78lT1I@HD=FFB0)y$2agzJcH*eD7T|THX-psCFOi`Rp~cH86|zQ z_ndnFoaC)L%KRq>^QK{$;}n;_2DLO><=i=4p_j94RuvgmTKMzx=I@Fz{29(|QJ$k0 zClCPw0RjO60RjO6_YQ%1B6N)J|36;+|NncJU=TS#AVAT1eN03U@o6q`MtY4Zic_u8gVA+e&c#64cNAr-h^%9sl~D0m1q|SpS>< H@Adzmgw`T| diff --git a/README.md b/README.md index e4760af..4ed8b7a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![loli-safe](https://i.imgur.com/YqO1nuc.png) +![loli-safe](https://i.kanacchi.moe/m9pi.png) # loli-safe Pomf-like image uploading service, written in NodeJS diff --git a/public/.DS_Store b/public/.DS_Store index 213a4b963884d931bbf6022081d4deb826eed035..0a0d8a3119046464c821a02369a2ba25da959105 100644 GIT binary patch delta 254 zcmZp1XmQwZPE3~JXHr2wP^8@rOTGDIDC`=3>X<9G=ngdhEc~R UzZRF7SgEv`UE(;~K-n%20B2=7NdN!< delta 387 zcmZp1XmQwZPRyH8I;kKhv$({-;1(kjGYcylI|nBhHxDm2uK*7(FL!KkMt*s4Nn%N9 zu~TAEynsw_W=d*OVo`WzN=ZgYYMyIOYFTQYf00jON$O+)@ubOt0um7%0tYxbIO7E* zs;dnx40IHX&CF|c6spb5fov0Fv)WotP7V%PZLhGT%C^a?w;w)o?D&b3Po6$w00Txw v2+be@rD4?b$tT5SHnU3{XQPFy3u)zQp!1m+vKWfXf{XHU^7GPxe25PLTb*Nx diff --git a/public/index.html b/public/index.html index dcd4697..bbf12e1 100644 --- a/public/index.html +++ b/public/index.html @@ -5,6 +5,7 @@ + @@ -39,7 +40,7 @@

- +

@@ -50,67 +51,5 @@ - - \ No newline at end of file diff --git a/public/js/envResolver.js b/public/js/envResolver.js deleted file mode 100644 index a7419b4..0000000 --- a/public/js/envResolver.js +++ /dev/null @@ -1,83 +0,0 @@ -var http = function (url, success, failure) { - var request = new XMLHttpRequest(); - request.open("GET", url, true); - request.send(null); - request.onreadystatechange = function () { - if (request.readyState == 4) { - if (request.status == 200) - success(request.responseText); - else if (failure) - failure(request.status, request.statusText); - } - }; -}; -var mockXhr = function () { - XMLHttpRequest = XhrMock; - FormData = FormDataMock; -}; -var resolveEnvironment = function () { - if (window.location.href.toString().toLowerCase().indexOf('file://') >= 0) { - mockXhr(); - return; - } - http('api/check', function (result) { - if (result !== 'API OK') - mockXhr(); - }, function () { - mockXhr(); - }); -}; -var FormDataMock = (function () { - function FormDataMock() { - this.data = {}; - } - FormDataMock.prototype.append = function (key, data, additional) { - this.data[key] = { data: data, additional: additional }; - }; - return FormDataMock; -})(); -var XhrMock = (function () { - function XhrMock() { - this.loaded = 0; - this.step = 2000000; - this.readyState = 0; - this.status = 0; - this.upload = { onprogress: function () { } }; - } - XhrMock.prototype.open = function (method, url, async) { - }; - XhrMock.prototype.setRequestHeader = function (name, value) { - }; - XhrMock.prototype.send = function (formData) { - this.file = formData.data['file'].data; - this.performStep(); - }; - XhrMock.prototype.abort = function () { - window.clearTimeout(this.timeoutId); - }; - XhrMock.prototype.performStep = function () { - var _this = this; - this.timeoutId = window.setTimeout(function () { - if (_this.addStep() === _this.file.size) { - _this.readyState = 4; - _this.status = 200; - _this.onload(new Event('loaded')); - } - else { - var e = { - lengthComputable: true, - loaded: _this.loaded, - total: _this.file.size - }; - _this.upload.onprogress(e); - _this.performStep(); - } - }, 100); - }; - XhrMock.prototype.addStep = function () { - var newValue = this.loaded + this.step; - this.loaded = newValue > this.file.size ? this.file.size : newValue; - return this.loaded; - }; - return XhrMock; -})(); diff --git a/public/js/pureupload.min.js b/public/js/pureupload.min.js deleted file mode 100755 index 508ffb6..0000000 --- a/public/js/pureupload.min.js +++ /dev/null @@ -1 +0,0 @@ -var pu;!function(t){function e(t,e,i){if(t.addEventListener)t.addEventListener(e,i);else{var o=t;o.attachEvent?o.attachEvent("on"+e,i):o[e]=i}}function i(t,e){var i;return i="object"==typeof t?c(o(u(t),function(t){return"length"!==t}),function(e){return t[e]}):t,n(i,function(t){t.uploadStatus=e||t.uploadStatus,t.responseCode=t.responseCode||0,t.responseText=t.responseText||"",t.progress=t.progress||0,t.sentBytes=t.sentBytes||0,t.cancel=t.cancel||function(){}}),i}function o(t,e){var i=[];return t?(n(t,function(t){e(t)&&i.push(t)}),i):i}function n(t,e){if(t)for(var i=0;ie||0===t.size)},o.prototype.isFileTypeInvalid=function(t){if(t.name&&this.options.accept&&("*"!==this.options.accept.trim()||"*.*"!==this.options.accept.trim())&&this.options.validateExtension&&this.options.accept.indexOf("/")===-1){var e=this.options.accept.split(","),i=t.name.substring(t.name.lastIndexOf("."),t.name.length);if(i.indexOf(".")===-1)return!0;for(var o=!0,n=0;n=0&&(this.uploadAreas[e].destroy(),this.uploadAreas.splice(e,1))},t}();t.Uploader=m;var F=function(){function e(t,e){this.queuedFiles=[],this.options=t,this.callbacks=e,this.setFullOptions(),this.setFullCallbacks()}return e.prototype.addFiles=function(t){var e=this;n(t,function(t){e.queuedFiles.push(t),t.remove=s(t.remove,function(){e.removeFile(t)}),e.callbacks.onFileAddedCallback&&e.callbacks.onFileAddedCallback(t),t.uploadStatus===g.failed?e.callbacks.onErrorCallback&&e.callbacks.onErrorCallback(t):t.uploadStatus=g.queued}),this.filesChanged()},e.prototype.removeFile=function(t,e){void 0===e&&(e=!1);var i=p(this.queuedFiles,t);i<0||(this.deactivateFile(t),this.queuedFiles.splice(i,1),this.callbacks.onFileRemovedCallback&&this.callbacks.onFileRemovedCallback(t),e||this.filesChanged())},e.prototype.clearFiles=function(t,e){var i=this;void 0===t&&(t=[]),void 0===e&&(e=!1),e||(t=t.concat([g.queued,g.uploading])),n(o(this.queuedFiles,function(e){return p(t,e.uploadStatus)<0}),function(t){return i.removeFile(t,!0)}),this.callbacks.onQueueChangedCallback&&this.callbacks.onQueueChangedCallback(this.queuedFiles)},e.prototype.filesChanged=function(){this.options.autoRemove&&this.removeFinishedFiles(),this.options.autoStart&&this.startWaitingFiles(),this.callbacks.onQueueChangedCallback&&this.callbacks.onQueueChangedCallback(this.queuedFiles),this.checkAllFinished()},e.prototype.checkAllFinished=function(){var t=o(this.queuedFiles,function(t){return p([g.queued,g.uploading],t.uploadStatus)>=0});0===t.length&&this.callbacks.onAllFinishedCallback&&this.callbacks.onAllFinishedCallback()},e.prototype.setFullOptions=function(){this.options.maxParallelUploads=this.options.maxParallelUploads||0,this.options.autoStart=t.isFileApi&&(this.options.autoStart||!1),this.options.autoRemove=this.options.autoRemove||!1},e.prototype.setFullCallbacks=function(){var t=this;this.callbacks.onFileAddedCallback=this.callbacks.onFileAddedCallback||function(){},this.callbacks.onFileRemovedCallback=this.callbacks.onFileRemovedCallback||function(){},this.callbacks.onAllFinishedCallback=this.callbacks.onAllFinishedCallback||function(){},this.callbacks.onQueueChangedCallback=this.callbacks.onQueueChangedCallback||function(){},this.callbacks.onFileStateChangedCallback=function(){return t.filesChanged()}},e.prototype.startWaitingFiles=function(){n(this.getWaitingFiles(),function(t){return t.start()})},e.prototype.removeFinishedFiles=function(){var t=this;n(o(this.queuedFiles,function(t){return p([g.uploaded,g.canceled],t.uploadStatus)>=0}),function(e){return t.removeFile(e,!0)})},e.prototype.deactivateFile=function(t){t.uploadStatus===g.uploading&&t.cancel(),t.uploadStatus=g.removed,t.cancel=function(){},t.remove=function(){},t.start=function(){}},e.prototype.getWaitingFiles=function(){if(!this.options.autoStart)return[];var t=o(this.queuedFiles,function(t){return t.uploadStatus===g.queued});if(this.options.maxParallelUploads>0){var e=o(this.queuedFiles,function(t){return t.uploadStatus===g.uploading}).length,i=this.options.maxParallelUploads-e;if(i<=0)return[];t=t.slice(0,i)}return t},e}();t.UploadQueue=F;var g;!function(t){t[t.queued=0]="queued",t[t.uploading=1]="uploading",t[t.uploaded=2]="uploaded",t[t.failed=3]="failed",t[t.canceled=4]="canceled",t[t.removed=5]="removed"}(g=t.UploadStatus||(t.UploadStatus={}))}(pu||(pu={})); \ No newline at end of file diff --git a/public/js/queueRenderer.js b/public/js/queueRenderer.js deleted file mode 100644 index ae06531..0000000 --- a/public/js/queueRenderer.js +++ /dev/null @@ -1,87 +0,0 @@ -var getQueueRenderer = function () { - return new QueueRenderer(); -}; -var QueueRenderer = (function () { - function QueueRenderer() { - } - QueueRenderer.prototype.createTextDiv = function (className, value) { - var element = document.createElement("div"); - element.className = className; - element.innerHTML = value; - return element; - }; - QueueRenderer.prototype.createButton = function (value, callback) { - var element = document.createElement("button"); - element.className = "table-row-button"; - element.innerHTML = value; - element.addEventListener("click", callback); - return element; - }; - QueueRenderer.prototype.createQueueRow = function (file, queueSettings) { - var itemRow = document.createElement("div"); - itemRow.id = file.guid; - itemRow.className = "table-row-item"; - this.renderQueueRowContent(itemRow, file, queueSettings); - return itemRow; - }; - QueueRenderer.prototype.translateFileStatus = function (file) { - console.log(file) - console.log(pu) - switch (file.uploadStatus.toString()) { - case pu.UploadStatus.queued: - return "Queued"; - case pu.UploadStatus.uploading: - return "Uploading"; - case pu.UploadStatus.uploaded: - return "Uploaded"; - case pu.UploadStatus.failed: - return "Failed"; - case pu.UploadStatus.canceled: - return "Canceled"; - } - return "Unknown"; - }; - QueueRenderer.prototype.renderQueueRowContent = function (itemRow, file, queueSettings) { - while (itemRow.firstChild) - itemRow.removeChild(itemRow.firstChild); - itemRow.appendChild(this.createTextDiv('table-row-item-status', this.translateFileStatus(file))); - itemRow.appendChild(this.createTextDiv('table-row-item-name', file.name)); - itemRow.appendChild(this.createTextDiv('table-row-item-progress', file.progress.toString() + "%")); - switch (file.uploadStatus.toString()) { - case pu.UploadStatus.queued: - if (!queueSettings.autoStart) { - itemRow.appendChild(this.createButton("Start", function () { return file.start(); })); - break; - } - case pu.UploadStatus.uploading: - itemRow.appendChild(this.createButton("Cancel", function () { return file.cancel(); })); - break; - case pu.UploadStatus.uploaded: - case pu.UploadStatus.failed: - case pu.UploadStatus.canceled: - itemRow.appendChild(this.createButton("Delete", function () { return file.remove(); })); - break; - } - }; - QueueRenderer.prototype.renderItemProgress = function (queueId, file) { - var itemRow = document.getElementById(file.guid); - for (var i = 0; i < itemRow.childNodes.length; i++) { - var node = itemRow.childNodes[i]; - if (node.attributes.getNamedItem('class').value == 'table-row-item-progress') { - node.textContent = file.progress.toString() + "%"; - break; - } - } - }; - QueueRenderer.prototype.renderQueue = function (queueId, queueTitle, files, queueSettings) { - var _this = this; - var queue = document.getElementById(queueId); - while (queue.firstChild) - queue.removeChild(queue.firstChild); - queue.appendChild(this.createTextDiv("table-header-title", queueTitle)); - files.forEach(function (file) { - queue.appendChild(_this.createQueueRow(file, queueSettings)); - }); - }; - return QueueRenderer; -})(); diff --git a/public/js/upload.js b/public/js/upload.js new file mode 100644 index 0000000..4795679 --- /dev/null +++ b/public/js/upload.js @@ -0,0 +1,56 @@ +var maxSize = '512'; +var urlPrefix = ''; + +var xhr = new XMLHttpRequest(); +xhr.onreadystatechange = function() { + if (xhr.readyState == XMLHttpRequest.DONE) { + if(xhr.responseText !== 'not-authorized'){ + document.getElementById('btnGithub').style.display = 'none'; + document.getElementById('dropzone').style.display = 'flex'; + } + if(xhr.responseText.maxFileSize) + maxSize = xhr.responseText.maxFileSize; + if(xhr.responseText.urlPrefix) + urlPrefix = xhr.responseText.urlPrefix + '/'; + } +} +xhr.open('GET', '/api/info', true); +xhr.send(null); + +window.onload = function () { + + var previewNode = document.querySelector("#template"); + previewNode.id = ""; + var previewTemplate = previewNode.parentNode.innerHTML; + previewNode.parentNode.removeChild(previewNode); + + var dropzone = new Dropzone('div#dropzone', { + url: '/api/upload', + paramName: 'file', + maxFilesize: maxSize, + parallelUploads: 2, + uploadMultiple: false, + previewsContainer: 'div#uploads', + previewTemplate: previewTemplate, + createImageThumbnails: false, + maxFiles: 1000, + autoProcessQueue: true + }); + + // Update the total progress bar + dropzone.on("uploadprogress", function(file, progress) { + file.previewElement.querySelector(".progress").style.width = progress + "%"; + }); + + dropzone.on("success", function(file, response) { + // Handle the responseText here. For example, add the text to the preview element: + a = document.createElement('a'); + a.href = window.location.origin + '/' + urlPrefix + response.filename; + a.target = '_blank'; + a.innerHTML = response.filename; + + file.previewTemplate.querySelector(".progress").style.display = 'none'; + file.previewTemplate.querySelector(".link").appendChild(a); + }); + +}; \ No newline at end of file