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.

100 lines
3.7 KiB

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