factor out some duplicated conditionals for XLSX export support

pull/1/head
ansuz 4 years ago
parent 3f3155bd28
commit f3fbeaf397

@ -1390,6 +1390,9 @@ define([
}); });
}; };
var supportsXLSX = function () {
return !(typeof(Atomics) === "undefined" || typeof (SharedArrayBuffer) === "undefined");
};
var exportXLSXFile = function() { var exportXLSXFile = function() {
var text = getContent(); var text = getContent();
@ -1403,7 +1406,7 @@ define([
ext = ['.docx', /*'.odt',*/ '.bin']; ext = ['.docx', /*'.odt',*/ '.bin'];
} }
if (typeof(Atomics) === "undefined" || typeof (SharedArrayBuffer) === "undefined") { if (!supportsXLSX()) {
ext = ['.bin']; ext = ['.bin'];
warning = '<div class="alert alert-info cp-alert-top">'+Messages.oo_exportChrome+'</div>'; warning = '<div class="alert alert-info cp-alert-top">'+Messages.oo_exportChrome+'</div>';
} }
@ -1583,7 +1586,7 @@ define([
if (ext === "bin") { if (ext === "bin") {
return void importFile(content); return void importFile(content);
} }
if (typeof(Atomics) === "undefined" || typeof (SharedArrayBuffer) === "undefined") { if (!supportsXLSX()) {
return void UI.alert(Messages.oo_invalidFormat); return void UI.alert(Messages.oo_invalidFormat);
} }
var div = h('div.cp-oo-x2tXls', [ var div = h('div.cp-oo-x2tXls', [
@ -1758,7 +1761,7 @@ define([
} else if (type === "oodoc") { } else if (type === "oodoc") {
accept = ['.bin', '.odt', '.docx']; accept = ['.bin', '.odt', '.docx'];
} }
if (typeof(Atomics) === "undefined" || typeof (SharedArrayBuffer) === "undefined") { if (!supportsXLSX()) {
accept = ['.bin']; accept = ['.bin'];
} }

Loading…
Cancel
Save