hardcode warnings about import/export support

pull/1/head
ansuz 4 years ago
parent 8735fafe0d
commit c127fc5843

@ -575,12 +575,18 @@ define([
} }
else if (callback) {*/ else if (callback) {*/
// Old import button, used in settings // Old import button, used in settings
button var importer = importContent((data && data.binary) ? 'application/octet-stream' : 'text/plain', callback, {
.click(common.prepareFeedback(type))
.click(importContent((data && data.binary) ? 'application/octet-stream' : 'text/plain', callback, {
accept: data ? data.accept : undefined, accept: data ? data.accept : undefined,
binary: data ? data.binary : undefined binary: data ? data.binary : undefined
})); });
var handler = data.first? function () {
data.first(importer);
}: importer; //importContent;
button
.click(common.prepareFeedback(type))
.click(handler);
//} //}
break; break;
case 'upload': case 'upload':

@ -51,6 +51,8 @@ define([
{ {
var saveAs = window.saveAs; var saveAs = window.saveAs;
var Nacl = window.nacl; var Nacl = window.nacl;
Messages.oo_exportChrome = "Your browser cannot handle conversion to and from Microsoft Office formats. We suggest using a recent version of Firefox or Chrome."; // XXX
Messages.oo_importBin = "Click OK to import CryptPad's internal .bin format."; // XXX
var APP = window.APP = { var APP = window.APP = {
$: $, $: $,
@ -74,6 +76,7 @@ define([
}; };
var supportsXLSX = function () { var supportsXLSX = function () {
//if (true) { return false; } // XXX
return !(typeof(Atomics) === "undefined" || typeof (SharedArrayBuffer) === "undefined"); return !(typeof(Atomics) === "undefined" || typeof (SharedArrayBuffer) === "undefined");
}; };
@ -1927,7 +1930,7 @@ define([
if (!supportsXLSX()) { if (!supportsXLSX()) {
ext = ['.bin']; ext = ['.bin'];
warning = '<div class="alert alert-info cp-alert-top">'+Messages.oo_exportChrome+'</div>'; warning = h('div.alert.alert-info.cp-alert-top', Messages.oo_exportChrome);
} }
var types = ext.map(function (val) { var types = ext.map(function (val) {
@ -1950,7 +1953,12 @@ define([
}; };
var $select = UIElements.createDropdown(dropdownConfig); var $select = UIElements.createDropdown(dropdownConfig);
UI.prompt(Messages.exportPrompt+warning, Util.fixFileName(suggestion), function (filename) { var promptMessage = h('span', [
Messages.exportPrompt,
warning
]);
UI.prompt(promptMessage, Util.fixFileName(suggestion), function (filename) {
// $select.getValue() // $select.getValue()
if (!(typeof(filename) === 'string' && filename)) { return; } if (!(typeof(filename) === 'string' && filename)) { return; }
var ext = ($select.getValue() || '').slice(1); var ext = ($select.getValue() || '').slice(1);
@ -2520,15 +2528,28 @@ define([
} else if (type === "doc") { } else if (type === "doc") {
accept = ['.bin', '.odt', '.docx']; accept = ['.bin', '.odt', '.docx'];
} }
var first;
if (!supportsXLSX()) { if (!supportsXLSX()) {
accept = ['.bin']; accept = ['.bin'];
first = function (cb) {
var msg = h('span', [
Messages.oo_exportChrome,
' ', h('span', Messages.oo_importBin),
]);
UI.confirm(msg, function (yes) {
if (yes) {
cb();
}
});
};
} }
if (common.isLoggedIn()) { if (common.isLoggedIn()) {
window.CryptPad_deleteLastCp = deleteLastCp; window.CryptPad_deleteLastCp = deleteLastCp;
var $importXLSX = common.createButton('import', true, { var $importXLSX = common.createButton('import', true, {
accept: accept, accept: accept,
binary : ["ods", "xlsx", "odt", "docx", "odp", "pptx"] binary : ["ods", "xlsx", "odt", "docx", "odp", "pptx"],
first: first,
}, importXLSXFile); }, importXLSXFile);
$importXLSX.appendTo(toolbar.$drawer); $importXLSX.appendTo(toolbar.$drawer);
common.createButton('hashtag', true).appendTo(toolbar.$drawer); common.createButton('hashtag', true).appendTo(toolbar.$drawer);

Loading…
Cancel
Save