Created
February 21, 2014 22:41
-
-
Save staxmanade/9145105 to your computer and use it in GitHub Desktop.
downloadable github files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* The hope was to be able to drag out of the browser files from github onto the file system. | |
* I thought I saw the prototype work correctly once, but can't get it working anymore :( | |
* | |
* | |
* | |
* | |
* License: Make It Work: ( someone help me make this work ) | |
* | |
* TODO: | |
* - Make this work correctly | |
* - Turn into a Chrome plugin | |
* - Look to correclty support mime types. (don't hard-code text/plain) | |
*/ | |
$('.js-directory-link').each(function(){ | |
$(this).attr('draggable', true); | |
var filePath = $(this).attr('href'); | |
var downloadUrl = "https://raw2.github.com" + filePath.replace("/blob/", '/'); | |
var fileName = downloadUrl.slice(downloadUrl.lastIndexOf("/")+1) | |
var url = "text/plain:" + fileName + ":" + downloadUrl; | |
this.addEventListener("dragstart",function(e){ | |
console.log('downloading...:', url); | |
e.dataTransfer.setData("DownloadURL", url); | |
},false); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment