I’ve ran some code in the console and I’m trying to adapt it to a .omnijs Solitary Action. Here’s what I have currently:
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "adiabatic",
"description": "Colors predictions.",
"label": "Color Predictions",
"paletteLabel": "Color Predictions"
}*/
var _ = function() {
const o = document.outline;
const greenStyle = o.namedStyles.byName('Highlight: Green');
const redStyle = o.namedStyles.byName('Highlight: Red');
const happenedColumn = o.columns.byTitle('Happened?');
function colorize() {
for (const item of o.rootItem.leaves) {
item.style.clear();
if (item.valueForColumn(happenedColumn).name === 'yes') {
item.style.setStyle(greenStyle);
} else if (item.valueForColumn(happenedColumn).name === 'no') {
item.style.setStyle(redStyle);
}
}
}
function clearHappenedColumn() {
for (const item of o.rootItem.leaves) {
item.style.clear(); // line 31
const h = item.valueForColumn(happenedColumn)
if (h) h.remove();
}
colorize();
}
var action = new Plugin.Action(function(selection, sender) {
colorize();
});
action.validate = function(selection, sender) {
return true;
};
return action;
}();
_;
I put the file in ~/Library/Containers/com.omnigroup.OmniOutliner5/Data/Library/Application Support/PlugIns/
and went to the Automation menu in OmniOutliner. “Color Predictions” was grayed out, so I opened up the console to see what could’ve been wrong. I saw this:
at /Users/comatoast/Library/Containers/com.omnigroup.OmniOutliner5/Data/Library/Application Support/PlugIns/color-predictions.omnijs:31
ReferenceError: Can't find variable: Plugin /Users/comatoast/Library/Containers/com.omnigroup.OmniOutliner5/Data/Library/Application Support/PlugIns/color-predictions.omnijs:31
…repeated for a total of nine times. Line 31 is the call to item.style.clear()
in clearHappenedColumn()
. It’s explicitly marked as such with a comment.
I have no idea why I’m getting this error and I don’t know what it means, as I’m not referring to anything I think of as a “Plugin” on that line. Can anyone give me an idea of what I’m doing wrong?