|
| 1 | +(function() { |
| 2 | + /* options, customize to your needs */ |
| 3 | + var server = '//html2canvas.hertzen.com/build', |
| 4 | + proxy = '//html2canvas.appspot.com', |
| 5 | + debug = false, |
| 6 | + profile = false; |
| 7 | + //DEBUG: server = 'http://localhost/html2canvas'; debug = true; |
| 8 | + var debugFiles = [ |
| 9 | + 'external/jquery-1.6.2.min', |
| 10 | + 'src/Core', |
| 11 | + 'src/Generate', |
| 12 | + 'src/Parse', |
| 13 | + 'src/Preload', |
| 14 | + 'src/Queue', |
| 15 | + 'src/Renderer', |
| 16 | + 'src/plugins/jquery.plugin.html2canvas' |
| 17 | + ], |
| 18 | + relFiles = [ |
| 19 | + '//code.jquery.com/jquery-1.6.4.js', |
| 20 | + 'html2canvas', |
| 21 | + 'jquery.plugin.html2canvas' |
| 22 | + ], |
| 23 | + i = 0, el = null; |
| 24 | + var loader = { |
| 25 | + index: 0, |
| 26 | + head: document.getElementsByTagName('head')[0], |
| 27 | + statusline: document.createElement('div'), |
| 28 | + files: (debug ? debugFiles : relFiles), |
| 29 | + onload: function () { |
| 30 | + var _ = this; |
| 31 | + if (_.index < _.files.length) { |
| 32 | + var el = document.createElement('script'); |
| 33 | + el.type = 'text/javascript'; |
| 34 | + el.onload = function() { |
| 35 | + _.onload(); |
| 36 | + }; |
| 37 | + el.onerror = function() { |
| 38 | + _.statusline.style.color = 'red'; |
| 39 | + _.statusline.innerHTML = _.statusline.innerHTML + ' failed'; |
| 40 | + _.statusline.onclick = function() { |
| 41 | + _.statusline.parentNode.removeChild(_.statusline); |
| 42 | + }; |
| 43 | + }; |
| 44 | + if (_.files[_.index].substr(0, 2) === '//') { |
| 45 | + el.src = _.files[_.index]; |
| 46 | + } |
| 47 | + else { |
| 48 | + el.src = server + '/' + _.files[_.index] + '.js'; |
| 49 | + } |
| 50 | + _.head.appendChild(el); |
| 51 | + ++_.index; |
| 52 | + _.statusline.innerHTML = 'html2canvas: loading "' + el.src + '" ' + _.index + ' / ' + _.files.length + '...'; |
| 53 | + } |
| 54 | + else { |
| 55 | + _.statusline.parentNode.removeChild(_.statusline); |
| 56 | + delete _.statusline; |
| 57 | + $(document.documentElement).html2canvas({ |
| 58 | + logging: debug, |
| 59 | + profile: profile |
| 60 | + }); |
| 61 | + } |
| 62 | + } |
| 63 | + }, statusline = loader.statusline; |
| 64 | + statusline.style.position = 'fixed'; |
| 65 | + statusline.style.bottom = '0px'; |
| 66 | + statusline.style.right = '20px'; |
| 67 | + statusline.style.backgroundColor = 'white'; |
| 68 | + statusline.style.border = '1px solid black'; |
| 69 | + statusline.style.borderBottomWidth = '0px'; |
| 70 | + statusline.style.padding = '2px 5px'; |
| 71 | + statusline.style.zIndex = 9999999; |
| 72 | + document.body.appendChild(statusline); |
| 73 | + loader.onload(); |
| 74 | +}()); |
0 commit comments