-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
48 lines (35 loc) · 1.64 KB
/
main.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
$(document).ready(function() {
console.log("running");
var question = 1;
var count = 0;
$(".qlink_container").each(function( index ) {
var localStorageCurrently = localStorage.getItem("questionComplete");
if(localStorageCurrently!=null && localStorageCurrently.indexOf("," + question + ",") !== -1) {
var html = "<input type='checkbox' checked name='questionNumber' value='" + question + "'> " + $(this).html();
count++;
} else {
var html = "<input type='checkbox' name='questionNumber' value='" + question + "'> " + $(this).html();
}
$(this).html(html);
question++;
});
$('.board_item_title p.qtext_para').text("500 Data Structures and Algorithms practice problems and their solutions (" + count + "/500)");
//handles storage in localStorage to remeber what has been completed
$('input[type="checkbox"][name="questionNumber"]').change(function() {
if(this.checked) {
count++;
var localStorageCurrently = localStorage.getItem("questionComplete");
var questionNumber = $(this).val();
var questionComplete = localStorageCurrently + "," + questionNumber + ",";
localStorage.setItem("questionComplete", questionComplete);
} else {
count--;
var localStorageCurrently = localStorage.getItem("questionComplete");
var questionNumber = $(this).val();
var questionComplete = localStorageCurrently.replace("," + questionNumber + ",", "");
localStorage.setItem("questionComplete", questionComplete);
}
$('.board_item_title p.qtext_para').text("500 Data Structures and Algorithms practice problems and their solutions (" + count + "/500)");
console.log(localStorage.getItem("questionComplete"));
});
});