Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ts/Bootstrap.ts')
-rw-r--r--ts/Bootstrap.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/ts/Bootstrap.ts b/ts/Bootstrap.ts
new file mode 100644
index 0000000..c8850bf
--- /dev/null
+++ b/ts/Bootstrap.ts
@@ -0,0 +1,33 @@
+import { DEPENDENCIES } from './CONST'
+
+export default class Bootstrap {
+ public static start() {
+ Bootstrap.checkDependencies();
+ Bootstrap.checkFrame();
+ Bootstrap.checkSpecialPage();
+ }
+
+ private static checkDependencies() {
+ for (let dependency of DEPENDENCIES) {
+ if (typeof (<any>window)[dependency] === 'undefined') {
+ throw `Dependency "${dependency}" is missing.`;
+ }
+ }
+ }
+
+ private static checkFrame() {
+ if (window.parent && window !== window.parent) {
+ throw `Abort, because we are running inside a frame.`;
+ }
+ }
+
+ private static checkSpecialPage() {
+ if (/^(\/index.php)?\/s\//.test(location.pathname)) {
+ throw `Abort, because we dont want to start chat on public shares.`;
+ }
+
+ if (OC.generateUrl('login/flow') === window.location.pathname) {
+ throw `Abort, because chat is not needed on flow login.`;
+ }
+ }
+}