New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quiz#3 #4
base: example3
Are you sure you want to change the base?
Quiz#3 #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Quiz#3 | ||
|
||
Consider what will happen when we try to test these global object. | ||
Other defects are still avaiable. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ var TodoInputManager = { | |
_input: null, // Will be an element when starting up. | ||
drawInput(motd) { | ||
var input = TodoInputManager._input; | ||
// Quiz#3 | ||
var tidyUp = function() { | ||
input.value = ''; | ||
input.disabled = false; | ||
|
@@ -24,6 +25,7 @@ var TodoInputManager = { | |
if (this.readyState == 4 && this.status == 200) { | ||
var motd = this.response; | ||
// The flow ends here. | ||
// Quiz#3 | ||
afterFetch(motd); | ||
} else { | ||
// We omit the error in this novice's example. | ||
|
@@ -32,11 +34,14 @@ var TodoInputManager = { | |
xhr.send(); | ||
}, | ||
|
||
// Quiz#3 | ||
saveData(todoItem, afterSave) { | ||
console.log('saved'); | ||
// Quiz#3 | ||
afterSave(); | ||
}, | ||
|
||
// Quiz#3 | ||
onUserCreateNewTodo(event, afterCreation) { | ||
var input = TodoInputManager._input; | ||
if (0x0D === event.keyCode) { | ||
|
@@ -62,6 +67,7 @@ var TodoInputManager = { | |
} | ||
}; | ||
|
||
// Quiz#3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
看懂這執行順序天殺的花了我好多時間 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You know there are thousands code like this torture people everyday. So it's a "real" case, and that's what I want you to catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 達仁好兇XD There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 對不起 <(_ _)> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine. Because when I saw some code in real codebase like this I will also spit some f* words. And it's always good to see you can pick such issues. |
||
exports.TodoInputManager = TodoInputManager; | ||
})(window); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
'use strict'; | ||
|
||
// Kick off | ||
// Quiz#3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 未來要init東西若多,按這寫法不就....,應該用個list放入要init的物件並用迴圈去初始化。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. We have some similar methods in Gaia. For example: Although to deal with real bootstrapping flow, you need some more delicate and complete solutions. |
||
document.addEventListener('DOMContentLoaded', function(event) { | ||
TodoListManager.init(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 比起 manager, component 的命名會比較好吧? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes...that's one issue I always wonder why Gaia people named things like this so thoughtlessly. However, I need to remind you that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Component somehow feel like a static object and work passively. While involving control logic, manager seems more suitable in this case. |
||
TodoInputManager.init(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要測試這個東西還要傳一個 event 進來,感覺其實應該可以不用