Jeff Thompson | e06b31e | 2012-09-30 17:19:19 -0700 | [diff] [blame] | 1 | <?xml version = "1.0" encoding="utf-8" ?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
| 3 | "DTD/xhtml1-strict.dtd"> |
| 4 | <html xmlns = "http://www.w3.org/1999/xhtml"> |
| 5 | |
| 6 | <head> |
| 7 | <title>NDN Image Loader</title> |
Jeff Thompson | 38422f4 | 2012-11-15 00:20:39 -0800 | [diff] [blame] | 8 | |
| 9 | <script type="text/javascript" src="../Helper.js"></script> |
Jeff Thompson | e06b31e | 2012-09-30 17:19:19 -0700 | [diff] [blame] | 10 | |
| 11 | <script type="text/javascript"> |
| 12 | var loadedImageString = ""; |
| 13 | var connector = new NDN(); |
| 14 | var pieceNumber = 0; |
| 15 | var count = 0; |
| 16 | var end = false; |
| 17 | var LOG = 0; |
| 18 | var pieceSize = 1000; |
| 19 | |
| 20 | |
| 21 | function getPiece(){ |
| 22 | if(!pieceNumber) pieceNumber = 0; |
| 23 | var contentName = "/image/piece" + pieceNumber; |
| 24 | var co = connector.get( contentName ); |
| 25 | |
| 26 | if(co){ |
| 27 | loadedImageString += DataUtils.toString(co.content); |
| 28 | console.log("Received length: " + co.content.length); |
| 29 | if(co.content.length == pieceSize){ |
| 30 | pieceNumber += co.content.length; |
| 31 | getPiece(); |
| 32 | } |
| 33 | else document.getElementById('image').src += loadedImageString; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | </script> |
| 42 | |
| 43 | </head> |
| 44 | <body > |
| 45 | <div> |
| 46 | <button onclick="getPiece()">Get image</button> |
| 47 | </div> |
| 48 | <div > |
| 49 | <applet id="JavaSocketBridge" archive="../JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0"> |
| 50 | </applet> |
| 51 | </div> |
| 52 | |
| 53 | <p id="result"></p> |
| 54 | <div> |
| 55 | <img id="image" src="data:image/png;base64," alt="Image placeholder" /> |
| 56 | </div> |
| 57 | |
| 58 | </body> |
| 59 | </html> |