Skip to content

Commit 544ac97

Browse files
committed
Merge remote-tracking branch 'refs/remotes/parkjs814/gh-pages' into gh-pages
2 parents 0178af4 + 63f303f commit 544ac97

File tree

429 files changed

+50055
-1198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

429 files changed

+50055
-1198
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
presets: ['es2015']
3+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
.DS_Store
33
node_modules
4+
_*

ES6.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
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.
1+
# ES6 Project
52

63
## Build System
74

8-
The new app uses [gulp](http://gulpjs.com/) to:
5+
Our project uses [gulp](http://gulpjs.com/) to:
96

107
- combine all individual modules into a single file
118
- transpile ES6 code to ES5 with [babel.js](http://babeljs.io/)
@@ -31,54 +28,45 @@ gulp
3128

3229
*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)
3330

34-
### [js/index.js](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js)
31+
### [js/index.js](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/index.js)
3532

36-
The app entry point is [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js).
33+
The app entry point is [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/index.js).
3734
It performs the initial application setup (loads the app when jQuery loads, loads the initial data from the server etc.)
3835

39-
### [js/app/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/app)
36+
### [js/app/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/app)
4037

41-
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.
42-
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).
38+
The main application object is [`js/app/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/app/index.js), which holds the necessary global application state flags and application level methods.
39+
It is [extended once the app loads in `index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/index.js#L30) with the contents of [`app/constructor`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/app/constructor.js) and [`app/cache`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/app/cache.js).
4340
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.
4441

45-
### [js/dom/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/dom)
42+
### [js/dom/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/dom)
4643

4744
The `js/dom` folder holds all the code interacting with the DOM (go figure 😜).
4845
The code is split into:
4946

5047
- "static" methods that are used everywhere (such as adding algorithm info to the DOM) and,
5148
- setup code which is called within the `app/constructor`, after the DOM is ready, to initialize all the elements with their contents and listeners.
5249

53-
### [js/editor/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/editor)
50+
### [js/editor/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/editor)
5451

5552
The `js/editor` folder holds the code to create and execute code in the ace editor.
5653

57-
### [js/module/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/module)
54+
### [js/module/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/module)
5855

5956
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.
6057
The only changes are present in `js/tracer.js` where the code is converted to ES6.
61-
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.
58+
All the modules are exported together and then "required" inside the entry point [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/index.js) where they are [attached to the global `window` object](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/index.js#L33) so [`eval` can use them](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/js/editor/executor.js#L7) when executing code in the code editor.
6259

63-
### [js/server/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server)
60+
### [js/server/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/server)
6461

6562
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/).
66-
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.
67-
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.
63+
In [`js/server/ajax`](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/server/ajax) are some helper methods to make requesting from the server a little easier.
64+
The main method is [`js/server/ajax/request.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/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.
6865

69-
### [js/trace_manager/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server/ajax)
66+
### [js/trace_manager/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/server/ajax)
7067

7168
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.
7269

73-
### [js/utils/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/utils)
70+
### [js/utils/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/js/utils)
7471

7572
The `utils` folder holds a few helper methods that are used everywhere such as building the strings for algorithm and file directories.
76-
77-
## Remaining updates
78-
79-
- Any algorithms added since ES6 updates were pushed to master.
80-
- 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:
81-
82-
- https://github.com/parkjs814/AlgorithmVisualizer/pull/97
83-
- https://github.com/parkjs814/AlgorithmVisualizer/pull/101
84-
- https://github.com/parkjs814/AlgorithmVisualizer/pull/102

algorithm/cryptography/caesar_cipher/basic/code.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ function cipher(str, rotation, direction, cipherTracer) {
3737
str = str.substring(0, i) + currChar + str.substring(i + 1);
3838
logger._print('Current result: ' + str);
3939
}
40-
40+
4141
return str;
4242
}
4343

4444
function encrypt(str, rotation) {
4545
logger._print('Encrypting: ' + str);
46-
return cipher(str, rotation, 'down', encryptTracer);
46+
return cipher(str, rotation, 'up', encryptTracer);
4747
}
4848

4949
function decrypt(str, rotation) {
5050
logger._print('Decrypting: ' + str);
51-
return cipher(str, rotation, 'up', decryptTracer);
51+
return cipher(str, rotation, 'down', decryptTracer);
5252
}
5353

5454
var encrypted = encrypt(string, rotation);

algorithm/dp/catalan_number/desc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Catalan Number": " Pascal's triangle is a triangular array of the binomial coefficients.",
2+
"Catalan Number": " In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects.The Catalan numbers on nonnegative integers n are a set of numbers that arise in tree enumeration problems of the type, 'In how many ways can a regular n-gon be divided into n-2 triangles if different orientations are counted separately?' (Euler's polygon division problem).",
33
"Applications": [
44
"The number of ways to stack coins on a bottom row that consists of n consecutive coins in a plane, such that no coins are allowed to be put on the two sides of the bottom coins and every additional coin must be above two other coins, is the nth Catalan number",
55
"The number of ways to group a string of n pairs of parentheses, such that each open parenthesis has a matching closed parenthesis, is the nth Catalan number",

algorithm/dp/fibonacci/desc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Fibonacci Sequence": "Finding Fibonacci sequence using dynamic programming.",
33
"Complexity": {
4-
"time": "O(n<sup>2</sup>)",
4+
"time": "O(n)",
55
"space": "O(n)"
66
},
77
"References": [
@@ -10,4 +10,4 @@
1010
"files": {
1111
"basic": "Fibonacci Sequence"
1212
}
13-
}
13+
}

branding/opencollective/logo.psd

13 KB
Binary file not shown.

css/stylesheet.css

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ section {
295295
}
296296

297297
.files_bar > .wrapper.shadow-left.shadow-right {
298-
box-shadow: inset 16px 0 16px -16px rgba(0, 0, 0, .6),
299-
inset -16px 0 16px -16px rgba(0, 0, 0, .6);
298+
box-shadow: inset 16px 0 16px -16px rgba(0, 0, 0, .6), inset -16px 0 16px -16px rgba(0, 0, 0, .6);
300299
}
301300

302301
.explanation_container {
@@ -432,3 +431,57 @@ pre {
432431
.mtbl-col.notified {
433432
background: #f00;
434433
}
434+
435+
#loading-slider {
436+
position: absolute;
437+
width: 100%;
438+
height: 2px;
439+
}
440+
441+
#loading-slider.loaded {
442+
visibility: hidden;
443+
}
444+
445+
.line {
446+
position: absolute;
447+
background: #4a8df8;
448+
width: 100%;
449+
left: 0;
450+
right: 0;
451+
top: 0;
452+
height: 3px;
453+
}
454+
455+
.break {
456+
position: absolute;
457+
background: #222;
458+
width: 6px;
459+
height: 2px;
460+
}
461+
462+
.dot1 {
463+
animation: loading 2s infinite;
464+
}
465+
466+
.dot2 {
467+
animation: loading 2s 0.5s infinite;
468+
}
469+
470+
.dot3 {
471+
animation: loading 2s 1s infinite;
472+
}
473+
474+
@keyframes loading {
475+
from {
476+
left: 0;
477+
}
478+
to {
479+
left: 100%;
480+
}
481+
}
482+
483+
input[type=number]::-webkit-inner-spin-button,
484+
input[type=number]::-webkit-outer-spin-button {
485+
-webkit-appearance: none;
486+
margin: 0;
487+
}

gulpfile.babel.js

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
'use strict';
2+
3+
import path from 'path';
4+
import gulp from 'gulp';
5+
import uglify from 'gulp-uglify';
6+
import cleanCSS from 'gulp-clean-css';
7+
import autoprefixer from 'gulp-autoprefixer';
8+
import concat from 'gulp-concat';
9+
import header from 'gulp-header';
10+
import babel from 'gulp-babel';
11+
import gutil from 'gulp-util';
12+
import sourcemaps from 'gulp-sourcemaps';
13+
import connect from 'gulp-connect';
14+
import browserify from 'browserify';
15+
import babelify from 'babelify';
16+
import source from 'vinyl-source-stream';
17+
import buffer from 'vinyl-buffer';
18+
import pkg from './package.json';
19+
20+
const appName = 'algorithm_visualizer';
21+
const appEntryPoint = './js/index.js';
22+
23+
const outputPaths = {
24+
javascript: './public',
25+
css: './public',
26+
sourceMaps: './'
27+
};
28+
29+
const banner = [
30+
'/**',
31+
' * <%= pkg.name %> - <%= pkg.description %>',
32+
' * @version v<%= pkg.version %>',
33+
' * @author <%= pkg.author %>',
34+
' * @link <%= pkg.homepage %>',
35+
' * @license <%= pkg.license %>',
36+
' */',
37+
''
38+
].join('\n');
39+
40+
// build directories
41+
42+
const cssDir = path.join(__dirname, 'css', '**', '*.css');
43+
const jsDir = path.join(__dirname, 'js', '**', '*.js');
44+
45+
// CSS
46+
47+
gulp.task('minify-css', () => {
48+
gutil.log('\n\nBuild CSS Paths: \n', cssDir, '\n\n');
49+
50+
return gulp.src(cssDir)
51+
.pipe(autoprefixer())
52+
.pipe(cleanCSS({
53+
compatibility: 'ie8'
54+
}))
55+
.pipe(concat(`${appName}.min.css`))
56+
.pipe(header(banner, {
57+
pkg
58+
}))
59+
.pipe(gulp.dest(outputPaths.css))
60+
.pipe(connect.reload());
61+
});
62+
63+
gulp.task('build-css', () => {
64+
gutil.log('\n\nBuild CSS Paths: \n', cssDir, '\n\n');
65+
66+
return gulp.src(cssDir)
67+
.pipe(autoprefixer())
68+
.pipe(concat(`${appName}.css`))
69+
.pipe(header(banner, {
70+
pkg
71+
}))
72+
.pipe(gulp.dest(outputPaths.css))
73+
.pipe(connect.reload());
74+
});
75+
76+
// JS
77+
78+
gulp.task('minify-js', () => {
79+
80+
gutil.log('\n\nBuild JS Paths: \n', jsDir, '\n\n');
81+
82+
return browserify({
83+
entries: './js/index.js',
84+
debug: true
85+
})
86+
.transform('babelify', {
87+
presets: ['es2015']
88+
})
89+
.bundle()
90+
.pipe(source(`${appName}.min.js`))
91+
.pipe(header(banner, {
92+
pkg
93+
}))
94+
.pipe(buffer())
95+
.pipe(sourcemaps.init())
96+
.pipe(uglify())
97+
.pipe(sourcemaps.write(outputPaths.sourceMaps))
98+
.pipe(gulp.dest(outputPaths.javascript))
99+
.pipe(connect.reload());
100+
101+
});
102+
103+
gulp.task('build-js', () => {
104+
105+
gutil.log('\n\nBuild JS Paths: \n', jsDir, '\n\n');
106+
107+
return browserify({
108+
entries: './js/index.js',
109+
debug: true
110+
})
111+
.transform('babelify', {
112+
presets: ['es2015']
113+
})
114+
.bundle()
115+
.pipe(source(`${appName}.js`))
116+
.pipe(header(banner, {
117+
pkg
118+
}))
119+
.pipe(buffer())
120+
.pipe(sourcemaps.init())
121+
.pipe(sourcemaps.write(outputPaths.sourceMaps))
122+
.pipe(gulp.dest(outputPaths.javascript))
123+
.pipe(connect.reload());
124+
});
125+
126+
// Build
127+
128+
gulp.task('compile-css', ['build-css', 'minify-css']);
129+
gulp.task('compile-js', ['build-js', 'minify-js']);
130+
gulp.task('build', ['compile-css', 'compile-js']);
131+
132+
// Server
133+
134+
gulp.task('connect', function() {
135+
136+
connect.server({
137+
livereload: true
138+
});
139+
});
140+
141+
// Watch
142+
143+
gulp.task('watch', ['build'], function() {
144+
gulp.watch(jsDir, ['compile-js']);
145+
gulp.watch(cssDir, ['compile-css']);
146+
});
147+
148+
// Default
149+
150+
gulp.task('default', ['connect', 'watch']);

0 commit comments

Comments
 (0)