style: apply linter suggestions

This commit is contained in:
Edouard Vanbelle
2026-04-07 22:50:42 +02:00
parent 1ce29c101d
commit a4266a6e93
33 changed files with 444 additions and 437 deletions
+21 -21
View File
@@ -17,8 +17,8 @@ class WopiEditor {
* Fetches supported extensions from the server (cached after first call).
*/
async canEdit(filename) {
var ext = filename.split('.').pop().toLowerCase();
var supported = await this._getSupportedExtensions();
const ext = filename.split('.').pop().toLowerCase();
const supported = await this._getSupportedExtensions();
return supported.includes(ext);
}
@@ -38,8 +38,8 @@ class WopiEditor {
async openInTab(fileId, fileName, action) {
action = action || 'edit';
try {
var data = await this._getEditorUrlWithFallback(fileId, fileName, action);
var hostUrl = '/wopi/edit/' + encodeURIComponent(fileId) + '?access_token=' + encodeURIComponent(data.access_token);
const data = await this._getEditorUrlWithFallback(fileId, fileName, action);
const hostUrl = `/wopi/edit/${encodeURIComponent(fileId)}?access_token=${encodeURIComponent(data.access_token)}`;
window.open(hostUrl, '_blank');
} catch (error) {
console.error('Failed to open WOPI editor in tab:', error);
@@ -53,12 +53,12 @@ class WopiEditor {
* Fetch editor URL and WOPI token from the backend.
*/
async _getEditorUrl(fileId, action) {
var response = await fetch('/api/wopi/editor-url?file_id=' + encodeURIComponent(fileId) + '&action=' + encodeURIComponent(action), {
const response = await fetch(`/api/wopi/editor-url?file_id=${encodeURIComponent(fileId)}&action=${encodeURIComponent(action)}`, {
credentials: 'same-origin'
});
if (!response.ok) {
var text = await response.text();
throw new Error('Editor URL request failed: ' + response.status + ' ' + text);
const text = await response.text();
throw new Error(`Editor URL request failed: ${response.status} ${text}`);
}
return response.json();
}
@@ -94,55 +94,55 @@ class WopiEditor {
_showModal(editorData, fileName) {
this.closeEditor();
var modal = document.createElement('div');
const modal = document.createElement('div');
modal.id = 'wopi-editor-modal';
modal.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;z-index:10000;background:#fff;';
var header = document.createElement('div');
const header = document.createElement('div');
header.style.cssText =
'height:40px;background:#333;color:#fff;display:flex;align-items:center;justify-content:space-between;padding:0 16px;font-family:sans-serif;font-size:14px;';
var title = document.createElement('span');
const title = document.createElement('span');
title.textContent = fileName;
header.appendChild(title);
var closeBtn = document.createElement('button');
const closeBtn = document.createElement('button');
closeBtn.textContent = '\u2715';
closeBtn.style.cssText = 'background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:4px 8px;';
closeBtn.onclick = this.closeEditor.bind(this);
header.appendChild(closeBtn);
var form = document.createElement('form');
const form = document.createElement('form');
form.id = 'wopi_form';
form.target = 'wopi_frame';
form.action = editorData.editor_url;
form.method = 'post';
form.style.display = 'none';
var tokenInput = document.createElement('input');
const tokenInput = document.createElement('input');
tokenInput.name = 'access_token';
tokenInput.value = editorData.access_token;
tokenInput.type = 'hidden';
form.appendChild(tokenInput);
var ttlInput = document.createElement('input');
const ttlInput = document.createElement('input');
ttlInput.name = 'access_token_ttl';
ttlInput.value = editorData.access_token_ttl;
ttlInput.type = 'hidden';
form.appendChild(ttlInput);
var frameHolder = document.createElement('div');
const frameHolder = document.createElement('div');
frameHolder.style.cssText = 'position:absolute;top:40px;left:0;right:0;bottom:0;';
// Loading spinner (removed once the editor signals ready)
var spinner = document.createElement('div');
const spinner = document.createElement('div');
spinner.id = 'wopi-loading-spinner';
spinner.style.cssText =
'position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;background:#f5f5f5;z-index:1;';
spinner.innerHTML = '<i class="fas fa-spinner fa-spin empty-state-icon spinner"></i>';
frameHolder.appendChild(spinner);
var iframe = document.createElement('iframe');
const iframe = document.createElement('iframe');
iframe.name = 'wopi_frame';
iframe.title = 'Document Editor';
iframe.style.cssText = 'width:100%;height:100%;border:none;';
@@ -175,9 +175,9 @@ class WopiEditor {
if (msgId === 'UI_Close' || msgId === 'close') {
this.closeEditor();
} else if (msgId === 'App_LoadingStatus') {
var status = data.Values && data.Values.Status;
const status = data.Values?.Status;
if (status === 'Document_Loaded' || status === 'Frame_Ready') {
var sp = document.getElementById('wopi-loading-spinner');
const sp = document.getElementById('wopi-loading-spinner');
if (sp) sp.remove();
}
}
@@ -225,9 +225,9 @@ class WopiEditor {
*/
async _fetchSupportedExtensions() {
try {
var response = await fetch('/wopi/supported-extensions');
const response = await fetch('/wopi/supported-extensions');
if (response.ok) {
var exts = await response.json();
const exts = await response.json();
if (Array.isArray(exts) && exts.length > 0) {
this._supportedExtensions = exts;
return exts;