|
@@ -10,7 +10,6 @@
|
|
<script type="text/javascript" src="script/tocas/tocas.js"></script>
|
|
<script type="text/javascript" src="script/tocas/tocas.js"></script>
|
|
<script type="text/javascript" src="script/jquery.min.js"></script>
|
|
<script type="text/javascript" src="script/jquery.min.js"></script>
|
|
<script type="text/javascript" src="script/ao_module.js"></script>
|
|
<script type="text/javascript" src="script/ao_module.js"></script>
|
|
- <script type="text/javascript" src="SystemAO/desktop/offline/pong.js"></script>
|
|
|
|
<script type="text/javascript" src="SystemAO/desktop/script/jsCalendar/source/jsCalendar.js"></script>
|
|
<script type="text/javascript" src="SystemAO/desktop/script/jsCalendar/source/jsCalendar.js"></script>
|
|
<style>
|
|
<style>
|
|
body {
|
|
body {
|
|
@@ -3243,7 +3242,7 @@
|
|
title += " file";
|
|
title += " file";
|
|
}
|
|
}
|
|
|
|
|
|
- parent.newFloatWindow({
|
|
|
|
|
|
+ newFloatWindow({
|
|
url: "SystemAO/file_system/file_operation.html#" + configHash,
|
|
url: "SystemAO/file_system/file_operation.html#" + configHash,
|
|
width: 400,
|
|
width: 400,
|
|
height: 220,
|
|
height: 220,
|
|
@@ -3962,7 +3961,7 @@
|
|
//When the user selected more than one item on desktop
|
|
//When the user selected more than one item on desktop
|
|
addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
|
|
addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
|
|
addContextMenuItem($("#contextmenu"), 'Open With', "<i class='caret right icon'></i>", "handleOpenWith", true);
|
|
addContextMenuItem($("#contextmenu"), 'Open With', "<i class='caret right icon'></i>", "handleOpenWith", true);
|
|
- addContextMenuItem($("#contextmenu"), 'Share', "<i class='caret right icon'></i>", "handleFileShare", true);
|
|
|
|
|
|
+ //addContextMenuItem($("#contextmenu"), 'Share', "<i class='caret right icon'></i>", "handleFileShare", true);
|
|
addContextMenuSeperator($("#contextmenu"));
|
|
addContextMenuSeperator($("#contextmenu"));
|
|
addContextMenuItem($("#contextmenu"), 'Download in Zip', "<i class='download icon'></i>", "downloadFile", false);
|
|
addContextMenuItem($("#contextmenu"), 'Download in Zip', "<i class='download icon'></i>", "downloadFile", false);
|
|
addContextMenuItem($("#contextmenu"), 'Make a Copy', "<i class='copy icon'></i>", "handleCloning", false);
|
|
addContextMenuItem($("#contextmenu"), 'Make a Copy', "<i class='copy icon'></i>", "handleCloning", false);
|
|
@@ -4192,6 +4191,15 @@
|
|
|
|
|
|
function handleOpenWith(target, event){
|
|
function handleOpenWith(target, event){
|
|
$("#subcontextmenu").html("");
|
|
$("#subcontextmenu").html("");
|
|
|
|
+ //Updates 19 May 2021: Added support for better parsing Open With List
|
|
|
|
+ var exts = [];
|
|
|
|
+ //Get all exts from the selected files
|
|
|
|
+ $(".launchIconWrapper.selected").each(function(){
|
|
|
|
+ var filename = $(this).parent().attr("filename");
|
|
|
|
+ var ext = "." + filename.split(".").pop();
|
|
|
|
+ exts.push(ext);
|
|
|
|
+ });
|
|
|
|
+
|
|
$.get("system/modules/list",function(data){
|
|
$.get("system/modules/list",function(data){
|
|
if (data.error !== undefined){
|
|
if (data.error !== undefined){
|
|
alert(data.error);
|
|
alert(data.error);
|
|
@@ -4200,16 +4208,223 @@
|
|
var openWithTargets = [];
|
|
var openWithTargets = [];
|
|
for (var i =0; i < data.length; i++){
|
|
for (var i =0; i < data.length; i++){
|
|
var thisModule = data[i];
|
|
var thisModule = data[i];
|
|
- if (thisModule.SupportEmb == true){
|
|
|
|
|
|
+
|
|
|
|
+ //If this module support this ext, add it to list
|
|
|
|
+ var thisModuleSupportExt = thisModule.SupportedExt;
|
|
|
|
+ if (thisModule.Name == "File Manager"){
|
|
|
|
+ //Exceptional case
|
|
addContextMenuItem($("#subcontextmenu"), thisModule.Name, "", "openSelectedWith", false);
|
|
addContextMenuItem($("#subcontextmenu"), thisModule.Name, "", "openSelectedWith", false);
|
|
}
|
|
}
|
|
|
|
+ if (thisModuleSupportExt == null || thisModuleSupportExt.length == 0){
|
|
|
|
+ //Not supporting anything
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ thisModuleSupportExt.forEach(supportedExt => {
|
|
|
|
+ if (exts.includes(supportedExt)){
|
|
|
|
+ //Add this to the menu
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), thisModule.Name, "", "openSelectedWith", false);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //if (thisModule.SupportEmb == true){
|
|
|
|
+ // addContextMenuItem($("#subcontextmenu"), thisModule.Name, "", "openSelectedWith", false);
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //Add select more opener option
|
|
|
|
+ addContextMenuSeperator($("#subcontextmenu"));
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), "Select Other WebApps", ``, "openOpenSelector", false);
|
|
}
|
|
}
|
|
showSubContextMenu(target);
|
|
showSubContextMenu(target);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function handleFileShare(target, object){
|
|
|
|
+ $("#subcontextmenu").html("");
|
|
|
|
+ //Get the selected file
|
|
|
|
+ var targetFile = $(".launchIconWrapper.selected")[0];
|
|
|
|
+ var fileData = $(targetFile).parent().attr("filedata");
|
|
|
|
+ if (fileData != undefined){
|
|
|
|
+ fileData = JSON.parse(decodeURIComponent(fileData));
|
|
|
|
+ //Check if the target file is shared
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: "system/file_system/share/checkShared",
|
|
|
|
+ data: {path: fileData.Filepath},
|
|
|
|
+ success: function(data){
|
|
|
|
+ if (data.IsShared == true){
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), "Open Shared Link", `<i class="external icon"></i>`, "openSharedLink", false, {
|
|
|
|
+ payload: {
|
|
|
|
+ uuid: data.ShareUUID.UUID
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), "Copy Link", `<i class="copy icon"></i>`, "copySharedLink", false, {
|
|
|
|
+ payload: {
|
|
|
|
+ uuid: data.ShareUUID.UUID
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ addContextMenuSeperator($("#subcontextmenu"));
|
|
|
|
+ addContextMenuTitle($("#subcontextmenu"), `<i class="share alternate icon"></i> Change Share Settings`);
|
|
|
|
+ }else{
|
|
|
|
+ addContextMenuTitle($("#subcontextmenu"), `<i class="share alternate icon"></i> Share this File`);
|
|
|
|
+ }
|
|
|
|
+ console.log(data);
|
|
|
|
+
|
|
|
|
+ var checkmarkStyle = `style="color: #71ba68;"`;
|
|
|
|
+ var anyoneClass = "";
|
|
|
|
+ if (data.ShareUUID.Permission == "anyone"){
|
|
|
|
+ anyoneClass = `<i ${checkmarkStyle} class="checkmark icon"></i>`;
|
|
|
|
+ }
|
|
|
|
+ var signedinClass = "";
|
|
|
|
+ if (data.ShareUUID.Permission == "signedin"){
|
|
|
|
+ signedinClass = `<i ${checkmarkStyle} class="checkmark icon"></i>`;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var sameGroupClass = "";
|
|
|
|
+ if (data.ShareUUID.Permission == "samegroup"){
|
|
|
|
+ samegroup = `<i ${checkmarkStyle} class="checkmark icon"></i>`;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), `<i class="globe icon"></i> Anyone with Link`, anyoneClass, "shareWithThisPermission", false, {
|
|
|
|
+ payload: {
|
|
|
|
+ type: "anyone"
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), `<i class="user circle outline icon"></i> Anyone Signed In`, signedinClass, "shareWithThisPermission", false, {
|
|
|
|
+ payload: {
|
|
|
|
+ type: "signedin"
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), `<i class="users icon"></i> Same Group Users`, sameGroupClass, "shareWithThisPermission", false,{
|
|
|
|
+ payload: {
|
|
|
|
+ type: "samegroup"
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (data.IsShared == true){
|
|
|
|
+ //This file is shared.
|
|
|
|
+ addContextMenuSeperator($("#subcontextmenu"));
|
|
|
|
+ addContextMenuItem($("#subcontextmenu"), "Remove Share", `<i style="color: #d97762;" class="trash icon"></i>`, "shareWithThisPermission", false,{
|
|
|
|
+ payload: {
|
|
|
|
+ type: "remove"
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ showSubContextMenu(target);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Copy the shared link
|
|
|
|
+ function copySharedLink(target, event){
|
|
|
|
+ var payload = getContextMenuPayload(target);
|
|
|
|
+ if (payload == null){
|
|
|
|
+ //Something wrong
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Generate the share link
|
|
|
|
+ let protocol = "https://";
|
|
|
|
+ if (location.protocol !== 'https:') {
|
|
|
|
+ protocol = "http://";
|
|
|
|
+ }
|
|
|
|
+ var shareURL = protocol + window.location.hostname + ":" + window.location.port + "/share?id=" + payload.uuid;
|
|
|
|
+
|
|
|
|
+ //Copy the text to clipboard
|
|
|
|
+ const area = document.createElement('textarea');
|
|
|
|
+ document.body.appendChild(area);
|
|
|
|
+
|
|
|
|
+ area.value = shareURL;
|
|
|
|
+ area.select();
|
|
|
|
+ document.execCommand('copy');
|
|
|
|
+
|
|
|
|
+ document.body.removeChild(area);
|
|
|
|
+
|
|
|
|
+ //Update status so it show the user it has been coped
|
|
|
|
+ $(target).html(`<i style="color: #71ba68;" class="checkmark icon"></i> Copied!`);
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ if ($(target).length > 0){
|
|
|
|
+ $(target).html(`Copy Link
|
|
|
|
+ <span class="description">
|
|
|
|
+ <i class="copy icon"></i>
|
|
|
|
+ </span>`);
|
|
|
|
+ }
|
|
|
|
+ }, 3000);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Open the shared file link
|
|
|
|
+ function openSharedLink(target, event){
|
|
|
|
+ var payload = getContextMenuPayload(target);
|
|
|
|
+ if (payload == null){
|
|
|
|
+ //Something wrong
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var targetURL = "share?id=" + payload.uuid;
|
|
|
|
+ window.open(targetURL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function shareWithThisPermission(target, event){
|
|
|
|
+ var payload = getContextMenuPayload(target);
|
|
|
|
+ if (payload == null){
|
|
|
|
+ //Something wrong
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Get the selected file
|
|
|
|
+ var selectedFileObjects = $(".launchIconWrapper.selected");
|
|
|
|
+ if (selectedFileObjects.length == 0){
|
|
|
|
+ //Not found
|
|
|
|
+ return
|
|
|
|
+ }else if (selectedFileObjects.length > 1){
|
|
|
|
+ //This should not happens. If it did happens, use the first one
|
|
|
|
+ selectedFileObjects = selectedFileObjects[0];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Extract file information
|
|
|
|
+ var fileData = $(selectedFileObjects).parent().attr("filedata");
|
|
|
|
+ fileData = JSON.parse(decodeURIComponent(fileData));
|
|
|
|
+
|
|
|
|
+ //Convert the desktop file data to ArozOS generic filedata
|
|
|
|
+ var afd = {
|
|
|
|
+ "filename": fileData.Filename,
|
|
|
|
+ "filepath": fileData.Filepath,
|
|
|
|
+ "shareMode": payload.type
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //Create a new share for this
|
|
|
|
+ var targetURL = "SystemAO/file_system/file_share.html#" + encodeURIComponent(JSON.stringify([afd]));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //Calculate the window spawn position
|
|
|
|
+ var basePosition = $(selectedFileObjects).offset();
|
|
|
|
+ var left = basePosition.left + 100;
|
|
|
|
+ if (left + 320 > window.innerWidth){
|
|
|
|
+ left = basePosition.left - 350;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var top = basePosition.top;
|
|
|
|
+ if (top + 480 > window.innerHeight){
|
|
|
|
+ top = window.innerHeight - 480;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ newFloatWindow({
|
|
|
|
+ url: targetURL,
|
|
|
|
+ width: 330,
|
|
|
|
+ height: 480,
|
|
|
|
+ left: left,
|
|
|
|
+ top: top,
|
|
|
|
+ appicon: "SystemAO/file_system/img/share.svg",
|
|
|
|
+ title: "Share File"
|
|
|
|
+ }, function(windowUUID){
|
|
|
|
+ //Set the window to fixed window
|
|
|
|
+ setFloatWindowResizePolicy(windowUUID, false);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ hideAllContextMenus();
|
|
|
|
+ }
|
|
|
|
+
|
|
function openObjectProperty(target, object){
|
|
function openObjectProperty(target, object){
|
|
var filelist = [];
|
|
var filelist = [];
|
|
$(".launchIconWrapper.selected").each(function(){
|
|
$(".launchIconWrapper.selected").each(function(){
|
|
@@ -4229,6 +4444,27 @@
|
|
hideAllContextMenus();
|
|
hideAllContextMenus();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //Open the file extension selector
|
|
|
|
+ function openOpenSelector(target, event){
|
|
|
|
+ var filedata = $($(".launchIconWrapper.selected")[0]).parent().attr("filedata")
|
|
|
|
+ filedata = JSON.parse(decodeURIComponent(filedata));
|
|
|
|
+
|
|
|
|
+ var fileDescriptor = {
|
|
|
|
+ filepath: filedata.Filepath,
|
|
|
|
+ filename: filedata.Filename
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ newFloatWindow({
|
|
|
|
+ url: "SystemAO/file_system/defaultOpener.html#" + encodeURIComponent(JSON.stringify(fileDescriptor)),
|
|
|
|
+ width: 320,
|
|
|
|
+ height: 510,
|
|
|
|
+ appicon: "SystemAO/file_system/img/opener.png",
|
|
|
|
+ title: "Select WebApp to Open File",
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ hideAllContextMenus();
|
|
|
|
+ }
|
|
|
|
+
|
|
function openSelectedWith(target, event){
|
|
function openSelectedWith(target, event){
|
|
var targetModulename = $(target).text().trim();
|
|
var targetModulename = $(target).text().trim();
|
|
var openFileList = [];
|
|
var openFileList = [];
|
|
@@ -4250,9 +4486,7 @@
|
|
|
|
|
|
//Open the files with the given module
|
|
//Open the files with the given module
|
|
openFileWithModule(targetModuleInfo, openFileList);
|
|
openFileWithModule(targetModuleInfo, openFileList);
|
|
-
|
|
|
|
hideAllContextMenus();
|
|
hideAllContextMenus();
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function getModuleInfoFromName(moduleName){
|
|
function getModuleInfoFromName(moduleName){
|
|
@@ -4265,25 +4499,48 @@
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ This function is used to generate menu items for context menu.
|
|
|
|
+ Options example
|
|
|
|
+ {
|
|
|
|
+ payload: {
|
|
|
|
+ //Some JSON based payload here
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
|
|
-
|
|
|
|
- function addContextMenuItem(target, keyword, hotkey = undefined, functionName, containSubMenu = false) {
|
|
|
|
|
|
+ function addContextMenuItem(target, keyword, hotkey = undefined, functionName, containSubMenu = false, options=undefined) {
|
|
var itemClass = "item";
|
|
var itemClass = "item";
|
|
if (containSubMenu) {
|
|
if (containSubMenu) {
|
|
itemClass = "item submenu";
|
|
itemClass = "item submenu";
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ var payload = "";
|
|
|
|
+ if (options != undefined && options.payload != undefined){
|
|
|
|
+ payload = encodeURIComponent(JSON.stringify(options.payload));
|
|
|
|
+ }
|
|
|
|
+
|
|
if (hotkey !== undefined) {
|
|
if (hotkey !== undefined) {
|
|
- target.append(`<div class="${itemClass}" onclick="${functionName}(this,event);">
|
|
|
|
|
|
+ target.append(`<div class="${itemClass}" onclick="${functionName}(this,event);" payload="${payload}">
|
|
${keyword}
|
|
${keyword}
|
|
<span class="description">${hotkey}</span>
|
|
<span class="description">${hotkey}</span>
|
|
</div>`);
|
|
</div>`);
|
|
} else {
|
|
} else {
|
|
- target.append(`<div class="${itemClass}" onclick="${functionName}(this,event);">
|
|
|
|
|
|
+ target.append(`<div class="${itemClass}" onclick="${functionName}(this,event);" payload="${payload}">
|
|
${keyword}
|
|
${keyword}
|
|
</div>`);
|
|
</div>`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function getContextMenuPayload(object){
|
|
|
|
+ var encodedPayload = $(object).attr("payload");
|
|
|
|
+ if (encodedPayload != ""){
|
|
|
|
+ return JSON.parse(decodeURIComponent(encodedPayload));
|
|
|
|
+ }else{
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
function listIconsize(target, event) {
|
|
function listIconsize(target, event) {
|
|
$("#subcontextmenu").html("");
|
|
$("#subcontextmenu").html("");
|
|
var smallCheckmark = undefined;
|
|
var smallCheckmark = undefined;
|
|
@@ -4319,6 +4576,12 @@
|
|
$(target).append(`<div class="divider"></div>`);
|
|
$(target).append(`<div class="divider"></div>`);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function addContextMenuTitle(target, title){
|
|
|
|
+ $(target).append(`<div class="header">
|
|
|
|
+ ${title}
|
|
|
|
+ </div>`);
|
|
|
|
+ }
|
|
|
|
+
|
|
function downloadURL() {
|
|
function downloadURL() {
|
|
alert("WIP");
|
|
alert("WIP");
|
|
hideAllContextMenus();
|
|
hideAllContextMenus();
|