This commit is contained in:
meetqy 2024-03-16 13:48:11 +08:00
parent 0b5e236df4
commit 06b075b1a4

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
window.clipboard_op = ''; window.clipboard_op = "";
window.clipboard = []; window.clipboard = [];
window.actions_history = []; window.actions_history = [];
window.window_nav_history = {}; window.window_nav_history = {};
@ -43,63 +43,65 @@ window.mouseX = 0;
window.mouseY = 0; window.mouseY = 0;
// get all logged-in users // get all logged-in users
try{ try {
window.logged_in_users = JSON.parse(localStorage.getItem("logged_in_users")); window.logged_in_users = JSON.parse(localStorage.getItem("logged_in_users"));
}catch(e){ } catch (e) {
window.logged_in_users = []; window.logged_in_users = [];
} }
if(window.logged_in_users === null) if (window.logged_in_users === null) window.logged_in_users = [];
window.logged_in_users = [];
// this sessions's user // this sessions's user
window.auth_token = localStorage.getItem("auth_token"); window.auth_token = localStorage.getItem("auth_token");
try{ try {
window.user = JSON.parse(localStorage.getItem("user")); window.user = JSON.parse(localStorage.getItem("user"));
}catch(e){ } catch (e) {
window.user = null; window.user = null;
} }
// in case this is the first time user is visiting multi-user feature // in case this is the first time user is visiting multi-user feature
if(window.logged_in_users.length === 0 && window.user !== null){ if (window.logged_in_users.length === 0 && window.user !== null) {
let tuser = window.user; let tuser = window.user;
tuser.auth_token = window.auth_token tuser.auth_token = window.auth_token;
window.logged_in_users.push(tuser); window.logged_in_users.push(tuser);
localStorage.setItem("logged_in_users", window.logged_in_users); localStorage.setItem("logged_in_users", window.logged_in_users);
} }
window.last_window_zindex = 1; window.last_window_zindex = 1;
// first visit tracker // first visit tracker
window.first_visit_ever = localStorage.getItem("has_visited_before") === null ? true : false; window.first_visit_ever =
localStorage.getItem("has_visited_before") === null ? true : false;
localStorage.setItem("has_visited_before", true); localStorage.setItem("has_visited_before", true);
// system paths // system paths
if(window.user !== undefined && window.user !== null){ if (window.user !== undefined && window.user !== null) {
window.desktop_path = '/' + window.user.username + '/Desktop'; window.desktop_path = "/" + window.user.username + "/Desktop";
window.trash_path = '/' + window.user.username + '/Trash'; window.trash_path = "/" + window.user.username + "/Trash";
window.appdata_path = '/' + window.user.username + '/AppData'; window.appdata_path = "/" + window.user.username + "/AppData";
window.documents_path = '/' + window.user.username + '/Documents'; window.documents_path = "/" + window.user.username + "/Documents";
window.pictures_path = '/' + window.user.username + '/Photos'; window.pictures_path = "/" + window.user.username + "/Photos";
window.videos_path = '/' + window.user.username + '/Videos'; window.videos_path = "/" + window.user.username + "/Videos";
window.audio_path = '/' + window.user.username + '/Audio'; window.audio_path = "/" + window.user.username + "/Audio";
window.home_path = '/' + window.user.username; window.home_path = "/" + window.user.username;
} }
window.root_dirname = 'Puter'; window.root_dirname = "Puter";
// user preferences, persisted across sessions, cached in localStorage // user preferences, persisted across sessions, cached in localStorage
try { try {
window.user_preferences = JSON.parse(localStorage.getItem('user_preferences')) window.user_preferences = JSON.parse(
}catch(e){ localStorage.getItem("user_preferences")
window.user_preferences = null; );
} catch (e) {
window.user_preferences = null;
} }
// default values // default values
if (window.user_preferences === null) { if (window.user_preferences === null) {
window.user_preferences = { window.user_preferences = {
show_hidden_files: false, show_hidden_files: false,
} };
} }
window.window_stack = [] window.window_stack = [];
window.toolbar_height = 30; window.toolbar_height = 30;
window.default_taskbar_height = 50; window.default_taskbar_height = 50;
window.taskbar_height = window.default_taskbar_height; window.taskbar_height = window.default_taskbar_height;
@ -112,39 +114,53 @@ window.operation_id = 0;
window.operation_cancelled = []; window.operation_cancelled = [];
window.last_enter_pressed_to_rename_ts = 0; window.last_enter_pressed_to_rename_ts = 0;
window.window_counter = 0; window.window_counter = 0;
window.keypress_item_seach_term = ''; window.keypress_item_seach_term = "";
window.keypress_item_seach_buffer_timeout = undefined; window.keypress_item_seach_buffer_timeout = undefined;
window.first_visit_animation = false; window.first_visit_animation = false;
window.show_twitter_link = true; window.show_twitter_link = true;
window.animate_window_opening = true; window.animate_window_opening = true;
window.animate_window_closing = true; window.animate_window_closing = true;
window.desktop_loading_fade_delay = (window.first_visit_ever && first_visit_animation ? 6000 : 1000); window.desktop_loading_fade_delay =
window.first_visit_ever && first_visit_animation ? 6000 : 1000;
window.watchItems = []; window.watchItems = [];
window.appdata_signatures = {}; window.appdata_signatures = {};
window.appCallbackFunctions = []; window.appCallbackFunctions = [];
// 'Launch' apps // 'Launch' apps
window.launch_apps = []; window.launch_apps = [];
window.launch_apps.recent = [] window.launch_apps.recent = [];
window.launch_apps.recommended = [] window.launch_apps.recommended = [];
// Is puter being loaded inside an iframe? // Is puter being loaded inside an iframe?
if (window.location !== window.parent.location) { if (window.location !== window.parent.location) {
window.is_embedded = true; window.is_embedded = true;
// taskbar is not needed in embedded mode // taskbar is not needed in embedded mode
window.taskbar_height = 0; window.taskbar_height = 0;
} else { } else {
window.is_embedded = false; window.is_embedded = false;
} }
// calculate desktop height and width // calculate desktop height and width
window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height; window.desktop_height =
window.innerHeight - window.toolbar_height - window.taskbar_height;
window.desktop_width = window.innerWidth; window.desktop_width = window.innerWidth;
// recalculate desktop height and width on window resize // recalculate desktop height and width on window resize
$( window ).on( "resize", function() { $(window).on("resize", function () {
window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height; const radio = window.desktop_width / window.innerWidth;
window.desktop_width = window.innerWidth;
window.desktop_height =
window.innerHeight - window.toolbar_height - window.taskbar_height;
window.desktop_width = window.innerWidth;
const { top } = $(".window-login").position();
const width = $(".window-login").width();
$(".window-login").css({
left: (window.desktop_width - width) / 2,
top: top / radio,
});
}); });
// for now `active_element` is basically the last element that was clicked, // for now `active_element` is basically the last element that was clicked,
@ -167,10 +183,10 @@ window.window_border_radius = 4;
window.sites = []; window.sites = [];
window.feature_flags = { window.feature_flags = {
// if true, the user will be able to create shortcuts to files and directories // if true, the user will be able to create shortcuts to files and directories
create_shortcut: true, create_shortcut: true,
// if true, the user will be asked to confirm before navigating away from Puter only if there is at least one window open // if true, the user will be asked to confirm before navigating away from Puter only if there is at least one window open
prompt_user_when_navigation_away_from_puter: false, prompt_user_when_navigation_away_from_puter: false,
// if true, the user will be able to zip and download directories // if true, the user will be able to zip and download directories
download_directory: true, download_directory: true,
} };