chore: Fix eslint issues in helper/ files

/puter/src/helpers/determine_active_container_parent.js
  22:30  error  'active_element' is not defined         no-undef
  25:30  error  'active_element' is not defined         no-undef
  29:30  error  'active_element' is not defined         no-undef
  32:41  error  'active_element' is not defined         no-undef
  32:61  error  'active_element' is not defined         no-undef
  33:30  error  'active_element' is not defined         no-undef
  36:41  error  'active_item_container' is not defined  no-undef
  37:28  error  'active_item_container' is not defined  no-undef

/puter/src/helpers/download.js
  51:27  error  'api_origin' is not defined           no-undef
  52:59  error  'auth_token' is not defined           no-undef
  92:16  error  'operation_cancelled' is not defined  no-undef

/puter/src/helpers/new_context_menu_item.js
  38:21  error  'create_folder' is not defined  no-undef
  48:21  error  'create_file' is not defined    no-undef
  56:21  error  'create_file' is not defined    no-undef
  70:25  error  'create_file' is not defined    no-undef

/puter/src/helpers/refresh_item_container.js
   83:13  error  'update_window_layout' is not defined                no-undef
   86:13  error  'update_details_layout_sort_visuals' is not defined  no-undef
  124:35  error  'trash_path' is not defined                          no-undef
  162:29  error  Empty block statement                                no-empty
  166:51  error  'path' is not defined                                no-undef
  168:34  error  'trash_path' is not defined                          no-undef
  168:62  error  'appdata_path' is not defined                        no-undef
  171:38  error  'desktop_item_positions' is not defined              no-undef
  178:37  error  'item_icon' is not defined                           no-undef
  207:31  error  'trash_path' is not defined                          no-undef
  216:21  error  'sort_items' is not defined                          no-undef
  217:26  error  Empty block statement                                no-empty
  222:13  error  'sort_items' is not defined                          no-undef
  233:17  error  'update_explorer_footer_item_count' is not defined   no-undef

/puter/src/helpers/update_title_based_on_uploads.js
  21:41  error  'active_uploads' is not defined  no-undef
  22:59  error  'active_uploads' is not defined  no-undef
  23:51  error  'active_uploads' is not defined  no-undef
  27:51  error  'active_uploads' is not defined  no-undef
This commit is contained in:
Sam Atkins 2024-05-02 17:02:53 +01:00
parent eefc0d41e1
commit b6c491171c
5 changed files with 33 additions and 31 deletions

View File

@ -19,22 +19,22 @@
const determine_active_container_parent = function(){
// the container is either an ancestor of active element...
let parent_container = $(active_element).closest('.item-container');
let parent_container = $(window.active_element).closest('.item-container');
// ... or a descendant of it...
if(parent_container.length === 0){
parent_container = $(active_element).find('.item-container');
parent_container = $(window.active_element).find('.item-container');
}
// ... or siblings or cousins
if(parent_container.length === 0){
parent_container = $(active_element).closest('.window').find('.item-container');
parent_container = $(window.active_element).closest('.window').find('.item-container');
}
// ... or the active element itself (if it's a container)
if(parent_container.length === 0 && active_element && $(active_element).hasClass('item-container')){
parent_container = $(active_element);
if(parent_container.length === 0 && window.active_element && $(window.active_element).hasClass('item-container')){
parent_container = $(window.active_element);
}
// ... or if there is no active element, the selected item that is not blurred
if(parent_container.length === 0 && active_item_container){
parent_container = active_item_container;
if(parent_container.length === 0 && window.active_item_container){
parent_container = window.active_item_container;
}
return parent_container;

View File

@ -48,8 +48,8 @@ const download = function(options){
let item_download_progress = batch_download_progress[options.item_upload_id];
let xhr = new XMLHttpRequest();
xhr.open("post", (api_origin + '/download'), true);
xhr.setRequestHeader("Authorization", "Bearer " + auth_token);
xhr.open("post", (window.api_origin + '/download'), true);
xhr.setRequestHeader("Authorization", "Bearer " + window.auth_token);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.addEventListener('load', function(e){
@ -89,7 +89,7 @@ const download = function(options){
// Regularly check if this operation has been cancelled by the user
//----------------------------------------------
cancel_check_interval = setInterval(() => {
if(operation_cancelled[options.operation_id]){
if(window.operation_cancelled[options.operation_id]){
xhr.abort();
clearInterval(cancel_check_interval);
clearInterval(progress_check_interval);

View File

@ -35,7 +35,7 @@ const new_context_menu_item = function(dirname, append_to_element){
html: i18n('new_folder'),
icon: `<img src="${html_encode(window.icons['folder.svg'])}" class="ctx-item-icon">`,
onClick: function(){
create_folder(dirname, append_to_element);
window.create_folder(dirname, append_to_element);
}
},
// divider
@ -45,7 +45,7 @@ const new_context_menu_item = function(dirname, append_to_element){
html: i18n('text_document'),
icon: `<img src="${html_encode(window.icons['file-text.svg'])}" class="ctx-item-icon">`,
onClick: async function(){
create_file({dirname: dirname, append_to_element: append_to_element, name: 'New File.txt'});
window.create_file({dirname: dirname, append_to_element: append_to_element, name: 'New File.txt'});
}
},
// HTML Document
@ -53,7 +53,7 @@ const new_context_menu_item = function(dirname, append_to_element){
html: i18n('html_document'),
icon: `<img src="${html_encode(window.icons['file-html.svg'])}" class="ctx-item-icon">`,
onClick: async function(){
create_file({dirname: dirname, append_to_element: append_to_element, name: 'New File.html'});
window.create_file({dirname: dirname, append_to_element: append_to_element, name: 'New File.html'});
}
},
// JPG Image
@ -67,7 +67,7 @@ const new_context_menu_item = function(dirname, append_to_element){
canvas.height = 600;
canvas.toBlob((blob) =>{
create_file({dirname: dirname, append_to_element: append_to_element, name: 'New Image.jpg', content: blob});
window.create_file({dirname: dirname, append_to_element: append_to_element, name: 'New Image.jpg', content: blob});
});
}
},

View File

@ -17,6 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import path from '../lib/path.js';
import UIItem from '../UI/UIItem.js';
const refresh_item_container = function(el_item_container, options){
@ -80,10 +81,10 @@ const refresh_item_container = function(el_item_container, options){
$(el_item_container).attr('data-sort_order', fsentry.sort_order ?? 'asc');
// update layout
if(el_window && el_window.length > 0)
update_window_layout(el_window, fsentry.layout);
window.update_window_layout(el_window, fsentry.layout);
//
if(fsentry.layout === 'details'){
update_details_layout_sort_visuals(el_window, fsentry.sort_by, fsentry.sort_order);
window.update_details_layout_sort_visuals(el_window, fsentry.sort_by, fsentry.sort_order);
}
});
@ -121,7 +122,7 @@ const refresh_item_container = function(el_item_container, options){
}
// trash icon
if(container_path === trash_path && el_window_head_icon){
if(container_path === window.trash_path && el_window_head_icon){
if(fsentries.length > 0){
$(el_window_head_icon).attr('src', window.icons['trash-full.svg']);
}else{
@ -160,22 +161,23 @@ const refresh_item_container = function(el_item_container, options){
metadata = JSON.parse(fsentry.metadata);
}
catch(e){
// Ignored
}
}
const item_path = fsentry.path ?? path.join($(el_window).attr('data-path'), fsentry.name);
// render any item but Trash/AppData
if(item_path !== trash_path && item_path !== appdata_path){
if(item_path !== window.trash_path && item_path !== window.appdata_path){
// if this is trash, get original name from item metadata
fsentry.name = (metadata && metadata.original_name !== undefined) ? metadata.original_name : fsentry.name;
const position = desktop_item_positions[fsentry.uid] ?? undefined;
const position = window.desktop_item_positions[fsentry.uid] ?? undefined;
UIItem({
appendTo: el_item_container,
uid: fsentry.uid,
immutable: fsentry.immutable,
associated_app_name: fsentry.associated_app?.name,
path: item_path,
icon: await item_icon(fsentry),
icon: await window.item_icon(fsentry),
name: (metadata && metadata.original_name !== undefined) ? metadata.original_name : fsentry.name,
is_dir: fsentry.is_dir,
multiselectable: !is_openFileDialog,
@ -204,7 +206,7 @@ const refresh_item_container = function(el_item_container, options){
appendTo: el_item_container,
uid: trash.id,
immutable: trash.immutable,
path: trash_path,
path: window.trash_path,
icon: {image: (trash.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']), type: 'icon'},
name: trash.name,
is_dir: trash.is_dir,
@ -213,15 +215,15 @@ const refresh_item_container = function(el_item_container, options){
is_trash: true,
sortable: false,
});
sort_items(el_item_container, $(el_item_container).attr('data-sort_by'), $(el_item_container).attr('data-sort_order'));
window.sort_items(el_item_container, $(el_item_container).attr('data-sort_by'), $(el_item_container).attr('data-sort_order'));
}catch(e){
// Ignored
}
}
// sort items
sort_items(
el_item_container,
$(el_item_container).attr('data-sort_by'),
window.sort_items(
el_item_container,
$(el_item_container).attr('data-sort_by'),
$(el_item_container).attr('data-sort_order')
);
@ -230,7 +232,7 @@ const refresh_item_container = function(el_item_container, options){
// update footer item count if this is an explorer window
if(el_window)
update_explorer_footer_item_count(el_window);
window.update_explorer_footer_item_count(el_window);
},
// This makes sure the loading spinner shows up if the request takes longer than 1 second
// and stay there for at least 1 second since the flickering is annoying

View File

@ -18,13 +18,13 @@
*/
const update_title_based_on_uploads = function(){
const active_uploads_count = _.size(active_uploads);
if(active_uploads_count === 1 && !isNaN(Object.values(active_uploads)[0])){
document.title = Math.round(Object.values(active_uploads)[0]) + '% Uploading';
const active_uploads_count = _.size(window.active_uploads);
if(active_uploads_count === 1 && !isNaN(Object.values(window.active_uploads)[0])){
document.title = Math.round(Object.values(window.active_uploads)[0]) + '% Uploading';
}else if(active_uploads_count > 1){
// get the average progress
let total_progress = 0;
for (const [key, value] of Object.entries(active_uploads)) {
for (const [key, value] of Object.entries(window.active_uploads)) {
total_progress += Math.round(value);
}
const avgprog = Math.round(total_progress / active_uploads_count)