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.
 
 
 

159 lines
5.8 KiB

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