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.

95 lines
3.5 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 fileLabel = document.createElement("span");
  8. fileLabel.innerHTML = file.name;
  9. file.fileLabel = fileLabel;
  10. upload.appendChild(fileLabel);
  11. var fileActions = document.createElement("div");
  12. fileActions.className = "right";
  13. file.fileActions = fileActions;
  14. upload.appendChild(fileActions);
  15. var cancelAction = document.createElement("span");
  16. cancelAction.className = "cancel";
  17. cancelAction.innerHTML = "Cancel";
  18. cancelAction.addEventListener('click', function(ev) {
  19. this.removeFile(file);
  20. }.bind(this));
  21. file.cancelActionElement = cancelAction;
  22. fileActions.appendChild(cancelAction);
  23. var progress = document.createElement("span");
  24. file.progressElement = progress;
  25. fileActions.appendChild(progress);
  26. file.uploadElement = upload;
  27. document.getElementById("uploads").appendChild(upload);
  28. },
  29. uploadprogress: function(file, p, bytesSent) {
  30. p = parseInt(p);
  31. file.progressElement.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.fileActions.removeChild(file.progressElement);
  40. var fileLabelLink = document.createElement("a");
  41. fileLabelLink.href = resp.url;
  42. fileLabelLink.target = "_blank";
  43. fileLabelLink.innerHTML = resp.url;
  44. file.fileLabel.innerHTML = "";
  45. file.fileLabelLink = fileLabelLink;
  46. file.fileLabel.appendChild(fileLabelLink);
  47. var deleteAction = document.createElement("span");
  48. deleteAction.innerHTML = "Delete";
  49. deleteAction.className = "cancel";
  50. deleteAction.addEventListener('click', function(ev) {
  51. xhr = new XMLHttpRequest();
  52. xhr.open("DELETE", resp.url, true);
  53. xhr.setRequestHeader("X-Delete-Key", resp.delete_key);
  54. xhr.onreadystatechange = function(file) {
  55. if (xhr.readyState == 4 && xhr.status === 200) {
  56. var text = document.createTextNode("Deleted ");
  57. file.fileLabel.insertBefore(text, file.fileLabelLink);
  58. file.fileLabel.className = "deleted";
  59. file.fileActions.removeChild(file.cancelActionElement);
  60. }
  61. }.bind(this, file);
  62. xhr.send();
  63. });
  64. file.fileActions.removeChild(file.cancelActionElement);
  65. file.cancelActionElement = deleteAction;
  66. file.fileActions.appendChild(deleteAction);
  67. },
  68. error: function(file, resp, xhrO) {
  69. file.fileActions.removeChild(file.cancelActionElement);
  70. file.fileActions.removeChild(file.progressElement);
  71. if (file.status === "canceled") {
  72. file.fileLabel.innerHTML = file.name + ": Canceled ";
  73. }
  74. else {
  75. file.fileLabel.innerHTML = file.name + ": " + resp.error;
  76. }
  77. file.fileLabel.className = "error";
  78. },
  79. maxFilesize: 4096,
  80. previewsContainer: "#uploads",
  81. parallelUploads: 5,
  82. headers: {"Accept": "application/json"},
  83. dictDefaultMessage: "Click or Drop file(s)",
  84. dictFallbackMessage: ""
  85. };