Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

121 řádky
4.4 KiB

  1. $(document).ready(function () {
  2. // Terminal typing animation
  3. $("#from-terminal p").typed({
  4. strings: ["curl --upload-file ./hello.txt https://transfer.sh/hello.txt\n######################################################\nhttps://transfer.sh/66nb8/hello.txt \n "],
  5. typeSpeed: 0, // typing speed
  6. backSpeed: 0, // backspacing speed
  7. startDelay: 0, // time before typing starts
  8. backDelay: 500, // pause before backspacing
  9. loop: false, // loop on or off (true or false)
  10. loopCount: false, // number of loops, false = infinite
  11. showCursor: true,
  12. attr: null, // attribute to type, null = text for everything except inputs, which default to placeholder
  13. callback: function(){ } // call function after typing is done
  14. });
  15. // Smooth scrolling
  16. $('a[href*=#]:not([href=#])').click(function () {
  17. if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
  18. var target = $(this.hash);
  19. target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
  20. if (target.length) {
  21. $('html,body').animate({
  22. scrollTop: target.offset().top
  23. }, 1000);
  24. return false;
  25. }
  26. }
  27. });
  28. // function resizePages() {
  29. // var h = $(window).height();
  30. // var height = h < 600 ? 600 : h;
  31. /* $('section').css('height',height);
  32. $('#home').css('height',height*0.98);
  33. }
  34. resizePages();*/
  35. });
  36. (function () {
  37. var files = Array()
  38. function upload(file) {
  39. var li = $('<li style="clear:both;"/>');
  40. li.append($('<div><div class="progress active upload-progress" style="margin-bottom: 0;"><div class="progress-bar bar" style="width: 0%;"></div></div><p>Uploading... ' + file.name + '</p></div>'));
  41. $(li).appendTo($('.queue'));
  42. var xhr = new XMLHttpRequest();
  43. xhr.upload.addEventListener("progress", function (e) {
  44. var pc = parseInt((e.loaded / e.total * 100));
  45. $('.upload-progress', $(li)).show();
  46. $('.upload-progress .bar', $(li)).css('width', pc + "%");
  47. }, false);
  48. xhr.onreadystatechange = function (e) {
  49. if (xhr.readyState == 4) {
  50. $('.upload-progress', $(li)).hide();
  51. $('#web').addClass('uploading');
  52. // progress.className = (xhr.status == 200 ? "success" : "failure");
  53. if (xhr.status == 200) {
  54. $(li).html('<a target="_blank" href="' + xhr.responseText + '">' + xhr.responseText + '</a>');
  55. } else {
  56. $(li).html('<span>Error (' + xhr.status + ') during upload of file ' + file.name + '</span>');
  57. }
  58. files.push(xhr.responseText.replace("https://transfer.sh/", "").replace("\n", ""));
  59. // files.push(URI(xhr.responseText).absoluteTo(location.href).toString());
  60. $(".download-zip").attr("href", URI("(" + files.join(",") + ").zip").absoluteTo(location.href).toString());
  61. $(".download-tar").attr("href", URI("(" + files.join(",") + ").tar.gz").absoluteTo(location.href).toString());
  62. $(".all-files").css("opacity", "1");
  63. }
  64. };
  65. // should queue all uploads.
  66. // start upload
  67. xhr.open("PUT", '/' + file.name, true);
  68. xhr.setRequestHeader("X_FILENAME", file.name);
  69. xhr.send(file);
  70. };
  71. $(document).bind("dragenter", function (event) {
  72. event.preventDefault();
  73. }).bind("dragover", function (event) {
  74. event.preventDefault();
  75. // show drop indicator
  76. }).bind("dragleave", function (event) {}).bind("drop dragdrop", function (event) {
  77. var files = event.originalEvent.target.files || event.originalEvent.dataTransfer.files;
  78. $.each(files, function (index, file) {
  79. console.debug(file);
  80. upload(file);
  81. });
  82. event.stopPropagation();
  83. event.preventDefault();
  84. });
  85. $('a.browse').on('click', function (event) {
  86. $("input[type=file]").click();
  87. return (false);
  88. });
  89. $('input[type=file]').on('change', function (event) {
  90. $.each(this.files, function (index, file) {
  91. if (file instanceof Blob) {
  92. upload(file);
  93. }
  94. });
  95. });
  96. })();