window.URL = window.URL || window.webkitURL; function download(ref, range, name) { var xhr = new XMLHttpRequest(); xhr.open('GET', ref, true); xhr.setRequestHeader("Range", "bytes="+range); xhr.responseType = 'blob'; xhr.onload = function () { var a = document.createElement('a'), file; file = new Blob([xhr.response], { type : 'application/octet-stream' }); a.href = window.URL.createObjectURL(file); a.download = name; a.click(); }; xhr.send(); } function format(size) { var max = sets[sets.length-1]; var cols = Math.floor(Math.sqrt(max/size)+2); var lines = Math.floor(((max/size)+1)/cols+1); var e = document.getElementById('floppies'); var s, i, j, ofs, fd, fds, curset; for (i = 0, ofs = 0, curset = 0, fd = 1, s = ""; i < lines; i++) { s += ""; for (j = 0; j < cols; j++) { fds = ""+fd; if (fd < 100) fds = "0"+fds; if (fd < 10) fds = "0"+fds; s += ""; if (ofs < max) { s += "fd"+fds+""; if (ofs >= sets[curset]) { curset++; fd = (Math.floor(fd/100)+1)*100; } else fd++; } if (i == lines-1 && j == cols-1) { s += "md5" } s += ""; } s += ""; } e.innerHTML = s; for (i = 0, ofs = 0, curset = 0, fd = 0; ofs < max;) { i++; fd++; ofs = Number.parseInt(ofs)+Number.parseInt(size); if (ofs >= sets[curset]) { fds = ""+fd; if (fd < 100) fds = "0"+fds; if (fd < 10) fds = "0"+fds; e = document.getElementById('cnt'+curset); if (e) e.innerHTML = i; e = document.getElementById('last'+curset); if (e) e.innerHTML = fds; curset++; fd = (Math.floor(fd/100)+1)*100-1; } } } var e = document.getElementById('format'); try { var dummy = new Blob(); e.innerHTML=""; } catch (err) { e.innerHTML="1.44MB"; } .