index.html 3.09 KB
Newer Older
Cédric Moreau's avatar
Cédric Moreau committed
1
2
3
4
5
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
Cédric Moreau's avatar
v1.6.2    
Cédric Moreau committed
6
  <title>Duniter 1.6.2</title>
Cédric Moreau's avatar
Cédric Moreau committed
7
8
9
  <style>
    html {
      font-family: "Courier New", Courier, monospace;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      border: none;
    }
    body {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      border: none;
      overflow: hidden;
    }
    iframe {
      width: 100%;
      height: 100%;
      border: none;
Cédric Moreau's avatar
Cédric Moreau committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    }
    img {
      width: 50%;
      margin-left: auto;
      margin-right: auto;
      display: block;

      margin-top: 40vh;
      transform: translateY(-50%);
    }
    h1 {
      text-align: center;
      width: 80%;
      margin-top: -10%;
      margin-left: auto;
      margin-right: auto;
    }
  </style>
</head>
<body>
<img src="duniter.png"/>
<h1 id="loader">Loading...</h1>
<script type="text/javascript">
51
52
53
54

  const SERVER_ORIGIN = '127.0.0.1:9220';

  let gui = require('nw.gui');
55

56
  let packageJSON = require(require('path').resolve('./package.json'));
Cédric Moreau's avatar
Cédric Moreau committed
57
58
  function reqListener () {
    document.getElementById('loader').innerHTML = 'Server ready.';
59
60
    clearTimeout(strangeTimeout);
    clearInterval(testInterval);
61
62
63
64
65
66
67
68
69
70
71
72
73
    document.getElementById('loader').remove();
    document.getElementsByTagName('img')[0].remove();
    const iframe = document.createElement('iframe');
    document.getElementsByTagName('body')[0].appendChild(iframe);
    iframe.src = "http://" + SERVER_ORIGIN;

    const interval = setInterval(() => {
      if (iframe.contentWindow.duniterChildCallback) {
        clearInterval(interval);
        iframe.contentWindow.duniterChildCallback(gui);
      }
    }, 1000);

74
75
76
77
78
    let memorizedValue = null;
    try {
      memorizedValue = JSON.parse(localStorage.getItem('DUNITER_WINDOW_SIZE'));
    } catch (e) {
    }
79
80
    const NORMAL_WIDTH = 1200;
    const NORMAL_HEIGHT = 850;
81
    const DUNITER_WINDOW_SIZE = memorizedValue || {
82
83
              width: NORMAL_WIDTH,
              height: NORMAL_HEIGHT,
84
85
86
              min_height: 600,
              min_width: 600
            };
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

    window.resizeTo(DUNITER_WINDOW_SIZE.width, DUNITER_WINDOW_SIZE.height);

    const heightDifference = DUNITER_WINDOW_SIZE.height - NORMAL_HEIGHT;
    const widthDifference  = DUNITER_WINDOW_SIZE.width - NORMAL_WIDTH;

    if (heightDifference != 0 || widthDifference != 0) {
      window.moveBy(-widthDifference / 2, -heightDifference / 2);
    }

    // Remember the size
    window.onresize = function() {
      DUNITER_WINDOW_SIZE.height = window.innerHeight;
      DUNITER_WINDOW_SIZE.width = window.innerWidth;
      localStorage.setItem('DUNITER_WINDOW_SIZE', JSON.stringify(DUNITER_WINDOW_SIZE));
    };
Cédric Moreau's avatar
Cédric Moreau committed
103
104
105
106
  }
  function test() {
    var oReq = new XMLHttpRequest();
    oReq.addEventListener("load", reqListener);
107
    oReq.open("GET", "http://" + SERVER_ORIGIN);
Cédric Moreau's avatar
Cédric Moreau committed
108
109
110
111
112
    oReq.send();
  }
  function strange () {
    document.getElementById('loader').innerHTML = 'The server is not starting...';
  }
113
114
  var testInterval = setInterval(test, 800);
  var strangeTimeout = setTimeout(strange, 8000);
Cédric Moreau's avatar
Cédric Moreau committed
115
116
</script>
</body>
117
</html>