Skip to content

Commit fb801c6

Browse files
Fikset oransje farge i HeapSort array og fjernet død kode + Interface
1 parent e5f0f0c commit fb801c6

File tree

8 files changed

+9
-290
lines changed

8 files changed

+9
-290
lines changed

Heap/js/Controller.js

+1-28
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
///<reference path="View.ts"/>
55
///<reference path="IAlgorithm.ts"/>
66
///<reference path="EventManager.ts"/>
7-
///<reference path="IView.ts"/>
7+
///<reference path="View.ts"/>
88
///<reference path="methods.ts"/>
99
///<reference path="MaxHeapFree.ts"/>
1010
var Controller = /** @class */ (function () {
@@ -30,54 +30,27 @@ var Controller = /** @class */ (function () {
3030
Controller.prototype.getAlgorithm = function () {
3131
return this.algorithm;
3232
};
33-
Controller.prototype.lockScreen = function (b) {
34-
viewer.screenLockThis(b);
35-
};
3633
Controller.prototype.setArrow = function (index) {
3734
viewer.setThisArrow(index);
3835
};
39-
Controller.prototype.setSelectedIndex = function (index, select) {
40-
viewer.selectThisIndex(index, select);
41-
};
42-
Controller.prototype.setValueAtIndex = function (i, bValue, oldVal) {
43-
viewer.setValueAtThisIndex(i, bValue, oldVal);
44-
};
45-
Controller.prototype.setValueAtSortIndex = function (i, bValue) {
46-
viewer.setValueAtThisSortIndex(i, bValue);
47-
};
4836
Controller.prototype.connectNodes = function (child, parent) {
4937
viewer.connectThisNodes(child, parent);
5038
};
51-
Controller.prototype.highlightNode = function (index, color) {
52-
viewer.highlightThisNode(index, color);
53-
};
5439
Controller.prototype.highlightSortElem = function (index, color) {
5540
viewer.highlightThisSortElem(index, color);
5641
};
57-
Controller.prototype.removeHighlight = function (node) {
58-
viewer.removeThisHighlight(node);
59-
};
6042
Controller.prototype.getNameOfCurrentAlgorithm = function () {
6143
return this.algorithm.getName();
6244
};
6345
Controller.prototype.getArrayClone = function () {
6446
return this.algorithm.getArray().slice(0, this.algorithm.getArray().length);
6547
};
66-
Controller.prototype.setArray = function (array) {
67-
this.algorithm.setArray(array);
68-
};
6948
Controller.prototype.displaySize = function (root, size) {
7049
viewer.displayNodeSize(root, size);
7150
};
7251
Controller.prototype.addNode = function (i) {
7352
this.algorithm.add(i);
7453
};
75-
Controller.prototype.swapNode = function (child, parent) {
76-
viewer.swapNode(child, parent);
77-
};
78-
/**
79-
* Remove the maximum/minimum element
80-
*/
8154
Controller.prototype.removeNode = function () {
8255
this.algorithm.remove();
8356
};

Heap/js/Controller.ts

+1-36
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
///<reference path="View.ts"/>
55
///<reference path="IAlgorithm.ts"/>
66
///<reference path="EventManager.ts"/>
7-
///<reference path="IView.ts"/>
7+
///<reference path="View.ts"/>
88
///<reference path="methods.ts"/>
99
///<reference path="MaxHeapFree.ts"/>
1010

@@ -33,42 +33,18 @@ class Controller {
3333
return this.algorithm;
3434
}
3535

36-
lockScreen(b: boolean) {
37-
viewer.screenLockThis(b);
38-
}
39-
4036
setArrow(index: number) {
4137
viewer.setThisArrow(index);
4238
}
4339

44-
setSelectedIndex(index: number, select: boolean) {
45-
viewer.selectThisIndex(index, select);
46-
}
47-
48-
setValueAtIndex(i: number, bValue: any, oldVal: any) {
49-
viewer.setValueAtThisIndex(i, bValue, oldVal);
50-
}
51-
52-
setValueAtSortIndex(i: number, bValue) {
53-
viewer.setValueAtThisSortIndex(i, bValue);
54-
}
55-
5640
connectNodes(child: number, parent: number) {
5741
viewer.connectThisNodes(child, parent);
5842
}
5943

60-
highlightNode(index: number, color: string) {
61-
viewer.highlightThisNode(index, color);
62-
}
63-
6444
highlightSortElem(index: number, color: string) {
6545
viewer.highlightThisSortElem(index, color);
6646
}
6747

68-
removeHighlight(node: number) {
69-
viewer.removeThisHighlight(node);
70-
}
71-
7248
getNameOfCurrentAlgorithm() {
7349
return this.algorithm.getName();
7450
}
@@ -77,10 +53,6 @@ class Controller {
7753
return this.algorithm.getArray().slice(0, this.algorithm.getArray().length);
7854
}
7955

80-
setArray(array: number[]) {
81-
this.algorithm.setArray(array);
82-
}
83-
8456
displaySize(root: number, size: number) {
8557
viewer.displayNodeSize(root, size);
8658
}
@@ -89,13 +61,6 @@ class Controller {
8961
this.algorithm.add(i);
9062
}
9163

92-
swapNode(child: number, parent: number) {
93-
viewer.swapNode(child, parent);
94-
}
95-
96-
/**
97-
* Remove the maximum/minimum element
98-
*/
9964
removeNode() {
10065
this.algorithm.remove();
10166
}

Heap/js/IView.js

-4
This file was deleted.

Heap/js/IView.ts

-24
This file was deleted.

Heap/js/View.js

+2-88
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ var View = /** @class */ (function () {
2020
View.prototype.displayThisArray = function (array) {
2121
displayArray(JSON.stringify(array));
2222
};
23-
View.prototype.selectThisIndex = function (index, b) {
24-
var forwardSteps = function (index, b) {
25-
return function () {
26-
selectIndex(index, b);
27-
};
28-
}(index, b);
29-
var backwardSteps = function (index, b) {
30-
return function () {
31-
selectIndex(index, !b);
32-
};
33-
}(index, b);
34-
manager.addEvent(new FrontendEvent(forwardSteps, backwardSteps, this.animSpeed));
35-
};
3623
View.prototype.setThisArrow = function (index) {
3724
var forward = function (index) {
3825
return function () {
@@ -46,32 +33,6 @@ var View = /** @class */ (function () {
4633
}(index);
4734
manager.addEvent(new FrontendEvent(forward, backward, this.animSpeed));
4835
};
49-
View.prototype.setValueAtThisIndex = function (i, bValue, oldVal) {
50-
var forwardSteps = function (i, bValue) {
51-
return function () {
52-
setValueAtIndex(i, bValue);
53-
};
54-
}(i, bValue);
55-
var backwardSteps = function (i, oldVal) {
56-
return function () {
57-
setValueAtIndex(i, oldVal);
58-
};
59-
}(i, oldVal);
60-
manager.addEvent(new FrontendEvent(forwardSteps, backwardSteps, this.animSpeed));
61-
};
62-
View.prototype.setValueAtThisSortIndex = function (i, bValue) {
63-
var forwardSteps = function (i, bValue) {
64-
return function () {
65-
setValueAtSortIndex(i, bValue);
66-
};
67-
}(i, bValue);
68-
var backwardSteps = function (i, bValue) {
69-
return function () {
70-
setValueAtSortIndex(i, "");
71-
};
72-
}(i, bValue);
73-
manager.addEvent(new FrontendEvent(forwardSteps, backwardSteps, this.animSpeed));
74-
};
7536
View.prototype.connectThisNodes = function (child, parent) {
7637
var forwardSteps = function (child, parent) {
7738
return function () {
@@ -85,19 +46,6 @@ var View = /** @class */ (function () {
8546
}(child, parent);
8647
manager.addEvent(new FrontendEvent(forwardSteps, backwardSteps, this.animSpeed));
8748
};
88-
View.prototype.highlightThisNode = function (index, color) {
89-
var forward = function (index, color) {
90-
return function () {
91-
highlightNode(index, color);
92-
};
93-
}(index, color);
94-
var backward = function (index) {
95-
return function () {
96-
removeHighlight(index);
97-
};
98-
}(index);
99-
manager.addEvent(new FrontendEvent(forward, backward, this.animSpeed));
100-
};
10149
View.prototype.highlightThisSortElem = function (index, color) {
10250
var forward = function (index, color) {
10351
return function () {
@@ -111,27 +59,6 @@ var View = /** @class */ (function () {
11159
}(index);
11260
manager.addEvent(new FrontendEvent(forward, backward, this.animSpeed));
11361
};
114-
View.prototype.removeThisHighlight = function (index) {
115-
// Find the current color
116-
var color = "";
117-
var classList = document.getElementById('arrayElem' + index).className.split(/\s+/);
118-
for (var i = 0; i < classList.length; i++) {
119-
if (classList[i] === 'orange' || classList[i] === 'green') {
120-
color = classList[i];
121-
}
122-
}
123-
var forward = function (index) {
124-
return function () {
125-
removeHighlight(index);
126-
};
127-
}(index);
128-
var backward = function (index, color) {
129-
return function () {
130-
highlightNode(index, color);
131-
};
132-
}(index, color);
133-
manager.addEvent(new FrontendEvent(forward, forward, this.animSpeed));
134-
};
13562
View.prototype.stepForward = function () {
13663
this.clickedPlay = false;
13764
manager.next();
@@ -168,19 +95,6 @@ var View = /** @class */ (function () {
16895
setValueAtIndex(i, i);
16996
}
17097
};
171-
View.prototype.screenLockThis = function (locked) {
172-
var lck = function (lock) {
173-
return function () {
174-
screenLock(lock);
175-
};
176-
}(locked);
177-
var notLck = function (lock) {
178-
return function () {
179-
screenLock(!lock);
180-
};
181-
}(locked);
182-
manager.addEvent(new FrontendEvent(lck, notLck, this.animSpeed));
183-
};
18498
View.prototype.setSlow = function () {
18599
manager.delayTime = 1500;
186100
this.restartManager();
@@ -333,12 +247,12 @@ var View = /** @class */ (function () {
333247
return function () {
334248
selectIndex(0, true);
335249
highlightNode(0, "orange");
336-
sortHighlightElem(this.sortIndex, "orange");
250+
sortHighlightElem(sortIndex, "orange");
337251
};
338252
}(arrIndex, sortIndex, color);
339253
var backward = function (index1, index2, color) {
340254
return function () {
341-
removeSortHighlight(this.sortIndex);
255+
removeSortHighlight(sortIndex);
342256
removeHighlight(0);
343257
selectIndex(0, false);
344258
};

0 commit comments

Comments
 (0)