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.

116 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 qrCode = document.createElement("div");
  51. qrCode.className = "qrcode";
  52. file.uploadElement.qrCode = qrCode;
  53. file.uploadElement.appendChild(qrCode);
  54. new QRCode(qrCode, resp.url);
  55. var deleteAction = document.createElement("span");
  56. deleteAction.innerHTML = "Delete";
  57. deleteAction.className = "cancel";
  58. deleteAction.addEventListener('click', function(ev) {
  59. xhr = new XMLHttpRequest();
  60. xhr.open("DELETE", resp.url, true);
  61. xhr.setRequestHeader("Linx-Delete-Key", resp.delete_key);
  62. xhr.onreadystatechange = function(file) {
  63. if (xhr.readyState == 4 && xhr.status === 200) {
  64. var text = document.createTextNode("Deleted ");
  65. file.fileLabel.insertBefore(text, file.fileLabelLink);
  66. file.fileLabel.className = "deleted";
  67. file.fileActions.removeChild(file.cancelActionElement);
  68. file.uploadElement.qrCode.remove();
  69. }
  70. }.bind(this, file);
  71. xhr.send();
  72. });
  73. file.fileActions.removeChild(file.cancelActionElement);
  74. file.cancelActionElement = deleteAction;
  75. file.fileActions.appendChild(deleteAction);
  76. },
  77. error: function(file, resp, xhrO) {
  78. file.fileActions.removeChild(file.cancelActionElement);
  79. file.fileActions.removeChild(file.progressElement);
  80. if (file.status === "canceled") {
  81. file.fileLabel.innerHTML = file.name + ": Canceled ";
  82. }
  83. else {
  84. if (resp.error) {
  85. file.fileLabel.innerHTML = file.name + ": " + resp.error;
  86. }
  87. else if (resp.includes("<html")) {
  88. file.fileLabel.innerHTML = file.name + ": Server Error";
  89. }
  90. else {
  91. file.fileLabel.innerHTML = file.name + ": " + resp;
  92. }
  93. }
  94. file.fileLabel.className = "error";
  95. },
  96. maxFilesize: Math.round(parseInt(document.getElementById("dropzone").getAttribute("data-maxsize"), 10) / 1024 / 1024),
  97. previewsContainer: "#uploads",
  98. parallelUploads: 5,
  99. headers: {"Accept": "application/json"},
  100. dictDefaultMessage: "Click or Drop file(s)",
  101. dictFallbackMessage: ""
  102. };
  103. // @end-license