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.

119 lines
4.3 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. var dzone = document.getElementById("dzone");
  5. dzone.style.display = "block";
  6. },
  7. addedfile: function(file) {
  8. var upload = document.createElement("div");
  9. upload.className = "upload";
  10. var fileLabel = document.createElement("span");
  11. fileLabel.innerHTML = file.name;
  12. file.fileLabel = fileLabel;
  13. upload.appendChild(fileLabel);
  14. var fileActions = document.createElement("div");
  15. fileActions.className = "right";
  16. file.fileActions = fileActions;
  17. upload.appendChild(fileActions);
  18. var cancelAction = document.createElement("span");
  19. cancelAction.className = "cancel";
  20. cancelAction.innerHTML = "Cancel";
  21. cancelAction.addEventListener('click', function(ev) {
  22. this.removeFile(file);
  23. }.bind(this));
  24. file.cancelActionElement = cancelAction;
  25. fileActions.appendChild(cancelAction);
  26. var progress = document.createElement("span");
  27. file.progressElement = progress;
  28. fileActions.appendChild(progress);
  29. file.uploadElement = upload;
  30. document.getElementById("uploads").appendChild(upload);
  31. },
  32. uploadprogress: function(file, p, bytesSent) {
  33. p = parseInt(p);
  34. file.progressElement.innerHTML = p + "%";
  35. 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 + '%)');
  36. },
  37. sending: function(file, xhr, formData) {
  38. formData.append("randomize", document.getElementById("randomize").checked);
  39. formData.append("expires", document.getElementById("expires").value);
  40. },
  41. success: function(file, resp) {
  42. file.fileActions.removeChild(file.progressElement);
  43. var fileLabelLink = document.createElement("a");
  44. fileLabelLink.href = resp.url;
  45. fileLabelLink.target = "_blank";
  46. fileLabelLink.innerHTML = resp.url;
  47. file.fileLabel.innerHTML = "";
  48. file.fileLabelLink = fileLabelLink;
  49. file.fileLabel.appendChild(fileLabelLink);
  50. var deleteAction = document.createElement("span");
  51. deleteAction.innerHTML = "Delete";
  52. deleteAction.className = "cancel";
  53. deleteAction.addEventListener('click', function(ev) {
  54. xhr = new XMLHttpRequest();
  55. xhr.open("DELETE", resp.url, true);
  56. xhr.setRequestHeader("Linx-Delete-Key", resp.delete_key);
  57. xhr.onreadystatechange = function(file) {
  58. if (xhr.readyState == 4 && xhr.status === 200) {
  59. var text = document.createTextNode("Deleted ");
  60. file.fileLabel.insertBefore(text, file.fileLabelLink);
  61. file.fileLabel.className = "deleted";
  62. file.fileActions.removeChild(file.cancelActionElement);
  63. }
  64. }.bind(this, file);
  65. xhr.send();
  66. });
  67. file.fileActions.removeChild(file.cancelActionElement);
  68. file.cancelActionElement = deleteAction;
  69. file.fileActions.appendChild(deleteAction);
  70. },
  71. error: function(file, resp, xhrO) {
  72. file.fileActions.removeChild(file.cancelActionElement);
  73. file.fileActions.removeChild(file.progressElement);
  74. if (file.status === "canceled") {
  75. file.fileLabel.innerHTML = file.name + ": Canceled ";
  76. }
  77. else {
  78. if (resp.error) {
  79. file.fileLabel.innerHTML = file.name + ": " + resp.error;
  80. }
  81. else if (resp.includes("<html")) {
  82. file.fileLabel.innerHTML = file.name + ": Server Error";
  83. }
  84. else {
  85. file.fileLabel.innerHTML = file.name + ": " + resp;
  86. }
  87. }
  88. file.fileLabel.className = "error";
  89. },
  90. maxFilesize: Math.round(parseInt(document.getElementById("dropzone").getAttribute("data-maxsize"), 10) / 1024 / 1024),
  91. previewsContainer: "#uploads",
  92. parallelUploads: 5,
  93. headers: {"Accept": "application/json"},
  94. dictDefaultMessage: "Click or Drop file(s) or Paste image",
  95. dictFallbackMessage: ""
  96. };
  97. document.onpaste = function(event) {
  98. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  99. for (index in items) {
  100. var item = items[index];
  101. if (item.kind === "file") {
  102. Dropzone.forElement("#dropzone").addFile(item.getAsFile());
  103. }
  104. }
  105. };
  106. // @end-license