diff options
Diffstat (limited to 'ts/Bootstrap.ts')
-rw-r--r-- | ts/Bootstrap.ts | 33 |
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.`; + } + } +} |