10 examples of 'jquery offline download' in JavaScript

Every line of 'jquery offline download' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
120function download(url) {
121 torrents[url] = true;
122 // If the torrent already exists, kick off the downloads of the files, as this
123 // won't happen naturally when the torrent is added (because it already exists!)
124 if(btapp.has('torrent')) {
125 if(btapp.get('torrent').each(function(torrent) {
126 if(torrent.has('properties')) {
127 if(torrent.get('properties').get('download_url') === url) {
128 download_torrent_files(torrent.get('properties'));
129 return;
130 }
131 }
132 }));
133 }
134}
1function download(file, ext) {
2 var d = new Date();
3 var n = d.getTime();
4 if (window.navigator.msSaveOrOpenBlob) // IE10+
5 window.navigator.msSaveOrOpenBlob(file, n + ext);
6 else { // Others
7 var a = document.createElement("a"),
8 url = URL.createObjectURL(file);
9 a.href = url;
10 a.download = n + ext;
11 document.body.appendChild(a);
12 a.click();
13 setTimeout(function() {
14 document.body.removeChild(a);
15 window.URL.revokeObjectURL(url);
16 }, 0);
17 }
18}
7export function download(url) {
8 const iframe = document.createElement("iframe");
9 iframe.src = url;
10 iframe.style.display = "none";
11 document.body.appendChild(iframe);
12}
606attachment.download(function downloaded() {
607 if (!attachment._file) {
608 return;
609 }
610
611 node.setAttribute('state', 'downloaded');
612});
505function download(filename, url) {
506 var a = window.document.createElement('a'),
507 bd = document.querySelector('body');
508 bd.appendChild(a);
509 a.setAttribute('href', url);
510 a.setAttribute('download', filename);
511 a.click();
512 bd.removeChild(a);
513}
722function onDownload(link) {
723
724 $("#downloadForRealz").html("Download " + $(link).text());
725 $("#downloadForRealz").attr('href', urlRoot + $(link).text());
726
727 $("#tos").fadeIn('fast');
728 $("#landing").fadeOut('fast');
729
730 return true;
731}
14function download(url, w, progress = () => {}) {
15 return new Promise((resolve, reject) => {
16 let protocol = /^https:/.exec(url) ? https : http
17 progress(0)
18 protocol
19 .get(url, res1 => {
20 protocol = /^https:/.exec(res1.headers.location) ? https : http
21 protocol
22 .get(res1.headers.location, res2 => {
23 const total = parseInt(res2.headers['content-length'], 10)
24 let completed = 0
25 res2.pipe(w)
26 res2.on('data', data => {
27 completed += data.length
28 progress(completed / total)
29 })
30 res2.on('progress', progress)
31 res2.on('error', reject)
32 res2.on('end', () => resolve(w.path))
33 })
34 .on('error', reject)
35 })
36 .on('error', reject)
37 })
38}
41setTimeout(function loadUrl() { // eslint-disable-line
42 iframe.contentWindow.location.href = url;
43}, 50);
16function download(url: string, filename: string) {
17 console.log(`download ${url}...`)
18 return new Promise((resolve) => {
19 request(url, resolve).pipe(fs.createWriteStream(filename))
20 });
21}
10function download(fileUrl, filename, callback) {
11 https
12 .get(fileUrl, function(response) {
13 if (
14 response.statusCode > 300 &&
15 response.statusCode < 400 &&
16 response.headers.location
17 ) {
18 if (url.parse(response.headers.location).hostname) {
19 https.get(response.headers.location, function(res) {
20 writeToFile(filename, res, callback);
21 });
22 } else {
23 https
24 .get(
25 url.resolve(
26 url.parse(fileUrl).hostname,
27 response.headers.location
28 ),
29 function(res) {
30 writeToFile(filename, res, callback);
31 }
32 )
33 .on("error", callback);
34 }
35 } else {
36 writeToFile(filename, response, callback);
37 }
38 })
39 .on("error", callback);
40}

Related snippets