| 1603 | |
| 1604 | === Javascript === |
| 1605 | This implementation is WRONG, for files >= 2GB it counts WRONG hash, for example for dummy avi file it is '''61f7751ec2a72bfb''' instead '''61f7751fc2a72bfb''' - please send us correct code. Thanks! |
| 1606 | {{{ |
| 1607 | #!javascript |
| 1608 | var b = 65536; |
| 1609 | fs = file.size; |
| 1610 | var e = Array(8); |
| 1611 | for (var a = fs, f = 0; f < 8; f++) { |
| 1612 | e[f] = a & 255; |
| 1613 | a = a >> 8 |
| 1614 | } |
| 1615 | a = fs; |
| 1616 | |
| 1617 | |
| 1618 | |
| 1619 | var c = file.slice(0, b); |
| 1620 | var g = new FileReader; |
| 1621 | |
| 1622 | |
| 1623 | g.onloadend = function (h) { |
| 1624 | if (h.target.readyState == FileReader.DONE) { |
| 1625 | |
| 1626 | for (var f = h.target.result, d = 0; d < f.length; d++) e[(d + 8) % 8] += f.charCodeAt(d); |
| 1627 | c = file.slice(a - b); |
| 1628 | var g = new FileReader; |
| 1629 | |
| 1630 | g.onloadend = function (c) { |
| 1631 | var b = "languages"; |
| 1632 | if (c.target.readyState == FileReader.DONE) { |
| 1633 | f = c.target.result; |
| 1634 | for (d = 0; d < f.length; d++) e[(d + 8) % 8] += f.charCodeAt(d); |
| 1635 | lang = $("#SubLanguageID").multiselect("getChecked").map(function(){return this.value}).get().join(","); |
| 1636 | if (lang == "") lang = "all"; |
| 1637 | var url = "http://www.opensubtitles.org/" + $(location).attr('pathname').substr(1,2) + "/search/sublanguageid-" + lang + "/moviehash-" + binl2hex(e) + "/moviebytesize-" + fs + "/dragsearch-on"; |
| 1638 | document.location = url; |
| 1639 | } |
| 1640 | }; |
| 1641 | g.readAsBinaryString(c) |
| 1642 | } |
| 1643 | }; |
| 1644 | g.readAsBinaryString(c) |
| 1645 | |
| 1646 | function binl2hex(a) { |
| 1647 | var b = 255; |
| 1648 | a[1] += a[0] >> 8; |
| 1649 | a[0] = a[0] & b; |
| 1650 | a[2] += a[1] >> 8; |
| 1651 | a[1] = a[1] & b; |
| 1652 | a[3] += a[2] >> 8; |
| 1653 | a[2] = a[2] & b; |
| 1654 | a[4] += a[3] >> 8; |
| 1655 | a[3] = a[3] & b; |
| 1656 | a[5] += a[4] >> 8; |
| 1657 | a[4] = a[4] & b; |
| 1658 | a[6] += a[5] >> 8; |
| 1659 | a[5] = a[5] & b; |
| 1660 | a[7] += a[6] >> 8; |
| 1661 | a[6] = a[6] & b; |
| 1662 | a[7] = a[7] & b; |
| 1663 | for (var d = "0123456789abcdef", e = "", c = 7; c > -1; c--) e += d.charAt(a[c] >> 4 & 15) + d.charAt(a[c] & 15); |
| 1664 | return e |
| 1665 | } |
| 1666 | |
| 1667 | }}} |