-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotes.js
73 lines (58 loc) · 1.93 KB
/
notes.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// STEP 1. Window Load (client side browser javascript)
// window.onload = function(){
// STEP 2. Cookie Model (attributes)
// // MODEL=====================================================
// function Cookie(){
// this.type = "chocolate chip";
// this.softness = 6;
// this.remaining = 3
// };
// STEP 3. Cookie Factory (creating new cookies)
// //MODEL FACTOR
// createCookie = function(){
// return new Cookie();
// };
// STEP 4. Object Prototype Functions (Methods on the model/object)
// //MODEL METHODS ===============================================
// Cookie.prototype = {
// eat: function(){
// this.remaining -= 1;
// },
// dipInMilk: function(){
// this.softness += 2;
// },
// anythingLeft: function(){
// if (this.remaining > 0) { return "There's more" }
// else { return "It's all gone" };
// }
// };
// STEP 5. ALl about DOM element manipulation ( event listeners, callbacks)
// var el = document.getElementsByClassName("new");
// el[0].addEventListener("click", addCookie, false)
// var otherel = document.getElementsByClassName("eat");
// otherel[0].addEventListener("click", eatAllCookies, false)
// };
// STEP 6. "DRIVER CODE" Showing that our object works
// var cookieJar = []
// // PSEUDO CONTROLLER ===============================
// function addCookie(){
// var cookie = createCookie()
// cookieJar.push(cookie);
// console.log(cookie);
// console.log(cookieJar);
// // $('.new').html("<img src="http://eleventhstack.files.wordpress.com/2013/06/chocolate_chip_cookies.jpg"></img>")
// }
// function eatAllCookies(){
// console.log(cookieJar)
// for(var i = 0; i < cookieJar.length; i++){
// cookieJar[i].eat();
// console.log(cookieJar[i].remaining);
// console.log(cookieJar[i].anythingLeft());
// }
// }
// EXTRA TIME
// // VIEW !!! ===========================================
// // cookieView = {}
// // cookiewView.prototype = function(){
// // printCookie:
// // }