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.

136 lines
5.0 KiB

  1. // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
  2. var qrCodeCheckbox = document.getElementById("qrcode-show");
  3. if (qrCodeCheckbox !== null) {
  4. qrCodeCheckbox.addEventListener('change', function() {
  5. var qrCodeCheckbox = document.getElementById("qrcode-show");
  6. if (qrCodeCheckbox == null) {
  7. return;
  8. }
  9. var qrCodes = document.getElementsByClassName('qrcode');
  10. for(var i=0; i<qrCodes.length; i++) {
  11. qrCodes[i].style.display = qrCodeCheckbox.checked ? "block" : "none";
  12. }
  13. })
  14. }
  15. Dropzone.options.dropzone = {
  16. init: function() {
  17. var dzone = document.getElementById("dzone");
  18. dzone.style.display = "block";
  19. },
  20. addedfile: function(file) {
  21. var upload = document.createElement("div");
  22. upload.className = "upload";
  23. var fileLabel = document.createElement("span");
  24. fileLabel.innerHTML = file.name;
  25. file.fileLabel = fileLabel;
  26. upload.appendChild(fileLabel);
  27. var fileActions = document.createElement("div");
  28. fileActions.className = "right";
  29. file.fileActions = fileActions;
  30. upload.appendChild(fileActions);
  31. var cancelAction = document.createElement("span");
  32. cancelAction.className = "cancel";
  33. cancelAction.innerHTML = "Cancel";
  34. cancelAction.addEventListener('click', function(ev) {
  35. this.removeFile(file);
  36. }.bind(this));
  37. file.cancelActionElement = cancelAction;
  38. fileActions.appendChild(cancelAction);
  39. var progress = document.createElement("span");
  40. file.progressElement = progress;
  41. fileActions.appendChild(progress);
  42. file.uploadElement = upload;
  43. document.getElementById("uploads").appendChild(upload);
  44. },
  45. uploadprogress: function(file, p, bytesSent) {
  46. p = parseInt(p);
  47. file.progressElement.innerHTML = p + "%";
  48. 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 + '%)');
  49. },
  50. sending: function(file, xhr, formData) {
  51. formData.append("randomize", document.getElementById("randomize").checked);
  52. formData.append("expires", document.getElementById("expires").value);
  53. },
  54. success: function(file, resp) {
  55. file.fileActions.removeChild(file.progressElement);
  56. var fileLabelLink = document.createElement("a");
  57. fileLabelLink.href = resp.url;
  58. fileLabelLink.target = "_blank";
  59. fileLabelLink.innerHTML = resp.url;
  60. file.fileLabel.innerHTML = "";
  61. file.fileLabelLink = fileLabelLink;
  62. file.fileLabel.appendChild(fileLabelLink);
  63. var qrCode = document.createElement("div");
  64. qrCode.className = "qrcode";
  65. file.uploadElement.qrCode = qrCode;
  66. // Determine if the QR code should be shown or not
  67. var qrCodeCheckbox = document.getElementById("qrcode-show");
  68. if (qrCodeCheckbox !== null) {
  69. qrCode.style.display = qrCodeCheckbox.checked ? "block" : "none";
  70. }
  71. file.uploadElement.appendChild(qrCode);
  72. new QRCode(qrCode, resp.url);
  73. var deleteAction = document.createElement("span");
  74. deleteAction.innerHTML = "Delete";
  75. deleteAction.className = "cancel";
  76. deleteAction.addEventListener('click', function(ev) {
  77. xhr = new XMLHttpRequest();
  78. xhr.open("DELETE", resp.url, true);
  79. xhr.setRequestHeader("Linx-Delete-Key", resp.delete_key);
  80. xhr.onreadystatechange = function(file) {
  81. if (xhr.readyState == 4 && xhr.status === 200) {
  82. var text = document.createTextNode("Deleted ");
  83. file.fileLabel.insertBefore(text, file.fileLabelLink);
  84. file.fileLabel.className = "deleted";
  85. file.fileActions.removeChild(file.cancelActionElement);
  86. file.uploadElement.qrCode.remove();
  87. }
  88. }.bind(this, file);
  89. xhr.send();
  90. });
  91. file.fileActions.removeChild(file.cancelActionElement);
  92. file.cancelActionElement = deleteAction;
  93. file.fileActions.appendChild(deleteAction);
  94. },
  95. error: function(file, resp, xhrO) {
  96. file.fileActions.removeChild(file.cancelActionElement);
  97. file.fileActions.removeChild(file.progressElement);
  98. if (file.status === "canceled") {
  99. file.fileLabel.innerHTML = file.name + ": Canceled ";
  100. }
  101. else {
  102. if (resp.error) {
  103. file.fileLabel.innerHTML = file.name + ": " + resp.error;
  104. }
  105. else if (resp.includes("<html")) {
  106. file.fileLabel.innerHTML = file.name + ": Server Error";
  107. }
  108. else {
  109. file.fileLabel.innerHTML = file.name + ": " + resp;
  110. }
  111. }
  112. file.fileLabel.className = "error";
  113. },
  114. maxFilesize: Math.round(parseInt(document.getElementById("dropzone").getAttribute("data-maxsize"), 10) / 1024 / 1024),
  115. previewsContainer: "#uploads",
  116. parallelUploads: 5,
  117. headers: {"Accept": "application/json"},
  118. dictDefaultMessage: "Click or Drop file(s)",
  119. dictFallbackMessage: ""
  120. };
  121. // @end-license