aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.html
blob: 9e5acd7050ea924fa23328f08ebd508dd2dfc0ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Franz</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <link rel="stylesheet" type="text/css" href="./styles/main.css" />
  <script type="text/javascript" src="./app.js"></script>
</head>
<body>
  <div class="window-draggable"></div>
  <div class="dev-warning">DEV MODE</div>
  <div id="root"></div>
  <script>
    document.querySelector('body').classList.add(process.platform);

    const { isDevMode } = require('./environment');
    if (isDevMode) {
      document.querySelector('body').classList.add('isDevMode');

      (function() {
        const lrHost = 'http://localhost:35729';
        const s = document.createElement('script');
        s.async = true;
        s.setAttribute('src', lrHost + '/livereload.js');
        document.body.appendChild(s);

        s.onload = () => {
          console.log('livereload loaded');
          const originalReloadBehaviour = window._onLiveReloadFileChanged;

          window._onLiveReloadFileChanged = (file) => {
            if (!file.path.includes('/build/webview/') && !file.path.includes('/build/index.js') && !file.path.includes('/build/electron/')) {
              originalReloadBehaviour(file);
            } else {              
              if (file.path.includes('/build/webview/')) {
                console.log('Livereload: Reloading all webvies');
                const webviews = document.querySelectorAll('webview').forEach(webview => webview.reload());
              } else {
                console.log('Livereload: skip reload as only main process files have changed');
              }
            }
          }
        }
      })();
    }
  </script>
</body
</html>