2016-12-15 03:56:54 -06:00
|
|
|
// If not debug, don't print anything on the console
|
2017-03-07 08:51:31 -06:00
|
|
|
// except in tile debug mode (Ctrl-Shift-Alt-d)
|
2017-04-24 09:29:16 -05:00
|
|
|
console.log2 = console.log;
|
2016-12-15 03:56:54 -06:00
|
|
|
if (loleaflet_logging !== 'true') {
|
|
|
|
var methods = ['warn', 'info', 'debug', 'trace', 'log', 'assert', 'time', 'timeEnd'];
|
|
|
|
for (var i = 0; i < methods.length; i++) {
|
|
|
|
console[methods[i]] = function() {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 14:59:16 -05:00
|
|
|
// Include our main css file
|
|
|
|
require('./main.css');
|
|
|
|
|
2016-08-02 14:52:23 -05:00
|
|
|
var $ = require('jquery');
|
|
|
|
global.$ = global.jQuery = $;
|
|
|
|
|
|
|
|
require('smartmenus');
|
|
|
|
require('jquery-ui');
|
|
|
|
require('jquery-contextmenu');
|
2016-09-30 09:52:03 -05:00
|
|
|
require('timeago');
|
2017-04-24 09:29:16 -05:00
|
|
|
global.Autolinker = require('autolinker');
|
2016-08-02 14:52:23 -05:00
|
|
|
// FIXME: would be good to remove w2ui script tags and require
|
|
|
|
// like other modules. problem is that w2ui doesn't export
|
|
|
|
// its global variables for a module, so following doesn't work
|
|
|
|
// This also leads to toolbar.js being included
|
|
|
|
//global.w2ui = require('./3rdparty/w2ui/w2ui');
|
|
|
|
|
|
|
|
global._ = function (string) {
|
|
|
|
return string.toLocaleString();
|
|
|
|
};
|
|
|
|
require('json-js/json2');
|
|
|
|
require('l10n-for-node');
|
|
|
|
require('select2');
|
|
|
|
require('evol-colorpicker');
|
|
|
|
require('malihu-custom-scrollbar-plugin')($);
|
|
|
|
|
|
|
|
var vex = require('vex-js');
|
|
|
|
vex.dialog = require('vex-js/js/vex.dialog.js');
|
|
|
|
vex.defaultOptions.className = 'vex-theme-plain';
|
|
|
|
global.vex = vex;
|
|
|
|
|
|
|
|
var errorMessages = require('./dist/errormessages');
|
|
|
|
|
|
|
|
function getParameterByName(name) {
|
|
|
|
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
|
|
|
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
|
|
|
results = regex.exec(location.search);
|
|
|
|
return results === null ? "" : results[1].replace(/\+/g, " ");
|
|
|
|
}
|
|
|
|
var lang = getParameterByName('lang');
|
|
|
|
if (lang) {
|
|
|
|
String.locale = lang;
|
|
|
|
}
|
|
|
|
|
2016-11-07 06:29:42 -06:00
|
|
|
var L = require('loleaflet');
|
|
|
|
require('./dist/plugins/draw-0.2.4/dist/leaflet.draw.js');
|
|
|
|
|
2016-08-02 14:52:23 -05:00
|
|
|
var wopiSrc = getParameterByName('WOPISrc');
|
|
|
|
|
|
|
|
if (wopiSrc !== '' && access_token !== '') {
|
2016-11-29 09:47:18 -06:00
|
|
|
var wopiParams = { 'access_token': access_token, 'access_token_ttl': access_token_ttl };
|
2016-08-02 14:52:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var filePath = getParameterByName('file_path');
|
|
|
|
var title = getParameterByName('title');
|
|
|
|
if (title === '') {
|
|
|
|
title = decodeURIComponent(filePath.substring(filePath.lastIndexOf('/')+1));
|
|
|
|
}
|
|
|
|
|
2016-09-20 00:27:39 -05:00
|
|
|
var permission = getParameterByName('permission') || 'edit';
|
2016-08-02 14:52:23 -05:00
|
|
|
var timestamp = getParameterByName('timestamp');
|
|
|
|
// Shows close button if non-zero value provided
|
|
|
|
var closebutton = getParameterByName('closebutton');
|
|
|
|
// Shows revision history file menu option
|
|
|
|
var revHistoryEnabled = getParameterByName('revisionhistory');
|
2017-03-10 03:28:47 -06:00
|
|
|
// Should the document go inactive or not
|
|
|
|
var alwaysActive = getParameterByName('alwaysactive');
|
2017-05-24 09:28:14 -05:00
|
|
|
// Disable the about dialog
|
|
|
|
var disableAbout = getParameterByName('disableabout');
|
2016-09-21 11:52:11 -05:00
|
|
|
// Loleaflet Debug mode
|
|
|
|
var debugMode = getParameterByName('debug');
|
2016-08-02 14:52:23 -05:00
|
|
|
if (wopiSrc === '' && filePath === '') {
|
|
|
|
vex.dialog.alert(errorMessages.wrongwopisrc);
|
|
|
|
}
|
|
|
|
if (host === '') {
|
|
|
|
vex.dialog.alert(errorMessages.emptyhosturl);
|
|
|
|
}
|
|
|
|
|
|
|
|
// loleaflet.js accesses these globals
|
|
|
|
// TODO: Get rid of these globals
|
|
|
|
global.closebutton = closebutton;
|
|
|
|
global.revHistoryEnabled = revHistoryEnabled;
|
2017-05-24 09:28:14 -05:00
|
|
|
global.disableAbout = disableAbout;
|
2016-08-03 07:57:23 -05:00
|
|
|
global.title = title;
|
2016-09-30 04:50:06 -05:00
|
|
|
global.errorMessages = errorMessages;
|
2016-08-02 14:52:23 -05:00
|
|
|
var docURL, docParams;
|
2016-11-07 10:07:40 -06:00
|
|
|
var isWopi = false;
|
2016-08-02 14:52:23 -05:00
|
|
|
if (wopiSrc != '') {
|
2016-11-17 01:01:25 -06:00
|
|
|
docURL = decodeURIComponent(wopiSrc);
|
2016-10-25 02:13:00 -05:00
|
|
|
docParams = wopiParams;
|
2016-11-07 10:07:40 -06:00
|
|
|
isWopi = true;
|
2016-08-02 14:52:23 -05:00
|
|
|
} else {
|
|
|
|
docURL = filePath;
|
2016-10-25 02:13:00 -05:00
|
|
|
docParams = {};
|
2016-08-02 14:52:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
var map = L.map('map', {
|
2017-05-10 23:02:38 -05:00
|
|
|
server: host,
|
|
|
|
doc: docURL,
|
|
|
|
docParams: docParams,
|
|
|
|
permission: permission,
|
|
|
|
timestamp: timestamp,
|
|
|
|
documentContainer: 'document-container',
|
|
|
|
debug: debugMode,
|
2017-03-10 03:28:47 -06:00
|
|
|
wopi: isWopi,
|
2017-05-10 23:02:38 -05:00
|
|
|
alwaysActive: alwaysActive,
|
|
|
|
idleTimeoutSecs: idleTimeoutSecs, // Dim when user is idle.
|
2017-05-18 13:05:45 -05:00
|
|
|
outOfFocusTimeoutSecs: outOfFocusTimeoutSecs // Dim after switching tabs.
|
2016-09-28 08:59:41 -05:00
|
|
|
});
|
2016-08-02 14:52:23 -05:00
|
|
|
// toolbar.js (loaded in <script> tag accesses map as global variable,
|
|
|
|
// so expose it
|
|
|
|
global.map = map;
|
|
|
|
|
|
|
|
////// Controls /////
|
|
|
|
map.addControl(L.control.scroll());
|
|
|
|
map.addControl(L.control.dialog());
|
|
|
|
map.addControl(L.control.partsPreview());
|
|
|
|
map.addControl(L.control.tabs());
|
|
|
|
map.addControl(L.control.columnHeader());
|
|
|
|
map.addControl(L.control.rowHeader());
|
|
|
|
map.addControl(L.control.contextMenu());
|
|
|
|
map.addControl(L.control.menubar());
|
|
|
|
|
2016-12-28 11:44:49 -06:00
|
|
|
window.addEventListener('beforeunload', function () {
|
|
|
|
if (global.map && global.map._socket) {
|
|
|
|
global.map._socket.close();
|
|
|
|
}
|
|
|
|
});
|
2016-08-02 14:52:23 -05:00
|
|
|
//require('./dist/toolbar/toolbar');
|