Use a safer web wizard detection algorithm
This commit is contained in:
parent
549d8619a8
commit
65f0ad49c8
38
console.js
38
console.js
|
@ -10,6 +10,17 @@ function supportsVB () {
|
|||
return typeof window.VBSEval === 'unknown' && typeof window.VBSExecute === 'unknown'
|
||||
}
|
||||
|
||||
function hasWebWizardExtensions () {
|
||||
if (typeof window.external !== 'unknown') return false
|
||||
return supportsVB() ? InWebWizard() : typeof window.external.SetWizardButtons === 'unknown'
|
||||
}
|
||||
|
||||
function inSketchUp () {
|
||||
return /\bSketchUp\//.test(navigator.userAgent)
|
||||
}
|
||||
|
||||
var originalConsole = window.console;
|
||||
|
||||
window.onload = function () {
|
||||
var output = document.getElementById("output");
|
||||
var input = document.getElementById("input");
|
||||
|
@ -69,7 +80,6 @@ window.onload = function () {
|
|||
}
|
||||
}
|
||||
|
||||
var originalConsole = window.console;
|
||||
window.console = {};
|
||||
|
||||
function makeLogger (name, color) {
|
||||
|
@ -211,11 +221,25 @@ window.onload = function () {
|
|||
}
|
||||
|
||||
// Try to detect the wizard extensions.
|
||||
if (supportsVB() && InWebWizard()) {
|
||||
window.external.SetHeaderText('Windows Scripting Console', "Explore this wizard's scripting environment.");
|
||||
window.external.SetWizardButtons(1, 0, 0);
|
||||
// An onback function is required by the web wizard specification
|
||||
window.onback = function () {
|
||||
window.external.FinalBack();
|
||||
try {
|
||||
if (hasWebWizardExtensions()) {
|
||||
window.external.SetHeaderText('Windows Scripting Console', "Explore this wizard's scripting environment.");
|
||||
window.external.SetWizardButtons(1, 0, 0);
|
||||
// An onback function is required by the web wizard specification
|
||||
window.onback = function () {
|
||||
window.external.FinalBack();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
/*
|
||||
* In some browser contexts, such as IE7 embedded in the Compiled HTML viewer,
|
||||
* interactions with window.external can cause "Not implemented" errors;
|
||||
* if any of those occur, we ignore them.
|
||||
* We cannot filter the errors to specifically ignore "Not implemented",
|
||||
* because the error text gets translated to other languages
|
||||
* ("Non implémenté" in French) and there are no other attributes to compare on.
|
||||
*/
|
||||
if (originalConsole && originalConsole.error) {
|
||||
originalConsole.error('Could not setup Web Wizard extensions:', err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue