Created
December 8, 2015 12:20
-
-
Save sergeysova/4e93abca2780c00ff1d5 to your computer and use it in GitHub Desktop.
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
window.downloadFile = function (sUrl) { | |
//iOS devices do not support downloading. We have to inform user about this. | |
if (/(iP)/g.test(navigator.userAgent)) { | |
alert('Your device does not support files downloading. Please try again in desktop browser.'); | |
return false; | |
} | |
//If in Chrome or Safari - download via virtual link click | |
if (window.downloadFile.isChrome || window.downloadFile.isSafari) { | |
//Creating new link node. | |
var link = document.createElement('a'); | |
link.href = sUrl; | |
if (link.download !== undefined) { | |
//Set HTML5 download attribute. This will prevent file from opening if supported. | |
var fileName = nazvan; //название фаила | |
link.download = fileName; | |
} | |
//Dispatching click event. | |
if (document.createEvent) { | |
var e = document.createEvent('MouseEvents'); | |
e.initEvent('click', true, true); | |
link.dispatchEvent(e); | |
return true; | |
} | |
} | |
// Force file download (whether supported by server). | |
if (sUrl.indexOf('?') === -1) { | |
sUrl += '?download'; | |
} | |
window.open(sUrl, '_self'); | |
return true; | |
} | |
window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; | |
window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1; | |
for (i = 0; i < 84; i++) { | |
var vibsil = $("div.image a:eq("+i+")").attr("href"); | |
var div = document.createElement('div'); | |
var parentElem = document.getElementById("syda"); | |
div.className = "moyclass"; | |
parentElem.appendChild(div) | |
$('.moyclass:eq('+i+')').load(vibsil+' a.zoom'); | |
} | |
for (i = 0; i < 83; i++) { | |
var kar = $('a.zoom:eq('+i+')').attr('href'); | |
var nazvan = $('a.zoom:eq('+i+') img').attr('alt'); | |
downloadFile(kar); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment