Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4408)

Unified Diff: chrome/common/extensions/docs/examples/apps/calculator/app/model.js

Issue 11189023: Renamed Calculator app's non-DOM "events" to "inputs". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/apps/calculator/app/model.js
diff --git a/chrome/common/extensions/docs/examples/apps/calculator/app/model.js b/chrome/common/extensions/docs/examples/apps/calculator/app/model.js
index 0faa70847d2c1aaed123c7f8be5925fa7a27e104..295a2979971155660c84f2d16b111958a0236514 100644
--- a/chrome/common/extensions/docs/examples/apps/calculator/app/model.js
+++ b/chrome/common/extensions/docs/examples/apps/calculator/app/model.js
@@ -9,14 +9,14 @@ function Model(precision) {
}
/**
- * Handles a calculator event, updating the calculator state accordingly and
+ * Handles a calculator key input, updating the calculator state accordingly and
* returning an object with 'accumulator', 'operator', and 'operand' properties
* representing that state.
*
* @private
*/
-Model.prototype.handle = function(event) {
- switch (event) {
+Model.prototype.handle = function(input) {
+ switch (input) {
case '+':
case '-':
case '/':
@@ -26,7 +26,7 @@ Model.prototype.handle = function(event) {
// operator. In either case, clear the operand and the defaults.
var operator = this.operand && this.operator;
var result = this.calculate_(operator, this.operand);
- return this.reset_({accumulator: result, operator: event});
+ return this.reset_({accumulator: result, operator: input});
case '=':
// For the equal sign, perform the current calculation and save the
// operator and operands used as defaults, or if there is no current
@@ -55,7 +55,7 @@ Model.prototype.handle = function(event) {
(initial !== '0') ? this.set_({operand: '-' + this.operand}) :
this.set_({});
default:
- var operand = (this.operand || '0') + event;
+ var operand = (this.operand || '0') + input;
var duplicate = (operand.replace(/[^.]/g, '').length > 1);
var overflow = (operand.replace(/[^0-9]/g, '').length > this.precision);
return operand.match(/^0[0-9]/) ? this.set_({operand: operand[1]}) :

Powered by Google App Engine
This is Rietveld 408576698