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.
 
 
 

167 lines
5.6 KiB

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