From c160971f0caef12f302cef71975b380091248aa3 Mon Sep 17 00:00:00 2001 From: Steve Krouse Date: Mon, 12 Feb 2018 11:18:42 -0500 Subject: [PATCH 1/2] removed global mode --- dist/woof.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/dist/woof.js b/dist/woof.js index 2575b43..e3e0bfa 100644 --- a/dist/woof.js +++ b/dist/woof.js @@ -2324,12 +2324,14 @@ var getData = function getData(url, callback) { }); }; -// find the woof.js script tag in the page -var currentScript = document.currentScript || Array.prototype.slice.call(document.getElementsByTagName('script')).find(function (s) { - return s.src.includes('woof.js'); -}); +// global mode code removed: -if (JSON.parse(currentScript.getAttribute('global')) !== false) { - // unless the script tag containing Woof has an attribute global="false", start Woof in global mode - Woof.prototype.extend(window, new Woof({ global: true, fullScreen: true })); -} +// find the woof.js script tag in the page +// var currentScript = document.currentScript || Array.prototype.slice.call(document.getElementsByTagName('script')).find(function (s) { +// return s.src.includes('woof.js'); +// }); + +// if (JSON.parse(currentScript.getAttribute('global')) !== false) { +// // unless the script tag containing Woof has an attribute global="false", start Woof in global mode +// Woof.prototype.extend(window, new Woof({ global: true, fullScreen: true })); +// } From 54fc6f6b9ab5033aaef7893710d98739f8bad35c Mon Sep 17 00:00:00 2001 From: Steve Krouse Date: Fri, 23 Feb 2018 21:52:50 +0000 Subject: [PATCH 2/2] added WOOF_GLOBAL_MODE constant --- dist/woof.js | 29 +++++++++++++++-------------- src/woof.es6.js | 8 ++++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/dist/woof.js b/dist/woof.js index e3e0bfa..0a91b54 100644 --- a/dist/woof.js +++ b/dist/woof.js @@ -1778,11 +1778,10 @@ Woof.prototype.Sound = function () { low: 0.5, normal: 1 } - }; - // Convert given value to corresponding audio object value - // Throw error if given value not found in allowed values - var soundVolumeToAudioVolume = function soundVolumeToAudioVolume(val) { + // Convert given value to corresponding audio object value + // Throw error if given value not found in allowed values + };var soundVolumeToAudioVolume = function soundVolumeToAudioVolume(val) { if (typeof val == "number") { if (val >= 0 && val <= 1) { return val; @@ -2324,14 +2323,16 @@ var getData = function getData(url, callback) { }); }; -// global mode code removed: - // find the woof.js script tag in the page -// var currentScript = document.currentScript || Array.prototype.slice.call(document.getElementsByTagName('script')).find(function (s) { -// return s.src.includes('woof.js'); -// }); - -// if (JSON.parse(currentScript.getAttribute('global')) !== false) { -// // unless the script tag containing Woof has an attribute global="false", start Woof in global mode -// Woof.prototype.extend(window, new Woof({ global: true, fullScreen: true })); -// } +var currentScript = document.currentScript || Array.prototype.slice.call(document.getElementsByTagName('script')).find(function (s) { + return s.src.includes('woof.js'); +}); +// the script tag containing Woof has an attribute global="false" +var falseGlobalAttribute = currentScript.getAttribute('global') === 'false'; +// WOOF_GLOBAL_MODE = false was set before this script was loaded +var falseConstant = typeof window.WOOF_GLOBAL_MODE !== 'undefined' && window.WOOF_GLOBAL_MODE === false; +var globalMode = !falseGlobalAttribute && !falseConstant; + +if (globalMode) { + Woof.prototype.extend(window, new Woof({ global: true, fullScreen: true })); +} diff --git a/src/woof.es6.js b/src/woof.es6.js index d41b3c4..de272f6 100644 --- a/src/woof.es6.js +++ b/src/woof.es6.js @@ -1778,8 +1778,12 @@ const getData = (url, callback) => { // find the woof.js script tag in the page var currentScript = document.currentScript || Array.prototype.slice.call(document.getElementsByTagName('script')).find(s => s.src.includes('woof.js')) +// the script tag containing Woof has an attribute global="false" +var falseGlobalAttribute = currentScript.getAttribute('global') === 'false' +// WOOF_GLOBAL_MODE = false was set before this script was loaded +var falseConstant = typeof window.WOOF_GLOBAL_MODE !== 'undefined' && window.WOOF_GLOBAL_MODE === false +var globalMode = !falseGlobalAttribute && !falseConstant -if (JSON.parse(currentScript.getAttribute('global')) !== false) { - // unless the script tag containing Woof has an attribute global="false", start Woof in global mode +if (globalMode) { Woof.prototype.extend(window, new Woof({global: true, fullScreen: true})); } \ No newline at end of file