diff --git a/.nuxt/store.js b/.nuxt/store.js index 88eac3a..004c59c 100644 --- a/.nuxt/store.js +++ b/.nuxt/store.js @@ -18,7 +18,10 @@ void (function updateModules() { // Enforce store modules store.modules = store.modules || {} + resolveStoreModules(require('../store/state.js'), 'state.js') resolveStoreModules(require('../store/storeRoute.js'), 'storeRoute.js') + resolveStoreModules(require('../store/modules/coordinates.js'), 'modules/coordinates.js') + resolveStoreModules(require('../store/modules/display.js'), 'modules/display.js') // If the environment supports hot reloading... @@ -26,7 +29,10 @@ void (function updateModules() { // Whenever any Vuex module is updated... module.hot.accept([ '../store/index.js', + '../store/state.js', '../store/storeRoute.js', + '../store/modules/coordinates.js', + '../store/modules/display.js', ], () => { // Update `root.modules` with the latest definitions. updateModules() diff --git a/components/DisplayMixin.js b/components/DisplayMixin.js deleted file mode 100644 index 825d137..0000000 --- a/components/DisplayMixin.js +++ /dev/null @@ -1,86 +0,0 @@ -export const DisplayMixin = { - // Should probably store display variable in data{} of this file... - methods: { - // Modifier functions - scaler(input, scale=+this.$store.state.scale){ // –> scale #s of any given input. - switch(input.constructor){ - case Number: - return input * scale - case String: - return +input * scale - case Array: - if (input[0].constructor==Array){ // 2D - return input.map(xy => [xy[0]*scale, xy[1]*scale]) - } else { // 1D - return input.map(el => el * scale) - } - case Object: // assuming {'C': [x1,y1, x2,y2, x,y]} - Object.keys(input).map(function(key, index) { - input[key] = input[key].map(el => el*scale) - }) - return input - } - }, - - // Independant functions - getXDisp(xConst, action, xDisp){ // –> # - xConst = xConst.reduce((a, b) => a + b, 0) //children branches [1,2] x=0+dx of 2. etc - const y = action['y'] - const dx = Array.isArray(y) ? y[0] : 0 - return this.scaler(xDisp+dx, 50) - // remove 50 so scale uniformly could make x&y scales... added to to-do - }, - getYDisp(key, action){ // –> # - switch(+this.$store.state.display) { - case 1: - return this.scaler(+key) - case 2: - // future cases - default: - const y = action['y'] - const yDisp = Array.isArray(y) ? y[1] : y - return this.scaler(yDisp) - } - }, - - // Dependent Functions - More than necessary, but there if needed - getXYDisp(key, xConst, xDisp, action){ // –> [x, y] - var xDisp = this.getXDisp(xConst, action, xDisp) - var yDisp = this.getYDisp(key, action) - return [xDisp, yDisp] - }, - - getXDispPath(bItems){ // –> [x1, x2, ...] - const xConst = bItems.x - var xDisp = this.$store.getters.solveXDisp(xConst) - const path = Object.values(bItems.path) - return path.map(actions => this.getXDisp(xConst, actions, xDisp)) - }, - getYDispPath(bItems){ // –> [y1, y2, ...] - const kv = Object.entries(bItems.path) - return kv.map(kv => this.getYDisp(kv[0], kv[1])) - }, - getDispPath(bItems){ // –> [[x, y], ...] - const xConst = bItems.x - var xDisp = this.$store.getters.solveXDisp(xConst) - const kvArr = Object.entries(bItems.path) - return kvArr.map(kv => this.getXYDisp(kv[0], xConst, xDisp, kv[1])) - }, - - // Relative Link Function - getLink(link) { - if (Object.keys(this._$).includes(link.coord[0])) { - // relative link - if given branch exists - var [branchName, event] = link.coord - var branch = this._$[branchName] - var action = branch.path[event] - var xDisp = this.$store.getters.solveXDisp(branch['x']) - var XYLink = this.getXYDisp(event, branch['x'], xDisp, action) - } else { - // hard link - var XYLink = this.scaler(link.coord) - } - return XYLink - }, - } -} \ No newline at end of file diff --git a/components/Glyphs.vue b/components/Glyphs.vue index dd85b58..e75c0bf 100755 --- a/components/Glyphs.vue +++ b/components/Glyphs.vue @@ -1,8 +1,8 @@ @@ -11,11 +11,9 @@ import _ from "lodash"; import Dot from "./Glyphs/Dot.vue"; import Book from "./Glyphs/Book.vue"; -import { DisplayMixin } from "~/components/DisplayMixin.js"; export default { - props:['items', 'i', 'turn'], - mixins: [DisplayMixin], + props:['items', 'i', 'coords'], components: { Dot: Dot, Book: Book diff --git a/components/Links.vue b/components/Links.vue index 1c48c96..03a05d2 100644 --- a/components/Links.vue +++ b/components/Links.vue @@ -2,20 +2,18 @@ \ No newline at end of file diff --git a/components/UI/Search.vue b/components/UI/Search.vue new file mode 100644 index 0000000..defa056 --- /dev/null +++ b/components/UI/Search.vue @@ -0,0 +1,91 @@ + + + + + + + {{ option }} + + + + + + + + + \ No newline at end of file diff --git a/components/VGitGraph.vue b/components/VGitGraph.vue index f2b5ac4..bf69ecd 100644 --- a/components/VGitGraph.vue +++ b/components/VGitGraph.vue @@ -7,29 +7,29 @@ Transition group doesnt work as v-show=false yeilds x&y=0. Thus, they appear from the top left corner of the screen. --> - + - + - + @@ -51,10 +51,21 @@ export default { Glyphs }, created() { + this.$store.dispatch('initTimeArr') this.initRoots() this.initDisplacement() // dx must be defined before any x values are calculated. Nan causes SSR err. // if in paths.vue, dx may not be defined when links or glyph call it + this.$store.dispatch('updateCache') // call last, after initializations + //console.log('cache: ', this._Coords.cache) + }, + computed:{ + cssProps() { + return {'--duration': `${this._Display.scaling}s`} + }, + branchCache() { + return this._Coords.cache[this._Display.display] + } }, methods: { filterLinks(path) { @@ -65,22 +76,30 @@ export default { }, initRoots() { var filtered = Object.keys(this.$store.getters.rootBranches) - this.$store.commit('addVisible', filtered) - console.log('otp: ', this.$store.state.show) + this.$store.dispatch('addVisible', filtered) + //console.log('otp: ', this._Display.show) }, initDisplacement() { - _.forEach(this._$, (v,branchName) => { + _.forEach(this._Branches, (v, branchName) => { const displacement = this.$store.getters.maxDx(branchName) this.$store.commit('dxCreate', {key:branchName, value:displacement}) }) + //console.log('displacement:', this._Coords.displacement) }, - + display(branchName) { + if(!_.isEmpty(this._Display.filtered)) { + return branchName in this._Display.filtered + } else { + return branchName in this._Display.show + } + } } }; \ No newline at end of file diff --git a/components/VInterface.vue b/components/VInterface.vue new file mode 100644 index 0000000..2245176 --- /dev/null +++ b/components/VInterface.vue @@ -0,0 +1,79 @@ + + + + Scale + + {{ _Display.scale }} + + + + Display + + {{ ['Paths', 'Turns', 'Time'][_Display.display] }} + + + + + + + + + + + + \ No newline at end of file diff --git a/layouts/default.vue b/layouts/default.vue index 0b069e2..f785d9f 100755 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -29,8 +29,9 @@ html { min-height: 100vh; display: flex; justify-content: center; - align-items: center; + /* align-items: center; */ text-align: center; + overflow: scroll; } .button--green { diff --git a/pages/index.vue b/pages/index.vue index cf9d8c3..ae7b9d1 100755 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,32 +1,36 @@ + + - Display - - {{ ['Paths', 'Turns', 'Time'][$store.state.display] }} + + + + {{ new Date(unix*1000).toLocaleDateString("en-US") }} + + - - - - - Scale - - {{ $store.state.scale }} - - - - + + + Scale: {{_Display.scale }} + Scaling: {{_Display.scaling}} + Display: {{_Display.display}} + {{_Coords.cache}} + + + \ No newline at end of file diff --git a/store/index.js b/store/index.js index d7d1edc..a63f747 100755 --- a/store/index.js +++ b/store/index.js @@ -1,380 +1,29 @@ -export const strict = false; - -/* Due to the need of relative links when y-display changes, I need a key -to reference an event so i can get the coordinates. - -I have chosen "turn" to be the key, as globaly it is the most intuitive to -sort and search by. However, it doesnt make the methods any simpler... - -Alternative: -I believe using "y" as the key would improve simplicity. I would lose the -x-override however, I would make this a dx key to shift from the xConst of -the branch: -x=xConst -path: { - y: {turn:0, dx:"if applicable", ...} -} -i'll play around with this as well later. -If i can figure out general coordinate functions/methods, this will be -easier as json and that file are the only ones that need editing. -perhaps a mixin? I think this makes sense. -*/ - -export const state = () => ({ - display: 0, - scale: 50, - show: {}, - displacement: {}, - branches: { - "P1": { - x: [1], - children: ["P1.1"], - color:'#f00fff', - path: { - 1: { y: 1, unix: 1569580240, - glyph: "", event: "url", - link: { coord: [0, 0], type: "Path" } // hard link - }, - 5: { y: [1, 2], unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 8: { y: [1, 3], unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 11: { y: [0, 4], unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: [0, 5], unix: 1569580240, - glyph: "", event: "url", - link: { } - } - }, - }, - "P1.1": { - x: [2, 1], - children: [], - color:'#000864', - path: { - 8: { y: 3, unix: 1569580240, - glyph: "", event: "url", - link: { coord: ["P1", 5], type: "Path" } // hard link - }, - 11: { y: [0, 4], unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: [1,5], unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 17: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - } - }, - "P0": { - x: [0], - children: ["P0.1", "P0.-1"], - color:'#6f0606', - path: { - 0: { y: [0, 0], unix: 1569580240, - glyph: "Book", event: "url", - link: { } - }, - 5: { y: 1, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 8: { y: 2, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 11: { y: 3, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - }, - }, - "P0.1": { - x: [0, 1], - children: [], - color:'#000864', - path: { - 8: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { coord: ["P0", 5], type: "Path" } // hard link - }, - 11: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 17: { y: 7, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - } - }, - "P0.-1": { - x: [0, -1], - children: [], - color:'#000864', - path: { - 8: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { coord: ["P0", 5], type: "Path" } // hard link - }, - 11: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 17: { y: 7, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - } - }, - "P3": { - x: [-3], - children: ["P3.1"], - color:'#6f0fff', - path: { - 1: { y: 2, unix: 1569580240, - glyph: "", event: "url", - link: { coord: [0, 0], type: "Path" } // hard link - }, - 5: { y: 3, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 8: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 11: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - }, - }, - "P3.1": { - x: [-3, 1], - children: [], - color:'#000864', - path: { - 8: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { coord: ["P3", 5], type: "Path" } // hard link - }, - 11: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 17: { y: 7, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - } - }, - "P2": { - x: [3], - children: ["P2.-1", "P2.-2"], - color:'#6f0fff', - path: { - 1: { y: 2, unix: 1569580240, - glyph: "", event: "url", - link: { coord: [0, 0], type: "Path" } // hard link - }, - 5: { y: 3, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 8: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 11: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - }, - }, - "P2.-1": { - x: [3, -1], - children: ["P2.-1.-1"], - color:'#000864', - path: { - 8: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { coord: ["P2", 5], type: "Path" } // hard link - }, - 11: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 17: { y: 7, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - } - }, - "P2.-2": { - x: [3, -2], - children: [], - color:'#000864', - path: { - 8: { y: 4, unix: 1569580240, - glyph: "", event: "url", - link: { coord: ["P2", 5], type: "Path" } // hard link - }, - 11: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 17: { y: 7, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - } - }, - "P2.-1.-1": { - x: [3, -1, -1], - children: [], - color:'#000864', - path: { - 14: { y: 6, unix: 1569580240, - glyph: "", event: "url", - link: { coord: ["P2.-1", 11], type: "Path" } - }, - 17: { y: 7, unix: 1569580240, - glyph: "", event: "url", - link: { } - } - } - }, - "GM": { - x: [-1], - children: ['GM2'], - color: '#008fb5', - path: { - /* 0: { y: [1, 0], unix: 1569580240, - glyph: "Book", event: "url", - link: { } - }, */ - 2: { y: 1, unix: 1569580240, - glyph: "", event: "url", - link: {coord:['P0', 0], type: "Path" } - }, - 4: { y: 2, unix: 1569580240, - glyph: "", event: "url", - link: { } - }, - 7: { y: 3, unix: 1569580240, - glyph: "", event: "url", - link: {coord:['P1', 11], type:"Dotted" } // relative link - }, - 13: { y: 5, unix: 1569580240, - glyph: "", event: "url", - link: {coord:['P1', 11], type:"Dotted" } // relative link - } - }, - }, - "GM2": { - x: [-2], - children: [], - color:'#0fb500', - path: { - 3: { y: 2, unix: 1569580240, - glyph: "Dot", event: "url", - link: { coord: ['GM', 2], type: "Path" } // relative link - }, - 6: { y: 3, unix: 1569580240, - glyph: "Dot", event: "url", - link: { } - }, - 9: { y: 4, unix: 1569580240, - glyph: "Dot", event: "url", - link: { } - }, - 12: { y: 5, unix: 1569580240, - glyph: "Dot", event: "url", - link: { } - }, - 15: { y: 6, unix: 1569580240, - glyph: "Dot", event: "url", - link: { } - } - } - } - } -}); - import Vue from "vue"; import _ from "lodash"; -export const mutations = { - addVisible (state, key) { // show: {bName: x, ...} - for (var k of key) { - Vue.set(state.show, k, state.branches[k].x) - } - }, - removeVisible (state, key) { - if (key in state.show) { - Vue.delete(state.show, key) - } - }, - setVisible (state, keyArr) { - state.show = {} - mutations.addVisible(state, keyArr) - }, - dxCreate (state, payload) { - state.displacement[payload.key] = payload.value - } -} +// Root stuff +import state from "./state.js" + +// Modules +import Coordinates from "./modules/coordinates.js" +import Display from "./modules/display.js" +export const modules = { + Coordinates, + Display +} + +//export const strict = false; export const getters = { + // Init functions rootBranches: state => { var filtered = _.pickBy(state.branches, function(branch) { return branch.x.length===1; }); return filtered }, - compareX(arr1, arr2) { + // Helper functions + compareX: () => (arr1, arr2) => { const ln = Math.max(arr1.length, arr2.length) for(var i=0; i (xConst) => { - const sign = getters.compareX(xConst, [0]) - // Get prior Branches. (cant loop through just show as x is needed) - const xArr = _.pickBy(state.show, (x,k) => ( - (!_.isEqual(xConst, [0]) && _.isEqual(x, [0])) || // shift all but 0 by 1 - getters.compareX(x, [0]) === sign && // +/- from [0] - getters.compareX(xConst, x) === sign // prior branches closer to zero = sign - )) - // sum displacement of prior branches - const sum = _.sum(_.map(xArr, (v,k)=>sign * state.displacement[k])) - return sum + scaler: ( state, getters, rootGetters ) => (input, scale=state.Display.scale) => { // –> scale #s of any given input. + switch(input.constructor){ + case Number: + return input * scale + case String: + return +input * scale + case Array: + if (input[0].constructor==Array){ // 2D + return input.map(xy => [xy[0]*scale, xy[1]*scale]) + } else { // 1D + return input.map(el => el * scale) + } + case Object: // assuming {'C': [x1,y1, x2,y2, x,y]} + Object.keys(input).map(function(key, index) { + input[key] = input[key].map(el => el*scale) + }) + return input + } }, - maxDx: (state) => (key) => { - const path = state.branches[key].path - const dxArr = _.mapValues(path, function(o) { - return o.y.length==2? Math.abs(o.y[0])+1:1 - }) - return _.max(_.values(dxArr)) - } } diff --git a/store/modules/coordinates.js b/store/modules/coordinates.js new file mode 100644 index 0000000..90533e9 --- /dev/null +++ b/store/modules/coordinates.js @@ -0,0 +1,130 @@ +import Vue from "vue"; +import _ from "lodash"; + +export default { + state() { + return { + cache: {}, + timeSet: {}, + displacement: {}, + } + }, + + getters:{ + pseudoZero: () => (displayObject, sign) => { + // not empty and seearch results.len > 1 + if (_.keys(displayObject).length>1){ + // if x=[0] is in displayObject + return '0' in _.invert(displayObject)? 0 : sign + } else {return 0} + }, + solveXDisp: (state, getters, rootState, rootGetters) => (xConst) => { + const sign = rootGetters.compareX(xConst, [0]) + // Get prior Branches. (cant loop through just show as x is needed) + var displayed = _.isEmpty(rootState.Display.filtered)?rootState.Display.show:rootState.Display.filtered + const xArr = _.pickBy(displayed, (x,k) => ( + (!_.isEqual(xConst, [0]) && _.isEqual(x, [0])) || // shift all but 0 by 1 + rootGetters.compareX(x, [0]) === sign && // +/- from [0] + rootGetters.compareX(xConst, x) === sign // prior branches closer to zero = sign + )) + // sum displacement of prior branches + const sum = _.sum(_.map(xArr, (v,k)=>sign * state.displacement[k])) + return sum + getters.pseudoZero(state.filtered, sign) // mod displacement for search results + }, + maxDx: (state, getters, rootState) => (key) => { + const path = rootState.branches[key].path + const dxArr = _.mapValues(path, function(o) { + return o.y.length==2? Math.abs(o.y[0])+1:1 + }) + return _.max(_.values(dxArr)) + }, + // Independant functions + getXDisp: ( state, getters, rootGetters ) => (xConst, action, xDisp) => { // –> # + xConst = xConst.reduce((a, b) => a + b, 0) //children branches [1,2] x=0+dx of 2. etc + const y = action['y'] + const dx = Array.isArray(y) ? y[0] : 0 + return getters.scaler(xDisp+dx, 50) + // remove 50 so scale uniformly could make x&y scales... added to to-do + }, + getYDisp: ( state, getters, rootState ) => (key, action) => { // –> # + switch(+rootState.Display.display) { + case 1: + return getters.scaler(+key) + case 2: + const yUnix = state.timeSet.indexOf(action.unix) + return getters.scaler(yUnix) + case 3: + // future cases + default: + const y = action['y'] + const yDisp = Array.isArray(y) ? y[1] : y + return getters.scaler(yDisp) + } + }, + // Dependent Functions + getXYDisp: ( state, getters, rootGetters ) => (key, xConst, xDisp, action) => { // –> [x, y] + var xDisp = getters.getXDisp(xConst, action, xDisp) + var yDisp = getters.getYDisp(key, action) + return [xDisp, yDisp] + }, + cacheCalc: ( state, getters, rootGetters ) => (bItems) =>{ // –> [[x, y], ...] + // necessary to cache between svg layers (psths, links, & glyphs). + const xConst = bItems.x + var xDisp = getters.solveXDisp(xConst) + const kvArr = Object.entries(bItems.path) + let output = Object.fromEntries( + // Path data should be an array, can revert to getDispPath() once implemented. + kvArr.map(([k, v]) => [k, getters.getXYDisp(k, xConst, xDisp, v)]) + ) + return output + }, + // Relative Link Function + getLink: ( state, getters, rootState ) => (link) => { + if (Object.keys(rootState.branches).includes(link.coord[0])) { + // relative link - if given branch exists + var [branchName, event] = link.coord + var branch = rootState.branches[branchName] + var action = branch.path[event] + var xDisp = getters.solveXDisp(branch['x']) + var XYLink = getters.getXYDisp(event, branch['x'], xDisp, action) + } else { + // hard link + var XYLink = getters.scaler(link.coord) + } + return XYLink + }, + }, + + mutations: { + dxCreate (state, payload) { + state.displacement[payload.key] = payload.value + }, + updateBranch(state, payload) { + var display = payload.display + if (!(display in state.cache)) { + //init display cache if necessary + Vue.set(state.cache, display, {}) + } + Vue.set(state.cache[display], payload.key, payload.val) + }, + setTime(state, arr){ + Vue.set(state, 'timeSet', arr) + } + }, + + actions: { + updateCache({ commit, getters, rootState }) { + for(let [key, bItems] of Object.entries(rootState.branches)) { + var Payload = {key: key, val: getters.cacheCalc(bItems), display: rootState.Display.display } + commit('updateBranch', Payload) + } + }, + initTimeArr({commit, state, rootState}) { + var timeArr = _.map(rootState.branches, (branch) => { + return _.map(branch.path, 'unix') + }) + var timeSet = _.sortedUniq(_.flatten(timeArr).sort()) + commit('setTime', timeSet) + }, + } +} \ No newline at end of file diff --git a/store/modules/display.js b/store/modules/display.js new file mode 100644 index 0000000..0dff9fd --- /dev/null +++ b/store/modules/display.js @@ -0,0 +1,52 @@ +import Vue from "vue"; +import _ from "lodash"; + +export default { + state() { + return { + scale: 50, + scaling:1, + display: 0, + show: {}, + filtered: false, + } + }, + + mutations: { + removeVisible(state, key) { + if (key in state.show) { + Vue.delete(state.show, key) + } + }, + set(state, payload) { + Vue.set(state, payload.key, payload.value) + //state[payload.key] = payload.value; + }, + show(state, payload) { + Vue.set(state.show, payload.key, payload.value) + }, + filtered(state, payload) { + Vue.set(state.filtered, payload.key, payload.value) + } + }, + + actions: { + setFiltered({commit, state, rootState}, keyArr) { + commit('set', {key: 'filtered', value: {}}) + if (keyArr){ + for (var k of keyArr) { + commit('filtered', {key: k, value: rootState.branches[k].x}) + } + } + }, + addVisible({commit, state, rootState}, key) { // show: {bName: x, ...} + for (var k of key) { + commit('show', {key: k, value: rootState.branches[k].x}) + } + }, + setVisible({commit, dispatch, state}, keyArr) { + commit('set', {key: 'show', value: {}}) + dispatch('addVisible', keyArr) + }, + } +} diff --git a/store/state.js b/store/state.js new file mode 100644 index 0000000..5dc6463 --- /dev/null +++ b/store/state.js @@ -0,0 +1,339 @@ +/* Due to the need of relative links when y-display changes, I need a key +to reference an event so i can get the coordinates. + +I have chosen "turn" to be the key, as globaly it is the most intuitive to +sort and search by. However, it doesnt make the methods any simpler... + +Alternative: +I believe using "y" as the key would improve simplicity. I would lose the +x-override however, I would make this a dx key to shift from the xConst of +the branch: +x=xConst +path: { + y: {turn:0, dx:"if applicable", ...} +} +i'll play around with this as well later. +If i can figure out general coordinate functions/methods, this will be +easier as json and that file are the only ones that need editing. +perhaps a mixin? I think this makes sense. +*/ +export default () => ({ + branches: { + "P1": { + x: [1], + children: ["P1.1"], + color:'#f00fff', + path: { + 1: { y: 1, unix: 1568160000, + glyph: "", event: "url", + link: { coord: [0, 0], type: "Path" } // hard link + }, + 5: { y: [1, 2], unix: 1568505600, + glyph: "", event: "url", + link: { } + }, + 8: { y: [1, 3], unix: 1568764800, + glyph: "", event: "url", + link: { } + }, + 11: { y: [0, 4], unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: [0, 5], unix: 1569283200, + glyph: "", event: "url", + link: { } + } + }, + }, + "P1.1": { + x: [2, 1], + children: [], + color:'#000864', + path: { + 8: { y: 3, unix: 1568764800, + glyph: "", event: "url", + link: { coord: ["P1", 5], type: "Path" } // hard link + }, + 11: { y: [0, 4], unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: [1,5], unix: 1569283200, + glyph: "", event: "url", + link: { } + }, + 17: { y: 6, unix: 1569542400, + glyph: "", event: "url", + link: { } + } + } + }, + "P0": { + x: [0], + children: ["P0.1", "P0.-1"], + color:'#6f0606', + path: { + 0: { y: [0, 0], unix: 1568073600, + glyph: "Book", event: "url", + link: { } + }, + 5: { y: 1, unix: 1568505600, + glyph: "", event: "url", + link: { } + }, + 8: { y: 2, unix: 1568764800, + glyph: "", event: "url", + link: { } + }, + 11: { y: 3, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 4, unix: 1569283200, + glyph: "", event: "url", + link: { } + } + }, + }, + "P0.1": { + x: [0, 1], + children: [], + color:'#000864', + path: { + 8: { y: 4, unix: 1568764800, + glyph: "", event: "url", + link: { coord: ["P0", 5], type: "Path" } // hard link + }, + 11: { y: 5, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { } + }, + 17: { y: 7, unix: 1569542400, + glyph: "", event: "url", + link: { } + } + } + }, + "P0.-1": { + x: [0, -1], + children: [], + color:'#000864', + path: { + 8: { y: 4, unix: 1568764800, + glyph: "", event: "url", + link: { coord: ["P0", 5], type: "Path" } // hard link + }, + 11: { y: 5, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { } + }, + 17: { y: 7, unix: 1569542400, + glyph: "", event: "url", + link: { } + } + } + }, + "P3": { + x: [-3], + children: ["P3.1"], + color:'#6f0fff', + path: { + 1: { y: 2, unix: 1568160000, + glyph: "", event: "url", + link: { coord: [0, 0], type: "Path" } // hard link + }, + 5: { y: 3, unix: 1568505600, + glyph: "", event: "url", + link: { } + }, + 8: { y: 4, unix: 1568764800, + glyph: "", event: "url", + link: { } + }, + 11: { y: 5, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { } + } + }, + }, + "P3.1": { + x: [-3, 1], + children: [], + color:'#000864', + path: { + 8: { y: 4, unix: 1568764800, + glyph: "", event: "url", + link: { coord: ["P3", 5], type: "Path" } // hard link + }, + 11: { y: 5, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { } + }, + 17: { y: 7, unix: 1569542400, + glyph: "", event: "url", + link: { } + } + } + }, + "P2": { + x: [3], + children: ["P2.-1", "P2.-2"], + color:'#6f0fff', + path: { + 1: { y: 2, unix: 1568160000, + glyph: "", event: "url", + link: { coord: [0, 0], type: "Path" } // hard link + }, + 5: { y: 3, unix: 1568505600, + glyph: "", event: "url", + link: { } + }, + 8: { y: 4, unix: 1568764800, + glyph: "", event: "url", + link: { } + }, + 11: { y: 5, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { } + } + }, + }, + "P2.-1": { + x: [3, -1], + children: ["P2.-1.-1"], + color:'#000864', + path: { + 8: { y: 4, unix: 1568764800, + glyph: "", event: "url", + link: { coord: ["P2", 5], type: "Path" } // hard link + }, + 11: { y: 5, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { } + }, + 17: { y: 7, unix: 1569542400, + glyph: "", event: "url", + link: { } + } + } + }, + "P2.-2": { + x: [3, -2], + children: [], + color:'#000864', + path: { + 8: { y: 4, unix: 1568764800, + glyph: "", event: "url", + link: { coord: ["P2", 5], type: "Path" } // hard link + }, + 11: { y: 5, unix: 1569024000, + glyph: "", event: "url", + link: { } + }, + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { } + }, + 17: { y: 7, unix: 1569542400, + glyph: "", event: "url", + link: { } + } + } + }, + "P2.-1.-1": { + x: [3, -1, -1], + children: [], + color:'#000864', + path: { + 14: { y: 6, unix: 1569283200, + glyph: "", event: "url", + link: { coord: ["P2.-1", 11], type: "Path" } + }, + 17: { y: 7, unix: 1569542400, + glyph: "", event: "url", + link: { } + } + } + }, + "GM": { + x: [-1], + children: ['GM2'], + color: '#008fb5', + path: { + /* 0: { y: [1, 0], unix: 1569580240, + glyph: "Book", event: "url", + link: { } + }, */ + 2: { y: 1, unix: 1568246400, + glyph: "", event: "url", + link: {coord:['P0', 0], type: "Path" } + }, + 4: { y: 2, unix: 1568419200, + glyph: "", event: "url", + link: { } + }, + 7: { y: 3, unix: 1568678400, + glyph: "", event: "url", + link: {coord:['P1', 11], type:"Dotted" } // relative link + }, + 13: { y: 5, unix: 1569196800, + glyph: "", event: "url", + link: {coord:['P1', 11], type:"Dotted" } // relative link + } + }, + }, + "GM2": { + x: [-2], + children: [], + color:'#0fb500', + path: { + 3: { y: 2, unix: 1568332800, + glyph: "Dot", event: "url", + link: { coord: ['GM', 2], type: "Path" } // relative link + }, + 6: { y: 3, unix: 1568592000, + glyph: "Dot", event: "url", + link: { } + }, + 9: { y: 4, unix: 1568851200, + glyph: "Dot", event: "url", + link: { } + }, + 12: { y: 5, unix: 1569110400, + glyph: "Dot", event: "url", + link: { } + }, + 15: { y: 6, unix: 1569369600, + glyph: "Dot", event: "url", + link: { } + } + } + } + } + } +) \ No newline at end of file diff --git a/store/storeRoute.js b/store/storeRoute.js index 39aebb0..4f884dd 100755 --- a/store/storeRoute.js +++ b/store/storeRoute.js @@ -2,8 +2,14 @@ import Vue from "vue"; Vue.mixin({ computed: { - _$() { + _Branches() { return this.$store.state.branches; + }, + _Display() { + return this.$store.state.Display; + }, + _Coords() { + return this.$store.state.Coordinates; } } });
+ Scale: {{_Display.scale }} + Scaling: {{_Display.scaling}} + Display: {{_Display.display}} + {{_Coords.cache}} +