|
|
@ -4,9 +4,15 @@ const target = document.createElement('div') |
|
|
|
|
|
|
|
const state = {items: [], show: null, links: [] } |
|
|
|
|
|
|
|
const imgs = ['Dienstmädchen2.svg', 'Rucksack2.svg', 'Theater2.svg', 'UnskilledLabour2.svg', 'weben.svg'] |
|
|
|
for (let i = 0; i < imgs.length; ++i) { |
|
|
|
state.items.push({id: i, state: 'face-down', img: imgs[i]}) |
|
|
|
const items = [ |
|
|
|
{img: 'Dienstmädchen2.svg', linkable: ['Prekär']}, |
|
|
|
{img: 'Rucksack2.svg', linkable: ['Prekär']}, |
|
|
|
{img: 'Theater2.svg', linkable: ['Prekär']}, |
|
|
|
{img: 'UnskilledLabour2.svg', linkable: ['Prekär']}, |
|
|
|
{img: 'weben.svg', linkable: ['Prekär']} |
|
|
|
] |
|
|
|
for (let i = 0; i < items.length; ++i) { |
|
|
|
state.items.push({id: i, state: 'face-down', img: items[i].img, linkable: items[i].linkable}) |
|
|
|
} |
|
|
|
|
|
|
|
class Actions { |
|
|
@ -21,21 +27,24 @@ class Actions { |
|
|
|
} |
|
|
|
link(from, to) { |
|
|
|
state.links.push({id: state.links.length, from, to}) |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
const actions = new Actions |
|
|
|
|
|
|
|
let display |
|
|
|
const dispatch = target => { |
|
|
|
let ret |
|
|
|
if (target.action) { |
|
|
|
actions[target.action](target.from, target.to) |
|
|
|
ret = actions[target.action](target.from, target.to) |
|
|
|
} else { |
|
|
|
const match = target.match(/\/([^/]+)\/([^/]+)/) |
|
|
|
if (match && Object.hasOwnProperty.call(Actions.prototype, match[2])) { |
|
|
|
actions[match[2]](match[1]) |
|
|
|
ret = actions[match[2]](match[1]) |
|
|
|
} else actions.reset() |
|
|
|
} |
|
|
|
display.render(state) |
|
|
|
return ret |
|
|
|
} |
|
|
|
window.onpopstate = e => { |
|
|
|
dispatch(document.location.search) |
|
|
|