Skip to content

Commit 85fdbb6

Browse files
committed
Added ES6.md and updated README.md to reference it.
1 parent bf516fd commit 85fdbb6

3 files changed

Lines changed: 100 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea
2-
.DS_Store
2+
.DS_Store
3+
node_modules

ES6.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# ES6 Project Update
2+
3+
The project is converted to ES6 and the code is added to the [master branch](https://github.com/parkjs814/AlgorithmVisualizer/tree/master).
4+
It will stay there until it reaches the same level as`gh-pages`, at which point the master branch will become the default branch.
5+
6+
## Build System
7+
8+
The new app uses [gulp](http://gulpjs.com/) to:
9+
10+
- combine all individual modules into a single file
11+
- transpile ES6 code to ES5 with babel
12+
- minimize JS and CSS code
13+
- generate source maps
14+
- add css autoprefixer to add vendor rules
15+
- provide a server with live-reload observing file changes
16+
17+
## Installation
18+
19+
Create a `.babelrc` file at the top level of the project with the following contents:
20+
21+
```js
22+
{
23+
presets: ['es2015']
24+
}
25+
```
26+
27+
This file is needed to run [`gulpfile.babel.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/gulpfile.babel.js) with ES6 syntax.
28+
29+
Steps for running the project:
30+
31+
```bash
32+
# install gulp globally so you can run it from the command line
33+
npm install -g gulp
34+
35+
# install all dependencies
36+
npm install
37+
38+
# run gulp to build all the files start the livereload server on http://localhost:8080
39+
gulp
40+
```
41+
42+
## Changes Summary
43+
44+
*Note:* Although no linter is added as of yet, the code closely follows the conventions from [Airbnb's Javascript style guide](https://github.com/airbnb/javascript)
45+
46+
### [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js)
47+
48+
The app entry point is [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js).
49+
It performs the initial application setup (loads the app when jQuery loads, loads the initial data from the server etc.)
50+
51+
### [js/app/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/app)
52+
53+
The main application object is [`js/app/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/app/index.js), which holds the necessary global application state flags and application level methods.
54+
It is [extended once the app loads in `index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js#L30) with the contents of [`app/constructor`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/app/constructor.js) and [`app/cache`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/app/cache.js).
55+
This means that from here on now, any file that does `require(/* path to js/app */)` is getting that populated object since calls to `require` are cached.
56+
57+
### [js/dom/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/dom)
58+
59+
The `js/dom` folder holds all the code interacting with the DOM (go figure 😜).
60+
The code is split into:
61+
62+
- "static" methods that are used everywhere (such as adding algorithm info to the DOM) and,
63+
- setup code which is called within the `app/constructor`, after the DOM is ready, to initialize all the elements with their contents and listeners.
64+
65+
### [js/editor/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/editor)
66+
67+
The `js/editor` folder holds the code to create and execute code in the ace editor.
68+
69+
### [js/module/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/module)
70+
71+
The `js/module` folder holds all the tracers and their variations and it is essentially the same as [`js/module`](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/module) on the `gh-pages` branch.
72+
The only changes are present in `js/tracer.js` where the code is converted to ES6.
73+
All the modules are exported together and then "required" inside the entry point [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js) where they are [attached to the global `window` object](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js#L33) so [`eval` can use them](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/editor/executor.js#L7) when executing code in the code editor.
74+
75+
### [js/server/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server)
76+
77+
The `js/server` folder holds all the code to load data from the server and utilizes promises from [RSVP.js](https://github.com/tildeio/rsvp.js/).
78+
In [`js/server/ajax`](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server/ajax) are some helper methods to make requesting from the server a little easier.
79+
The main method is [`js/server/ajax/request.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/server/ajax/request.js) that is used by all other methods to call `$.ajax` with certain options and set/reset the global `isLoading` flag for every request.
80+
81+
### [js/trace_manager/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server/ajax)
82+
83+
The `js/tracer_manager` folder holds the same logic as the [original `tracer_manager`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/tracer_manager.js) from `gh-pages` branch converted to ES6 and split into modules based on functionality.
84+
85+
### [js/utils/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/utils)
86+
87+
The `utils` folder holds a few helper methods that are used everywhere such as building the strings for algorithm and file directories.
88+
89+
## Remaining updates
90+
91+
- Any algorithms added since ES6 updates for pushed to master.
92+
- The following pull-request code is still missing from the ES6 project and needs to be added before a full project update can be made:
93+
94+
- https://github.com/parkjs814/AlgorithmVisualizer/pull/97
95+
- https://github.com/parkjs814/AlgorithmVisualizer/pull/101
96+
- https://github.com/parkjs814/AlgorithmVisualizer/pull/102

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#### [Oh yeah, ES6 update is here 😎](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/ES6.md)
2+
13
# Algorithm Visualizer
24

35
[![Join the chat at https://gitter.im/parkjs814/AlgorithmVisualizer](https://badges.gitter.im/parkjs814/AlgorithmVisualizer.svg)](https://gitter.im/parkjs814/AlgorithmVisualizer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

0 commit comments

Comments
 (0)