From 1098bee4d4227bcd81acbddd1ca62d91a3558e25 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Fri, 21 Jun 2019 12:03:49 +0200 Subject: [PATCH] refactor info/link extraction from onlinehelp to utils so that we can reuse that code for getting links from the docs Signed-off-by: Dominik Csapak --- Utils.js | 23 +++++++++++++++++++++++ button/HelpButton.js | 21 ++------------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Utils.js b/Utils.js index 645c525..ee0a0ce 100644 --- a/Utils.js +++ b/Utils.js @@ -593,6 +593,29 @@ Ext.define('Proxmox.Utils', { utilities: { return Ext.Date.format(servertime, 'Y-m-d H:i:s'); }, + get_help_info: function(section) { + var helpMap; + if (typeof proxmoxOnlineHelpInfo !== 'undefined') { + helpMap = proxmoxOnlineHelpInfo; + } else if (typeof pveOnlineHelpInfo !== 'undefined') { + // be backward compatible with older pve-doc-generators + helpMap = pveOnlineHelpInfo; + } else { + throw "no global OnlineHelpInfo map declared"; + } + + return helpMap[section]; + }, + + get_help_link: function(section) { + var info = Proxmox.Utils.get_help_info(section); + if (!info) { + return; + } + + return window.location.origin + info.link; + }, + openXtermJsViewer: function(vmtype, vmid, nodename, vmname, cmd) { var url = Ext.Object.toQueryString({ console: vmtype, // kvm, lxc, upgrade or shell diff --git a/button/HelpButton.js b/button/HelpButton.js index 1bf3f32..e0fc2a8 100644 --- a/button/HelpButton.js +++ b/button/HelpButton.js @@ -41,25 +41,11 @@ Ext.define('Proxmox.button.Help', { } }, - getOnlineHelpInfo: function (ref) { - var helpMap; - if (typeof proxmoxOnlineHelpInfo !== 'undefined') { - helpMap = proxmoxOnlineHelpInfo; - } else if (typeof pveOnlineHelpInfo !== 'undefined') { - // be backward compatible with older pve-doc-generators - helpMap = pveOnlineHelpInfo; - } else { - throw "no global OnlineHelpInfo map declared"; - } - - return helpMap[ref]; - }, - // this sets the link and the tooltip text setOnlineHelp:function(blockid) { var me = this; - var info = me.getOnlineHelpInfo(blockid); + var info = Proxmox.Utils.get_help_info(blockid); if (info) { me.onlineHelp = blockid; var title = info.title; @@ -81,10 +67,7 @@ Ext.define('Proxmox.button.Help', { var docsURI; if (me.onlineHelp) { - var info = me.getOnlineHelpInfo(me.onlineHelp); - if (info) { - docsURI = window.location.origin + info.link; - } + docsURI = Proxmox.Utils.get_help_link(me.onlineHelp); } if (docsURI) { -- 2.39.2