-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.html
97 lines (87 loc) · 2.75 KB
/
check.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<title>Checklist Item</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
//All of our checklist data
var data;
//What checklist are we reading?
var checklistNumber = window.location.href.slice(window.location.href.indexOf('?') + 1)
//An array of every step we completed
var completed = [];
$(document).ready(function() {
$("#clone").attr("href","make.php?parent="+checklistNumber);
//We fetch all the data, then the rest of the work is on the client
$.getJSON( "./get.php?parent="+checklistNumber, function(result) {
data = result['item'];
document.title = result['master']['description'];
}).done(function() {showItem()});
})
function showItem() {
if (data.len == 0) {
$("#step").html(step.data);
return;
}
var step = data[0];
console.log(step);
$("#step").html(step.data);
}
function nextItem(action) {
//We MUST do this before re-arranging the list
if (action != "skip") {
completed.push(data[0].item)
console.log(completed);
}
var oldItem = data.shift();
if (action == "skip") {
data.push(oldItem);
}
console.log("Checking to see if we're done...");
if (data.length == 0) {
$("#step").text("We're all done!");
$(".btn").hide();
return;
}
while(true) {
if(data[0].depend == null) {
console.log("This item depends on nothing");
break;
}
else if(completed.indexOf(data[0].depend) != -1) {
console.log("Item " + data[0].item + " satisfied dependency " + data[0].depend);
break;
}
else {
console.log("Item " + data[0].item + " UNsatisfied dependency " + data[0].depend);
var oldItem = data.shift();
data.push(oldItem);
}
}
showItem();
}
</script>
<style>
.btn {
font-size: 40px;
}
</style>
</head>
<body>
<div class='container-fluid'>
<div class='jumbotron center' style="min-height:20em"><center><h1 id='step' /></center></div>
<div class='row center'>
<button class='btn btn-block btn-success' onClick="nextItem();">Done</button>
</div>
<div class='row center'><h1> </h1></div>
<div class='row center'>
<button class='btn btn-block btn-warning' onClick="nextItem('skip');">Do This Later</button>
</div>
</div>
<div class="row center" style="height:50px;"></div>
<a href="" id="clone">Make a clone of this list</a>
</body>
</html>