summaryrefslogtreecommitdiffstats
path: root/browser/html/cool.html.m4
blob: 15e0584faadc138acba483f4d992f6434ac556ac (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
m4_dnl -*- Mode: HTML -*-x
m4_changequote([,])m4_dnl
m4_dnl# m4_foreachq(x, `item_1, item_2, ..., item_n', stmt)
m4_dnl# quoted list, alternate improved version
m4_define([m4_foreachq],[m4_ifelse([$2],[],[],[m4_pushdef([$1])_$0([$1],[$3],[],$2)m4_popdef([$1])])])m4_dnl
m4_define([_m4_foreachq],[m4_ifelse([$#],[3],[],[m4_define([$1],[$4])$2[]$0([$1],[$2],m4_shift(m4_shift(m4_shift($@))))])])m4_dnl
m4_define(_YEAR_,m4_esyscmd(date +%Y|tr -d '\n'))
<!DOCTYPE html>
<!-- saved from url=(0054)http://leafletjs.com/examples/quick-start-example.html -->
<html %UI_RTL_SETTINGS% style="height:100%"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Online Editor</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0 minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<script>
m4_dnl# Define MOBILEAPP as true if this is either for the iOS app or for the gtk+ "app" testbed
   window.welcomeUrl = '%WELCOME_URL%';
   window.feedbackUrl = '%FEEDBACK_URL%';
m4_define([MOBILEAPP],[])
m4_ifelse(IOSAPP,[true],[m4_define([MOBILEAPP],[true])])
m4_ifelse(GTKAPP,[true],[m4_define([MOBILEAPP],[true])])
m4_ifelse(ANDROIDAPP,[true],[m4_define([MOBILEAPP],[true])])
m4_ifelse(MOBILEAPP,[],
  // Start listening for Host_PostmessageReady message and save the
  // result for future
    window.WOPIpostMessageReady = false;
    var PostMessageReadyListener = function(e) {
    if (!(e && e.data))
        return;

    try {
        var msg = JSON.parse(e.data);
    } catch (err) {
        return;
    }

    if (msg.MessageId === 'Host_PostmessageReady') {
      window.WOPIPostmessageReady = true;
      window.removeEventListener('message', PostMessageReadyListener, false);
    }
  };
  window.addEventListener('message', PostMessageReadyListener, false);
)m4_dnl

m4_dnl# For use in conditionals in JS: window.ThisIsAMobileApp, window.ThisIsTheiOSApp,
m4_dnl# and window.ThisIsTheGtkApp

m4_ifelse(MOBILEAPP,[true],
  [   window.ThisIsAMobileApp = true;
   window.HelpFile = String.raw`m4_syscmd([cat html/cool-help.html])`;
   window.open = function (url, windowName, windowFeatures) {
     window.postMobileMessage('HYPERLINK ' + url); /* don't call the 'normal' window.open on mobile at all */
   }
   window.MobileAppName='MOBILEAPPNAME';
   brandProductName='MOBILEAPPNAME';],
  [   window.ThisIsAMobileApp = false;]
)
m4_ifelse(IOSAPP,[true],
  [   window.ThisIsTheiOSApp = true;
   window.postMobileMessage = function(msg) { window.webkit.messageHandlers.cool.postMessage(msg); };
   window.postMobileError   = function(msg) { window.webkit.messageHandlers.error.postMessage(msg); };
   window.postMobileDebug   = function(msg) { window.webkit.messageHandlers.debug.postMessage(msg); };],
  [   window.ThisIsTheiOSApp = false;]
)
m4_ifelse(GTKAPP,[true],
  [   window.ThisIsTheGtkApp = true;
   window.postMobileMessage = function(msg) { window.webkit.messageHandlers.cool.postMessage(msg, '*'); };
   window.postMobileError   = function(msg) { window.webkit.messageHandlers.error.postMessage(msg, '*'); };
   window.postMobileDebug   = function(msg) { window.webkit.messageHandlers.debug.postMessage(msg, '*'); };],
  [   window.ThisIsTheGtkApp = false;]
)
m4_ifelse(ANDROIDAPP,[true],
  [   window.ThisIsTheAndroidApp = true;
   window.postMobileMessage = function(msg) { window.COOLMessageHandler.postMobileMessage(msg); };
   window.postMobileError   = function(msg) { window.COOLMessageHandler.postMobileError(msg); };
   window.postMobileDebug   = function(msg) { window.COOLMessageHandler.postMobileDebug(msg); };],
  [   window.ThisIsTheAndroidApp = false;]
)

if (window.ThisIsTheiOSApp) {
  window.addEventListener('keydown', function(e) {
    if (e.metaKey) {
      e.preventDefault();
    }
    if (window.MagicKeyDownHandler)
      window.MagicKeyDownHandler(e);
  });
  window.addEventListener('keyup', function(e) {
    if (e.metaKey) {
      e.preventDefault();
    }
    if (window.MagicKeyUpHandler)
      window.MagicKeyUpHandler(e);
  });
}

var Base64ToArrayBuffer = function(base64Str) {
  var binStr = atob(base64Str);
  var ab = new ArrayBuffer(binStr.length);
  var bv = new Uint8Array(ab);
  for (var i = 0, l = binStr.length; i < l; i++) {
    bv[[i]] = binStr.charCodeAt(i);
  }
  return ab;
}

  window.bundlejsLoaded = false;
  window.fullyLoadedAndReady = false;
  window.addEventListener('load', function() {
    window.fullyLoadedAndReady = true;
  }, false);

window.isLocalStorageAllowed = (function() {
  var str = 'localstorage_test';
  try {
    localStorage.setItem(str, str);
    localStorage.removeItem(str);
    return true;
  } catch(e) {
    return false;
  }
})();
function onSlideClick(e){
	// Scroll
	document.getElementById(e.substring(2)).scrollIntoView( {behavior: 'smooth' });
	// Switch active indicator
	for (var i = 1; i<4; i++)
		document.getElementById('i-slide-' + i).classList.remove("active");
	document.getElementById(e).classList.add("active");
}

</script>

m4_ifelse(BUNDLE,[],
  <!-- Using individual CSS files -->
  m4_foreachq([fileCSS],[COOL_CSS],[<link rel="stylesheet" href="][m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])][fileCSS" />
]),
  [<!-- Dynamically load the bundle.css -->
<script>
var link = document.createElement('link');
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("href", '][m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])][bundle.css');
document.getElementsByTagName("head")[[0]].appendChild(link);
</script>
])
<!--%BRANDING_CSS%--> <!-- add your logo here -->
m4_ifelse(IOSAPP,[true],
  [<link rel="stylesheet" href="Branding/branding.css">])
m4_ifelse(ANDROIDAPP,[true],
  [<link rel="stylesheet" href="branding.css">])

m4_dnl Handle localization
m4_ifelse(MOBILEAPP,[true],
  [
   m4_ifelse(IOSAPP,[true],
     [],
     [<link rel="localizations" href="l10n/uno-localizations-override.json" type="application/vnd.oftn.l10n+json"/>
      <link rel="localizations" href="l10n/localizations.json" type="application/vnd.oftn.l10n+json"/>
      <link rel="localizations" href="l10n/locore-localizations.json" type="application/vnd.oftn.l10n+json"/>
      <link rel="localizations" href="l10n/help-localizations.json" type="application/vnd.oftn.l10n+json"/>
      <link rel="localizations" href="l10n/uno-localizations.json" type="application/vnd.oftn.l10n+json"/>])],
  [<link rel="localizations" href="%SERVICE_ROOT%/browser/%VERSION%/l10n/uno-localizations-override.json" type="application/vnd.oftn.l10n+json"/>
   <link rel="localizations" href="%SERVICE_ROOT%/browser/%VERSION%/l10n/localizations.json" type="application/vnd.oftn.l10n+json"/>
   <link rel="localizations" href="%SERVICE_ROOT%/browser/%VERSION%/l10n/locore-localizations.json" type="application/vnd.oftn.l10n+json"/>
   <link rel="localizations" href="%SERVICE_ROOT%/browser/%VERSION%/l10n/help-localizations.json" type="application/vnd.oftn.l10n+json"/>
   <link rel="localizations" href="%SERVICE_ROOT%/browser/%VERSION%/l10n/uno-localizations.json" type="application/vnd.oftn.l10n+json"/>]
)m4_dnl
</head>

  <body style="user-select: none;height:100%;display:flex;flex-direction:column">
    <!--The "controls" div holds map controls such as the Zoom button and
        it's separated from the map in order to have the controls on the top
        of the page all the time.

        The "document-container" div is the actual display of the document, is
        what the user sees and it should be no larger than the screen size.

        The "map" div is the actual document and it has the document's size
        and width, this being inside the smaller "document-container" will
        cause the content to overflow, creating scrollbars -->

    <nav class="main-nav" role="navigation">
      <!-- Mobile menu toggle button (hamburger/x icon) -->
      <input id="main-menu-state" type="checkbox" style="display: none"/>
      <ul id="main-menu" class="sm sm-simple lo-menu readonly"></ul>
      <div id="document-titlebar">
        <div class="document-title">
          <!-- visuallyhidden: hide it visually but keep it available to screen reader and other assistive technology -->
          <label class="visuallyhidden" for="document-name-input" aria-hidden="false">Document name</label>
          <input id="document-name-input" type="text" disabled="true" style="display: none"/>
        </div>
      </div>

      <div id="userListHeader">
        <div id="userListSummary"></div>
        <div id="userListPopover"></div>
      </div>

      <div id="closebuttonwrapper">
        <div class="closebuttonimage" id="closebutton"></div>
      </div>
     </nav>

     <table id="toolbar-wrapper">
     <tr>
       <td id="toolbar-logo"></td>
       <td id="toolbar-mobile-back" class="editmode-off"></td>
       <td id="toolbar-up"></td>
       <td id="toolbar-hamburger">
         <label class="main-menu-btn" for="main-menu-state">
           <span class="main-menu-btn-icon" id="main-menu-btn-icon"></span>
         </label>
       </td>
     </tr>
     <tr>
       <td colspan="4" id="formulabar" style="display: none"></td>
     </tr>
    </table>

    <!--%DOCUMENT_SIGNING_DIV%-->
    <script>
    m4_ifelse(MOBILEAPP,[true],
      [ window.documentSigningURL = ''; ],
      [ window.documentSigningURL = decodeURIComponent('%DOCUMENT_SIGNING_URL%'); ]
    )
    </script>

    <input id="insertgraphic" aria-labelledby="menu-insertgraphic" type="file" accept="image/*" style="position: fixed; top: -100em">
    <input id="selectbackground" aria-labelledby="menu-selectbackground" type="file" accept="image/*" style="position: fixed; top: -100em">

    <div id="main-document-content" style="display:flex; flex-direction: row; flex: 1; margin: 0; padding: 0; min-height: 0">
      <div id="presentation-controls-wrapper" class="readonly">
        <div id="slide-sorter"></div>
        <div id="presentation-toolbar" style="display: none"></div>
      </div>
      <div id="document-container" class="readonly" dir="ltr">
        <div id="map"></div>
      </div>
      <div id="sidebar-dock-wrapper" style="display: none;">
        <div id="sidebar-panel"></div>
      </div>
    </div>

    <div id="spreadsheet-toolbar" style="display: none"></div>

    <div id="mobile-edit-button" style="display: none">
      <div id="mobile-edit-button-image"></div>
    </div>

    <div id="toolbar-down" style="display: none"></div>
    <div id="toolbar-search" style="display: none"></div>
    <div id="mobile-wizard" style="display: none">
      <div id="mobile-wizard-tabs"></div>
      <table id="mobile-wizard-titlebar" class="mobile-wizard-titlebar" width="100%">
        <tr>
          <td id="mobile-wizard-back" class="mobile-wizard-back"></td>
          <td id="mobile-wizard-title" class="mobile-wizard-title ui-widget"></td>
        </tr>
      </table>
      <div id="mobile-wizard-content"></div>
    </div>

    <!-- Remove if you don't want the About dialog -->
    <div id="about-dialog" style="display:none; user-select: text">
      <div id="about-dialog-header">
        <fig id="integrator-logo"></fig>
        <h1 id="product-name">Collabora Online</h1>
      </div>
      <hr/>
      <div id="about-dialog-container">
        <div id="about-dialog-logos">
          <fig id="product-logo"></fig>
          <fig id="lokit-logo"></fig>
        </div>
        <div id="about-dialog-info-container">
          <div id="about-dialog-info">
            <div id="coolwsd-version-label"></div>
            <div style="margin-inline-end: auto;"><div id="coolwsd-version" dir="ltr"></div></div>
            <div class="spacer"></div>
            <div id="lokit-version-label"></div>
            <div style="margin-inline-end: auto;"><div id="lokit-version" dir="ltr"></div></div>
            m4_ifelse(MOBILEAPP,[],[<div id="served-by"><span id="served-by-label"></span>&nbsp;<span id="os-info"></span>&nbsp;<wbr><span id="coolwsd-id"></span></div>],[<p></p>])
            <div id="slow-proxy"></div>
            <p style="margin-inline-end: auto;"><span dir="ltr">Copyright © _YEAR_, VENDOR.</span></p>
          </div>
        </div>
      </div>
    </div>

    <script>
m4_ifelse(MOBILEAPP,[true],
     [window.host = '';
      window.serviceRoot = '';
      window.hexifyUrl = false;
      // We can't use %VERSION% here as there is no FileServer.cpp involved in a mobile app that
      // would expand the %FOO% things. But it seems that window.versionPath is not used in the
      // mobile apps anyway.
      // window.versionPath = 'UNKNOWN';
      window.accessToken = '';
      window.accessTokenTTL = '';
      window.accessHeader = '';
      window.postMessageOriginExt = '';
      window.coolLogging = 'true';
      window.enableWelcomeMessage = false;
      window.autoShowWelcome = false;
	  window.autoShowFeedback = true;
      window.outOfFocusTimeoutSecs = 1000000;
      window.idleTimeoutSecs = 1000000;
      window.protocolDebug = false;
      window.frameAncestors = '';
      window.socketProxy = false;
      window.tileSize = 256;
      window.uiDefaults = {};
      window.useIntegrationTheme = 'false';
      window.checkFileInfoOverride = {};],
     [window.host = '%HOST%';
      window.serviceRoot = '%SERVICE_ROOT%';
      window.hexifyUrl = %HEXIFY_URL%;
      window.versionPath = '%VERSION%';
      window.accessToken = '%ACCESS_TOKEN%';
      window.accessTokenTTL = '%ACCESS_TOKEN_TTL%';
      window.accessHeader = '%ACCESS_HEADER%';
      window.postMessageOriginExt = '%POSTMESSAGE_ORIGIN%';
      window.coolLogging = '%BROWSER_LOGGING%';
      window.coolwsdVersion = '%COOLWSD_VERSION%';
      window.enableWelcomeMessage = %ENABLE_WELCOME_MSG%;
      window.autoShowWelcome = %AUTO_SHOW_WELCOME%;
	  window.autoShowFeedback = %AUTO_SHOW_FEEDBACK%;
      window.userInterfaceMode = '%USER_INTERFACE_MODE%';
      window.useIntegrationTheme = '%USE_INTEGRATION_THEME%';
      window.enableMacrosExecution = '%ENABLE_MACROS_EXECUTION%';
      window.outOfFocusTimeoutSecs = %OUT_OF_FOCUS_TIMEOUT_SECS%;
      window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;
      window.protocolDebug = %PROTOCOL_DEBUG%;
      window.frameAncestors = decodeURIComponent('%FRAME_ANCESTORS%');
      window.socketProxy = %SOCKET_PROXY%;
      window.tileSize = 256;
      window.groupDownloadAsForNb = %GROUP_DOWNLOAD_AS%;
      window.uiDefaults = %UI_DEFAULTS%;
      window.checkFileInfoOverride = %CHECK_FILE_INFO_OVERRIDE%;])

// This is GLOBAL_JS:
m4_syscmd([cat ]GLOBAL_JS)m4_dnl

m4_ifelse(IOSAPP,[true],
     [window.userInterfaceMode = window.getParameterByName('userinterfacemode');])

m4_ifelse(ANDROIDAPP,[true],
     [window.userInterfaceMode = window.getParameterByName('userinterfacemode');])

// Dynamically load the appropriate *-mobile.css, *-tablet.css or *-desktop.css
var link = document.createElement('link');
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
var brandingLink = document.createElement('link');
brandingLink.setAttribute("rel", "stylesheet");
brandingLink.setAttribute("type", "text/css");

var theme_name = document.getElementsByName("theme")[[0]] ? document.getElementsByName("theme")[[0]].value : '';
var theme_prefix = '';
if(window.useIntegrationTheme === 'true' && theme_name.includes("nextcloud")) {
    theme_prefix = 'nextcloud/';
}

if (window.mode.isMobile()) {
    [link.setAttribute("href", ']m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])[device-mobile.css');]
    [brandingLink.setAttribute("href", ']m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])m4_ifelse(IOSAPP,[true],[Branding/])[' + theme_prefix + 'branding-mobile.css');]
} else if (window.mode.isTablet()) {
    [link.setAttribute("href", ']m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])[device-tablet.css');]
    [brandingLink.setAttribute("href", ']m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])m4_ifelse(IOSAPP,[true],[Branding/])[' + theme_prefix + 'branding-tablet.css');]
} else {
    [link.setAttribute("href", ']m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])[device-desktop.css');]
    [brandingLink.setAttribute("href", ']m4_ifelse(MOBILEAPP,[],[%SERVICE_ROOT%/browser/%VERSION%/])[' + theme_prefix + 'branding-desktop.css');]
}
document.getElementsByTagName("head")[[0]].appendChild(link);
document.getElementsByTagName("head")[[0]].appendChild(brandingLink);
</script>

m4_ifelse(MOBILEAPP,[true],
  <!-- This is for a mobile app so the script files are in the same folder -->
  m4_ifelse(BUNDLE,[],m4_foreachq([fileJS],[COOL_JS],
  [    <script src="fileJS" defer></script>
  ]),
  [    <script src="bundle.js" defer></script>
  ]),
  m4_ifelse(BUNDLE,[],
      <!-- Using indivisual JS files -->
      m4_foreachq([fileJS],[COOL_JS],
      [ <script src="%SERVICE_ROOT%/browser/%VERSION%/fileJS" defer></script>
      ]),
  [
       <!-- Using bundled JS files -->
       <script src="%SERVICE_ROOT%/browser/%VERSION%/bundle.js" defer></script>
  ])
)m4_dnl

    m4_ifelse(MOBILEAPP,[true],
    [<script src="m4_ifelse(IOSAPP,[true],[Branding/])branding.js"></script>],
    [<!--%BRANDING_JS%--> <!-- logo onclick handler -->
    <!--%CSS_VARIABLES%-->])
</body></html>