Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -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>
|
Jeff Thompson | d9784e0 | 2012-10-18 23:39:39 -0700 | [diff] [blame] | 7 | <title>NDN Encode/Decode Interest</title>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 8 |
|
Jeff Thompson | 38422f4 | 2012-11-15 00:20:39 -0800 | [diff] [blame] | 9 | <script type="text/javascript" src="../Helper.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 10 |
|
| 11 | <script type="text/javascript">
|
| 12 |
|
| 13 | function encode(){
|
Jeff Thompson | f3bd359 | 2012-09-29 23:25:30 -0700 | [diff] [blame] | 14 | var interest = new Interest( new Name(document.getElementById('interest').value ) );
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 15 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 16 | interest.scope = 1;
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 17 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 18 | var output = encodeToHexInterest(interest);
|
| 19 |
|
| 20 | document.getElementById('result').innerHTML = output;
|
| 21 |
|
| 22 | }
|
| 23 |
|
| 24 | function decode(){
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 | var input = document.getElementById('result').innerHTML;
|
| 29 |
|
| 30 |
|
| 31 | var interest = decodeHexInterest(input);
|
| 32 |
|
| 33 | if(LOG>3)console.log('INTEREST DECODED');
|
| 34 | if(LOG>3)console.log(interest);
|
| 35 |
|
| 36 | ///////////////////////////////////////
|
| 37 |
|
| 38 | var output ="";
|
| 39 |
|
Jeff Thompson | e85ff1d | 2012-09-29 21:21:57 -0700 | [diff] [blame] | 40 | if(interest.name!=null && interest.name.components!=null){
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 41 | output+= "NAME: ";
|
| 42 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 43 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 44 | output+= interest.name.getName();
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 45 |
|
Jeff Thompson | e85ff1d | 2012-09-29 21:21:57 -0700 | [diff] [blame] | 46 | /*for(var i=0;i<interest.name.components.length;i++){
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 47 | output+= "/"+ DataUtils.toString(interest.name.Components[i]);
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 48 | }*/
|
| 49 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 50 | output+= "<br />";
|
| 51 | output+= "<br />";
|
| 52 | }
|
| 53 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 54 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 55 | if(interest.scope!=null ){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 56 | output+= "SCOPE: ";
|
| 57 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 58 | output+= interest.scope;
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 59 |
|
| 60 | output+= "<br />";
|
| 61 | output+= "<br />";
|
| 62 | }
|
| 63 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 64 | if(interest.publisherID!=null ){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 65 | output+= "PUBLISHER ID: ";
|
| 66 |
|
Jeff Thompson | e85ff1d | 2012-09-29 21:21:57 -0700 | [diff] [blame] | 67 | output+= interest.publisherID.publisherID;
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 68 |
|
| 69 | output+= "PUBLISHER ID TYPE: ";
|
Jeff Thompson | e85ff1d | 2012-09-29 21:21:57 -0700 | [diff] [blame] | 70 | output+= interest.publisherID.publisherType;
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 71 | output+= "<br />";
|
| 72 | output+= "<br />";
|
| 73 | }
|
| 74 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 75 | if(interest.maxSuffixComponents!=null ){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 76 | output+= "MaxSuffixComponents : ";
|
| 77 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 78 | output+= interest.maxSuffixComponents;
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 79 |
|
| 80 | output+= "<br />";
|
| 81 | output+= "<br />";
|
| 82 | }
|
| 83 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 84 | if(interest.minSuffixComponents!=null ){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 85 | output+= "MinSuffixComponents : ";
|
| 86 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 87 | output+= interest.minSuffixComponents;
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 88 |
|
| 89 | output+= "<br />";
|
| 90 | output+= "<br />";
|
| 91 | }
|
| 92 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 93 | document.getElementById('result').innerHTML = output;
|
| 94 |
|
| 95 | }
|
| 96 |
|
| 97 | </script>
|
| 98 |
|
| 99 | </head>
|
| 100 | <body >
|
| 101 | <form>
|
| 102 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 103 | Please Enter an Interest:<br />
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 104 |
|
jeff | 9797d3d | 2012-09-03 15:07:13 -0700 | [diff] [blame] | 105 | <input id="interest" type="text" name="INTEREST" value="/PARC/abc" />
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 106 |
|
| 107 | </form>
|
| 108 | <button onclick="encode()">Encode</button>
|
| 109 | <button onclick="decode()">Decode</button>
|
| 110 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 111 | <p id="result"></p>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 112 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 113 |
|
| 114 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 115 | <!-- p id="result">01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000</p-->
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 116 |
|
| 117 | </body>
|
jeff | 9797d3d | 2012-09-03 15:07:13 -0700 | [diff] [blame] | 118 | </html>
|