mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
lint: pad prefix files (#4577)
* lint: pad_connectionstatus * lint: pad_utils * lint: pad_userlist.js -- still WIP * shift underscore not to be in require but to be used from window * lint: pad_modals * pad_impexp.js * lint: more errors done * lint: auto reconn * lint: pad_editor * lint: finish auto reconn * lint: imp exp rework * lint: import * lint: pad.js nearly done but pizza here... * lint: clientVars global query * put clientVars in window * Revert incorrect lint fixes * Properly fix guard-for-in lint errors * Properly fix no-unused-vars error regarding `gritter` * Refine lint fixes Co-authored-by: Richard Hansen <rhansen@rhansen.org>
This commit is contained in:
parent
34ee77993f
commit
0362d3b05d
11 changed files with 512 additions and 459 deletions
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
||||
* This helps other people to understand this code better and helps them to improve it.
|
||||
|
@ -20,24 +22,27 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const padimpexp = (function () {
|
||||
const padimpexp = (() => {
|
||||
// /// import
|
||||
let currentImportTimer = null;
|
||||
|
||||
function addImportFrames() {
|
||||
const addImportFrames = () => {
|
||||
$('#import .importframe').remove();
|
||||
const iframe = $('<iframe style="display: none;" name="importiframe" class="importframe"></iframe>');
|
||||
const iframe = $('<iframe>')
|
||||
.css('display', 'none')
|
||||
.attr('name', 'importiframe')
|
||||
.addClass('importframe');
|
||||
$('#import').append(iframe);
|
||||
}
|
||||
};
|
||||
|
||||
function fileInputUpdated() {
|
||||
const fileInputUpdated = () => {
|
||||
$('#importsubmitinput').addClass('throbbold');
|
||||
$('#importformfilediv').addClass('importformenabled');
|
||||
$('#importsubmitinput').removeAttr('disabled');
|
||||
$('#importmessagefail').fadeOut('fast');
|
||||
}
|
||||
};
|
||||
|
||||
function fileInputSubmit() {
|
||||
const fileInputSubmit = () => {
|
||||
$('#importmessagefail').fadeOut('fast');
|
||||
const ret = window.confirm(html10n.get('pad.impexp.confirmimport'));
|
||||
if (ret) {
|
||||
|
@ -64,13 +69,13 @@ const padimpexp = (function () {
|
|||
$('#importstatusball').show();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
function importFailed(msg) {
|
||||
const importFailed = (msg) => {
|
||||
importErrorMessage(msg);
|
||||
}
|
||||
};
|
||||
|
||||
function importDone() {
|
||||
const importDone = () => {
|
||||
$('#importsubmitinput').removeAttr('disabled').val(html10n.get('pad.impexp.importbutton'));
|
||||
window.setTimeout(() => {
|
||||
$('#importfileinput').removeAttr('disabled');
|
||||
|
@ -78,16 +83,16 @@ const padimpexp = (function () {
|
|||
$('#importstatusball').hide();
|
||||
importClearTimeout();
|
||||
addImportFrames();
|
||||
}
|
||||
};
|
||||
|
||||
function importClearTimeout() {
|
||||
const importClearTimeout = () => {
|
||||
if (currentImportTimer) {
|
||||
window.clearTimeout(currentImportTimer);
|
||||
currentImportTimer = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function importErrorMessage(status) {
|
||||
const importErrorMessage = (status) => {
|
||||
let msg = '';
|
||||
|
||||
if (status === 'convertFailed') {
|
||||
|
@ -102,9 +107,11 @@ const padimpexp = (function () {
|
|||
msg = html10n.get('pad.impexp.permission');
|
||||
}
|
||||
|
||||
function showError(fade) {
|
||||
$('#importmessagefail').html(`<strong style="color: red">${html10n.get('pad.impexp.importfailed')}:</strong> ${msg || html10n.get('pad.impexp.copypaste', '')}`)[(fade ? 'fadeIn' : 'show')]();
|
||||
}
|
||||
const showError = (fade) => {
|
||||
$('#importmessagefail').html(
|
||||
`<strong style="color: red">${html10n.get('pad.impexp.importfailed')}:</strong> ` +
|
||||
`${msg || html10n.get('pad.impexp.copypaste', '')}`)[(fade ? 'fadeIn' : 'show')]();
|
||||
};
|
||||
|
||||
if ($('#importexport .importmessage').is(':visible')) {
|
||||
$('#importmessagesuccess').fadeOut('fast');
|
||||
|
@ -114,7 +121,7 @@ const padimpexp = (function () {
|
|||
} else {
|
||||
showError();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// /// export
|
||||
|
||||
|
@ -134,16 +141,17 @@ const padimpexp = (function () {
|
|||
}
|
||||
|
||||
// ///
|
||||
var pad = undefined;
|
||||
let pad = undefined;
|
||||
const self = {
|
||||
init(_pad) {
|
||||
init: (_pad) => {
|
||||
pad = _pad;
|
||||
|
||||
// get /p/padname
|
||||
// if /p/ isn't available due to a rewrite we use the clientVars padId
|
||||
const pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname) || clientVars.padId;
|
||||
const padRootPath = /.*\/p\/[^/]+/.exec(document.location.pathname) || clientVars.padId;
|
||||
// get http://example.com/p/padname without Params
|
||||
const pad_root_url = `${document.location.protocol}//${document.location.host}${document.location.pathname}`;
|
||||
const dl = document.location;
|
||||
const padRootUrl = `${dl.protocol}//${dl.host}${dl.pathname}`;
|
||||
|
||||
// i10l buttom import
|
||||
$('#importsubmitinput').val(html10n.get('pad.impexp.importbutton'));
|
||||
|
@ -152,32 +160,32 @@ const padimpexp = (function () {
|
|||
});
|
||||
|
||||
// build the export links
|
||||
$('#exporthtmla').attr('href', `${pad_root_path}/export/html`);
|
||||
$('#exportetherpada').attr('href', `${pad_root_path}/export/etherpad`);
|
||||
$('#exportplaina').attr('href', `${pad_root_path}/export/txt`);
|
||||
$('#exporthtmla').attr('href', `${padRootPath}/export/html`);
|
||||
$('#exportetherpada').attr('href', `${padRootPath}/export/etherpad`);
|
||||
$('#exportplaina').attr('href', `${padRootPath}/export/txt`);
|
||||
|
||||
// activate action to import in the form
|
||||
$('#importform').attr('action', `${pad_root_url}/import`);
|
||||
$('#importform').attr('action', `${padRootUrl}/import`);
|
||||
|
||||
// hide stuff thats not avaible if abiword/soffice is disabled
|
||||
if (clientVars.exportAvailable == 'no') {
|
||||
if (clientVars.exportAvailable === 'no') {
|
||||
$('#exportworda').remove();
|
||||
$('#exportpdfa').remove();
|
||||
$('#exportopena').remove();
|
||||
|
||||
$('#importmessageabiword').show();
|
||||
} else if (clientVars.exportAvailable == 'withoutPDF') {
|
||||
} else if (clientVars.exportAvailable === 'withoutPDF') {
|
||||
$('#exportpdfa').remove();
|
||||
|
||||
$('#exportworda').attr('href', `${pad_root_path}/export/doc`);
|
||||
$('#exportopena').attr('href', `${pad_root_path}/export/odt`);
|
||||
$('#exportworda').attr('href', `${padRootPath}/export/doc`);
|
||||
$('#exportopena').attr('href', `${padRootPath}/export/odt`);
|
||||
|
||||
$('#importexport').css({height: '142px'});
|
||||
$('#importexportline').css({height: '142px'});
|
||||
} else {
|
||||
$('#exportworda').attr('href', `${pad_root_path}/export/doc`);
|
||||
$('#exportpdfa').attr('href', `${pad_root_path}/export/pdf`);
|
||||
$('#exportopena').attr('href', `${pad_root_path}/export/odt`);
|
||||
$('#exportworda').attr('href', `${padRootPath}/export/doc`);
|
||||
$('#exportpdfa').attr('href', `${padRootPath}/export/pdf`);
|
||||
$('#exportopena').attr('href', `${padRootPath}/export/odt`);
|
||||
}
|
||||
|
||||
addImportFrames();
|
||||
|
@ -185,7 +193,7 @@ const padimpexp = (function () {
|
|||
$('#importform').unbind('submit').submit(fileInputSubmit);
|
||||
$('.disabledexport').click(cantExport);
|
||||
},
|
||||
handleFrameCall(directDatabaseAccess, status) {
|
||||
handleFrameCall: (directDatabaseAccess, status) => {
|
||||
if (directDatabaseAccess === 'undefined') directDatabaseAccess = false;
|
||||
if (status !== 'ok') {
|
||||
importFailed(status);
|
||||
|
@ -201,18 +209,18 @@ const padimpexp = (function () {
|
|||
|
||||
importDone();
|
||||
},
|
||||
disable() {
|
||||
disable: () => {
|
||||
$('#impexp-disabled-clickcatcher').show();
|
||||
$('#import').css('opacity', 0.5);
|
||||
$('#impexp-export').css('opacity', 0.5);
|
||||
},
|
||||
enable() {
|
||||
enable: () => {
|
||||
$('#impexp-disabled-clickcatcher').hide();
|
||||
$('#import').css('opacity', 1);
|
||||
$('#impexp-export').css('opacity', 1);
|
||||
},
|
||||
};
|
||||
return self;
|
||||
}());
|
||||
})();
|
||||
|
||||
exports.padimpexp = padimpexp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue