Major update to rename ccnx to ndn, mainly in ndnProtocol and also in a few files with ccnx in comments.
diff --git a/js/ndnProtocol/content/ndnToolbar.js b/js/ndnProtocol/content/ndnToolbar.js
new file mode 100644
index 0000000..3716b98
--- /dev/null
+++ b/js/ndnProtocol/content/ndnToolbar.js
@@ -0,0 +1,42 @@
+Components.utils.import("chrome://modules/content/ndn-js.jsm");
+
+function ndnToolbarGetLatest(event){
+ if (window._content.document.location.protocol != "ndn:") {
+ alert("The address must start with ndn");
+ return;
+ }
+
+ // Parse the same as in ndnProtocolService newChannel.
+ var spec = window._content.document.location.href.trim();
+ var preHash = spec.split('#', 1)[0];
+ var hash = spec.substr(preHash.length).trim();
+ var preSearch = preHash.split('?', 1)[0];
+ var search = preHash.substr(preSearch.length).trim();
+ // Set nameString to the preSearch without the protocol.
+ var nameString = preSearch.trim();
+ if (nameString.indexOf(':') >= 0)
+ nameString = nameString.substr(nameString.indexOf(':') + 1).trim();
+
+ var name = new Name(nameString);
+ var indexOfVersion = getIndexOfVersion(name);
+ if (indexOfVersion < 0) {
+ alert("The ndn address does not have a version");
+ return;
+ }
+
+ var nameWithoutVersion = new Name(name.components.slice(0, indexOfVersion));
+ var searchWithChildSelector = (search == "" ? "?" : search + "&") + "ndn.ChildSelector=1";
+
+ var uri = "ndn:" + nameWithoutVersion.to_uri() + searchWithChildSelector + hash;
+ window._content.document.location = uri;
+}
+
+// Return the index of the last component that starts with 0xfd, or -1 if not found.
+function getIndexOfVersion(name) {
+ for (var i = name.components.length - 1; i >= 0; --i) {
+ if (name.components[i].length >= 1 && name.components[i][0] == 0xfd)
+ return i;
+ }
+
+ return -1;
+}
diff --git a/js/ndnProtocol/content/toolbar.xul b/js/ndnProtocol/content/toolbar.xul
new file mode 100644
index 0000000..3653378
--- /dev/null
+++ b/js/ndnProtocol/content/toolbar.xul
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<overlay id="Scrapper-Overlay"
+xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/x-javascript" src="chrome://toolbar/content/ndnToolbar.js" />
+
+<toolbox id="navigator-toolbox">
+ <toolbar id="NdnToolbar" toolbarname="ndnToolbar" >
+ <label value="NDN"/>
+ <toolbarbutton id="mdnToolbarGetLatestButton"
+ label="Get Latest" oncommand="ndnToolbarGetLatest(event)" />
+ </toolbar>
+</toolbox>
+
+</overlay>