init
parent
340d4caa9e
commit
eed3f1326b
@ -0,0 +1,39 @@
|
||||
let PubSub = ()=>{
|
||||
// state:
|
||||
let subscriptions_by_event = {}; // by event name, that is
|
||||
let subscriptions_by_name = {}; // subscriptions can be named, for easy unsubscribing
|
||||
|
||||
// methods:
|
||||
let pub = (e, ...params)=>{
|
||||
if(subscriptions_by_event[e]){
|
||||
subscriptions_by_event[e].forEach(subscription=>subscription.cb(...params))
|
||||
}
|
||||
};
|
||||
let sub = (e, cb, name)=>{ // 'name' is for unsubbing
|
||||
if(typeof subscriptions_by_event[e] === 'undefined'){
|
||||
subscriptions_by_event[e] = [];
|
||||
}
|
||||
|
||||
let subscription = { e, cb, name: name || '' };
|
||||
|
||||
subscriptions_by_event[e].push(subscription);
|
||||
if(subscription.name !== ''){
|
||||
if(typeof subscriptions_by_name[name] !== 'undefined'){ console.warn('Already subscription with name "'+name+'". Overwriting nonetheless.'); }
|
||||
subscriptions_by_name[name] = subscription;
|
||||
}
|
||||
};
|
||||
let unsub = (name)=>{
|
||||
// check if such a named subscription exists:
|
||||
if(typeof subscriptions_by_name[name] !== 'undefined'){
|
||||
// get ref to subscription object for later:
|
||||
let subscription = subscriptions_by_name[name];
|
||||
// delete subscription from both lists:
|
||||
subscriptions_by_event[subscription.e].splice(subscriptions_by_event[subscription.e].indexOf(subscription), 1);
|
||||
delete subscriptions_by_name[name];
|
||||
}
|
||||
};
|
||||
|
||||
return {pub, sub, unsub};
|
||||
}
|
||||
|
||||
export default PubSub;
|
@ -0,0 +1,16 @@
|
||||
import {pub, sub} from './pubsub.js';
|
||||
import state from './state.js';
|
||||
import redraw from './redraw.js';
|
||||
|
||||
// "raw" event listeners, which publish meaningful events, which are listened-to further-down:
|
||||
// ...
|
||||
|
||||
|
||||
// "meaningful" event listeners:
|
||||
//sub('set-current-node', (node_vm)=>{
|
||||
// state.current_node_vm = node_vm;
|
||||
// redraw();
|
||||
// });
|
||||
|
||||
|
||||
export default null;
|
@ -0,0 +1,15 @@
|
||||
import {elementOpen as o, elementClose as c, text as t} from '../vendor/incremental-dom.js';
|
||||
import state from '../state.js';
|
||||
import {pub} from '../pubsub.js';
|
||||
|
||||
|
||||
const App = ()=>{
|
||||
o('div', null, null,
|
||||
'id', 'header');
|
||||
o('h1');
|
||||
t('Options Calendar-Spread Optimizer');
|
||||
c('h1');
|
||||
c('div');
|
||||
}
|
||||
|
||||
export default App;
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,33 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.node, .node > .content, .node > .node-children-container {
|
||||
display: inline-block;
|
||||
width: min-content;
|
||||
}
|
||||
|
||||
.node {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.node > .content {
|
||||
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
|
||||
}
|
||||
.node[currently-selected-node] > .content {
|
||||
/* background-color: #7ea6fc; */
|
||||
box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
|
||||
}
|
||||
|
||||
.node > .content > textarea {
|
||||
background: transparent;
|
||||
resize: none;
|
||||
width: 80em;
|
||||
outline: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.node > .node-children-container {
|
||||
margin-left: 5em;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Calendar Optimizer</title>
|
||||
<link rel="stylesheet" href="index.css"></link>
|
||||
</head>
|
||||
<body>
|
||||
<script type='module' src="index.js"></script>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
import redraw from './redraw.js';
|
||||
import state from './state.js';
|
||||
import x from './behaviors.js';
|
||||
|
||||
// bootstrap initial state:
|
||||
|
||||
|
||||
redraw();
|
||||
|
||||
|
||||
/* TODO */
|
||||
/*
|
||||
*
|
||||
|
||||
|
||||
*/
|
@ -0,0 +1,7 @@
|
||||
// global PubSub instance:
|
||||
import PubSub from './PubSub.js';
|
||||
|
||||
const pubsub = PubSub();
|
||||
export const {pub, sub, unsub} = pubsub;
|
||||
|
||||
export default pubsub;
|
@ -0,0 +1,10 @@
|
||||
import {patch} from './vendor/incremental-dom.js';
|
||||
import App from './components/App.js';
|
||||
|
||||
export const redraw = ()=>{
|
||||
const root = document.getElementById('root');
|
||||
|
||||
patch(root, App);
|
||||
}
|
||||
|
||||
export default redraw;
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Bundled by jsDelivr using Rollup v2.67.2 and Terser v5.10.0.
|
||||
* Original file: /npm/nanoid@3.3.1/index.browser.js
|
||||
*
|
||||
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
||||
*/
|
||||
let t="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",e=t=>crypto.getRandomValues(new Uint8Array(t)),r=(t,e,r)=>{let l=(2<<Math.log(t.length-1)/Math.LN2)-1,n=-~(1.6*l*e/t.length);return(o=e)=>{let a="";for(;;){let e=r(n),g=n;for(;g--;)if(a+=t[e[g]&l]||"",a.length===o)return a}}},l=(t,l=21)=>r(t,l,e),n=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let l=63&r[t];e+=l<36?l.toString(36):l<62?(l-26).toString(36).toUpperCase():l<63?"_":"-"}return e};export{l as customAlphabet,r as customRandom,n as nanoid,e as random,t as urlAlphabet};export default null;
|
Loading…
Reference in New Issue