Skip to content

Commit 75cfe99

Browse files
committed
massive cleanup incl comments, graveyard funcs, console.logs
1 parent 09be1ea commit 75cfe99

35 files changed

+981
-1087
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ node_modules
1111
npm-debug.log*
1212
yarn-debug.log*
1313
yarn-error.log*
14-
/test
1514
/coverage
1615
package-lock.json
1716

HomeView.png

Lines changed: 0 additions & 1 deletion
This file was deleted.

Route2.png

Lines changed: 0 additions & 1 deletion
This file was deleted.

Route3.png

Lines changed: 0 additions & 1 deletion
This file was deleted.

quasar.conf.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ module.exports = function (ctx) {
8686
// analyze: true,
8787
// extractCSS: false,
8888
extendWebpack (cfg) {
89-
//cfg.module.rules.push({
89+
// cfg.module.rules.push({
9090
// enforce: 'pre',
9191
// test: /\.(js|vue)$/,
9292
// loader: 'eslint-loader',
9393
// exclude: /node_modules/,
9494
// options: {
9595
// formatter: require('eslint').CLIEngine.getFormatter('stylish')
9696
// }
97-
//})
97+
// })
9898
}
9999
},
100100

@@ -158,7 +158,7 @@ module.exports = function (ctx) {
158158
},
159159

160160
electron: {
161-
bundler:'builder',
161+
bundler: 'builder',
162162
// bundler: 'builder', // or 'packager'
163163

164164
extendWebpack (cfg) {
@@ -182,11 +182,11 @@ module.exports = function (ctx) {
182182
builder: {
183183
// https://www.electron.build/configuration/configuration
184184

185-
appId: 'com.electron.OverVue',
186-
win:{
187-
target:'nsis'
188-
},
185+
appId: 'com.electron.OverVue',
186+
win: {
187+
target: 'nsis'
188+
}
189189
}
190190
}
191191
}
192-
}
192+
}
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { app, BrowserWindow } from "electron";
1+
import { app, BrowserWindow } from 'electron'
22

33
/**
44
* Set `__statics` path to static files in production;
55
* The reason we are setting it here is that the path needs to be evaluated at runtime
66
*/
77
if (process.env.PROD) {
8-
global.__statics = require("path")
9-
.join(__dirname, "statics")
10-
.replace(/\\/g, "\\\\");
8+
global.__statics = require('path')
9+
.join(__dirname, 'statics')
10+
.replace(/\\/g, '\\\\')
1111
}
1212

13-
let mainWindow;
13+
let mainWindow
1414

15-
function createWindow() {
15+
function createWindow () {
1616
/**
1717
* Initial window options
1818
*/
@@ -24,25 +24,25 @@ function createWindow() {
2424
nodeIntegration: true,
2525
webSecurity: false
2626
}
27-
});
27+
})
2828

29-
mainWindow.loadURL(process.env.APP_URL);
29+
mainWindow.loadURL(process.env.APP_URL)
3030

31-
mainWindow.on("closed", () => {
32-
mainWindow = null;
33-
});
31+
mainWindow.on('closed', () => {
32+
mainWindow = null
33+
})
3434
}
3535

36-
app.on("ready", createWindow);
36+
app.on('ready', createWindow)
3737

38-
app.on("window-all-closed", () => {
39-
if (process.platform !== "darwin") {
40-
app.quit();
38+
app.on('window-all-closed', () => {
39+
if (process.platform !== 'darwin') {
40+
app.quit()
4141
}
42-
});
42+
})
4343

44-
app.on("activate", () => {
44+
app.on('activate', () => {
4545
if (mainWindow === null) {
46-
createWindow();
46+
createWindow()
4747
}
48-
});
48+
})

src/App.vue

Lines changed: 23 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,28 @@
55
</template>
66

77
<script>
8-
import { SET_ACTIVE_COMPONENT } from './store/types'
98
const deepEqual = require('lodash.isequal')
109
const cloneDeep = require('lodash.clonedeep')
1110
const throttle = require('lodash.throttle')
1211
import { defaultState } from './store/state/index.js'
1312
14-
15-
//use this to make sure these actions don't count as things you "undo"
13+
// use this to make sure these actions don't count as things you "undo"
1614
const ignoredActions = new Set([
17-
"setActiveComponent",
18-
"setActiveLayer",
19-
"upOneLayer",
20-
"setActiveHTML"
21-
])
22-
15+
'setActiveComponent',
16+
'setActiveLayer',
17+
'upOneLayer',
18+
'setActiveHTML'
19+
])
2320
2421
let redoMixin = {
2522
data () {
2623
return {
27-
// banana:[],
2824
doneAction: [],
2925
undoneAction: [],
3026
isTimetraveling: false,
3127
initialState: {}
3228
}
3329
},
34-
3530
created () {
3631
this.$store.subscribeAction((action, state) => {
3732
// console.log("We are saving this action!", action)
@@ -45,7 +40,7 @@ let redoMixin = {
4540
// console.log("Are these equal to each other?", action == this.undoneAction[this.undoneAction.length-1])
4641
if (!this.isTimetraveling) {
4742
if (this.undoneAction[this.undoneAction.length - 1]) {
48-
if (action.type == this.undoneAction[this.undoneAction.length - 1].type &&
43+
if (action.type === this.undoneAction[this.undoneAction.length - 1].type &&
4944
deepEqual(action.payload, this.undoneAction[this.undoneAction.length - 1].payload)) {
5045
this.undoneAction.pop()
5146
} else {
@@ -54,13 +49,11 @@ let redoMixin = {
5449
}
5550
}
5651
})
57-
// this.blankState = cloneDeep(this.$store)
5852
},
5953
6054
mounted () {
61-
62-
const throttledUndo = throttle(this.undo,300)
63-
const throttledRedo = throttle(this.redo,300)
55+
const throttledUndo = throttle(this.undo, 300)
56+
const throttledRedo = throttle(this.redo, 300)
6457
6558
window.addEventListener('keydown', event => {
6659
if (event.ctrlKey && event.key === 'z') {
@@ -75,62 +68,39 @@ let redoMixin = {
7568
}
7669
})
7770
78-
// commented code for hotkeys for debuging///////////////////////
79-
// window.addEventListener('keydown', event => {
80-
// if (event.ctrlKey && event.key === 'a') {
81-
// event.preventDefault()
82-
// if (this.$store.state.activeHTML !== '') {
83-
// this.$store.dispatch('setActiveLayer', {id:this.$store.state.activeHTML, text:"banana"})
84-
// }
85-
// }
86-
// });
87-
// window.addEventListener('keydown', event => {
88-
// if (event.ctrlKey && event.key === 'd') {
89-
// event.preventDefault()
90-
// if (this.$store.state.activeLayer.id !== '') {
91-
// this.$store.dispatch('upOneLayer', this.$store.state.activeLayer.id)
92-
// }
93-
// }
94-
// });
95-
//////////////////////////////////////////////////////////////////////
96-
97-
// console.log("do we want this? or this.$store.state?", this.$store.state)
9871
this.initialState = defaultState(this.$store.state)
9972
},
10073
10174
methods: {
10275
undo: function () {
103-
// do {
104-
// console.log("How far back?")
105-
if(this.doneAction.length ===0){
76+
if (this.doneAction.length === 0) {
10677
return
10778
}
10879
10980
this.isTimetraveling = true
11081
11182
let undone = this.doneAction.pop()
11283
113-
// assuming we have have something to undo, we check if we are undoing an action that has no feedback
114-
// like say changing active elements or active components or going up and down a layer since these can be obscured from immediate feedback
115-
// will just feel bad to undo (Imagine someone just clicking around out of boredom and then deciding to undo
116-
// will force them to have to undo the 30 highlights they just did instead of the last "Real" action)
117-
// if this happens we keep popping the doneAction queue and building up the redo queue.
84+
/* assuming we have have something to undo, we check if we are undoing an action that has no feedback
85+
e.g.: changing active elements or active components or going up and down a layer since these can be obscured from immediate feedback.
86+
these will feel bad to undo (imagine someone clicking around out of boredom and then deciding to undo
87+
this will force them to have to undo the 30 highlights they just did instead of the last "Real" action)
88+
if this happens we keep popping the doneAction queue and building up the redo queue. */
11889
if (undone !== undefined) {
11990
this.undoneAction.push(undone)
12091
if (ignoredActions.has(undone.type)) {
121-
// console.log('We did something useless!')
92+
// console.log('We undid an ignored action!')
12293
while (this.doneAction[this.doneAction.length - 1] &&
123-
ignoredActions.has(this.doneAction[this.doneAction.length - 1].type)){
94+
ignoredActions.has(this.doneAction[this.doneAction.length - 1].type)) {
12495
this.undoneAction.push(this.doneAction.pop())
12596
}
126-
// if we get here, that means we have undone all "useless" actions
127-
// so we have to do one more final pop and push, have to make sure it isn't null though
97+
/* if we get here, that means we have undone all "useless" actions
98+
so we have to do one more final pop and push, have to make sure it isn't null though */
12899
let finalPop = this.doneAction.pop()
129-
if(finalPop !== undefined){
100+
if (finalPop !== undefined) {
130101
this.undoneAction.push(finalPop)
131102
}
132103
}
133-
134104
}
135105
136106
let payload = {
@@ -139,8 +109,7 @@ let redoMixin = {
139109
}
140110
this.$store.commit('EMPTY_STATE', payload)
141111
this.doneAction.forEach(action => {
142-
//console.log('In the loop', this.$store)
143-
// this.$store.commit(`${mutation.type}`, mutation.payload);
112+
// console.log('in the undo loop', this.$store)
144113
this.$store.dispatch(action.type, cloneDeep(action.payload))
145114
this.doneAction.pop()
146115
})
@@ -150,14 +119,14 @@ let redoMixin = {
150119
redo: function () {
151120
let action = this.undoneAction.pop()
152121
153-
//we have to set timeTraveling to true to preserve the undoneAction array while we make changes
122+
// we have to set timeTraveling to true to preserve the undoneAction array while we make changes
154123
this.isTimetraveling = true
155124
if (action) {
156125
this.$store.dispatch(action.type, cloneDeep(action.payload))
157126
}
158127
this.isTimetraveling = false
159128
if (action && ignoredActions.has(action.type)) {
160-
//console.log('WE GOTTA DO MORE')
129+
// console.log('in the redo loop')
161130
this.redo()
162131
}
163132
}

src/components/CodeSnippet.vue

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
<!--
2+
Description:
3+
Dynamically renders Code Snippet in Footer
4+
Functionality includes: Displays children components and (nested) HTML elements in order of selection.
5+
-->
6+
17
<template>
28
<div class="codesnippet-container">
3-
<!-- <input type="checkbox" v-model="lineNumbers"> Linenumbers -->
49
<div class="top-p" v-if="activeComponent === ''">Select a component</div>
510
<div v-else>{{ `${activeComponent}.vue` }}</div>
611
<prism-editor
@@ -42,26 +47,22 @@ export default {
4247
window.outerHeight < 900 ? 22 : window.outerHeight < 1035 ? 24 : 27.5
4348
this.height = minHeight
4449
},
45-
// calls createTemplate and createBoiler to generate snippet
50+
// Calls createTemplate and createBoiler to generate snippet
4651
createCodeSnippet (componentName, children) {
4752
let result = `${this.createTemplate(
4853
componentName,
4954
children
5055
)}${this.createBoiler(componentName, children)}`
5156
return result
5257
},
58+
// Creates beginner boilerplate
5359
createTemplate (componentName, children) {
5460
let output = ``
5561
output += ` <div>\n`
56-
// children.forEach(name => {
57-
// output += ` <${name}>\n </${name}>\n`;
58-
// });
5962
let templateTagStr = this.writeTemplateTag(componentName)
6063
return `<template>\n ${output}${templateTagStr} </div>\n</template>`
6164
},
62-
63-
// We need a helper function to recursively iterate through the given html element's children and their children's children.
64-
65+
// Creates <template> boilerplate
6566
writeTemplateTag (componentName) {
6667
// console.log('writeTemplateTag invoked!')
6768
// create reference object
@@ -79,6 +80,7 @@ export default {
7980
navbar: ['<nav>', '</nav>']
8081
}
8182
83+
// Helper function that recursively iterates through the given html element's children and their children's children.
8284
function writeNested (childrenArray, indent) {
8385
if (!childrenArray.length) {
8486
return ''
@@ -106,7 +108,7 @@ export default {
106108
return nestedString
107109
}
108110
109-
// loop to iterate through compName arr
111+
// Iterates through active component's HTML elements list and adds to code snippet
110112
let htmlArr = this.componentMap[componentName].htmlList
111113
let outputStr = ``
112114
for (let el of htmlArr) {
@@ -130,6 +132,7 @@ export default {
130132
// console.log(`outputStr from writeTemplateTag: ${outputStr}`)
131133
return outputStr
132134
},
135+
// Creates boiler text for <script> and <style>
133136
createBoiler (componentName, children) {
134137
let str = ''
135138
children.forEach(name => {
@@ -151,7 +154,7 @@ export default {
151154
this.getWindowHeight()
152155
})
153156
},
154-
// updates code snippet, but broken cause children undefined, shows `function () { [native code] }`
157+
// Updates code snippet
155158
updated () {
156159
// console.log(`code: ${this.createCodeSnippet(this.activeComponent, this.componentMap[this.activeComponent].children)}`)
157160
// console.log('component map: ', this.componentMap);
@@ -168,6 +171,7 @@ export default {
168171
window.removeEventListener('resize', this.getWindowHeight)
169172
},
170173
watch: {
174+
// If HTML elements or components are added, rerenders Code Snippet
171175
componentMap: {
172176
deep: true,
173177
handler () {
@@ -179,9 +183,6 @@ export default {
179183
)}`
180184
}
181185
}
182-
},
183-
activeComponent: function () {
184-
// console.log('watching active component');
185186
}
186187
}
187188
}

0 commit comments

Comments
 (0)