Skip to content

Commit 916edd1

Browse files
committed
some small optimisations to improve #35
1 parent 245a3fc commit 916edd1

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

js/src/timer.js

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,14 @@ function() {
415415
return false;
416416
});
417417

418+
var projectsAjaxUrl = OC.generateUrl('/apps/timetracker/ajax/projects');
418419
$(".set-project").each(function(){
420+
//var interval = setInterval( function() {
421+
419422
var id = $(this).data('myid');
420423
var projectId = $(this).data('projectid');
421-
422-
var projectName = $(this).data('projectname');
423424
var projectColor = $(this).data('projectcolor');
424-
425-
425+
426426
$(this).select2({
427427
containerCssClass:'project-select',
428428
escapeMarkup : function(markup) { return markup; },
@@ -448,8 +448,8 @@ function() {
448448
);
449449
return $state;
450450
},
451-
ajax: {
452-
url: OC.generateUrl('/apps/timetracker/ajax/projects'),
451+
ajax: {
452+
url: projectsAjaxUrl,
453453

454454
dataType: 'json',
455455
delay: 250,
@@ -470,54 +470,54 @@ function() {
470470
$(this).data('myid',id);
471471

472472
$(this).val(projectId).trigger('change');
473-
473+
//clearInterval(interval);
474+
//}.bind(this),0);
474475
});
476+
477+
var tagsAjaxUrl = OC.generateUrl('/apps/timetracker/ajax/tags');
475478
$(".set-tag").each(function(){
476-
var id = $(this).data('myid');
477-
var tagIds = [];
478-
var tagNames = [];
479-
if(typeof($(this).data('tagids')) !== 'undefined'){
480-
tagIds = $(this).data('tagids').toString().split(',');
481-
tagNames = $(this).data('tagnames').toString().split(',');
482-
}
483-
484-
$(this).select2({
485-
tags: true,
486-
containerCssClass:'tags-select',
487-
placeholder: "Select tags...",
488-
allowClear: true,
489-
490-
ajax: {
491-
url: function () { return OC.generateUrl('/apps/timetracker/ajax/tags')+'?workItem='+$(this).data('myid');},
492-
data: function (params){
493-
var query = {
494-
q: params.term,
495-
type: 'public'
496-
}
497-
498-
// Query parameters will be ?search=[term]&type=public
499-
return query;
500-
},
501-
headers: { 'RequestToken': OC.requestToken },
502-
formatNoMatches: function() {
503-
return '';
504-
},
505-
dataType: 'json',
506-
delay: 250,
507-
processResults: function (data) { //json parse
508-
return {
509-
results: $.map(data.Tags,function(val, i){
510-
return { id: val.id, text:val.name};
511-
}),
512-
pagination: {
513-
more: false,
514-
}
515-
};
516-
},
517-
cache: false,
518-
},
519-
});
520-
$(this).select2('val', []);
479+
//var interval = setInterval( function() {
480+
481+
482+
$(this).select2({
483+
tags: true,
484+
containerCssClass:'tags-select',
485+
placeholder: "Select tags...",
486+
allowClear: true,
487+
488+
ajax: {
489+
url: function () { return tagsAjaxUrl+'?workItem='+$(this).data('myid');},
490+
data: function (params){
491+
var query = {
492+
q: params.term,
493+
type: 'public'
494+
}
495+
496+
// Query parameters will be ?search=[term]&type=public
497+
return query;
498+
},
499+
headers: { 'RequestToken': OC.requestToken },
500+
formatNoMatches: function() {
501+
return '';
502+
},
503+
dataType: 'json',
504+
delay: 250,
505+
processResults: function (data) { //json parse
506+
return {
507+
results: $.map(data.Tags,function(val, i){
508+
return { id: val.id, text:val.name};
509+
}),
510+
pagination: {
511+
more: false,
512+
}
513+
};
514+
},
515+
cache: false,
516+
},
517+
});
518+
$(this).select2('val', []);
519+
//clearInterval(interval);
520+
//}.bind(this),0);
521521
});
522522
$('input.select2-input').attr('autocomplete', "xxxxxxxxxxx")
523523

0 commit comments

Comments
 (0)