In reference to the ‘Keep Scripts order across devices’ post and based on the same idea as discussed in the 'Calling a scriptable from a scriptable, here’s an example script that when run displays lists of scripts that can be run (or edited). You can easily build a custom order and grouping and since this is in and of itself a script it will be automatically sync’d across devices.
The example below is one I put together that simply links to some scripts that I have on my devices. You must modify the content of the script for your device.
It could of course be genericised to use a file of data, but for the simplicity of sharing a starting point for people I’ve put the data in situ at the beginning of the script.
Select to reveal the script
//This defines the lists of scripts
// name = text to display in the list
// parent = name of any parent list item (matches against 'name')
// script = exact name of script. If blank, list item will be a heading
// linebreak = true if a line break should be added before the list item. Onl applies to headers
const scriptData = [
{
"name": "Default Scripts",
"parent": "",
"script": "",
"linebreak": true
},
{
"name": "Utility",
"parent": "",
"script": "",
"linebreak": true
},
{
"name": "Welcome Script",
"parent": "Default Scripts",
"script": "Welcome to Scriptable"
},
{
"name": "Examples",
"parent": "",
"script": "",
"linebreak": true
},
{
"name": "Select File Path",
"parent": "Examples",
"script": "Select File Path Example"
},
{
"name": "Alerts",
"parent": "Examples",
"script": "",
"linebreak": false
},
{
"name": "Alert 1",
"parent": "Alerts",
"script": "Alert Example"
},
{
"name": "Alert 2",
"parent": "Alerts",
"script": "Alert Example"
},
{
"name": "Library",
"parent": "Examples",
"script": "Library Example"
},
{
"name": "Base64",
"parent": "Utility",
"script": "Base64"
}
];
//A bit of HTML wrapper content for our list
const strHTMLStart = `<html>
<head>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto'>
<style>
html,body{font-family:"Roboto", sans-serif;font-size:15px;line-height:1.5; background-color: #ebf5d6;}html{overflow-x:hidden}
h1{font-size:36px; background-color: #5c7b1e; width: 98%; padding-left: 5px; color: white;}
h2{font-size:30px}h3{font-size:24px}
h1,h2{font-family:"Segoe UI",Arial,sans-serif;font-weight:400;margin:10px 0}
.highlight {background-color: yellowgreen; padding-left: 5px; padding-right: 5px }
</style>
</head>
<body>
<h1>Script Menu</h1>
Select a script to run it, or the edit link next to it to open it for editing. You can modify the lists by editing the JSON in <code>scriptData</code> in this script.
<hr/>
`;
const strHTMLEnd = `
<br/><hr/>
</body>
</html>`;
//Use a function to build indented lists
function buildLists(p_parent)
{
return scriptData.filter(function(node)
{
return (node.parent === p_parent);
}).map(function(node)
{
let exists = scriptData.some(function(childNode)
{
return childNode.parent === node.name;
});
let subList = (exists) ? 'n<ul>n' + buildLists(node.name).join('') + '</ul>n' : "";
let strItem = '<li>';
if(node.script === "")
{
//If specified, add a line break before the list item - we'll also highlight these entrie
if(node.linebreak)
{
strItem = '<br/><li><strong class="highlight">' + node.name + '</strong>';
}
else
{
strItem += '<strong>' + node.name + '</strong>';
}
}
else
{
//Add a little cog to this line
strItem += '⚙ ';
//Script - build the links
strItem += '<a href="scriptable:///run?scriptName=' + encodeURI(node.script) + '">' + node.name + '</a>';
strItem += ' [<a href="scriptable:///open?scriptName=' + encodeURI(node.script) + '">edit</a>]';
}
strItem += subList + '</li>n';
return strItem;
});
}
//Compose and display the HTML
strHTML = strHTMLStart + '<ul>n' + buildLists('').join('') + '</ul>' + strHTMLEnd;
console.log(strHTML);
WebView.loadHTML(strHTML);
Obviously if you want to do something similar outside of Scriptable, apps like Launcher, Launch Center Pro, etc. are the way to go. But I thought this was an interesting way that people might want to use to manage launches in app.
Hope people find this useful.