2014-10-20 15:08:28 +02:00
|
|
|
$(document).ready(function() {
|
2014-10-16 20:01:43 +02:00
|
|
|
|
|
|
|
// Terminal typing animation
|
2014-10-20 15:08:28 +02:00
|
|
|
/* $("#from-terminal p").typed({
|
|
|
|
strings: ["curl --upload-file ./hello.txt https://transfer.sh/hello.txt\n######################################################\nhttps://transfer.sh/66nb8/hello.txt \n "],
|
|
|
|
typeSpeed: 0, // typing speed
|
|
|
|
backSpeed: 0, // backspacing speed
|
|
|
|
startDelay: 0, // time before typing starts
|
|
|
|
backDelay: 500, // pause before backspacing
|
|
|
|
loop: false, // loop on or off (true or false)
|
|
|
|
loopCount: false, // number of loops, false = infinite
|
|
|
|
showCursor: true,
|
|
|
|
attr: null, // attribute to type, null = text for everything except inputs, which default to placeholder
|
|
|
|
callback: function(){ } // call function after typing is done
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
var typewriter = require('typewriter');
|
|
|
|
|
|
|
|
var twSpan = document.getElementById('terminal');
|
|
|
|
|
2014-10-20 16:20:00 +02:00
|
|
|
var tw = typewriter(twSpan).withAccuracy(100)
|
|
|
|
.withMinimumSpeed(17)
|
|
|
|
.withMaximumSpeed(25)
|
2014-10-20 15:08:28 +02:00
|
|
|
.build();
|
2014-10-20 17:23:12 +02:00
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
tw.put('$ ')
|
|
|
|
.waitRange(500, 1000)
|
2014-10-20 16:20:00 +02:00
|
|
|
.type('curl --upload-file ./hello.txt https://transfer.sh/hello.txt')
|
2014-10-20 15:08:28 +02:00
|
|
|
.put('<br/>')
|
2014-10-20 17:23:12 +02:00
|
|
|
.put('https://transfer.sh/66nb8/hello.txt ')
|
|
|
|
.put('<br/>')
|
|
|
|
.put('$ ')
|
|
|
|
.waitRange(500, 1000)
|
|
|
|
.put('<br/>')
|
|
|
|
.put('$ ')
|
|
|
|
.waitRange(500, 1000)
|
|
|
|
.put('<br/>')
|
|
|
|
.put('$ ')
|
|
|
|
.waitRange(500, 1000)
|
|
|
|
.type('transfer hello.txt')
|
|
|
|
.put('<br/>')
|
|
|
|
.type('####################################################')
|
|
|
|
.put(' 100.0%')
|
|
|
|
.put('<br/>')
|
|
|
|
.put('https://transfer.sh/eibhM/hello.txt ')
|
2014-10-20 16:20:00 +02:00
|
|
|
.put('<br/>')
|
2014-10-20 17:23:12 +02:00
|
|
|
.put('$ ')
|
2014-10-20 15:08:28 +02:00
|
|
|
.waitRange(1000, 1500)
|
|
|
|
.put('<br/>')
|
2014-10-20 17:23:12 +02:00
|
|
|
.put('$ ')
|
2014-10-16 20:01:43 +02:00
|
|
|
|
|
|
|
// Smooth scrolling
|
2014-10-20 15:08:28 +02:00
|
|
|
$('a[href*=#]:not([href=#])').click(function() {
|
2014-10-16 20:01:43 +02:00
|
|
|
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
|
|
|
|
var target = $(this.hash);
|
|
|
|
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
|
|
|
if (target.length) {
|
|
|
|
$('html,body').animate({
|
|
|
|
scrollTop: target.offset().top
|
|
|
|
}, 1000);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-10-20 11:15:41 +02:00
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
// function resizePages() {
|
|
|
|
// var h = $(window).height();
|
|
|
|
// var height = h < 600 ? 600 : h;
|
|
|
|
/* $('section').css('height',height);
|
2014-10-20 11:15:41 +02:00
|
|
|
$('#home').css('height',height*0.98);
|
|
|
|
}
|
|
|
|
resizePages();*/
|
2014-10-16 20:01:43 +02:00
|
|
|
});
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
(function() {
|
2014-10-16 20:01:43 +02:00
|
|
|
var files = Array()
|
|
|
|
|
|
|
|
function upload(file) {
|
2014-10-20 15:08:28 +02:00
|
|
|
|
|
|
|
$('.browse').addClass('uploading');
|
2014-10-16 20:01:43 +02:00
|
|
|
var li = $('<li style="clear:both;"/>');
|
2014-10-20 11:15:41 +02:00
|
|
|
|
2014-10-16 21:06:56 +02:00
|
|
|
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>'));
|
2014-10-16 20:01:43 +02:00
|
|
|
$(li).appendTo($('.queue'));
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
xhr.upload.addEventListener("progress", function(e) {
|
2014-10-16 20:01:43 +02:00
|
|
|
var pc = parseInt((e.loaded / e.total * 100));
|
|
|
|
$('.upload-progress', $(li)).show();
|
|
|
|
$('.upload-progress .bar', $(li)).css('width', pc + "%");
|
|
|
|
}, false);
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
xhr.onreadystatechange = function(e) {
|
2014-10-16 20:01:43 +02:00
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
$('.upload-progress', $(li)).hide();
|
2014-10-20 11:15:41 +02:00
|
|
|
$('#web').addClass('uploading');
|
2014-10-16 20:01:43 +02:00
|
|
|
// progress.className = (xhr.status == 200 ? "success" : "failure");
|
|
|
|
if (xhr.status == 200) {
|
2014-10-16 21:25:04 +02:00
|
|
|
$(li).html('<a target="_blank" href="' + xhr.responseText + '">' + xhr.responseText + '</a>');
|
2014-10-16 20:01:43 +02:00
|
|
|
} else {
|
2014-10-16 21:25:04 +02:00
|
|
|
$(li).html('<span>Error (' + xhr.status + ') during upload of file ' + file.name + '</span>');
|
2014-10-16 20:01:43 +02:00
|
|
|
}
|
|
|
|
|
2014-10-16 21:35:37 +02:00
|
|
|
files.push(xhr.responseText.replace("https://transfer.sh/", "").replace("\n", ""));
|
|
|
|
// files.push(URI(xhr.responseText).absoluteTo(location.href).toString());
|
2014-10-16 20:01:43 +02:00
|
|
|
|
|
|
|
$(".download-zip").attr("href", URI("(" + files.join(",") + ").zip").absoluteTo(location.href).toString());
|
|
|
|
$(".download-tar").attr("href", URI("(" + files.join(",") + ").tar.gz").absoluteTo(location.href).toString());
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
$(".all-files").addClass('show');
|
2014-10-16 20:01:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// should queue all uploads.
|
|
|
|
|
|
|
|
// start upload
|
|
|
|
xhr.open("PUT", '/' + file.name, true);
|
|
|
|
xhr.setRequestHeader("X_FILENAME", file.name);
|
|
|
|
xhr.send(file);
|
|
|
|
};
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
$(document).bind("dragenter", function(event) {
|
|
|
|
|
2014-10-16 20:01:43 +02:00
|
|
|
event.preventDefault();
|
2014-10-20 15:08:28 +02:00
|
|
|
}).bind("dragover", function(event) {
|
2014-10-16 20:01:43 +02:00
|
|
|
event.preventDefault();
|
|
|
|
// show drop indicator
|
2014-10-20 15:08:28 +02:00
|
|
|
$('#web').addClass('dragged');
|
|
|
|
}).bind("dragleave", function(event) {
|
|
|
|
$('#web').removeClass('dragged');
|
|
|
|
console.log('asdasd');
|
|
|
|
|
|
|
|
}).bind("drop dragdrop", function(event) {
|
2014-10-16 20:01:43 +02:00
|
|
|
var files = event.originalEvent.target.files || event.originalEvent.dataTransfer.files;
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
$.each(files, function(index, file) {
|
2014-10-16 20:01:43 +02:00
|
|
|
console.debug(file);
|
|
|
|
upload(file);
|
|
|
|
});
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
$('a.browse').on('click', function(event) {
|
2014-10-16 20:01:43 +02:00
|
|
|
$("input[type=file]").click();
|
|
|
|
return (false);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-20 15:08:28 +02:00
|
|
|
$('input[type=file]').on('change', function(event) {
|
|
|
|
$.each(this.files, function(index, file) {
|
2014-10-16 20:01:43 +02:00
|
|
|
if (file instanceof Blob) {
|
|
|
|
upload(file);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})();
|