From 559666229c87ed6668a8182d5793fa03b81b53bc Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 3 Feb 2016 03:12:58 +0000 Subject: Store help dialog injected strings together, inject all at once --- background_scripts/main.coffee | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 63729b8f..5c056fc9 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -144,13 +144,18 @@ root.helpDialogHtml = (showUnboundCommands, showCommandNames, customTitle) -> command = Commands.keyToCommandRegistry[key].command commandsToKey[command] = (commandsToKey[command] || []).concat(key) - dialogHtml = fetchFileContents("pages/help_dialog.html") + replacementStrings = + version: currentVersion + title: customTitle || "Help" + for group of Commands.commandGroups - dialogHtml = dialogHtml.replace("{{#{group}}}", + replacementStrings[group] = helpDialogHtmlForCommandGroup(group, commandsToKey, Commands.availableCommands, - showUnboundCommands, showCommandNames)) - dialogHtml = dialogHtml.replace("{{version}}", currentVersion) - dialogHtml = dialogHtml.replace("{{title}}", customTitle || "Help") + showUnboundCommands, showCommandNames) + + dialogHtml = fetchFileContents("pages/help_dialog.html") + for placeholder, replacementString of replacementStrings + dialogHtml = dialogHtml.replace "{{#{placeholder}}}", replacementString dialogHtml # -- cgit v1.2.3