Skip to content

Commit ffab3e9

Browse files
author
duaraghav8@gmail
committed
Merge remote-tracking branch 'upstream/gh-pages' into gh-pages
2 parents bae8d60 + 574ee5c commit ffab3e9

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

algorithm/cryptography/caesar_cipher/basic/code.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function getNextChar(currChar, direction) {
1010
var pos = alphabetMap[currChar];
1111
var nextPos = direction === 'up' ? getPosUp(pos) : getPosDown(pos);
1212
var nextChar = alphabet.charAt(nextPos);
13-
13+
1414
logger._print(currChar + ' -> ' + nextChar);
1515
return nextChar;
1616
}
@@ -21,24 +21,23 @@ function cipher(str, rotation, direction, cipherTracer) {
2121
for (var i = 0; i < str.length; i++) {
2222

2323
cipherTracer._wait();
24-
24+
2525
var currChar = str.charAt(i);
2626
var r = rotation;
2727

2828
logger._print('Rotating ' + currChar + ' ' + direction + ' ' + rotation + ' times');
29-
cipherTracer._notify(i)._wait();
29+
cipherTracer._select(i)._wait();
3030

3131
// perform given amount of rotations in the given direction
32-
while (--r > 0) {
32+
while (r-- > 0) {
3333
currChar = getNextChar(currChar, direction);
3434
cipherTracer._notify(i, currChar)._wait();
3535
}
36-
36+
3737
str = str.substring(0, i) + currChar + str.substring(i + 1);
3838
logger._print('Current result: ' + str);
3939
}
40-
41-
cipherTracer._select(0, i);
40+
4241
return str;
4342
}
4443

css/stylesheet.css

+7-6
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ button:not([disabled]):hover {
6565

6666
.btn.active,
6767
button.active {
68-
background: rgba(0, 0, 0, .28);
68+
background: rgb(38, 38, 38);
6969
}
7070

7171
.btn input,
@@ -138,7 +138,7 @@ nav h3 {
138138
}
139139

140140
.sidemenu #footer {
141-
border-top: 2px solid rgba(0, 0, 0, .28);
141+
border-top: 2px solid rgb(38, 38, 38);
142142
}
143143

144144
.sidemenu button {
@@ -181,7 +181,7 @@ section,
181181

182182
nav,
183183
section {
184-
border: 1px solid rgba(0, 0, 0, .28);
184+
border: 1px solid rgb(38, 38, 38);
185185
box-sizing: border-box;
186186
}
187187

@@ -227,7 +227,7 @@ section {
227227
z-index: 5;
228228
padding: 4px;
229229
font-size: 14px;
230-
background: rgba(0, 0, 0, .28);
230+
background: rgba(0, 0, 0, .4);
231231
}
232232

233233
.module_wrapper > .wrapper {
@@ -299,10 +299,11 @@ section {
299299
}
300300

301301
.explanation_container {
302+
border: none;
302303
top: 30px;
303304
height: 30px;
304-
background: rgba(0, 0, 0, .28);
305-
padding: 7px;
305+
background: rgb(38, 38, 38);
306+
padding: 8px;
306307
font-size: 12px;
307308
}
308309

js/module/array2d.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
100100
case 'notify':
101101
if (step.v) {
102102
var $row = this.$table.find('.mtbl-row').eq(step.x);
103-
$row.find('.mtbl-cell').eq(step.y).text(TracerUtil.refineNumber(step.v));
103+
$row.find('.mtbl-cell').eq(step.y).text(TracerUtil.refineByType(step.v));
104104
}
105105
case 'denotify':
106106
case 'select':
@@ -130,7 +130,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
130130
if (Tracer.prototype.setData.apply(this, arguments)) {
131131
this.$table.find('.mtbl-row').each(function (i) {
132132
$(this).children().each(function (j) {
133-
$(this).text(TracerUtil.refineNumber(D[i][j]));
133+
$(this).text(TracerUtil.refineByType(D[i][j]));
134134
});
135135
});
136136
return true;
@@ -143,7 +143,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
143143
for (var j = 0; j < D[i].length; j++) {
144144
var $cell = $('<div class="mtbl-cell">')
145145
.css(this.getCellCss())
146-
.text(TracerUtil.refineNumber(D[i][j]));
146+
.text(TracerUtil.refineByType(D[i][j]));
147147
$row.append($cell);
148148
}
149149
}

js/module/weighted_directed_graph.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
4545
switch (step.type) {
4646
case 'weight':
4747
var targetNode = this.graph.nodes(this.n(step.target));
48-
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineNumber(step.weight);
48+
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineByType(step.weight);
4949
break;
5050
case 'visit':
5151
case 'leave':
5252
var visit = step.type == 'visit';
5353
var targetNode = this.graph.nodes(this.n(step.target));
5454
var color = visit ? this.color.visited : this.color.left;
5555
targetNode.color = color;
56-
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineNumber(step.weight);
56+
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineByType(step.weight);
5757
if (step.source !== undefined) {
5858
var edgeId = this.e(step.source, step.target);
5959
var edge = this.graph.edges(edgeId);
@@ -97,7 +97,7 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
9797
target: this.n(j),
9898
color: this.color.default,
9999
size: 1,
100-
weight: TracerUtil.refineNumber(G[i][j])
100+
weight: TracerUtil.refineByType(G[i][j])
101101
});
102102
}
103103
}

js/tracer_manager.js

+6
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ var TracerUtil = {
189189
return value === "Infinity" ? Infinity : value;
190190
});
191191
},
192+
refineByType: function (item) {
193+
return $.isNumeric(item) ? this.refineNumber(item) : this.refineString(item);
194+
},
195+
refineString: function (string) {
196+
return string === '' ? ' ' : string;
197+
},
192198
refineNumber: function (number) {
193199
return number === Infinity ? '∞' : number;
194200
}

0 commit comments

Comments
 (0)