Skip to content

Commit 30356de

Browse files
committed
Add polyfill to support older browsers
1 parent d7b17f6 commit 30356de

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Assets/WebGLTemplates/Develop/debug-console.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ if (getCookie("addTimestamp") === "false") {
2121
addTimestamp = false;
2222
}
2323

24-
const urlParams = new URLSearchParams(window.location.search);
25-
const debugParam = urlParams.get('debug');
26-
const debug = debugParam === 'true';
27-
28-
initializeToggleButton(debug);
29-
initializeDebugConsole();
30-
31-
3224
function setCookie(cname, cvalue, exdays) {
3325
const d = new Date();
3426
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
@@ -609,3 +601,19 @@ function refreshTrackingDiv() {
609601
innerHtml += '</dl>';
610602
trackingDiv.innerHTML = innerHtml;
611603
}
604+
605+
// Polyfill for older browsers
606+
if (!String.prototype.replaceAll) {
607+
String.prototype.replaceAll = function(str, newStr) {
608+
if (str === '?')
609+
str = '\\\\?';
610+
return this.replace(str instanceof RegExp ? str : new RegExp(str, 'g'), newStr);
611+
}
612+
}
613+
614+
const urlParams = new URLSearchParams(window.location.search);
615+
const debugParam = urlParams.get('debug');
616+
const debug = debugParam === 'true';
617+
618+
initializeToggleButton(debug);
619+
initializeDebugConsole();

0 commit comments

Comments
 (0)