Contains the Concourse pipeline definition for building a line-server container
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.7 KiB

  1. // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
  2. Dropzone.options.dropzone = {
  3. init: function() {
  4. },
  5. addedfile: function(file) {
  6. var upload = document.createElement("div");
  7. upload.className = "upload";
  8. var fileLabel = document.createElement("span");
  9. fileLabel.innerHTML = file.name;
  10. file.fileLabel = fileLabel;
  11. upload.appendChild(fileLabel);
  12. var fileActions = document.createElement("div");
  13. fileActions.className = "right";
  14. file.fileActions = fileActions;
  15. upload.appendChild(fileActions);
  16. var cancelAction = document.createElement("span");
  17. cancelAction.className = "cancel";
  18. cancelAction.innerHTML = "Cancel";
  19. cancelAction.addEventListener('click', function(ev) {
  20. this.removeFile(file);
  21. }.bind(this));
  22. file.cancelActionElement = cancelAction;
  23. fileActions.appendChild(cancelAction);
  24. var progress = document.createElement("span");
  25. file.progressElement = progress;
  26. fileActions.appendChild(progress);
  27. file.uploadElement = upload;
  28. document.getElementById("uploads").appendChild(upload);
  29. },
  30. uploadprogress: function(file, p, bytesSent) {
  31. p = parseInt(p);
  32. file.progressElement.innerHTML = p + "%";
  33. file.uploadElement.setAttribute("style", 'background-image: -webkit-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -moz-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -ms-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -o-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%)');
  34. },
  35. sending: function(file, xhr, formData) {
  36. formData.append("randomize", document.getElementById("randomize").checked);
  37. formData.append("expires", document.getElementById("expires").selectedOptions[0].value);
  38. },
  39. success: function(file, resp) {
  40. file.fileActions.removeChild(file.progressElement);
  41. var fileLabelLink = document.createElement("a");
  42. fileLabelLink.href = resp.url;
  43. fileLabelLink.target = "_blank";
  44. fileLabelLink.innerHTML = resp.url;
  45. file.fileLabel.innerHTML = "";
  46. file.fileLabelLink = fileLabelLink;
  47. file.fileLabel.appendChild(fileLabelLink);
  48. var deleteAction = document.createElement("span");
  49. deleteAction.innerHTML = "Delete";
  50. deleteAction.className = "cancel";
  51. deleteAction.addEventListener('click', function(ev) {
  52. xhr = new XMLHttpRequest();
  53. xhr.open("DELETE", resp.url, true);
  54. xhr.setRequestHeader("X-Delete-Key", resp.delete_key);
  55. xhr.onreadystatechange = function(file) {
  56. if (xhr.readyState == 4 && xhr.status === 200) {
  57. var text = document.createTextNode("Deleted ");
  58. file.fileLabel.insertBefore(text, file.fileLabelLink);
  59. file.fileLabel.className = "deleted";
  60. file.fileActions.removeChild(file.cancelActionElement);
  61. }
  62. }.bind(this, file);
  63. xhr.send();
  64. });
  65. file.fileActions.removeChild(file.cancelActionElement);
  66. file.cancelActionElement = deleteAction;
  67. file.fileActions.appendChild(deleteAction);
  68. },
  69. error: function(file, resp, xhrO) {
  70. file.fileActions.removeChild(file.cancelActionElement);
  71. file.fileActions.removeChild(file.progressElement);
  72. if (file.status === "canceled") {
  73. file.fileLabel.innerHTML = file.name + ": Canceled ";
  74. }
  75. else {
  76. file.fileLabel.innerHTML = file.name + ": " + resp.error;
  77. }
  78. file.fileLabel.className = "error";
  79. },
  80. maxFilesize: 4096,
  81. previewsContainer: "#uploads",
  82. parallelUploads: 5,
  83. headers: {"Accept": "application/json"},
  84. dictDefaultMessage: "Click or Drop file(s)",
  85. dictFallbackMessage: ""
  86. };
  87. // @end-license