mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
Removed unused files
This commit is contained in:
parent
3b648ab45e
commit
b908343a12
@ -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
|
||||
|
||||
|
BIN
public/.DS_Store
vendored
BIN
public/.DS_Store
vendored
Binary file not shown.
@ -5,6 +5,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.0/css/bulma.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css">
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js"></script>
|
||||
<script type="text/javascript" src="/js/upload.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -39,7 +40,7 @@
|
||||
<p data-dz-name></p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<progress class="progress is-primary" value="100" max="100" data-dz-uploadprogress></progress>
|
||||
<progress class="progress is-danger" value="100" max="100" data-dz-uploadprogress></progress>
|
||||
<p data-dz-errormessage></p>
|
||||
<p class="link"></p>
|
||||
</div>
|
||||
@ -50,67 +51,5 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var maxSize = '512';
|
||||
var urlPrefix = '';
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE) {
|
||||
console.log(xhr.responseText)
|
||||
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);
|
||||
});
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -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;
|
||||
})();
|
1
public/js/pureupload.min.js
vendored
1
public/js/pureupload.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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;
|
||||
})();
|
56
public/js/upload.js
Normal file
56
public/js/upload.js
Normal file
@ -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);
|
||||
});
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user