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.

122 lines
4.9 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. var randomize = document.getElementById("randomize");
  39. if(randomize != null) {
  40. formData.append("randomize", randomize.checked);
  41. }
  42. formData.append("expires", document.getElementById("expires").value);
  43. },
  44. success: function(file, resp) {
  45. file.fileActions.removeChild(file.progressElement);
  46. var fileLabelLink = document.createElement("a");
  47. fileLabelLink.href = resp.url;
  48. fileLabelLink.target = "_blank";
  49. fileLabelLink.innerHTML = resp.url;
  50. file.fileLabel.innerHTML = "";
  51. file.fileLabelLink = fileLabelLink;
  52. file.fileLabel.appendChild(fileLabelLink);
  53. var deleteAction = document.createElement("span");
  54. deleteAction.innerHTML = "Delete";
  55. deleteAction.className = "cancel";
  56. deleteAction.addEventListener('click', function(ev) {
  57. xhr = new XMLHttpRequest();
  58. xhr.open("DELETE", resp.url, true);
  59. xhr.setRequestHeader("Linx-Delete-Key", resp.delete_key);
  60. xhr.onreadystatechange = function(file) {
  61. if (xhr.readyState == 4 && xhr.status === 200) {
  62. var text = document.createTextNode("Deleted ");
  63. file.fileLabel.insertBefore(text, file.fileLabelLink);
  64. file.fileLabel.className = "deleted";
  65. file.fileActions.removeChild(file.cancelActionElement);
  66. }
  67. }.bind(this, file);
  68. xhr.send();
  69. });
  70. file.fileActions.removeChild(file.cancelActionElement);
  71. file.cancelActionElement = deleteAction;
  72. file.fileActions.appendChild(deleteAction);
  73. },
  74. error: function(file, resp, xhrO) {
  75. file.fileActions.removeChild(file.cancelActionElement);
  76. file.fileActions.removeChild(file.progressElement);
  77. if (file.status === "canceled") {
  78. file.fileLabel.innerHTML = file.name + ": Canceled ";
  79. }
  80. else {
  81. if (resp.error) {
  82. file.fileLabel.innerHTML = file.name + ": " + resp.error;
  83. }
  84. else if (resp.includes("<html")) {
  85. file.fileLabel.innerHTML = file.name + ": Server Error";
  86. }
  87. else {
  88. file.fileLabel.innerHTML = file.name + ": " + resp;
  89. }
  90. }
  91. file.fileLabel.className = "error";
  92. },
  93. maxFilesize: Math.round(parseInt(document.getElementById("dropzone").getAttribute("data-maxsize"), 10) / 1024 / 1024),
  94. previewsContainer: "#uploads",
  95. parallelUploads: 5,
  96. headers: {"Accept": "application/json"},
  97. dictDefaultMessage: "Click or Drop file(s) or Paste image",
  98. dictFallbackMessage: ""
  99. };
  100. document.onpaste = function(event) {
  101. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  102. for (index in items) {
  103. var item = items[index];
  104. if (item.kind === "file") {
  105. Dropzone.forElement("#dropzone").addFile(item.getAsFile());
  106. }
  107. }
  108. };
  109. // @end-license