Skip to content

Commit d94e68c

Browse files
author
Harm Akkerman
committed
Fixed issue 194 and cleared up debug code
1 parent adbcf63 commit d94e68c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

js/src/timer.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ function() {
2525

2626

2727
$( function() {
28+
$('#work-input-form').on('submit', function(e) {
29+
e.preventDefault();
30+
createWorkItem($(this));
31+
});
2832
var days='30';
2933
var start = moment().startOf('day').subtract(29, 'days');
3034
var end = moment().endOf('day');
@@ -278,7 +282,7 @@ function() {
278282
"</div>"+
279283
"<div class='wi-child-duration'>"+((child.running == 1)?'running...':secondsToTimer(child.duration))+"</div>"+
280284
"<div class='wi-play-space'>"+
281-
"<span class='fas clickable fa-play wi-play' id="+child.id+" data-work-name='"+child.name+"' data-projectid="+child.projectId+" data-tagids='"+child.tags.map(function(tag) {return tag.id}).join(',')+"' ></span>"+
285+
"<span class='fas clickable fa-play wi-resume' id="+child.id+" data-work-name='"+child.name+"' data-projectid="+child.projectId+" data-tagids='"+child.tags.map(function(tag) {return tag.id}).join(',')+"' ></span>"+
282286
"</div>"+
283287
"</div>"+
284288
"</div>"+
@@ -594,19 +598,19 @@ function() {
594598
return false;
595599
}
596600

597-
function startTimer(projectId = null, tags = ""){
601+
function startTimer(projectId = null, tags = "", inputWorkName = null){
598602
if(localStorage.getItem('isTimerStarted') === 'true'){
599-
stopTimer(startTimer, [projectId, tags]);
603+
stopTimer(startTimer, [projectId, tags, inputWorkName]);
600604
return;
601605
}
602-
var workName = $('#work-input').val();
606+
var workName = inputWorkName ?? $('#work-input').val();
603607
if (workName == ''){
604608
workName = 'no description';
605609
}
606610
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/start-timer/'+encodeURIComponent(encodeURIComponent(workName)));
607611
var jqxhr = $.post(baseUrl, { projectId: projectId, tags: tags}, function() {
608612
})
609-
.done(function(data, status, jqXHR) {
613+
.done(function(data, status, jqxhr) {
610614
var response = data;
611615
if ('Error' in response){
612616
alert(response.Error);
@@ -639,7 +643,7 @@ function() {
639643
localStorage.setItem('isTimerStarted', false);
640644
$('#start-tracking > span').addClass("play-button").removeClass("stop-button");
641645
if (onStopped != null){
642-
onStopped(args[0], args[1]);
646+
onStopped(...args);
643647
} else {
644648
getWorkItems();
645649
}
@@ -664,6 +668,7 @@ function() {
664668
$('#start-tracking > span').addClass("play-button").removeClass("stop-button");
665669
}
666670
$( "#start-tracking" ).click(function() {
671+
console.log("Start tracking test" + $(this).data('work-name'));
667672
if(localStorage.getItem('isTimerStarted') === 'true'){
668673
stopTimer();
669674
} else {

0 commit comments

Comments
 (0)