There will be no server side request. So it has to be done by pure JS. For example I have this code.
function downloadFile(data, name, mime){
/// what to put here?
}
var txt="Hello world";
var filename="sample.txt";
var mime="text/plain";
downloadFile(txt,filename, mime);
I know of a library that does it entirely in browser without sending any http request. If I send a request I can do it by server side script. Just get the data and with some header a file download can be triggered. But I want to do it in Pure JS. NO server-side request.
The library you linked to uses https://github.com/dcneiner/Downloadify/ which uses Flash to ensure cross-browser compatibility. If you don't need to be sure that it works in all browsers, you can use a data uri and a pure javascript implementation as demonstrated here: https://gist.github.com/syntagmatic/2202660. You could also look at the new HTML5 File API: http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-filesystemurls.