Jeff Thompson | d51cb58 | 2013-03-17 19:00:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | * This is called from the NDN toolbar and the doorhanger popup on Firefox for Android. |
| 5 | */ |
| 6 | |
Jeff Thompson | 02b9f4d | 2012-11-29 14:40:57 -0800 | [diff] [blame] | 7 | Components.utils.import("chrome://modules/content/ndn-js.jsm"); |
Jeff Thompson | 6ad5c36 | 2012-12-27 17:57:02 -0800 | [diff] [blame] | 8 | Components.utils.import("chrome://modules/content/NdnProtocolInfo.jsm"); |
Jeff Thompson | 02b9f4d | 2012-11-29 14:40:57 -0800 | [diff] [blame] | 9 | |
Jeff Thompson | 3077981 | 2013-02-04 23:59:45 -0800 | [diff] [blame] | 10 | function ndnToolbarGetVersion(selector) { |
Jeff Thompson | d51cb58 | 2013-03-17 19:00:39 -0700 | [diff] [blame] | 11 | NdnProtocolInfo.getVersion(selector, window, alert); |
Jeff Thompson | 02b9f4d | 2012-11-29 14:40:57 -0800 | [diff] [blame] | 12 | } |
Jeff Thompson | 6ad5c36 | 2012-12-27 17:57:02 -0800 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | * This is called when the connected NDN hub changes. |
| 16 | */ |
| 17 | function onNdnHubChanged(host, port) { |
Jeff Thompson | d51cb58 | 2013-03-17 19:00:39 -0700 | [diff] [blame] | 18 | document.getElementById("ndnHubLabel").setAttribute("value", "Hub: " + host + ":" + port); |
Jeff Thompson | 6ad5c36 | 2012-12-27 17:57:02 -0800 | [diff] [blame] | 19 | } |
| 20 | |
Jeff Thompson | d51cb58 | 2013-03-17 19:00:39 -0700 | [diff] [blame] | 21 | if (window) |
| 22 | window.addEventListener("load", function() { NdnProtocolInfo.addNdnHubChangedListener(onNdnHubChanged); }, |
| 23 | false); |
Jeff Thompson | eec7267 | 2013-03-10 16:45:47 -0700 | [diff] [blame] | 24 | |
| 25 | function ndnToolbarSetHub() { |
Jeff Thompson | 9c24c47 | 2013-03-17 22:11:07 -0700 | [diff] [blame^] | 26 | var message = NdnProtocolInfo.setHub(window); |
| 27 | if (message != null) |
| 28 | document.getElementById("ndnHubLabel").setAttribute("value", message); |
Jeff Thompson | eec7267 | 2013-03-10 16:45:47 -0700 | [diff] [blame] | 29 | } |