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.

80 lines
3.0 KiB

  1. Dropzone.options.dropzone = {
  2. init: function() {
  3. },
  4. addedfile: function(file) {
  5. var upload = document.createElement("div");
  6. upload.className = "upload";
  7. var left = document.createElement("span");
  8. left.innerHTML = file.name;
  9. file.leftElement = left;
  10. upload.appendChild(left);
  11. var right = document.createElement("div");
  12. right.className = "right";
  13. var rightleft = document.createElement("span");
  14. rightleft.className = "cancel";
  15. rightleft.innerHTML = "Cancel";
  16. rightleft.onclick = function(ev) {
  17. this.removeFile(file);
  18. }.bind(this);
  19. var rightright = document.createElement("span");
  20. right.appendChild(rightleft);
  21. file.rightLeftElement = rightleft;
  22. right.appendChild(rightright);
  23. file.rightRightElement = rightright;
  24. file.rightElement = right;
  25. upload.appendChild(right);
  26. file.uploadElement = upload;
  27. document.getElementById("uploads").appendChild(upload);
  28. },
  29. uploadprogress: function(file, p, bytesSent) {
  30. p = parseInt(p);
  31. file.rightRightElement.innerHTML = p + "%";
  32. 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 + '%)');
  33. },
  34. sending: function(file, xhr, formData) {
  35. formData.append("randomize", document.getElementById("randomize").checked);
  36. formData.append("expires", document.getElementById("expires").selectedOptions[0].value);
  37. },
  38. success: function(file, resp) {
  39. file.rightLeftElement.innerHTML = "";
  40. file.leftElement.innerHTML = '<a target="_blank" href="' + resp.url + '">' + resp.url + '</a>';
  41. file.rightRightElement.innerHTML = "Delete";
  42. file.rightRightElement.className = "cancel";
  43. file.rightRightElement.onclick = function(ev) {
  44. xhr = new XMLHttpRequest();
  45. xhr.open("DELETE", resp.url, true);
  46. xhr.setRequestHeader("X-Delete-Key", resp.delete_key);
  47. xhr.onreadystatechange = function(file) {
  48. if (xhr.status === 200) {
  49. file.leftElement.innerHTML = 'Deleted <a target="_blank" href="' + resp.url + '">' + resp.url + '</a>';
  50. file.leftElement.className = "deleted";
  51. file.rightRightElement.onclick = null;
  52. file.rightRightElement.innerHTML = "";
  53. }
  54. }.bind(this, file);
  55. xhr.send();
  56. }.bind(this);
  57. },
  58. error: function(file, resp, xhrO) {
  59. file.rightLeftElement.onclick = null;
  60. file.rightLeftElement.innerHTML = "";
  61. file.rightRightElement.innerHTML = "";
  62. if (file.status === "canceled") {
  63. file.leftElement.innerHTML = file.name + ": Canceled ";
  64. }
  65. else {
  66. file.leftElement.innerHTML = file.name + ": " + resp.error;
  67. }
  68. file.leftElement.className = "error";
  69. },
  70. maxFilesize: 4096,
  71. previewsContainer: "#uploads",
  72. parallelUploads: 5,
  73. headers: {"Accept": "application/json"},
  74. dictDefaultMessage: "Click or Drop file(s)",
  75. dictFallbackMessage: ""
  76. };