|
1
|
|
|
/* |
|
2
|
|
|
* To change this license header, choose License Headers in Project Properties. |
|
3
|
|
|
* To change this template file, choose Tools | Templates |
|
4
|
|
|
* and open the template in the editor. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
var DepartmentAPI = {}; |
|
10
|
|
|
DepartmentAPI.departments = []; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
//below are the functions for the tabbed layout of the 'create job poster' page for managers |
|
14
|
|
|
DepartmentAPI.loadFromJSON = function(data) { |
|
15
|
|
|
|
|
16
|
|
|
console.log(data); |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
DepartmentAPI.departments = data; |
|
19
|
|
|
|
|
20
|
|
|
/*for(var department in departments) { |
|
21
|
|
|
DepartmentAPI.departments.push( department.id ); |
|
22
|
|
|
}*/ |
|
23
|
|
|
|
|
24
|
|
|
console.log(DepartmentAPI.departments); |
|
25
|
|
|
|
|
26
|
|
|
var createEditProfile_department = document.getElementById("createEditProfile_department"); |
|
27
|
|
|
|
|
28
|
|
|
for(var department in DepartmentAPI.departments){ |
|
|
|
|
|
|
29
|
|
|
var option = document.createElement("option"); |
|
30
|
|
|
option.setAttribute("value",DepartmentAPI.departments[department].id); |
|
31
|
|
|
option.innerHTML = DepartmentAPI.departments[department].value; |
|
32
|
|
|
createEditProfile_department.appendChild(option); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
}; |
|
36
|
|
|
|
|
37
|
|
|
DepartmentAPI.filterCreateJobPosterDepartments = function(firstLoad){ |
|
38
|
|
|
var departmentList = document.getElementById("createJobPoster_listOfDepartments"); |
|
39
|
|
|
Utilities.clearSelectOptions(departmentList); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
//Grab current text |
|
42
|
|
|
var departmentSearchBox=""; |
|
43
|
|
|
if(firstLoad !== true){ |
|
44
|
|
|
departmentSearchBox = document.getElementById("createJobPoster_department").value; |
|
45
|
|
|
} |
|
46
|
|
|
for(var i = 0;i < DepartmentAPI.departments.length;i++){ |
|
47
|
|
|
var departmentData = DepartmentAPI.departments[i]; |
|
48
|
|
|
console.log(departmentData); |
|
|
|
|
|
|
49
|
|
|
if(DepartmentAPI.departments[i].toLowerCase().includes(departmentSearchBox.toLowerCase())){ |
|
50
|
|
|
var department = document.createElement("li"); |
|
51
|
|
|
var dLink = document.createElement("a"); |
|
52
|
|
|
dLink.innerHTML = DepartmentAPI.departments[i]; |
|
53
|
|
|
dLink.setAttribute("href","javascript:DepartmentAPI.fillField('"+DepartmentAPI.departments[i]+"')"); |
|
|
|
|
|
|
54
|
|
|
department.innerHTML = ""; |
|
55
|
|
|
|
|
56
|
|
|
department.appendChild(dLink); |
|
57
|
|
|
departmentList.appendChild(department); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
}; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param {type} element |
|
64
|
|
|
* @returns {undefined} |
|
65
|
|
|
*/ |
|
66
|
|
|
DepartmentAPI.fillField = function(val){ |
|
67
|
|
|
var departmentSearchBox = document.getElementById("createJobPoster_department"); |
|
68
|
|
|
departmentSearchBox.value = val; |
|
69
|
|
|
|
|
70
|
|
|
}; |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
DepartmentAPI.getDepartments = function(locale){ |
|
74
|
|
|
var departments_url = DataAPI.baseURL+"/"+locale+"/Lookup/department"; |
|
|
|
|
|
|
75
|
|
|
DataAPI.sendRequest(departments_url, "GET", {}, null, function(request) { |
|
76
|
|
|
DepartmentAPI.loadedManagerDepartments(request.response); |
|
77
|
|
|
}); |
|
78
|
|
|
}; |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
DepartmentAPI.loadedManagerDepartments = function(response){ |
|
82
|
|
|
setTimeout(function(){ |
|
83
|
|
|
DepartmentAPI.loadFromJSON(JSON.parse(response)); |
|
84
|
|
|
} |
|
|
|
|
|
|
85
|
|
|
,1000); |
|
|
|
|
|
|
86
|
|
|
}; |