Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed mode reading and also adding popup report gen

  • Loading branch information...
commit 1b5b0363396f61e68e6f61dc361909fd06419513 1 parent 9598b84
@kthakore authored
Showing with 28 additions and 23 deletions.
  1. +28 −23 background.js
View
51 background.js
@@ -128,15 +128,16 @@ function Pomodoro(options) {
this.onTimerEnd = function (timer) {
this.running = false;
- this.report = {};
- if(this.current_key) {
- var reported_work = this.report[current_key];
- reported_work = reported_work + ', "' + prompt( "How well did you do this pomodoro? (1-5)", "5") + '"';
- this.report[current_key] = reported_work;
- }
+ if(this.current_key && this.mostRecentMode === 'work' ) {
+ var reported_work = this.report[this.current_key];
+ var feedback = prompt( "How well did you do this pomodoro? (1-5)", "5");
+ reported_work = reported_work + ', "' + feedback + '"';
+ this.report[this.current_key] = reported_work;
+
+ if( confirm( "Get report?" ) ) {
+ this.do_report();
+ }
- if( confirm( "Get report?" ) ) {
- this.do_report();
}
}
@@ -147,17 +148,19 @@ function Pomodoro(options) {
localStorageKeys.sort();
- var csv = 'Time, Worked On, Feedback';
+ var csv = '"Time", "Worked On", "Feedback"\n';
- for ( var key in localStorageKeys ) {
+ for ( var i = 0; i< localStorageKeys.length; i++ ) {
+
+ var int_key = parseInt( localStorageKeys[i], 10 );
+ var reported_work = this.report[int_key];
- var reported_work = this.report[key];
-
- csv += new Date( key ) + ", " + reported_work + '\n';
+ csv += '"' + new Date( int_key ) + '"' + ", " + reported_work + '\n';
}
-
- alert(csv);
+ var w = window.open( "", "Pomodoro Report", "menubar=no,height=500,width=500" );
+ w.document.write("<pre>"+csv+"</pre>");
+
}
@@ -166,17 +169,19 @@ function Pomodoro(options) {
this.mostRecentMode = this.nextMode;
this.nextMode = mostRecentMode;
- var working_on_message = prompt("What are you working on?", "Work");
- var startTime = new Date();
+ if ( this.mostRecentMode === 'work') {
+ var working_on_message = prompt("What are you working on?", "Work");
+
+ var startTime = new Date();
- this.current_key = startTime.getTime();
- if( this.report === undefined) {
- this.report = {};
- }
+ this.current_key = startTime.getTime();
+ if( this.report === undefined) {
+ this.report = {};
+ }
- this.report[this.current_key] = '"' + working_on_message + '"';
-
+ this.report[this.current_key] = '"' + working_on_message + '"';
+ }
for(var key in options.timer) {
timerOptions[key] = options.timer[key];
Please sign in to comment.
Something went wrong with that request. Please try again.