Permalink
Find file
dfdcc3b Dec 13, 2016
53 lines (48 sloc) 2.19 KB
<html>
<head>
<title>codedump</title>
<script src="https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js"></script>
<script>
function postcode() {
var client = new WebTorrent();
var file = new File([document.all('send').value], document.all('name').value);
client.seed(file, function(torrent){ document.all('deliver').innerHTML = 'Link to posted file:\nhttp://ronsoros.github.io/?' + torrent.infoHash });
}
function loaddoc(){
var query = window.location.search.slice(1);
if ( query != "" ) {
var tmpa = "magnet:?xt=urn:btih:$HASH&dn=inetd.c&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com";
query = tmpa.replace('$HASH', query);
document.all('send').value = "// Loading...";
var client = new WebTorrent();
client.add(query, function (torrent) {
// Torrents can contain many files. Let's use the first.
var file = torrent.files[0]
document.all('srcfile').innerHTML = file.name;
document.all('forkbtn').innerHTML = 'Fork this Code'
document.all('name').value = file.name;
// Display the file by adding it to the DOM. Supports video, audio, image, etc. files
var reader = new FileReader();
reader.addEventListener("loadend", function() {
// reader.result contains the contents of blob as a typed array
document.all('send').value = reader.result;
});
file.getBlob(function(err,blob) {
reader.readAsText(blob);
})
});
}
}
</script>
</head>
<body style='font-family: Arial; font-size: 14px;' onload="loaddoc()">
<h1>codedump</h1>share code instantly
<div id='deliver'></div>
<h2 id='srcfile'>New Source File</h2>
Name: <input type=text id='name'><br/>
<textarea style='width:100%;height:640px' id='send'></textarea>
<button onClick='postcode()' id='forkbtn'>Upload</button>
<script>
</script>
</body>
</html>