mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
chore: Clarify usage of window fields in UITaskbar.js
/puter/src/UI/UITaskbar.js 24:5 error 'global_element_id' is not defined no-undef 31:14 error 'api_origin' is not defined no-undef 36:40 error 'auth_token' is not defined no-undef 44:33 error 'global_element_id' is not defined no-undef 77:17 error 'launch_apps' is not defined no-undef 77:33 error 'launch_apps' is not defined no-undef 77:55 error 'launch_apps' is not defined no-undef 79:17 error 'launch_apps' is not defined no-undef 80:26 error 'api_origin' is not defined no-undef 85:52 error 'auth_token' is not defined no-undef 99:16 error 'launch_apps' is not defined no-undef 105:88 error 'launch_apps' is not defined no-undef 106:38 error 'launch_apps' is not defined no-undef 119:16 error 'launch_apps' is not defined no-undef 121:107 error 'launch_apps' is not defined no-undef 125:45 error 'launch_apps' is not defined no-undef 126:38 error 'launch_apps' is not defined no-undef 179:17 error 'launch_app' is not defined no-undef 201:25 error 'launch_app' is not defined no-undef 215:39 error 'trash_path' is not defined no-undef 228:68 error 'trash_path' is not defined no-undef 230:17 error 'launch_app' is not defined no-undef 236:13 error 'move_items' is not defined no-undef 236:31 error 'trash_path' is not defined no-undef 240:5 error 'make_taskbar_sortable' is not defined no-undef 262:22 error Empty block statement no-empty 284:29 error 'launch_app' is not defined no-undef 297:17 error 'update_taskbar' is not defined no-undef 301:17 error 'update_taskbar' is not defined no-undef
This commit is contained in:
parent
a5821815bf
commit
94291c4968
@ -21,19 +21,19 @@ import UITaskbarItem from './UITaskbarItem.js'
|
||||
import UIPopover from './UIPopover.js'
|
||||
|
||||
async function UITaskbar(options){
|
||||
global_element_id++;
|
||||
window.global_element_id++;
|
||||
|
||||
options = options ?? {};
|
||||
options.content = options.content ?? '';
|
||||
|
||||
// get launch apps
|
||||
$.ajax({
|
||||
url: api_origin + "/get-launch-apps",
|
||||
url: window.api_origin + "/get-launch-apps",
|
||||
type: 'GET',
|
||||
async: true,
|
||||
contentType: "application/json",
|
||||
headers: {
|
||||
"Authorization": "Bearer "+auth_token
|
||||
"Authorization": "Bearer "+window.auth_token
|
||||
},
|
||||
success: function (apps){
|
||||
window.launch_apps = apps;
|
||||
@ -41,7 +41,7 @@ async function UITaskbar(options){
|
||||
});
|
||||
|
||||
let h = '';
|
||||
h += `<div id="ui-taskbar_${global_element_id}" class="taskbar" style="height:${window.taskbar_height}px;"><span id='clock'></span></div>`;
|
||||
h += `<div id="ui-taskbar_${window.global_element_id}" class="taskbar" style="height:${window.taskbar_height}px;"><span id='clock'></span></div>`;
|
||||
|
||||
$('.desktop').append(h);
|
||||
|
||||
@ -74,15 +74,15 @@ async function UITaskbar(options){
|
||||
|
||||
// In the rare case that launch_apps is not populated yet, get it from the server
|
||||
// then populate the popover
|
||||
if(!launch_apps || !launch_apps.recent || launch_apps.recent.length === 0){
|
||||
if(!window.launch_apps || !window.launch_apps.recent || window.launch_apps.recent.length === 0){
|
||||
// get launch apps
|
||||
launch_apps = await $.ajax({
|
||||
url: api_origin + "/get-launch-apps",
|
||||
window.launch_apps = await $.ajax({
|
||||
url: window.api_origin + "/get-launch-apps",
|
||||
type: 'GET',
|
||||
async: true,
|
||||
contentType: "application/json",
|
||||
headers: {
|
||||
"Authorization": "Bearer "+auth_token
|
||||
"Authorization": "Bearer "+window.auth_token
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -96,14 +96,14 @@ async function UITaskbar(options){
|
||||
// -------------------------------------------
|
||||
// Recent apps
|
||||
// -------------------------------------------
|
||||
if(launch_apps.recent.length > 0){
|
||||
if(window.launch_apps.recent.length > 0){
|
||||
// heading
|
||||
apps_str += `<h1 class="start-section-heading start-section-heading-recent">${i18n('recent')}</h1>`;
|
||||
|
||||
// apps
|
||||
apps_str += `<div class="launch-apps-recent">`;
|
||||
for (let index = 0; index < window.launch_recent_apps_count && index < launch_apps.recent.length; index++) {
|
||||
const app_info = launch_apps.recent[index];
|
||||
for (let index = 0; index < window.launch_recent_apps_count && index < window.launch_apps.recent.length; index++) {
|
||||
const app_info = window.launch_apps.recent[index];
|
||||
apps_str += `<div title="${html_encode(app_info.title)}" data-name="${html_encode(app_info.name)}" class="start-app-card">`;
|
||||
apps_str += `<div class="start-app" data-app-name="${html_encode(app_info.name)}" data-app-uuid="${html_encode(app_info.uuid)}" data-app-icon="${html_encode(app_info.icon)}" data-app-title="${html_encode(app_info.title)}">`;
|
||||
apps_str += `<img class="start-app-icon" src="${html_encode(app_info.icon ? app_info.icon : window.icons['app.svg'])}">`;
|
||||
@ -116,14 +116,14 @@ async function UITaskbar(options){
|
||||
// -------------------------------------------
|
||||
// Reccomended apps
|
||||
// -------------------------------------------
|
||||
if(launch_apps.recommended.length > 0){
|
||||
if(window.launch_apps.recommended.length > 0){
|
||||
// heading
|
||||
apps_str += `<h1 class="start-section-heading start-section-heading-recommended" style="${launch_apps.recent.length > 0 ? 'padding-top: 30px;' : ''}">Recommended</h1>`;
|
||||
apps_str += `<h1 class="start-section-heading start-section-heading-recommended" style="${window.launch_apps.recent.length > 0 ? 'padding-top: 30px;' : ''}">Recommended</h1>`;
|
||||
|
||||
// apps
|
||||
apps_str += `<div class="launch-apps-recommended">`;
|
||||
for (let index = 0; index < launch_apps.recommended.length; index++) {
|
||||
const app_info = launch_apps.recommended[index];
|
||||
for (let index = 0; index < window.launch_apps.recommended.length; index++) {
|
||||
const app_info = window.launch_apps.recommended[index];
|
||||
apps_str += `<div title="${html_encode(app_info.title)}" data-name="${html_encode(app_info.name)}" class="start-app-card">`;
|
||||
apps_str += `<div class="start-app" data-app-name="${html_encode(app_info.name)}" data-app-uuid="${html_encode(app_info.uuid)}" data-app-icon="${html_encode(app_info.icon)}" data-app-title="${html_encode(app_info.title)}">`;
|
||||
apps_str += `<img class="start-app-icon" src="${html_encode(app_info.icon ? app_info.icon : window.icons['app.svg'])}">`;
|
||||
@ -176,7 +176,7 @@ async function UITaskbar(options){
|
||||
onClick: function(){
|
||||
let open_window_count = parseInt($(`.taskbar-item[data-app="explorer"]`).attr('data-open-windows'));
|
||||
if(open_window_count === 0){
|
||||
launch_app({ name: 'explorer', path: window.home_path});
|
||||
window.launch_app({ name: 'explorer', path: window.home_path});
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
@ -198,7 +198,7 @@ async function UITaskbar(options){
|
||||
onClick: function(){
|
||||
let open_window_count = parseInt($(`.taskbar-item[data-app="${app_info.name}"]`).attr('data-open-windows'));
|
||||
if(open_window_count === 0){
|
||||
launch_app({
|
||||
window.launch_app({
|
||||
name: app_info.name,
|
||||
})
|
||||
}else{
|
||||
@ -212,7 +212,7 @@ async function UITaskbar(options){
|
||||
//---------------------------------------------
|
||||
// add `Trash` to the taskbar
|
||||
//---------------------------------------------
|
||||
const trash = await puter.fs.stat(trash_path);
|
||||
const trash = await puter.fs.stat(window.trash_path);
|
||||
if(window.socket){
|
||||
window.socket.emit('trash.is_empty', {is_empty: trash.is_empty});
|
||||
}
|
||||
@ -225,19 +225,19 @@ async function UITaskbar(options){
|
||||
keep_in_taskbar: true,
|
||||
lock_keep_in_taskbar: true,
|
||||
onClick: function(){
|
||||
let open_windows = $(`.window[data-path="${html_encode(trash_path)}"]`);
|
||||
let open_windows = $(`.window[data-path="${html_encode(window.trash_path)}"]`);
|
||||
if(open_windows.length === 0){
|
||||
launch_app({ name: 'explorer', path: window.trash_path});
|
||||
window.launch_app({ name: 'explorer', path: window.trash_path});
|
||||
}else{
|
||||
open_windows.focusWindow();
|
||||
}
|
||||
},
|
||||
onItemsDrop: function(items){
|
||||
move_items(items, trash_path);
|
||||
window.move_items(items, window.trash_path);
|
||||
}
|
||||
})
|
||||
|
||||
make_taskbar_sortable();
|
||||
window.make_taskbar_sortable();
|
||||
}
|
||||
|
||||
window.make_taskbar_sortable = function(){
|
||||
@ -259,7 +259,6 @@ window.make_taskbar_sortable = function(){
|
||||
$(this).sortable('cancel');
|
||||
$('.taskbar .start-app').remove();
|
||||
return;
|
||||
}else{
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -281,7 +280,7 @@ window.make_taskbar_sortable = function(){
|
||||
onClick: function(){
|
||||
let open_window_count = parseInt($(`.taskbar-item[data-app="${$(ui.item).attr('data-app-name')}"]`).attr('data-open-windows'));
|
||||
if(open_window_count === 0){
|
||||
launch_app({
|
||||
window.launch_app({
|
||||
name: $(ui.item).attr('data-app-name'),
|
||||
})
|
||||
}else{
|
||||
@ -293,12 +292,12 @@ window.make_taskbar_sortable = function(){
|
||||
$(el).insertAfter(ui.item);
|
||||
// $(ui.item).insertBefore(`<h1>Hello!</h1>`);
|
||||
$(el).show();
|
||||
$(ui.item).removeItems();
|
||||
update_taskbar();
|
||||
$(ui.item).removeItems();
|
||||
window.update_taskbar();
|
||||
}
|
||||
// only proceed to update DB if the item sorted was a pinned item otherwise no point in updating the taskbar in DB
|
||||
else if($(ui.item).attr('data-keep-in-taskbar') === 'true'){
|
||||
update_taskbar();
|
||||
window.update_taskbar();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user