Add 2 new hooks for detecting page changes in the webUI

Ryan Blenis committed Dec 28, 2019 at 06:55 UTC 9b528e1ab95dbd01a6e5a5bb74e8894534648109
2 files changed +4
plugin_development.md
+2
@@ -63,6 +63,8 @@ These are separated into the following categories depending on the type of funct
63 `registerPluginTab`: callable when a device is selected in the MeshCentral web interface to register a new tab for plugin data, if required. Accepts an object, or function that returns an object, with the following properties: { tabId: "yourShortNameHere", tabTitle: "Your Display Name"}. A tab and div with the associated ID and title will be created for your use
64 `onDesktopDisconnect`: called when a remote desktop session is disconnected
65 `onWebUIStartupEnd`: called when the page has loaded for the first time after a login / refresh
66 +`goPageStart`: called before page changes take effect. Passes 2 arguments (<page number> : int, <event> : Event)
67 +`goPageEnd`: called after page changes take effect. Passes 2 arguments (<page number> : int, <event> : Event)
68
69 #### Exports
70 Any function can be exported to the Web UI layer by adding the name of the function to an `exports` array in the plugin object.
views/default.handlebars
+2
@@ -9834,6 +9834,7 @@
9834 }
9835
9836 function go(x, event) {
9837 + if (pluginHandler != null) pluginHandler.callHook('goPageStart', x, event);
9838 setSessionActivity();
9839 if (xxdialogMode) return;
9840 QV('uiMenu', false);
@@ -9959,6 +9960,7 @@
9960 } else {
9961 document.title = decodeURIComponent('{{{extitle}}}');
9962 }
9963 + if (pluginHandler != null) pluginHandler.callHook('goPageEnd', x, event);
9964 }
9965
9966 //