2018-09-17 16:31:46 +08:00
|
|
|
(function() {
|
2018-10-02 12:29:04 +08:00
|
|
|
var ps = require("preload-store").default;
|
2018-09-17 16:31:46 +08:00
|
|
|
var preloadedDataElement = document.getElementById("data-preloaded");
|
|
|
|
|
|
|
|
if (preloadedDataElement) {
|
|
|
|
var preloaded = JSON.parse(preloadedDataElement.dataset.preloaded);
|
|
|
|
|
|
|
|
Object.keys(preloaded).forEach(function(key) {
|
|
|
|
ps.store(key, JSON.parse(preloaded[key]));
|
|
|
|
});
|
|
|
|
}
|
2018-10-02 12:29:04 +08:00
|
|
|
|
|
|
|
var setupData = document.getElementById("data-discourse-setup").dataset;
|
|
|
|
|
2019-08-20 09:29:11 +08:00
|
|
|
window.Logster = window.Logster || {};
|
|
|
|
window.Logster.enabled = setupData.enableJsErrorReporting === "true";
|
|
|
|
|
2018-10-02 12:29:04 +08:00
|
|
|
Discourse.CDN = setupData.cdn;
|
|
|
|
Discourse.BaseUrl = setupData.baseUrl;
|
|
|
|
Discourse.BaseUri = setupData.baseUri;
|
|
|
|
Discourse.Environment = setupData.environment;
|
|
|
|
Discourse.SiteSettings = ps.get("siteSettings");
|
|
|
|
Discourse.ThemeSettings = ps.get("themeSettings");
|
|
|
|
Discourse.LetterAvatarVersion = setupData.letterAvatarVersion;
|
|
|
|
Discourse.MarkdownItURL = setupData.markdownItUrl;
|
|
|
|
Discourse.ServiceWorkerURL = setupData.serviceWorkerUrl;
|
|
|
|
I18n.defaultLocale = setupData.defaultLocale;
|
|
|
|
Discourse.start();
|
|
|
|
Discourse.set("assetVersion", setupData.assetVersion);
|
|
|
|
Discourse.Session.currentProp(
|
|
|
|
"disableCustomCSS",
|
|
|
|
setupData.disableCustomCss === "true"
|
|
|
|
);
|
|
|
|
|
|
|
|
if (setupData.safeMode) {
|
|
|
|
Discourse.Session.currentProp("safe_mode", setupData.safeMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
Discourse.HighlightJSPath = setupData.highlightJsPath;
|
2018-11-27 05:49:57 +08:00
|
|
|
Discourse.SvgSpritePath = setupData.svgSpritePath;
|
|
|
|
|
|
|
|
if (Discourse.Environment === "development") {
|
|
|
|
Discourse.SvgIconList = setupData.svgIconList;
|
|
|
|
}
|
2018-10-02 12:29:04 +08:00
|
|
|
|
2018-10-02 13:02:12 +08:00
|
|
|
if (setupData.s3BaseUrl) {
|
2018-10-02 12:29:04 +08:00
|
|
|
Discourse.S3CDN = setupData.s3Cdn;
|
|
|
|
Discourse.S3BaseUrl = setupData.s3BaseUrl;
|
|
|
|
}
|
2018-10-09 13:50:45 +08:00
|
|
|
|
|
|
|
Ember.RSVP.configure("onerror", function(e) {
|
|
|
|
// Ignore TransitionAborted exceptions that bubble up
|
|
|
|
if (e && e.message === "TransitionAborted") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Discourse.Environment === "development") {
|
2018-11-15 06:17:56 +08:00
|
|
|
/* eslint-disable no-console */
|
2018-10-09 13:50:45 +08:00
|
|
|
if (e) {
|
|
|
|
if (e.message || e.stack) {
|
|
|
|
console.log(e.message);
|
|
|
|
console.log(e.stack);
|
|
|
|
} else {
|
|
|
|
console.log("Uncaught promise: ", e);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log("A promise failed but was not caught.");
|
|
|
|
}
|
2018-11-15 06:17:56 +08:00
|
|
|
/* eslint-enable no-console */
|
2018-10-09 13:50:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
window.onerror(e && e.message, null, null, null, e);
|
|
|
|
});
|
2018-09-17 16:31:46 +08:00
|
|
|
})();
|