blob: 4cc5a92bea9451d8c53a1f68fe627f3d6a7f890a [file] [log] [blame]
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07001<?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 Thompsond9784e02012-10-18 23:39:39 -07007 <title>NDN Encode/Decode Interest</title>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07008
Jeff Thompson38422f42012-11-15 00:20:39 -08009 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070010
11 <script type="text/javascript">
12
13 function encode(){
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070014 var interest = new Interest( new Name(document.getElementById('interest').value ) );
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070015
Jeff Thompson86aea882012-09-29 17:32:48 -070016 interest.scope = 1;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070017
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070018 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 Thompsone85ff1d2012-09-29 21:21:57 -070040 if(interest.name!=null && interest.name.components!=null){
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070041 output+= "NAME: ";
42
Meki Cherkaoui8f173612012-06-06 01:05:40 -070043
Jeff Thompson86aea882012-09-29 17:32:48 -070044 output+= interest.name.getName();
Meki Cherkaoui8f173612012-06-06 01:05:40 -070045
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070046 /*for(var i=0;i<interest.name.components.length;i++){
Jeff Thompson86aea882012-09-29 17:32:48 -070047 output+= "/"+ DataUtils.toString(interest.name.Components[i]);
Meki Cherkaoui8f173612012-06-06 01:05:40 -070048 }*/
49
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070050 output+= "<br />";
51 output+= "<br />";
52 }
53
Meki Cherkaoui8f173612012-06-06 01:05:40 -070054
Jeff Thompson86aea882012-09-29 17:32:48 -070055 if(interest.scope!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070056 output+= "SCOPE: ";
57
Jeff Thompson86aea882012-09-29 17:32:48 -070058 output+= interest.scope;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070059
60 output+= "<br />";
61 output+= "<br />";
62 }
63
Jeff Thompson86aea882012-09-29 17:32:48 -070064 if(interest.publisherID!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070065 output+= "PUBLISHER ID: ";
66
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070067 output+= interest.publisherID.publisherID;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070068
69 output+= "PUBLISHER ID TYPE: ";
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070070 output+= interest.publisherID.publisherType;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070071 output+= "<br />";
72 output+= "<br />";
73 }
74
Jeff Thompson86aea882012-09-29 17:32:48 -070075 if(interest.maxSuffixComponents!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070076 output+= "MaxSuffixComponents : ";
77
Jeff Thompson86aea882012-09-29 17:32:48 -070078 output+= interest.maxSuffixComponents;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070079
80 output+= "<br />";
81 output+= "<br />";
82 }
83
Jeff Thompson86aea882012-09-29 17:32:48 -070084 if(interest.minSuffixComponents!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070085 output+= "MinSuffixComponents : ";
86
Jeff Thompson86aea882012-09-29 17:32:48 -070087 output+= interest.minSuffixComponents;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070088
89 output+= "<br />";
90 output+= "<br />";
91 }
92
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070093 document.getElementById('result').innerHTML = output;
94
95 }
96
97 </script>
98
99</head>
100<body >
101 <form>
102
Jeff Thompson7ed5ef52012-08-26 11:28:48 -0700103 Please Enter an Interest:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700104
jeff9797d3d2012-09-03 15:07:13 -0700105 <input id="interest" type="text" name="INTEREST" value="/PARC/abc" />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700106
107 </form>
108 <button onclick="encode()">Encode</button>
109 <button onclick="decode()">Decode</button>
110
Jeff Thompson7ed5ef52012-08-26 11:28:48 -0700111 <p id="result"></p>
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700112
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700113
114
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700115 <!-- p id="result">01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000</p-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700116
117</body>
jeff9797d3d2012-09-03 15:07:13 -0700118</html>