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.
 
 
 

148 lines
5.1 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. */
  16. var typewriter = require('typewriter');
  17. var twSpan = document.getElementById('terminal');
  18. var tw = typewriter(twSpan).withAccuracy(100)
  19. .withMinimumSpeed(17)
  20. .withMaximumSpeed(25)
  21. .build();
  22. tw.put('$ ')
  23. .waitRange(500, 1000)
  24. .type('curl --upload-file ./hello.txt https://transfer.sh/hello.txt')
  25. .put('<br/>')
  26. .waitRange(1000, 1500)
  27. .type('$ #######################')
  28. .put('<br/>')
  29. .waitRange(1000, 1500)
  30. .type('$ https://transfer.sh/66nb8/hello.txt ')
  31. .put('<br/>')
  32. // Smooth scrolling
  33. $('a[href*=#]:not([href=#])').click(function() {
  34. if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
  35. var target = $(this.hash);
  36. target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
  37. if (target.length) {
  38. $('html,body').animate({
  39. scrollTop: target.offset().top
  40. }, 1000);
  41. return false;
  42. }
  43. }
  44. });
  45. // function resizePages() {
  46. // var h = $(window).height();
  47. // var height = h < 600 ? 600 : h;
  48. /* $('section').css('height',height);
  49. $('#home').css('height',height*0.98);
  50. }
  51. resizePages();*/
  52. });
  53. (function() {
  54. var files = Array()
  55. function upload(file) {
  56. $('.browse').addClass('uploading');
  57. var li = $('<li style="clear:both;"/>');
  58. 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>'));
  59. $(li).appendTo($('.queue'));
  60. var xhr = new XMLHttpRequest();
  61. xhr.upload.addEventListener("progress", function(e) {
  62. var pc = parseInt((e.loaded / e.total * 100));
  63. $('.upload-progress', $(li)).show();
  64. $('.upload-progress .bar', $(li)).css('width', pc + "%");
  65. }, false);
  66. xhr.onreadystatechange = function(e) {
  67. if (xhr.readyState == 4) {
  68. $('.upload-progress', $(li)).hide();
  69. $('#web').addClass('uploading');
  70. // progress.className = (xhr.status == 200 ? "success" : "failure");
  71. if (xhr.status == 200) {
  72. $(li).html('<a target="_blank" href="' + xhr.responseText + '">' + xhr.responseText + '</a>');
  73. } else {
  74. $(li).html('<span>Error (' + xhr.status + ') during upload of file ' + file.name + '</span>');
  75. }
  76. files.push(xhr.responseText.replace("https://transfer.sh/", "").replace("\n", ""));
  77. // files.push(URI(xhr.responseText).absoluteTo(location.href).toString());
  78. $(".download-zip").attr("href", URI("(" + files.join(",") + ").zip").absoluteTo(location.href).toString());
  79. $(".download-tar").attr("href", URI("(" + files.join(",") + ").tar.gz").absoluteTo(location.href).toString());
  80. $(".all-files").addClass('show');
  81. }
  82. };
  83. // should queue all uploads.
  84. // start upload
  85. xhr.open("PUT", '/' + file.name, true);
  86. xhr.setRequestHeader("X_FILENAME", file.name);
  87. xhr.send(file);
  88. };
  89. $(document).bind("dragenter", function(event) {
  90. event.preventDefault();
  91. }).bind("dragover", function(event) {
  92. event.preventDefault();
  93. // show drop indicator
  94. $('#web').addClass('dragged');
  95. }).bind("dragleave", function(event) {
  96. $('#web').removeClass('dragged');
  97. console.log('asdasd');
  98. }).bind("drop dragdrop", function(event) {
  99. var files = event.originalEvent.target.files || event.originalEvent.dataTransfer.files;
  100. $.each(files, function(index, file) {
  101. console.debug(file);
  102. upload(file);
  103. });
  104. event.stopPropagation();
  105. event.preventDefault();
  106. });
  107. $('a.browse').on('click', function(event) {
  108. $("input[type=file]").click();
  109. return (false);
  110. });
  111. $('input[type=file]').on('change', function(event) {
  112. $.each(this.files, function(index, file) {
  113. if (file instanceof Blob) {
  114. upload(file);
  115. }
  116. });
  117. });
  118. })();