From 8985dd8445b44d5666bb61de50918d6d87773dc6 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Thu, 12 Dec 2019 16:34:42 +0100 Subject: [PATCH] Fix onComplete handler --- v3/index.tpl.go | 32 +++++++++++++++----------------- v3cdn/index.tpl.go | 24 ++++++++++++++++-------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/v3/index.tpl.go b/v3/index.tpl.go index ef45674..498e147 100644 --- a/v3/index.tpl.go +++ b/v3/index.tpl.go @@ -66,25 +66,23 @@ var indexTpl = ` showExtensions: true, showCommonExtensions: true, validatorUrl: null, - onComplete: function() { - var dom = document.querySelector('.scheme-container select'); - for (var key in dom) { - if (key.startsWith("__reactInternalInstance$")) { - var compInternals = dom[key]._currentElement; - var compWrapper = compInternals._owner; - compWrapper._instance.setScheme(window.location.protocol.slice(0,-1)); - } - } - } - }; + onComplete: function() { + if (cfg.preAuthorizeApiKey) { + for (var name in cfg.preAuthorizeApiKey) { + ui.preauthorizeApiKey(name, cfg.preAuthorizeApiKey[name]); + } + } - if (cfg.preAuthorizeApiKey) { - settings.onComplete = () => { - for (var name in cfg.preAuthorizeApiKey) { - ui.preauthorizeApiKey(name, cfg.preAuthorizeApiKey[name]); + var dom = document.querySelector('.scheme-container select'); + for (var key in dom) { + if (key.startsWith("__reactInternalInstance$")) { + var compInternals = dom[key]._currentElement; + var compWrapper = compInternals._owner; + compWrapper._instance.setScheme(window.location.protocol.slice(0,-1)); + } } - }; - } + } + }; if (cfg.showTopBar == false) { settings.plugins.push(function () { diff --git a/v3cdn/index.tpl.go b/v3cdn/index.tpl.go index 28a6089..370e923 100644 --- a/v3cdn/index.tpl.go +++ b/v3cdn/index.tpl.go @@ -65,16 +65,24 @@ var indexTpl = ` layout: "StandaloneLayout", showExtensions: true, showCommonExtensions: true, - validatorUrl: null - }; + validatorUrl: null, + onComplete: function() { + if (cfg.preAuthorizeApiKey) { + for (var name in cfg.preAuthorizeApiKey) { + ui.preauthorizeApiKey(name, cfg.preAuthorizeApiKey[name]); + } + } - if (cfg.preAuthorizeApiKey) { - settings.onComplete = () => { - for (var name in cfg.preAuthorizeApiKey) { - ui.preauthorizeApiKey(name, cfg.preAuthorizeApiKey[name]); + var dom = document.querySelector('.scheme-container select'); + for (var key in dom) { + if (key.startsWith("__reactInternalInstance$")) { + var compInternals = dom[key]._currentElement; + var compWrapper = compInternals._owner; + compWrapper._instance.setScheme(window.location.protocol.slice(0,-1)); + } } - }; - } + } + }; if (cfg.showTopBar == false) { settings.plugins.push(function () {