This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/public/assets/scripts/discourse-boot.js
CommanderRoot 86a783b3ad
DEV: Replace deprecated String.prototype.substr() (#16233)
String.prototype.substr() is deprecated so we replace it with String.prototype.slice() which works similarily but isn't deprecated.

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2022-04-01 17:35:17 +02:00

32 lines
990 B
JavaScript

(function () {
if (window.unsupportedBrowser) {
throw "Unsupported browser detected";
}
// TODO: Remove this and have resolver find the templates
const prefix = "discourse/templates/";
const adminPrefix = "admin/templates/";
let len = prefix.length;
Object.keys(requirejs.entries).forEach(function (key) {
if (key.indexOf(prefix) === 0) {
Ember.TEMPLATES[key.slice(len)] = require(key).default;
} else if (key.indexOf(adminPrefix) === 0) {
Ember.TEMPLATES[key] = require(key).default;
}
});
window.__widget_helpers = require("discourse-widget-hbs/helpers").default;
// TODO: Eliminate this global
window.virtualDom = require("virtual-dom");
let element = document.querySelector(
`meta[name="discourse/config/environment"]`
);
const config = JSON.parse(
decodeURIComponent(element.getAttribute("content"))
);
const event = new CustomEvent("discourse-booted", { detail: config });
document.dispatchEvent(event);
})();