blob: 0f754f7314964419bd342bb0cba817eec063644e [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">
Jeff Burke92dd8e42012-12-08 11:40:31 -08004<!--
5 See COPYING for copyright and distribution information.
6-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07007<html xmlns = "http://www.w3.org/1999/xhtml">
8
9<head>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070010 <title>NDN Encode/Decode Content Object</title>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070011
Alexander Afanasyev2a2c9d22013-03-13 16:21:32 -070012 <script type="text/javascript" src="../build/ndn-js.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070013
14 <script type="text/javascript">
15
16 function encode(){
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070017 var contentname = new Name( document.getElementById('contentname').value );
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070018
19 var content = document.getElementById('content').value;
20
21 var signedInfo = new SignedInfo();
Meki Cherkaoui8f173612012-06-06 01:05:40 -070022
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070023 signedInfo.setFields();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070024
Jeff Thompson2c580442013-07-31 11:51:18 -070025 var co = new ContentObject(contentname, signedInfo, content);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070026
27 co.sign();
28
29
30 var output = encodeToHexContentObject(co);
31
32 document.getElementById('result').innerHTML = output;
33
34 }
35
36 function decode(){
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070037 var input = document.getElementById('result').innerHTML;
38
Meki Cherkaoui8f173612012-06-06 01:05:40 -070039 input = input.toUpperCase();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070040
41 var co = decodeHexContentObject(input);
42
43 if(LOG>3)console.log('CONTENT OBJECT DECODED');
44 if(LOG>3)console.log(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070045
jeffcc8b3a92012-09-03 15:13:27 -070046 document.getElementById('result').innerHTML = contentObjectToHtml(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070047 }
48
49 </script>
50
51</head>
52<body >
53 <form>
54
55 Please Enter a Content Name:<br />
56
Jeff Thompsonbd829262012-11-30 22:28:37 -080057 <input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070058
Jeff Thompson12b029d2012-08-26 11:51:27 -070059 <br />Please Enter the Content:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070060
61 <textarea id="content" cols="40" rows="5" name="CONTENT" value="SUCCESS" >SUCCESS!</textarea>
62
63 </form>
64 <button onclick="encode()">Encode</button>
65 <button onclick="decode()">Decode</button>
66
67
Jeff Thompson12b029d2012-08-26 11:51:27 -070068 <p id="result"></p>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070069
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070070
71</body>
jeffcc8b3a92012-09-03 15:13:27 -070072</html>