Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0c4d4e6
AnimatedCircle: fix typo
chatziko Jan 12, 2020
804395c
add .gitignore
chatziko Jan 12, 2020
5082a58
improve code structure- no global variables- call all methods via obj…
chatziko Jan 12, 2020
5fffd6b
call Algorithm methods in OO way
chatziko Jan 12, 2020
ba9249c
proper subclassing
chatziko Jan 12, 2020
276aed8
use LF in the repo
chatziko Jan 12, 2020
2bd7859
comment out unreachable statement
chatziko Jan 12, 2020
3db9eb3
call AnimatedObject constructor before subclass'
chatziko Jan 12, 2020
04fef2a
AnimationManager: small bugfix
chatziko Jan 12, 2020
544ad5d
StackLL: remove global vars
chatziko Jan 13, 2020
a87ba83
StackArray: remove global variables
chatziko Jan 13, 2020
9a182b3
BFS: remove global vars
chatziko Jan 13, 2020
b839fa6
replace init() by the constructor in Animated* classes
chatziko Jan 17, 2020
91ba69a
QueueArray: remove global variables
chatziko Jan 17, 2020
0317629
QueueLL: remove global vars
chatziko Jan 17, 2020
677c54c
Algorithm*: remove global vars
chatziko Jan 17, 2020
cbc654d
SPLAYTREE -> SplayTree
chatziko Jan 17, 2020
834779c
fix typo
chatziko Jan 17, 2020
188ad3b
Create Function.prototype.bind only if not exists
chatziko Jan 18, 2020
0288ef8
BFS/DFS bugfix: empty messageID on reset
chatziko Jan 18, 2020
f2ff45b
Graph: set directed param in subclasses
chatziko Jan 18, 2020
a7cc3d9
BTree: allow passing max_degree in the constructor
chatziko Jan 19, 2020
c3e948b
fix typo
chatziko Jan 19, 2020
07c4773
Heap: allow passing a compare function
chatziko Mar 31, 2020
159b7da
buildHeap: allow passing initial data
chatziko Mar 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
19 changes: 8 additions & 11 deletions AlgorithmLibrary/AVL.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ function AVL(am, w, h)
this.init(am, w, h);

}

AVL.prototype = new Algorithm();
AVL.prototype.constructor = AVL;
AVL.superclass = Algorithm.prototype;
AVL.inheritFrom(Algorithm);


// Various constants
Expand Down Expand Up @@ -83,19 +80,19 @@ AVL.prototype.init = function(am, w, h)

AVL.prototype.addControls = function()
{
this.insertField = addControlToAlgorithmBar("Text", "");
this.insertField = this.addControlToAlgorithmBar("Text", "");
this.insertField.onkeydown = this.returnSubmit(this.insertField, this.insertCallback.bind(this), 4);
this.insertButton = addControlToAlgorithmBar("Button", "Insert");
this.insertButton = this.addControlToAlgorithmBar("Button", "Insert");
this.insertButton.onclick = this.insertCallback.bind(this);
this.deleteField = addControlToAlgorithmBar("Text", "");
this.deleteField = this.addControlToAlgorithmBar("Text", "");
this.deleteField.onkeydown = this.returnSubmit(this.deleteField, this.deleteCallback.bind(this), 4);
this.deleteButton = addControlToAlgorithmBar("Button", "Delete");
this.deleteButton = this.addControlToAlgorithmBar("Button", "Delete");
this.deleteButton.onclick = this.deleteCallback.bind(this);
this.findField = addControlToAlgorithmBar("Text", "");
this.findField = this.addControlToAlgorithmBar("Text", "");
this.findField.onkeydown = this.returnSubmit(this.findField, this.findCallback.bind(this), 4);
this.findButton = addControlToAlgorithmBar("Button", "Find");
this.findButton = this.addControlToAlgorithmBar("Button", "Find");
this.findButton.onclick = this.findCallback.bind(this);
this.printButton = addControlToAlgorithmBar("Button", "Print");
this.printButton = this.addControlToAlgorithmBar("Button", "Print");
this.printButton.onclick = this.printCallback.bind(this);
}

Expand Down
192 changes: 98 additions & 94 deletions AlgorithmLibrary/Algorithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,100 +24,6 @@
// authors and should not be interpreted as representing official policies, either expressed
// or implied, of the University of San Francisco

function addLabelToAlgorithmBar(labelName)
{
var element = document.createTextNode(labelName);

var tableEntry = document.createElement("td");
tableEntry.appendChild(element);


var controlBar = document.getElementById("AlgorithmSpecificControls");

//Append the element in page (in span).
controlBar.appendChild(tableEntry);
return element;
}

// TODO: Make this stackable like radio butons
// (keep backwards compatible, thought)
function addCheckboxToAlgorithmBar(boxLabel)
{
var element = document.createElement("input");

element.setAttribute("type", "checkbox");
element.setAttribute("value", boxLabel);

var label = document.createTextNode(boxLabel);

var tableEntry = document.createElement("td");
tableEntry.appendChild(element);
tableEntry.appendChild(label);

var controlBar = document.getElementById("AlgorithmSpecificControls");

//Append the element in page (in span).
controlBar.appendChild(tableEntry);
return element;
}

function addRadioButtonGroupToAlgorithmBar(buttonNames, groupName)
{
var buttonList = [];
var newTable = document.createElement("table");

for (var i = 0; i < buttonNames.length; i++)
{
var midLevel = document.createElement("tr");
var bottomLevel = document.createElement("td");

var button = document.createElement("input");
button.setAttribute("type", "radio");
button.setAttribute("name", groupName);
button.setAttribute("value", buttonNames[i]);
bottomLevel.appendChild(button);
midLevel.appendChild(bottomLevel);
var txtNode = document.createTextNode(" " + buttonNames[i]);
bottomLevel.appendChild(txtNode);
newTable.appendChild(midLevel);
buttonList.push(button);
}

var topLevelTableEntry = document.createElement("td");
topLevelTableEntry.appendChild(newTable);

var controlBar = document.getElementById("AlgorithmSpecificControls");
controlBar.appendChild(topLevelTableEntry);

return buttonList
}


function addControlToAlgorithmBar(type, name) {

var element = document.createElement("input");

element.setAttribute("type", type);
element.setAttribute("value", name);
// element.setAttribute("name", name);


var tableEntry = document.createElement("td");

tableEntry.appendChild(element);


var controlBar = document.getElementById("AlgorithmSpecificControls");

//Append the element in page (in span).
controlBar.appendChild(tableEntry);
return element;

}




function Algorithm(am)
{

Expand Down Expand Up @@ -396,3 +302,101 @@ Algorithm.prototype.cmd = function()
}

}

// Algorithm bar methods //////////////////

Algorithm.prototype.addLabelToAlgorithmBar = function(labelName)
{
var element = document.createTextNode(labelName);

var tableEntry = document.createElement("td");
tableEntry.appendChild(element);

//Append the element in page (in span).
var controlBar = this.animationManager.algorithmControlBar;
if(controlBar)
controlBar.appendChild(tableEntry);

return element;
}

// TODO: Make this stackable like radio butons
// (keep backwards compatible, thought)
Algorithm.prototype.addCheckboxToAlgorithmBar = function(boxLabel)
{
var element = document.createElement("input");

element.setAttribute("type", "checkbox");
element.setAttribute("value", boxLabel);

var label = document.createTextNode(boxLabel);

var tableEntry = document.createElement("td");
tableEntry.appendChild(element);
tableEntry.appendChild(label);

//Append the element in page (in span).
var controlBar = this.animationManager.algorithmControlBar;
if(controlBar)
controlBar.appendChild(tableEntry);

return element;
}

Algorithm.prototype.addRadioButtonGroupToAlgorithmBar = function(buttonNames, groupName)
{
var buttonList = [];
var newTable = document.createElement("table");

for (var i = 0; i < buttonNames.length; i++)
{
var midLevel = document.createElement("tr");
var bottomLevel = document.createElement("td");

var button = document.createElement("input");
button.setAttribute("type", "radio");
button.setAttribute("name", groupName);
button.setAttribute("value", buttonNames[i]);
bottomLevel.appendChild(button);
midLevel.appendChild(bottomLevel);
var txtNode = document.createTextNode(" " + buttonNames[i]);
bottomLevel.appendChild(txtNode);
newTable.appendChild(midLevel);
buttonList.push(button);
}

var topLevelTableEntry = document.createElement("td");
topLevelTableEntry.appendChild(newTable);

var controlBar = this.animationManager.algorithmControlBar;
if(controlBar)
controlBar.appendChild(topLevelTableEntry);

return buttonList
}


Algorithm.prototype.addControlToAlgorithmBar = function(type, name) {

var element = document.createElement("input");

element.setAttribute("type", type);
element.setAttribute("value", name);
// element.setAttribute("name", name);


var tableEntry = document.createElement("td");

tableEntry.appendChild(element);

//Append the element in page (in span).
var controlBar = this.animationManager.algorithmControlBar;
if(controlBar)
controlBar.appendChild(tableEntry);

return element;

}



Loading