diff --git a/src/helpers/determine_active_container_parent.js b/src/helpers/determine_active_container_parent.js
index 32a8388d6..c66d03f68 100644
--- a/src/helpers/determine_active_container_parent.js
+++ b/src/helpers/determine_active_container_parent.js
@@ -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;
diff --git a/src/helpers/download.js b/src/helpers/download.js
index 3429b6648..5ccbb8a26 100644
--- a/src/helpers/download.js
+++ b/src/helpers/download.js
@@ -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);
diff --git a/src/helpers/new_context_menu_item.js b/src/helpers/new_context_menu_item.js
index 05a7eeaf9..6c2ea49e1 100644
--- a/src/helpers/new_context_menu_item.js
+++ b/src/helpers/new_context_menu_item.js
@@ -35,7 +35,7 @@ const new_context_menu_item = function(dirname, append_to_element){
html: i18n('new_folder'),
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: `
`,
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: `
`,
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});
});
}
},
diff --git a/src/helpers/refresh_item_container.js b/src/helpers/refresh_item_container.js
index d111a04f9..51cb1d755 100644
--- a/src/helpers/refresh_item_container.js
+++ b/src/helpers/refresh_item_container.js
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+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
diff --git a/src/helpers/update_title_based_on_uploads.js b/src/helpers/update_title_based_on_uploads.js
index d7fc76f5a..aa0beadd7 100644
--- a/src/helpers/update_title_based_on_uploads.js
+++ b/src/helpers/update_title_based_on_uploads.js
@@ -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)