Skip to content

Commit

Permalink
Fix onComplete handler
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Dec 12, 2019
1 parent 1da30d3 commit 8985dd8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
32 changes: 15 additions & 17 deletions v3/index.tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
24 changes: 16 additions & 8 deletions v3cdn/index.tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 8985dd8

Please sign in to comment.