-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (50 loc) · 1.59 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var RecipeBuilder = function () {
var playground;
var linkingRecipes = false;
var recipeA, recipeB;
var init = function () {
playground = d3.select("#playground")
.append("svg:svg")
.attr("width", 1000)
.attr("height", 2000);
$("#add-recipe-button").click(addRecipe);
$("#link-two-recipes").change(linkRecipes);
};
var addRecipe = function () {
var dragUtil = new DragUtil(playground);
var countOfRecipes = $(".recipe").size();
dragUtil.addDraggableRectangle(countOfRecipes + 1, "recipe");
$(".recipe:last-child").on("click", joinRecipe);
};
var linkRecipes = function () {
var linkRecipesActive = $("#link-two-recipes").is(":checked");
if(linkRecipesActive) {
linkingRecipes = true;
} else {
linkingRecipes = false
}
recipeA = undefined;
recipeB = undefined;
};
var joinRecipe = function () {
var recipe = $(this);
console.log(this);
if(linkingRecipes) {
if(typeof recipeA === "undefined") {
console.log("Setting recipeA");
recipeA = recipe.rectangleId;
console.log(recipeA);
}
if(typeof recipeA !== "undefined" && typeof recipeB === "undefined") {
console.log("Setting recipeB");
recipeB = recipe.attr("rectangleId");
console.log(recipeB);
}
}
};
init();
}
var recipeBuilder;
$(function () {
recipeBuilder = new RecipeBuilder();
});