Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

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