<?xml version = "1.0" encoding="utf-8" ?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"DTD/xhtml1-strict.dtd"> | |
<html xmlns = "http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>NDN Encode/Decode Interest</title> | |
<script type="text/javascript" src="../Helper.js"></script> | |
<script type="text/javascript"> | |
function encode(){ | |
var interest = new Interest( new Name(document.getElementById('interest').value ) ); | |
interest.scope = 1; | |
var output = encodeToHexInterest(interest); | |
document.getElementById('result').innerHTML = output; | |
} | |
function decode(){ | |
var input = document.getElementById('result').innerHTML; | |
var interest = decodeHexInterest(input); | |
if(LOG>3)console.log('INTEREST DECODED'); | |
if(LOG>3)console.log(interest); | |
/////////////////////////////////////// | |
var output =""; | |
if(interest.name!=null && interest.name.components!=null){ | |
output+= "NAME: "; | |
output+= interest.name.getName(); | |
/*for(var i=0;i<interest.name.components.length;i++){ | |
output+= "/"+ DataUtils.toString(interest.name.Components[i]); | |
}*/ | |
output+= "<br />"; | |
output+= "<br />"; | |
} | |
if(interest.scope!=null ){ | |
output+= "SCOPE: "; | |
output+= interest.scope; | |
output+= "<br />"; | |
output+= "<br />"; | |
} | |
if(interest.publisherID!=null ){ | |
output+= "PUBLISHER ID: "; | |
output+= interest.publisherID.publisherID; | |
output+= "PUBLISHER ID TYPE: "; | |
output+= interest.publisherID.publisherType; | |
output+= "<br />"; | |
output+= "<br />"; | |
} | |
if(interest.maxSuffixComponents!=null ){ | |
output+= "MaxSuffixComponents : "; | |
output+= interest.maxSuffixComponents; | |
output+= "<br />"; | |
output+= "<br />"; | |
} | |
if(interest.minSuffixComponents!=null ){ | |
output+= "MinSuffixComponents : "; | |
output+= interest.minSuffixComponents; | |
output+= "<br />"; | |
output+= "<br />"; | |
} | |
document.getElementById('result').innerHTML = output; | |
} | |
</script> | |
</head> | |
<body > | |
<form> | |
Please Enter an Interest:<br /> | |
<input id="interest" type="text" name="INTEREST" value="/PARC/abc" /> | |
</form> | |
<button onclick="encode()">Encode</button> | |
<button onclick="decode()">Decode</button> | |
<p id="result"></p> | |
<!-- p id="result">01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000</p--> | |
</body> | |
</html> |