Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

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