diff --git a/src/gui/src/UI/UIItem.js b/src/gui/src/UI/UIItem.js
index 99ef77224..e644edd09 100644
--- a/src/gui/src/UI/UIItem.js
+++ b/src/gui/src/UI/UIItem.js
@@ -35,12 +35,12 @@ import mime from '../lib/mime.js';
const AI_APP_NAME = 'ai';
const parseItemMetadataForAI = (metadata) => {
- if ( ! metadata ) {
+ if (!metadata) {
return undefined;
}
try {
return JSON.parse(metadata);
- } catch ( error ) {
+ } catch (error) {
console.warn('Failed to parse item metadata for AI payload.', error);
return undefined;
}
@@ -67,17 +67,17 @@ const buildAIPayloadFromItems = ($elements) => {
const ensureAIAppIframe = async () => {
let $aiWindow = $(`.window[data-app="${AI_APP_NAME}"]`);
- if ( $aiWindow.length === 0 ) {
+ if ($aiWindow.length === 0) {
try {
await launch_app({ name: AI_APP_NAME });
- } catch ( error ) {
+ } catch (error) {
console.error('Failed to launch AI app.', error);
return null;
}
$aiWindow = $(`.window[data-app="${AI_APP_NAME}"]`);
}
- if ( $aiWindow.length === 0 ) {
+ if ($aiWindow.length === 0) {
return null;
}
@@ -88,12 +88,12 @@ const ensureAIAppIframe = async () => {
const sendSelectionToAIApp = async ($elements) => {
const items = buildAIPayloadFromItems($elements);
- if ( items.length === 0 ) {
+ if (items.length === 0) {
return;
}
const aiIframe = await ensureAIAppIframe();
- if ( !aiIframe || !aiIframe.contentWindow ) {
+ if (!aiIframe || !aiIframe.contentWindow) {
await UIAlert({
message: i18n('ai_app_unavailable'),
});
@@ -107,7 +107,7 @@ const sendSelectionToAIApp = async ($elements) => {
}, '*');
};
-async function UIItem (options) {
+function UIItem(options){
const matching_appendto_count = $(options.appendTo).length;
if ( matching_appendto_count > 1 ) {
$(options.appendTo).each(function () {
@@ -139,9 +139,7 @@ async function UIItem (options) {
options.immutable = (options.immutable === false || options.immutable === 0 || options.immutable === undefined ? 0 : 1);
options.sort_container_after_append = (options.sort_container_after_append !== undefined ? options.sort_container_after_append : false);
const is_shared_with_me = (options.path !== `/${window.user.username}` && !options.path.startsWith(`/${window.user.username}/`));
- const workers = await puter.workers.list();
- const is_worker = workers.find(w => w.file_path === options.path);
- const worker_url = is_worker?.url;
+
let website_url = window.determine_website_url(options.path);
// do a quick check to see if the target parent has any file type restrictions
@@ -167,8 +165,6 @@ async function UIItem (options) {
data-website_url = "${website_url ? html_encode(website_url) : ''}"
data-immutable="${options.immutable}"
data-is_shortcut = "${options.is_shortcut}"
- data-is_worker = "${is_worker !== undefined ? 1 : 0}"
- data-worker_url = "${is_worker !== undefined ? worker_url : 0}"
data-shortcut_to = "${html_encode(options.shortcut_to)}"
data-shortcut_to_path = "${html_encode(options.shortcut_to_path)}"
data-sortable = "${options.sortable ?? 'true'}"
@@ -244,12 +240,7 @@ async function UIItem (options) {
data-item-id="${item_id}"
title="${i18n('item_shortcut')}"
>`;
- // worker badge
- h += ``;
+
h += '';
// divider
@@ -997,9 +988,9 @@ async function UIItem (options) {
// -------------------------------------------
menu_items.push({
html: i18n('open_in_ai'),
- onClick: async function () {
+ onClick: async function(){
await sendSelectionToAIApp($selected_items);
- },
+ }
});
// -------------------------------------------
// -
@@ -1341,9 +1332,9 @@ async function UIItem (options) {
// -------------------------------------------
menu_items.push({
html: i18n('open_in_ai'),
- onClick: async function () {
+ onClick: async function(){
await sendSelectionToAIApp($(el_item));
- },
+ }
});
}
@@ -1889,50 +1880,6 @@ $(document).on('click', '.website-badge-popover-link', function (e) {
$(e.target).closest('.popover').remove();
});
-$(document).on('long-hover', '.item-is-worker', function (e) {
- const worker_url = e.target.parentNode.parentNode.getAttribute('data-worker_url');
- var box = e.target.getBoundingClientRect();
-
- var body = document.body;
- var docEl = document.documentElement;
-
- var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
- var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
-
- var clientTop = docEl.clientTop || body.clientTop || 0;
- var clientLeft = docEl.clientLeft || body.clientLeft || 0;
-
- var top = box.top + scrollTop - clientTop;
- var left = box.left + scrollLeft - clientLeft;
-
- if ( worker_url ) {
- let h = '