Completed
Push — master ( 5ac10e...30ddc4 )
by Yannick
07:31
created

script.js ➔ populate   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 20
rs 9.4285
c 1
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A script.js ➔ ... ➔ $.ajax.success 0 11 1
1
2
$( document ).ready(function() {
3
/*	
4
	//gets the current date information to be used in the datepicker
5
	var date = new Date();
6
	var currentMonth = date.getMonth();
7
	var currentDate = date.getDate();
8
	var currentYear = date.getFullYear();
9
10
  $( "#start_date" ).datetimepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, minDate: new Date(2014, 04 - 1, 12), maxDate: new Date(currentYear, currentMonth, currentDate, 23, 59) });
11
  $( "#end_date" ).datetimepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, minDate: new Date(2014, 04 - 1, 12), maxDate: new Date(currentYear, currentMonth, currentDate, 23, 59) });
12
  $( "#date" ).datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, minDate: new Date(2014, 04 - 1, 12), maxDate: new Date(currentYear, currentMonth, currentDate) });
13
*/  
14
  //custom select boxes
15
  if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
16
    $('.selectpicker').selectpicker('mobile');
17
	} else {
18
	  $('.selectpicker').selectpicker();
19
	}
20
  
21
  //search
22
  $("body.page-search .sub-menu input[type=text]").click(function(){
23
	    this.select();
24
	});
25
    
26
  //bootstrap popover
27
  $('[data-toggle="popover"]').popover({
28
    trigger: 'hover',
29
    'placement': 'bottom'
30
  });
31
  
32
  
33
});
34
35
function showSearchContainers(){
36
	$(".search-explore").hide();
37
	$(".search-containers").slideDown();
38
}
39
40
function showSubMenu(){
41
	$(".sub-menu-statistic").hide();
42
	$(".sub-menu-container").slideDown();
43
}
44
function language(selectObj) {
45
    var idx = selectObj.selectedIndex;
46
    var lang = selectObj.options[idx].value;
47
    document.cookie =  'language='+lang+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
48
    window.location.reload();
49
}
50
function populate(obj,str,selected) {
51
	console.log('populate');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
52
	$.ajax({
53
		url:'search-ajax.php',
54
		type:'GET',
55
		data: 'ask=' + str,
56
		dataType: 'json',
57
		success: function( json ) {
58
			var options = "";
59
			$.each(json, function(i, item){
60
				if ($.inArray(item.id,selected) != -1) {
61
					options += "<option value="+item.id+" selected>"+item.value+"</option>";
62
				} else {
63
					options += "<option value="+item.id+">"+item.value+"</option>";
64
				}
65
			});
66
			obj.append(options);
67
		}
68
	});
69
}
70