##// END OF EJS Templates
fix handling of no-checkpoint-defined...
MinRK -
Show More
@@ -144,11 +144,11 define([
144 };
144 };
145
145
146 SaveWidget.prototype._set_checkpoint_status = function (human_date, iso_date) {
146 SaveWidget.prototype._set_checkpoint_status = function (human_date, iso_date) {
147 var el = this.element.find('span#checkpoint_status')
147 var el = this.element.find('span#checkpoint_status');
148 if(human_date){
148 if(human_date){
149 el.text("Last Checkpoint: "+human_date).attr('title',iso_date);
149 el.text("Last Checkpoint: "+human_date).attr('title',iso_date);
150 } else {
150 } else {
151 el.text('').attr('title','no-checkpoint')
151 el.text('').attr('title', 'no-checkpoint');
152 }
152 }
153 };
153 };
154
154
@@ -185,13 +185,11 define([
185 } else {
185 } else {
186 return h;
186 return h;
187 }
187 }
188
188 };
189
190 }
191
189
192 SaveWidget.prototype._regularly_update_checkpoint_date = function(){
190 SaveWidget.prototype._regularly_update_checkpoint_date = function(){
193 if (!this._checkpoint_date) {
191 if (!this._checkpoint_date) {
194 this.set_checkpoint_status(null);
192 this._set_checkpoint_status(null);
195 console.log('no checkpoint done');
193 console.log('no checkpoint done');
196 return;
194 return;
197 }
195 }
@@ -202,7 +200,10 define([
202 var recall = function(t){
200 var recall = function(t){
203 // recall slightly later (1s) as long timeout in js might be imprecise,
201 // recall slightly later (1s) as long timeout in js might be imprecise,
204 // and you want to be call **after** the change of formatting should happend.
202 // and you want to be call **after** the change of formatting should happend.
205 return setTimeout($.proxy(that._regularly_update_checkpoint_date, that),(t+1000))
203 return setTimeout(
204 $.proxy(that._regularly_update_checkpoint_date, that),
205 t + 1000
206 );
206 }
207 }
207 var tdelta = Math.ceil(new Date()-this._checkpoint_date);
208 var tdelta = Math.ceil(new Date()-this._checkpoint_date);
208
209
@@ -210,18 +211,21 define([
210 // <x time> ago
211 // <x time> ago
211 if(tdelta < tdelta < 6*3600*1000){
212 if(tdelta < tdelta < 6*3600*1000){
212 recall(_next_timeago_update(tdelta));
213 recall(_next_timeago_update(tdelta));
213 this._set_checkpoint_status( chkd.fromNow(), longdate);
214 this._set_checkpoint_status(chkd.fromNow(), longdate);
214 // otherwise update every hour and show
215 // otherwise update every hour and show
215 // <Today | yesterday|...> at hh,mm,ss
216 // <Today | yesterday|...> at hh,mm,ss
216 } else {
217 } else {
217 recall(1*3600*1000)
218 recall(1*3600*1000);
218 this._set_checkpoint_status( chkd.calendar(), longdate);
219 this._set_checkpoint_status(chkd.calendar(), longdate);
219 }
220 }
220
221 };
221 }
222
222
223 SaveWidget.prototype._set_last_checkpoint = function (checkpoint) {
223 SaveWidget.prototype._set_last_checkpoint = function (checkpoint) {
224 this._checkpoint_date = new Date(checkpoint.last_modified);
224 if (checkpoint) {
225 this._checkpoint_date = new Date(checkpoint.last_modified);
226 } else {
227 this._checkpoint_date = null;
228 }
225 this._regularly_update_checkpoint_date();
229 this._regularly_update_checkpoint_date();
226
230
227 };
231 };
General Comments 0
You need to be logged in to leave comments. Login now