owl-bt
Version:
owl-bt is editor for Behavior trees. It has been inspired by Unreal engine behavior trees in a way, that it supports special node items like decorators and services. This makes trees smaller and much more readable.
41 lines (34 loc) • 919 B
JavaScript
//TODO: replace with sys clipboard
;
(function () {
const itemsStorageKey = 'Clipboard.items';
class Clipboard {
constructor() {
this._items = {};
}
set(key, value) {
let items = this._getItems();
items[key] = value;
localStorage.setItem(itemsStorageKey, JSON.stringify(items));
}
get(key) {
let items = this._getItems();
return items[key];
}
_getItems() {
let itemsStr = localStorage.getItem(itemsStorageKey);
if (!itemsStr) {
return {};
}
try {
return JSON.parse(itemsStr);
}
catch (e) {
console.error(e);
return {};
}
}
}
angular.module('editorApp')
.service('Clipboard', Clipboard);
})();