diff --git a/src/UI/UIWindow.js b/src/UI/UIWindow.js index 60a1abb8..ed182a55 100644 --- a/src/UI/UIWindow.js +++ b/src/UI/UIWindow.js @@ -26,12 +26,14 @@ import UIWindowPublishWebsite from './UIWindowPublishWebsite.js'; import UIWindowItemProperties from './UIWindowItemProperties.js'; import new_context_menu_item from '../helpers/new_context_menu_item.js'; import refresh_item_container from '../helpers/refresh_item_container.js'; +import UIWindowSaveAccount from './UIWindowSaveAccount.js'; +import UIWindowEmailConfirmationRequired from './UIWindowEmailConfirmationRequired.js'; const el_body = document.getElementsByTagName('body')[0]; async function UIWindow(options) { - const win_id = global_element_id++; - last_window_zindex++; + const win_id = window.global_element_id++; + window.last_window_zindex++; // options.dominant places the window in center close to top. options.dominant = options.dominant ?? false; @@ -45,7 +47,7 @@ async function UIWindow(options) { window.window_counter++; // add this window's id to the window_stack - window_stack.push(win_id); + window.window_stack.push(win_id); // ===================================== // set options defaults @@ -66,7 +68,7 @@ async function UIWindow(options) { options.body_css = options.body_css ?? {}; options.border_radius = options.border_radius ?? undefined; options.draggable_body = options.draggable_body ?? false; - options.element_uuid = options.element_uuid ?? uuidv4(); + options.element_uuid = options.element_uuid ?? window.uuidv4(); options.center = options.center ?? false; options.close_on_backdrop_click = options.close_on_backdrop_click ?? true; options.disable_parent_window = options.disable_parent_window ?? false; @@ -87,7 +89,7 @@ async function UIWindow(options) { // in the embedded/fullpage mode every window is on top since there is no taskbar to switch between windows // if user has specifically asked for this window to NOT stay on top, honor it. - if((is_embedded || window.is_fullpage_mode) && !options.parent_uuid && options.stay_on_top !== false) + if((window.is_embedded || window.is_fullpage_mode) && !options.parent_uuid && options.stay_on_top !== false) options.stay_on_top = true; // Keep the window on top of all previously opened windows options.stay_on_top = options.stay_on_top ?? false; @@ -171,7 +173,7 @@ async function UIWindow(options) { let h = ''; // Window - let zindex = options.stay_on_top ? (99999999 + last_window_zindex + 1 + ' !important') : last_window_zindex; + let zindex = options.stay_on_top ? (99999999 + window.last_window_zindex + 1 + ' !important') : window.last_window_zindex; let user_set_url_params = []; if (options.params !== undefined) { for (let key in options.params) { @@ -241,7 +243,7 @@ async function UIWindow(options) { h += ``; h += ``; // Minimize button, only if window is resizable and not embedded - if(options.is_resizable && options.show_minimize_button && !is_embedded) + if(options.is_resizable && options.show_minimize_button && !window.is_embedded) h += ``; // Maximize button if(options.is_resizable && options.show_maximize_button) @@ -286,7 +288,7 @@ async function UIWindow(options) { h += ``; h += ``; // Path - h += `
${navbar_path(options.path, window.user.username)}
`; + h += `
${window.navbar_path(options.path, window.user.username)}
`; // Path editor h += ``; // Layout settings @@ -433,7 +435,7 @@ async function UIWindow(options) { onClick: function(){ let open_window_count = parseInt($(`.taskbar-item[data-app="${options.app}"]`).attr('data-open-windows')); if(open_window_count === 0){ - launch_app({ + window.launch_app({ name: options.app, }) }else{ @@ -453,8 +455,8 @@ async function UIWindow(options) { // if directory, set window_nav_history and window_nav_history_current_position if(options.is_dir){ - window_nav_history[win_id] = [options.path]; - window_nav_history_current_position[win_id] = 0; + window.window_nav_history[win_id] = [options.path]; + window.window_nav_history_current_position[win_id] = 0; } // get all the elements needed @@ -521,7 +523,7 @@ async function UIWindow(options) { $(el_window).focusWindow(); } - if (animate_window_opening) { + if (window.animate_window_opening) { // animate window opening $(el_window).css({ 'opacity': '0', @@ -596,7 +598,7 @@ async function UIWindow(options) { $(el_savefiledialog_save_btn).on('click', function(e){ const filename = $(el_savefiledialog_filename).val(); try{ - validate_fsentry_name(filename) + window.validate_fsentry_name(filename) }catch(err){ UIAlert(err.message, 'error', 'OK') return; @@ -787,8 +789,8 @@ async function UIWindow(options) { } if(options.is_dir){ - navbar_path_droppable(el_window); - sidebar_item_droppable(el_window); + window.navbar_path_droppable(el_window); + window.sidebar_item_droppable(el_window); // -------------------------------------------------------- // Back button // -------------------------------------------------------- @@ -798,10 +800,10 @@ async function UIWindow(options) { return; // if ctrl/cmd are pressed, open in new window if(e.ctrlKey || e.metaKey){ - const dirpath = window_nav_history[win_id].at(window_nav_history_current_position[win_id] - 1); + const dirpath = window.window_nav_history[win_id].at(window.window_nav_history_current_position[win_id] - 1); UIWindow({ path: dirpath, - title: dirpath === '/' ? root_dirname : path.basename(dirpath), + title: dirpath === '/' ? window.root_dirname : path.basename(dirpath), icon: window.icons['folder.svg'], // uid: $(el_item).attr('data-uid'), is_dir: true, @@ -809,10 +811,10 @@ async function UIWindow(options) { } // ... otherwise, open in same window else{ - window_nav_history_current_position[win_id] > 0 && window_nav_history_current_position[win_id]--; - const new_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]); + window.window_nav_history_current_position[win_id] > 0 && window.window_nav_history_current_position[win_id]--; + const new_path = window.window_nav_history[win_id].at(window.window_nav_history_current_position[win_id]); // update window path - update_window_path(el_window, new_path); + window.update_window_path(el_window, new_path); } }) // -------------------------------------------------------- @@ -822,8 +824,8 @@ async function UIWindow(options) { let items = []; const pos = el_window_navbar_back_btn.getBoundingClientRect(); - for(let index = window_nav_history_current_position[win_id] - 1; index >= 0; index--){ - const history_item = window_nav_history[win_id].at(index); + for(let index = window.window_nav_history_current_position[win_id] - 1; index >= 0; index--){ + const history_item = window.window_nav_history[win_id].at(index); // build item for context menu items.push({ @@ -831,20 +833,20 @@ async function UIWindow(options) { val: index, onClick: async function(e){ let history_index = e.value; - window_nav_history_current_position[win_id] = history_index; - const new_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]); + window.window_nav_history_current_position[win_id] = history_index; + const new_path = window.window_nav_history[win_id].at(window.window_nav_history_current_position[win_id]); // if ctrl/cmd are pressed, open in new window if(e.ctrlKey || e.metaKey && (new_path !== undefined && new_path !== null)){ UIWindow({ path: new_path, - title: new_path === '/' ? root_dirname : path.basename(new_path), + title: new_path === '/' ? window.root_dirname : path.basename(new_path), icon: window.icons['folder.svg'], is_dir: true, }); } // update window path else{ - update_window_path(el_window, new_path); + window.update_window_path(el_window, new_path); } } }) @@ -866,10 +868,10 @@ async function UIWindow(options) { return; // if ctrl/cmd are pressed, open in new window if(e.ctrlKey || e.metaKey){ - const dirpath = window_nav_history[win_id].at(window_nav_history_current_position[win_id] + 1); + const dirpath = window.window_nav_history[win_id].at(window.window_nav_history_current_position[win_id] + 1); UIWindow({ path: dirpath, - title: dirpath === '/' ? root_dirname : path.basename(dirpath), + title: dirpath === '/' ? window.root_dirname : path.basename(dirpath), icon: window.icons['folder.svg'], // uid: $(el_item).attr('data-uid'), is_dir: true, @@ -877,12 +879,12 @@ async function UIWindow(options) { } // ... otherwise, open in same window else{ - window_nav_history_current_position[win_id]++; + window.window_nav_history_current_position[win_id]++; // get last path in history - const target_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]); + const target_path = window.window_nav_history[win_id].at(window.window_nav_history_current_position[win_id]); // update window path if(target_path !== undefined){ - update_window_path(el_window, target_path); + window.update_window_path(el_window, target_path); } } }) @@ -893,8 +895,8 @@ async function UIWindow(options) { let items = []; const pos = el_window_navbar_forward_btn.getBoundingClientRect(); - for(let index = window_nav_history_current_position[win_id] + 1; index < window_nav_history[win_id].length; index++){ - const history_item = window_nav_history[win_id].at(index); + for(let index = window.window_nav_history_current_position[win_id] + 1; index < window.window_nav_history[win_id].length; index++){ + const history_item = window.window_nav_history[win_id].at(index); // build item for context menu items.push({ @@ -902,20 +904,20 @@ async function UIWindow(options) { val: index, onClick: async function(e){ let history_index = e.value; - window_nav_history_current_position[win_id] = history_index; - const new_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]); + window.window_nav_history_current_position[win_id] = history_index; + const new_path = window.window_nav_history[win_id].at(window.window_nav_history_current_position[win_id]); // if ctrl/cmd are pressed, open in new window if(e.ctrlKey || e.metaKey && (new_path !== undefined && new_path !== null)){ UIWindow({ path: new_path, - title: new_path === '/' ? root_dirname : path.basename(new_path), + title: new_path === '/' ? window.root_dirname : path.basename(new_path), icon: window.icons['folder.svg'], is_dir: true, }); } // update window path else{ - update_window_path(el_window, new_path); + window.update_window_path(el_window, new_path); } } }) @@ -938,7 +940,7 @@ async function UIWindow(options) { if(e.ctrlKey || e.metaKey && (target_path !== undefined && target_path !== null)){ UIWindow({ path: target_path, - title: target_path === '/' ? root_dirname : path.basename(target_path), + title: target_path === '/' ? window.root_dirname : path.basename(target_path), icon: window.icons['folder.svg'], // uid: $(el_item).attr('data-uid'), is_dir: true, @@ -947,11 +949,11 @@ async function UIWindow(options) { // ... otherwise, open in same window else if(target_path !== undefined && target_path !== null){ // update history - window_nav_history[win_id] = window_nav_history[win_id].slice(0, window_nav_history_current_position[win_id]+1); - window_nav_history[win_id].push(target_path); - window_nav_history_current_position[win_id]++; + window.window_nav_history[win_id] = window.window_nav_history[win_id].slice(0, window.window_nav_history_current_position[win_id]+1); + window.window_nav_history[win_id].push(target_path); + window.window_nav_history_current_position[win_id]++; // update window path - update_window_path(el_window, target_path); + window.update_window_path(el_window, target_path); } }) @@ -965,7 +967,7 @@ async function UIWindow(options) { html: `${layouts[i]}`, icon: cur_layout === layouts[i] ? '✓' : '', onClick: async function(e){ - update_window_layout(el_window, layouts[i]); + window.update_window_layout(el_window, layouts[i]); window.set_layout($(el_window).attr('data-uid'), layouts[i]); } }) @@ -980,10 +982,10 @@ async function UIWindow(options) { for(let i=0; i { - create_shortcut( + window.create_shortcut( path.basename($(item_to_move).attr('data-path')), $(item_to_move).attr('data-is_dir') === '1', - $(mouseover_window).attr('data-path'), + $(window.mouseover_window).attr('data-path'), null, $(item_to_move).attr('data-shortcut_to') === '' ? $(item_to_move).attr('data-uid') : $(item_to_move).attr('data-shortcut_to'), $(item_to_move).attr('data-shortcut_to_path') === '' ? $(item_to_move).attr('data-path') : $(item_to_move).attr('data-shortcut_to_path'), @@ -1261,7 +1263,7 @@ async function UIWindow(options) { } // otherwise, move items else{ - move_items(items_to_move, $(mouseover_window).attr('data-path')); + window.move_items(items_to_move, $(window.mouseover_window).attr('data-path')); } }, over: function(event, ui){ @@ -1283,7 +1285,7 @@ async function UIWindow(options) { // -------------------------------------------------------- if(options.is_resizable){ $(el_window_head).dblclick(function () { - scale_window(el_window); + window.scale_window(el_window); }) } @@ -1299,7 +1301,7 @@ async function UIWindow(options) { // -------------------------------------------------------- if(options.is_resizable){ $(el_window_head_scale_btn).click(function () { - scale_window(el_window); + window.scale_window(el_window); }) } @@ -1356,7 +1358,7 @@ async function UIWindow(options) { if(options.is_dir){ // if files were dropped... if(e.dataTransfer?.items?.length>0){ - upload_items(e.dataTransfer.items, $(el_window).attr('data-path')) + window.upload_items(e.dataTransfer.items, $(el_window).attr('data-path')) } // de-highlight all windows $('.item-container').removeClass('item-container-active'); @@ -1410,14 +1412,14 @@ async function UIWindow(options) { }); // if at any point the window's width is "too small", hide the sidebar - if($(el_window).width() < window_width_threshold_for_sidebar){ - if(width_before_snap >= window_width_threshold_for_sidebar && !sidebar_hidden){ + if($(el_window).width() < window.window_width_threshold_for_sidebar){ + if(width_before_snap >= window.window_width_threshold_for_sidebar && !sidebar_hidden){ $(el_window_sidebar).hide(); } sidebar_hidden = true; } // if at any point the window's width is "big enough", show the sidebar - else if($(el_window).width() >= window_width_threshold_for_sidebar){ + else if($(el_window).width() >= window.window_width_threshold_for_sidebar){ if(sidebar_hidden){ $(el_window_sidebar).show(); } @@ -1432,7 +1434,7 @@ async function UIWindow(options) { // since jquery draggable sets the z-index automatically we need this to // bring windows to the front when they are clicked. - last_window_zindex = parseInt($(el_window).css('z-index')); + window.last_window_zindex = parseInt($(el_window).css('z-index')); //transform causes draggable to start inaccurately $(el_window).css('transform', 'none'); @@ -1457,7 +1459,7 @@ async function UIWindow(options) { // if window is not snapped, check if it should be snapped snap_trigger_timeout = setTimeout(function(){ // if cursor is not in a snap zone, don't snap - if(!current_active_snap_zone){ + if(!window.current_active_snap_zone){ return; } // if dragging has stopped by now, don't snap @@ -1466,81 +1468,81 @@ async function UIWindow(options) { } // W - if(!window_is_snapped && current_active_snap_zone === 'w'){ + if(!window_is_snapped && window.current_active_snap_zone === 'w'){ window_snap_placeholder.css({ 'display': 'block', 'width': '50%', - 'height': desktop_height, - 'top': toolbar_height, + 'height': window.desktop_height, + 'top': window.toolbar_height, 'left': 0, - 'z-index': last_window_zindex - 1, + 'z-index': window.last_window_zindex - 1, }) } // NW - else if(!window_is_snapped && current_active_snap_zone === 'nw'){ + else if(!window_is_snapped && window.current_active_snap_zone === 'nw'){ window_snap_placeholder.css({ 'display': 'block', 'width': '50%', - 'height': desktop_height/2, - 'top': toolbar_height, + 'height': window.desktop_height/2, + 'top': window.toolbar_height, 'left': 0, - 'z-index': last_window_zindex - 1, + 'z-index': window.last_window_zindex - 1, }) } // NE - else if(!window_is_snapped && current_active_snap_zone ==='ne'){ + else if(!window_is_snapped && window.current_active_snap_zone ==='ne'){ window_snap_placeholder.css({ 'display': 'block', 'width': '50%', - 'height': desktop_height/2, - 'top': toolbar_height, - 'left': desktop_width/2, - 'z-index': last_window_zindex - 1, + 'height': window.desktop_height/2, + 'top': window.toolbar_height, + 'left': window.desktop_width/2, + 'z-index': window.last_window_zindex - 1, }) } // E - else if(!window_is_snapped && current_active_snap_zone ==='e'){ + else if(!window_is_snapped && window.current_active_snap_zone ==='e'){ window_snap_placeholder.css({ 'display': 'block', 'width': '50%', - 'height': desktop_height, - 'top': toolbar_height, + 'height': window.desktop_height, + 'top': window.toolbar_height, 'left': 'initial', 'right': 0, - 'z-index': last_window_zindex - 1, + 'z-index': window.last_window_zindex - 1, }) } // N - else if(!window_is_snapped && current_active_snap_zone ==='n'){ + else if(!window_is_snapped && window.current_active_snap_zone ==='n'){ window_snap_placeholder.css({ 'display': 'block', - 'width': desktop_width, - 'height': desktop_height, - 'top': toolbar_height, + 'width': window.desktop_width, + 'height': window.desktop_height, + 'top': window.toolbar_height, 'left': 0, - 'z-index': last_window_zindex - 1, + 'z-index': window.last_window_zindex - 1, }) } // SW - else if(!window_is_snapped && current_active_snap_zone ==='sw'){ + else if(!window_is_snapped && window.current_active_snap_zone ==='sw'){ window_snap_placeholder.css({ 'display': 'block', - 'top': toolbar_height + desktop_height/2, + 'top': window.toolbar_height + window.desktop_height/2, 'left': 0, 'width': '50%', - 'height': desktop_height/2, - 'z-index': last_window_zindex - 1, + 'height': window.desktop_height/2, + 'z-index': window.last_window_zindex - 1, }) } // SE - else if(!window_is_snapped && current_active_snap_zone ==='se'){ + else if(!window_is_snapped && window.current_active_snap_zone ==='se'){ window_snap_placeholder.css({ 'display': 'block', - 'top': toolbar_height + desktop_height/2, - 'left': desktop_width/2, + 'top': window.toolbar_height + window.desktop_height/2, + 'left': window.desktop_width/2, 'width': '50%', - 'height': desktop_height/2, - 'z-index': last_window_zindex - 1, + 'height': window.desktop_height/2, + 'z-index': window.last_window_zindex - 1, }) } @@ -1556,7 +1558,7 @@ async function UIWindow(options) { }, 500); // if mouse is not in a snap zone, hide snap placeholder - if(snap_placeholder_active && !current_active_snap_zone){ + if(snap_placeholder_active && !window.current_active_snap_zone){ snap_placeholder_active = false; window_snap_placeholder.fadeOut(80); } @@ -1587,62 +1589,62 @@ async function UIWindow(options) { setTimeout(function(){ // snap to w - if(current_active_snap_zone === 'w'){ + if(window.current_active_snap_zone === 'w'){ $(el_window).css({ - 'top': toolbar_height, + 'top': window.toolbar_height, 'left': 0, 'width': '50%', - 'height': desktop_height, + 'height': window.desktop_height, }) } // snap to nw - else if(current_active_snap_zone === 'nw'){ + else if(window.current_active_snap_zone === 'nw'){ $(el_window).css({ - 'top': toolbar_height, + 'top': window.toolbar_height, 'left': 0, 'width': '50%', - 'height': desktop_height/2, + 'height': window.desktop_height/2, }) } // snap to ne - else if(current_active_snap_zone === 'ne'){ + else if(window.current_active_snap_zone === 'ne'){ $(el_window).css({ - 'top': toolbar_height, + 'top': window.toolbar_height, 'left': '50%', 'width': '50%', - 'height': desktop_height/2, + 'height': window.desktop_height/2, }) } // snap to sw - else if(current_active_snap_zone === 'sw'){ + else if(window.current_active_snap_zone === 'sw'){ $(el_window).css({ - 'top': toolbar_height + desktop_height/2, + 'top': window.toolbar_height + window.desktop_height/2, 'left': 0, 'width': '50%', - 'height': desktop_height/2, + 'height': window.desktop_height/2, }) } // snap to se - else if(current_active_snap_zone === 'se'){ + else if(window.current_active_snap_zone === 'se'){ $(el_window).css({ - 'top': toolbar_height + desktop_height/2, - 'left': desktop_width/2, + 'top': window.toolbar_height + window.desktop_height/2, + 'left': window.desktop_width/2, 'width': '50%', - 'height': desktop_height/2, + 'height': window.desktop_height/2, }) } // snap to e - else if(current_active_snap_zone === 'e'){ + else if(window.current_active_snap_zone === 'e'){ $(el_window).css({ - 'top': toolbar_height, + 'top': window.toolbar_height, 'left': '50%', 'width': '50%', - 'height': desktop_height, + 'height': window.desktop_height, }) } // snap to n - else if(current_active_snap_zone === 'n'){ - scale_window(el_window); + else if(window.current_active_snap_zone === 'n'){ + window.scale_window(el_window); } // snap placeholder is no longer active snap_placeholder_active = false; @@ -1653,14 +1655,14 @@ async function UIWindow(options) { window_is_snapped = true; // if at any point the window's width is "too small", hide the sidebar - if($(el_window).width() < window_width_threshold_for_sidebar){ - if(width_before_snap >= window_width_threshold_for_sidebar && !sidebar_hidden){ + if($(el_window).width() < window.window_width_threshold_for_sidebar){ + if(width_before_snap >= window.window_width_threshold_for_sidebar && !sidebar_hidden){ $(el_window_sidebar).hide(); } sidebar_hidden = true; } // if at any point the window's width is "big enough", show the sidebar - else if($(el_window).width() >= window_width_threshold_for_sidebar){ + else if($(el_window).width() >= window.window_width_threshold_for_sidebar){ if(sidebar_hidden){ $(el_window_sidebar).show(); } @@ -1671,9 +1673,9 @@ async function UIWindow(options) { // if window is dropped below the taskbar, move it up // the lst '- 30' is to account for the window head - if($(el_window).position().top > window.innerHeight - taskbar_height - 30 && !window_will_snap){ + if($(el_window).position().top > window.innerHeight - window.taskbar_height - 30 && !window_will_snap){ $(el_window).animate({ - top: window.innerHeight - taskbar_height - 60, + top: window.innerHeight - window.taskbar_height - 60, }, 100); } // if window is dropped too far to the right, move it left @@ -1700,7 +1702,7 @@ async function UIWindow(options) { // Resizable // -------------------------------------------------------- if(options.is_resizable){ - if($(el_window).width() < window_width_threshold_for_sidebar){ + if($(el_window).width() < window.window_width_threshold_for_sidebar){ $(el_window_sidebar).hide(); sidebar_hidden = true; } @@ -1715,14 +1717,14 @@ async function UIWindow(options) { }, resize: function (e, ui) { // if at any point the window's width is "too small", hide the sidebar - if(ui.size.width < window_width_threshold_for_sidebar){ - if(ui.originalSize.width >= window_width_threshold_for_sidebar && !sidebar_hidden){ + if(ui.size.width < window.window_width_threshold_for_sidebar){ + if(ui.originalSize.width >= window.window_width_threshold_for_sidebar && !sidebar_hidden){ $(el_window_sidebar).hide(); } sidebar_hidden = true; } // if at any point the window's width is "big enough", show the sidebar - else if(ui.size.width >= window_width_threshold_for_sidebar){ + else if(ui.size.width >= window.window_width_threshold_for_sidebar){ if(sidebar_hidden){ $(el_window_sidebar).show(); } @@ -1730,10 +1732,10 @@ async function UIWindow(options) { } // when resizing the top of the window, make sure the window head is not hidden behind the toolbar - if($(el_window).position().top < toolbar_height){ - var difference = toolbar_height - $(el_window).position().top; + if($(el_window).position().top < window.toolbar_height){ + var difference = window.toolbar_height - $(el_window).position().top; $(el_window).css({ - 'top': toolbar_height, + 'top': window.toolbar_height, 'height': ui.size.height - difference // Reduce the height by the difference }); // don't resize @@ -1770,7 +1772,7 @@ async function UIWindow(options) { $('.window').css('pointer-events', 'initial'); const new_width = $(el_window_sidebar).width(); // save new width in the cloud, to user's settings - setItem({key: "window_sidebar_width", value: new_width}); + window.setItem({key: "window_sidebar_width", value: new_width}); // save new width locally, to window object window.window_sidebar_width = new_width; } @@ -1817,7 +1819,7 @@ async function UIWindow(options) { html: $(el_window).attr('data-is_maximized') === '0' ? 'Maximize' : 'Restore', onClick: function(){ // maximize window - scale_window(el_window); + window.scale_window(el_window); } }); menu_items.push({ @@ -1864,7 +1866,7 @@ async function UIWindow(options) { event.preventDefault(); if(options.allow_context_menu && event.target === el_window_body){ // Regular directories - if($(el_window).attr('data-path') !== trash_path){ + if($(el_window).attr('data-path') !== window.trash_path){ UIContextMenu({ parent_element: el_window_body, items: [ @@ -1878,32 +1880,32 @@ async function UIWindow(options) { html: i18n('name'), icon: $(el_window).attr('data-sort_by') === 'name' ? '✓' : '', onClick: async function(){ - sort_items(el_window_body, 'name', $(el_window).attr('data-sort_order')); - set_sort_by($(el_window).attr('data-uid'), 'name', $(el_window).attr('data-sort_order')) + window.sort_items(el_window_body, 'name', $(el_window).attr('data-sort_order')); + window.set_sort_by($(el_window).attr('data-uid'), 'name', $(el_window).attr('data-sort_order')) } }, { html: i18n('date_modified'), icon: $(el_window).attr('data-sort_by') === 'modified' ? '✓' : '', onClick: async function(){ - sort_items(el_window_body, 'modified', $(el_window).attr('data-sort_order')); - set_sort_by($(el_window).attr('data-uid'), 'modified', $(el_window).attr('data-sort_order')) + window.sort_items(el_window_body, 'modified', $(el_window).attr('data-sort_order')); + window.set_sort_by($(el_window).attr('data-uid'), 'modified', $(el_window).attr('data-sort_order')) } }, { html: i18n('type'), icon: $(el_window).attr('data-sort_by') === 'type' ? '✓' : '', onClick: async function(){ - sort_items(el_window_body, 'type', $(el_window).attr('data-sort_order')); - set_sort_by($(el_window).attr('data-uid'), 'type', $(el_window).attr('data-sort_order')) + window.sort_items(el_window_body, 'type', $(el_window).attr('data-sort_order')); + window.set_sort_by($(el_window).attr('data-uid'), 'type', $(el_window).attr('data-sort_order')) } }, { html: i18n('size'), icon: $(el_window).attr('data-sort_by') === 'size' ? '✓' : '', onClick: async function(){ - sort_items(el_window_body, 'size', $(el_window).attr('data-sort_order')); - set_sort_by($(el_window).attr('data-uid'), 'size', $(el_window).attr('data-sort_order')) + window.sort_items(el_window_body, 'size', $(el_window).attr('data-sort_order')); + window.set_sort_by($(el_window).attr('data-uid'), 'size', $(el_window).attr('data-sort_order')) } }, // ------------------------------------------- @@ -1915,8 +1917,8 @@ async function UIWindow(options) { icon: $(el_window).attr('data-sort_order') === 'asc' ? '✓' : '', onClick: async function(){ const sort_by = $(el_window).attr('data-sort_by') - sort_items(el_window_body, sort_by, 'asc'); - set_sort_by($(el_window).attr('data-uid'), sort_by, 'asc') + window.sort_items(el_window_body, sort_by, 'asc'); + window.set_sort_by($(el_window).attr('data-uid'), sort_by, 'asc') } }, { @@ -1924,8 +1926,8 @@ async function UIWindow(options) { icon: $(el_window).attr('data-sort_order') === 'desc' ? '✓' : '', onClick: async function(){ const sort_by = $(el_window).attr('data-sort_by') - sort_items(el_window_body, sort_by, 'desc'); - set_sort_by($(el_window).attr('data-uid'), sort_by, 'desc') + window.sort_items(el_window_body, sort_by, 'desc'); + window.set_sort_by($(el_window).attr('data-uid'), sort_by, 'desc') } }, @@ -1970,12 +1972,12 @@ async function UIWindow(options) { // ------------------------------------------- { html: i18n('paste'), - disabled: (clipboard.length === 0 || $(el_window).attr('data-path') === '/') ? true : false, + disabled: (window.clipboard.length === 0 || $(el_window).attr('data-path') === '/') ? true : false, onClick: function(){ - if(clipboard_op === 'copy') - copy_clipboard_items($(el_window).attr('data-path'), el_window_body); - else if(clipboard_op === 'move') - move_clipboard_items(el_window_body) + if(window.clipboard_op === 'copy') + window.copy_clipboard_items($(el_window).attr('data-path'), el_window_body); + else if(window.clipboard_op === 'move') + window.move_clipboard_items(el_window_body) } }, // ------------------------------------------- @@ -1983,9 +1985,9 @@ async function UIWindow(options) { // ------------------------------------------- { html: i18n('undo'), - disabled: actions_history.length > 0 ? false : true, + disabled: window.actions_history.length > 0 ? false : true, onClick: function(){ - undo_last_action(); + window.undo_last_action(); } }, // ------------------------------------------- @@ -1995,7 +1997,7 @@ async function UIWindow(options) { html: i18n('upload_here'), disabled: $(el_window).attr('data-path') === '/' ? true : false, onClick: function(){ - init_upload_using_dialog(el_window_body, $(el_window).attr('data-path') + '/'); + window.init_upload_using_dialog(el_window_body, $(el_window).attr('data-path') + '/'); } }, // ------------------------------------------- @@ -2033,7 +2035,7 @@ async function UIWindow(options) { html: i18n('deploy_as_app'), disabled: !options.is_dir, onClick: async function () { - launch_app({ + window.launch_app({ name: 'dev-center', file_path: $(el_window).attr('data-path'), file_uid: $(el_window).attr('data-uid'), @@ -2056,11 +2058,11 @@ async function UIWindow(options) { let window_height = 500; let window_width = 450; - let left = mouseX; + let left = window.mouseX; left -= 200; left = left > (window.innerWidth - window_width)? (window.innerWidth - window_width) : left; - let top = mouseY; + let top = window.mouseY; top = top > (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height))? (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height)) : top; UIWindowItemProperties(options.title, options.path, options.uid, left, top, window_width, window_height); @@ -2099,15 +2101,15 @@ async function UIWindow(options) { return; // todo this has to be case-insensitive but the `i` selector doesn't work on ^= - $(`.item[data-path^="${html_encode(trash_path)}/"]`).each(function(){ - delete_item(this); + $(`.item[data-path^="${html_encode(window.trash_path)}/"]`).each(function(){ + window.delete_item(this); }) // update other clients if(window.socket){ window.socket.emit('trash.is_empty', {is_empty: true}); } // use the 'empty trash' icon - $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']); + $(`.item[data-path="${html_encode(window.trash_path)}" i], .item[data-shortcut_to_path="${html_encode(window.trash_path)}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']); } }, ] @@ -2143,7 +2145,7 @@ async function UIWindow(options) { $(el_item).removeClass('item-selected'); // if files were dropped... if(e.dataTransfer?.items?.length > 0){ - upload_items(e.dataTransfer.items, $(el_item).attr('data-path')) + window.upload_items(e.dataTransfer.items, $(el_item).attr('data-path')) } e.stopPropagation(); @@ -2160,7 +2162,7 @@ async function UIWindow(options) { if(options.is_fullpage){ $(el_window).hide() setTimeout(function(){ - enter_fullpage_mode(el_window); + window.enter_fullpage_mode(el_window); $(el_window).show() }, 5); } @@ -2170,8 +2172,8 @@ async function UIWindow(options) { function delete_window_element (el_window){ // if this is the active element, set it to null - if(active_element === el_window){ - active_element = null; + if(window.active_element === el_window){ + window.active_element = null; } // remove DOM element $(el_window).remove(); @@ -2192,7 +2194,7 @@ $(document).on('click', '.window-sidebar-item', async function(e){ UIWindow({ path: item_path, title: path.basename(item_path), - icon: await item_icon({is_dir: true, path: item_path}), + icon: await window.item_icon({is_dir: true, path: item_path}), // todo // uid: $(el_item).attr('data-uid'), is_dir: true, @@ -2207,11 +2209,11 @@ $(document).on('click', '.window-sidebar-item', async function(e){ } // update window path only if it's a new path AND no ctrl/cmd key pressed else if(item_path !== $(el_window).attr('data-path')){ - window_nav_history[parent_win_id] = window_nav_history[parent_win_id].slice(0, window_nav_history_current_position[parent_win_id] + 1); - window_nav_history[parent_win_id].push(item_path); - window_nav_history_current_position[parent_win_id]++; + window.window_nav_history[parent_win_id] = window.window_nav_history[parent_win_id].slice(0, window.window_nav_history_current_position[parent_win_id] + 1); + window.window_nav_history[parent_win_id].push(item_path); + window.window_nav_history_current_position[parent_win_id]++; - update_window_path(el_window, item_path); + window.update_window_path(el_window, item_path); } }) @@ -2254,7 +2256,7 @@ $(document).on('contextmenu taphold', '.window-sidebar-item', function(event){ UIWindow({ path: item_path, title: path.basename(item_path), - icon: await item_icon({is_dir: true, path: item_path}), + icon: await window.item_icon({is_dir: true, path: item_path}), // todo // uid: $(el_item).attr('data-uid'), is_dir: true, @@ -2361,7 +2363,7 @@ $(document).on('blur', '.window-navbar-path-input', function(e){ $(document).on('keyup', '.window-navbar-path-input', function(e){ if (e.key === 'Enter' || e.keyCode === 13) { - update_window_path($(e.target).closest('.window'), $(e.target).val()); + window.update_window_path($(e.target).closest('.window'), $(e.target).val()); $(e.target).hide(); $(e.target).siblings('.window-navbar-path').show().select(); } @@ -2377,7 +2379,7 @@ $(document).on('click', '.window-navbar-path-dirname', function(e){ const dirpath = $(this).attr('data-path'); UIWindow({ path: dirpath, - title: dirpath === '/' ? root_dirname : path.basename(dirpath), + title: dirpath === '/' ? window.root_dirname : path.basename(dirpath), icon: window.icons['folder.svg'], // uid: $(el_item).attr('data-uid'), is_dir: true, @@ -2386,10 +2388,10 @@ $(document).on('click', '.window-navbar-path-dirname', function(e){ } // only change dir if target is not the same as current path else if($el_parent_window.attr('data-path') !== $(this).attr('data-path')){ - window_nav_history[parent_win_id] = window_nav_history[parent_win_id].slice(0, window_nav_history_current_position[parent_win_id]+1); - window_nav_history[parent_win_id].push($(this).attr('data-path')); - window_nav_history_current_position[parent_win_id] = window_nav_history[parent_win_id].length - 1; - update_window_path($el_parent_window, $(this).attr('data-path')); + window.window_nav_history[parent_win_id] = window.window_nav_history[parent_win_id].slice(0, window.window_nav_history_current_position[parent_win_id]+1); + window.window_nav_history[parent_win_id].push($(this).attr('data-path')); + window.window_nav_history_current_position[parent_win_id] = window.window_nav_history[parent_win_id].length - 1; + window.update_window_path($el_parent_window, $(this).attr('data-path')); } }) @@ -2433,7 +2435,7 @@ $(document).on('contextmenu taphold', '.window-navbar-path-dirname', function(ev onClick: function(){ UIWindow({ path: $(el).attr('data-path'), - title: $(el).attr('data-path') === '/' ? root_dirname : path.basename($(el).attr('data-path')), + title: $(el).attr('data-path') === '/' ? window.root_dirname : path.basename($(el).attr('data-path')), icon: window.icons['folder.svg'], uid: $(el).attr('data-uid'), is_dir: true, @@ -2450,12 +2452,12 @@ $(document).on('contextmenu taphold', '.window-navbar-path-dirname', function(ev // ------------------------------------------- menu_items.push({ html: "Paste", - disabled: clipboard.length > 0 ? false : true, + disabled: window.clipboard.length > 0 ? false : true, onClick: function(){ - if(clipboard_op === 'copy') - copy_clipboard_items($(el).attr('data-path'), null); - else if(clipboard_op === 'move') - move_clipboard_items(null, $(el).attr('data-path')) + if(window.clipboard_op === 'copy') + window.copy_clipboard_items($(el).attr('data-path'), null); + else if(window.clipboard_op === 'move') + window.move_clipboard_items(null, $(el).attr('data-path')) } }) @@ -2481,7 +2483,7 @@ window.navbar_path_droppable = (el_window)=>{ tolerance: 'pointer', drop: function( event, ui ) { // check if item was actually dropped on this navbar path - if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id')){ + if($(window.mouseover_window).attr('data-id') !== $(el_window).attr('data-id')){ return; } const items_to_move = [] @@ -2500,7 +2502,7 @@ window.navbar_path_droppable = (el_window)=>{ // if alt key is down, create shortcut items if(event.altKey){ items_to_move.forEach((item_to_move) => { - create_shortcut( + window.create_shortcut( path.basename($(item_to_move).attr('data-path')), $(item_to_move).attr('data-is_dir') === '1', $(this).attr('data-path'), @@ -2512,7 +2514,7 @@ window.navbar_path_droppable = (el_window)=>{ } // move items else{ - move_items(items_to_move, $(this).attr('data-path')); + window.move_items(items_to_move, $(this).attr('data-path')); } $('.item-container').droppable('enable') @@ -2522,7 +2524,7 @@ window.navbar_path_droppable = (el_window)=>{ }, over: function(event, ui){ // check if item was actually hovered over this window - if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id')) + if($(window.mouseover_window).attr('data-id') !== $(el_window).attr('data-id')) return; // Don't do anything if the dragged item is NOT a UIItem @@ -2602,14 +2604,14 @@ window.update_window_path = async function(el_window, target_path){ if(is_dir){ // if nav history for this window is empty, disable forward btn - if(window_nav_history[win_id] && window_nav_history[win_id].length - 1 === window_nav_history_current_position[win_id]) + if(window.window_nav_history[win_id] && window.window_nav_history[win_id].length - 1 === window.window_nav_history_current_position[win_id]) $(el_window_navbar_forward_btn).addClass('window-navbar-btn-disabled'); // ... else, enable forawrd btn else $(el_window_navbar_forward_btn).removeClass('window-navbar-btn-disabled'); // disable back button if path is root - if(window_nav_history_current_position[win_id] === 0) + if(window.window_nav_history_current_position[win_id] === 0) $(el_window_navbar_back_btn).addClass('window-navbar-btn-disabled'); // ... enable back btn in all other cases else @@ -2623,7 +2625,7 @@ window.update_window_path = async function(el_window, target_path){ $(el_window_navbar_up_btn).removeClass('window-navbar-btn-disabled'); $(el_window_item_container).attr('data-path', target_path); - $(el_window).find('.window-navbar-path').html(navbar_path(target_path, window.user.username)); + $(el_window).find('.window-navbar-path').html(window.navbar_path(target_path, window.user.username)); // empty body to be filled with the results of /readdir $(el_window_body).find('.item').removeItems() @@ -2684,10 +2686,10 @@ window.update_window_path = async function(el_window, target_path){ $(el_window_navbar_path_input).val(target_path); $(el_window_navbar_path_input).attr('data-path', target_path); // update layout - update_window_layout(el_window, fsentry.layout); + window.update_window_layout(el_window, fsentry.layout); // update explore header if in details view 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); } }); }catch(err){ @@ -2695,7 +2697,7 @@ window.update_window_path = async function(el_window, target_path){ // todo optim: this is dumb because updating the window should only happen if this /readdir request is successful, // in that case there is no need for using update_window_path on error!! - update_window_path(el_window, old_path); + window.update_window_path(el_window, old_path); } } // path is '/' (global root) @@ -2704,15 +2706,15 @@ window.update_window_path = async function(el_window, target_path){ $(el_window).addClass('window-null'); $(el_window).attr('data-uid', 'null'); $(el_window).attr('data-name', ''); - $(el_window).find('.window-head-title').text(root_dirname); + $(el_window).find('.window-head-title').text(window.root_dirname); } if(is_dir){ refresh_item_container(el_window_body); - navbar_path_droppable(el_window) + window.navbar_path_droppable(el_window) } - update_explorer_footer_selected_items_count(el_window); + window.update_explorer_footer_selected_items_count(el_window); } // -------------------------------------------------------- @@ -2724,7 +2726,7 @@ window.sidebar_item_droppable = (el_window)=>{ tolerance: 'pointer', drop: function( event, ui ) { // check if item was actually dropped on this navbar path - if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id')){ + if($(window.mouseover_window).attr('data-id') !== $(el_window).attr('data-id')){ return; } const items_to_move = [] @@ -2743,7 +2745,7 @@ window.sidebar_item_droppable = (el_window)=>{ // if alt key is down, create shortcut items if(event.altKey){ items_to_move.forEach((item_to_move) => { - create_shortcut( + window.create_shortcut( path.basename($(item_to_move).attr('data-path')), $(item_to_move).attr('data-is_dir') === '1', $(this).attr('data-path'), @@ -2755,7 +2757,7 @@ window.sidebar_item_droppable = (el_window)=>{ } // move items else{ - move_items(items_to_move, $(this).attr('data-path')); + window.move_items(items_to_move, $(this).attr('data-path')); } $('.item-container').droppable('enable') @@ -2765,7 +2767,7 @@ window.sidebar_item_droppable = (el_window)=>{ }, over: function(event, ui){ // check if item was actually hovered over this window - if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id')) + if($(window.mouseover_window).attr('data-id') !== $(el_window).attr('data-id')) return; // Don't do anything if the dragged item is NOT a UIItem @@ -2804,7 +2806,7 @@ $.fn.close = async function(options) { // tell child app that this window is about to close, get its response if(app_uses_sdk){ if(!options.bypass_iframe_messaging){ - const resp = await sendWindowWillCloseMsg(el_iframe.get(0)); + const resp = await window.sendWindowWillCloseMsg(el_iframe.get(0)); if(!resp.msg){ return false; } @@ -2815,8 +2817,8 @@ $.fn.close = async function(options) { if($(this).hasClass('window')){ const win_id = parseInt($(this).attr('data-id')); let window_uuid = $(this).attr('data-element_uuid'); - // remove all instances of win_id from window_stack - _.pullAll(window_stack, [win_id]); + // remove all instances of win_id from window.window_stack + _.pullAll(window.window_stack, [win_id]); // taskbar update let open_window_count = parseInt($(`.taskbar-item[data-app="${$(this).attr('data-app')}"]`).attr('data-open-windows')); // update open window count of corresponding taskbar item @@ -2826,14 +2828,14 @@ $.fn.close = async function(options) { // decide whether to remove taskbar item if(open_window_count === 1){ $(`.taskbar-item[data-app="${$(this).attr('data-app')}"] .active-taskbar-indicator`).hide(); - remove_taskbar_item($(`.taskbar-item[data-app="${$(this).attr('data-app')}"][data-keep-in-taskbar="false"]`)); + window.remove_taskbar_item($(`.taskbar-item[data-app="${$(this).attr('data-app')}"][data-keep-in-taskbar="false"]`)); } // if no more windows of this app are open, remove taskbar item if(open_window_count - 1 === 0) $(`.taskbar-item[data-app="${$(this).attr('data-app')}"] .active-taskbar-indicator`).hide(); // if a fullpage window is closed, show desktop and taskbar if($(this).attr('data-is_fullpage') === '1'){ - exit_fullpage_mode(); + window.exit_fullpage_mode(); } // FileDialog closed @@ -2850,11 +2852,11 @@ $.fn.close = async function(options) { // close any open FileDialogs belonging to this window $(`.window-filedialog[data-parent_uuid="${window_uuid}"]`).close(); // bring focus to the last window in the window-stack (only if not minimized) - if(!_.isEmpty(window_stack)){ - const $last_window_in_stack = $(`.window[data-id="${window_stack[window_stack.length - 1]}"]`); + if(!_.isEmpty(window.window_stack)){ + const $last_window_in_stack = $(`.window[data-id="${window.window_stack[window.window_stack.length - 1]}"]`); // check if previous window is not minimized if($last_window_in_stack !== null && $last_window_in_stack.attr('data-is_minimized') !== '1' && $last_window_in_stack.attr('data-is_minimized') !== 'true'){ - $(`.window[data-id="${window_stack[window_stack.length - 1]}"]`).focusWindow(); + $(`.window[data-id="${window.window_stack[window.window_stack.length - 1]}"]`).focusWindow(); } // otherwise, change URL/Title to desktop else{ @@ -2913,7 +2915,7 @@ $.fn.close = async function(options) { } } // focus back to desktop? - if(_.isEmpty(window_stack)){ + if(_.isEmpty(window.window_stack)){ // The following is to make sure the iphone keyboard is dismissed when the last window is closed if(isMobile.phone || isMobile.tablet){ document.activeElement.blur(); @@ -2921,7 +2923,7 @@ $.fn.close = async function(options) { } // focus back to desktop $('.desktop').find('.item-blurred').removeClass('item-blurred'); - active_item_container = $('.desktop.item-container').get(0); + window.active_item_container = $('.desktop.item-container').get(0); } }) @@ -2946,7 +2948,7 @@ window.scale_window = (el_window)=>{ // set new size and position $(el_window).css({ - 'top': toolbar_height+'px', + 'top': window.toolbar_height+'px', 'left': '0', 'width': '100%', 'height': `calc(100% - ${window.taskbar_height + window.toolbar_height + 1}px)`, @@ -3004,7 +3006,7 @@ window.set_sort_by = function(item_uid, sort_by, sort_order){ sort_order = 'asc'; $.ajax({ - url: api_origin + "/set_sort_by", + url: window.api_origin + "/set_sort_by", type: 'POST', data: JSON.stringify({ sort_by: sort_by, @@ -3014,11 +3016,11 @@ window.set_sort_by = function(item_uid, sort_by, sort_order){ async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, success: function (){ @@ -3080,7 +3082,7 @@ $.fn.showWindow = async function(options) { width: $(el_window).attr('data-orig-width') + 'px', height: $(el_window).attr('data-orig-height') + 'px', }); - $(el_window).css('z-index', ++last_window_zindex); + $(el_window).css('z-index', ++window.last_window_zindex); setTimeout(() => { $(this).focusWindow(); @@ -3120,15 +3122,15 @@ $.fn.focusWindow = function(event) { $('.window-app-iframe').not($app_iframe).css('pointer-events', 'none'); // bring this window to front, only if it's not stay_on_top if($(this).attr('data-stay_on_top') !== 'true'){ - $(this).css('z-index', ++last_window_zindex); + $(this).css('z-index', ++window.last_window_zindex); } // if this window has a parent, bring them to the front too if($(this).attr('data-parent_uuid') !== 'null'){ - $(`.window[data-element_uuid="${$(this).attr('data-parent_uuid')}"]`).css('z-index', last_window_zindex); + $(`.window[data-element_uuid="${$(this).attr('data-parent_uuid')}"]`).css('z-index', window.last_window_zindex); } // if this window has child windows, bring them to the front too if($(this).attr('data-element_uuid') !== 'null'){ - $(`.window[data-parent_uuid="${$(this).attr('data-element_uuid')}"]`).css('z-index', ++last_window_zindex); + $(`.window[data-parent_uuid="${$(this).attr('data-element_uuid')}"]`).css('z-index', ++window.last_window_zindex); } // // if this has an iframe, focus on it @@ -3144,17 +3146,17 @@ $.fn.focusWindow = function(event) { event !== undefined && (event.type === 'click' || event.type === 'dblclick' || event.type === 'contextmenu' || event.type === 'mousedown' || event.type === 'mouseup' || event.type === 'mousemove') ){ - $app_iframe.get(0).contentWindow.postMessage({msg: "click", x: (mouseX - rect.left), y: (mouseY - rect.top)}, '*'); + $app_iframe.get(0).contentWindow.postMessage({msg: "click", x: (window.mouseX - rect.left), y: (window.mouseY - rect.top)}, '*'); } } // set active_item_container - active_item_container = $(this).find('.item-container').get(0); + window.active_item_container = $(this).find('.item-container').get(0); // grey out all selected items on other windows/desktop - $('.item-container').not(active_item_container).find('.item-selected').addClass('item-blurred'); + $('.item-container').not(window.active_item_container).find('.item-selected').addClass('item-blurred'); // update window-stack - window_stack.push(parseInt($(this).attr('data-id'))); + window.window_stack.push(parseInt($(this).attr('data-id'))); // remove blurred class from items on this window - $(active_item_container).find('.item-blurred').removeClass('item-blurred'); + $(window.active_item_container).find('.item-blurred').removeClass('item-blurred'); //change window URL const update_window_url = $(this).attr('data-update_window_url'); if(update_window_url === 'true' || update_window_url === null){ @@ -3249,13 +3251,13 @@ $(document).on('click', '.explore-table-headers-th', function(e){ } // sort - sort_items($(e.target).closest('.window-body'), sort_by, sort_order); - set_sort_by($(e.target).closest('.window').attr('data-uid'), sort_by, sort_order) + window.sort_items($(e.target).closest('.window-body'), sort_by, sort_order); + window.set_sort_by($(e.target).closest('.window').attr('data-uid'), sort_by, sort_order) }) window.set_layout = function(item_uid, layout){ $.ajax({ - url: api_origin + "/set_layout", + url: window.api_origin + "/set_layout", type: 'POST', data: JSON.stringify({ item_uid: item_uid, @@ -3264,11 +3266,11 @@ window.set_layout = function(item_uid, layout){ async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, success: function (){ @@ -3277,7 +3279,7 @@ window.set_layout = function(item_uid, layout){ if(el_window.length > 0){ let sort_by = el_window.attr('data-sort_by'); let sort_order = el_window.attr('data-sort_order'); - update_details_layout_sort_visuals(el_window, sort_by, sort_order); + window.update_details_layout_sort_visuals(el_window, sort_by, sort_order); } } }