|
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 BranchAPI = {}; |
|
10
|
|
|
BranchAPI.branches = []; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
//below are the functions for the tabbed layout of the 'create job poster' page for managers |
|
14
|
|
|
BranchAPI.loadFromJSON = function(data) { |
|
15
|
|
|
|
|
16
|
|
|
console.log(data); |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
BranchAPI.branches = data; |
|
19
|
|
|
|
|
20
|
|
|
console.log(BranchAPI.branches); |
|
21
|
|
|
|
|
22
|
|
|
var createEditProfile_branch = document.getElementById("createEditProfile_branch"); |
|
23
|
|
|
|
|
24
|
|
|
for(var branch in BranchAPI.branches){ |
|
|
|
|
|
|
25
|
|
|
var option = document.createElement("option"); |
|
26
|
|
|
option.setAttribute("value",BranchAPI.branches[branch].id); |
|
27
|
|
|
option.innerHTML = BranchAPI.branches[branch].value; |
|
28
|
|
|
createEditProfile_branch.appendChild(option); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
}; |
|
32
|
|
|
|
|
33
|
|
|
BranchAPI.filterCreateJobPosterBranches = function(firstLoad){ |
|
34
|
|
|
var branchList = document.getElementById("createJobPoster_listOfDivisions"); |
|
35
|
|
|
branchList.innerHTML = ""; |
|
36
|
|
|
|
|
37
|
|
|
//Grab current text |
|
38
|
|
|
var branchSearchBox=""; |
|
39
|
|
|
if(firstLoad !== true){ |
|
40
|
|
|
branchSearchBox = document.getElementById("createJobPoster_branch").value; |
|
41
|
|
|
} |
|
42
|
|
|
for(var i = 0;i < BranchAPI.branches.length;i++){ |
|
43
|
|
|
var branchData = BranchAPI.branches[i]; |
|
44
|
|
|
console.log(branchData); |
|
|
|
|
|
|
45
|
|
|
if(BranchAPI.branches[i].toLowerCase().includes(branchSearchBox.toLowerCase())){ |
|
46
|
|
|
var branch = document.createElement("li"); |
|
47
|
|
|
var dLink = document.createElement("a"); |
|
48
|
|
|
dLink.innerHTML = BranchAPI.branches[i]; |
|
49
|
|
|
dLink.setAttribute("href","javascript:BranchAPI.fillField('"+BranchAPI.branches[i]+"')"); |
|
|
|
|
|
|
50
|
|
|
branch.innerHTML = ""; |
|
51
|
|
|
|
|
52
|
|
|
branch.appendChild(dLink); |
|
53
|
|
|
branchList.appendChild(branch); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
}; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param {type} element |
|
60
|
|
|
* @returns {undefined} |
|
61
|
|
|
*/ |
|
62
|
|
|
BranchAPI.fillField = function(val){ |
|
63
|
|
|
var branchSearchBox = document.getElementById("createJobPoster_branch"); |
|
64
|
|
|
branchSearchBox.value = val; |
|
65
|
|
|
|
|
66
|
|
|
}; |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
BranchAPI.getBranches = function(locale){ |
|
70
|
|
|
var branches_url = DataAPI.baseURL+"/"+locale+"/Lookup/branch"; |
|
|
|
|
|
|
71
|
|
|
DataAPI.sendRequest(branches_url, 'GET', {}, null, function(request) { |
|
72
|
|
|
BranchAPI.loadedManagerBranches(request.response); |
|
73
|
|
|
}); |
|
74
|
|
|
}; |
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
BranchAPI.loadedManagerBranches = function(response){ |
|
78
|
|
|
setTimeout(function(){ |
|
79
|
|
|
BranchAPI.loadFromJSON(JSON.parse(response)); |
|
80
|
|
|
} |
|
|
|
|
|
|
81
|
|
|
,1000); |
|
|
|
|
|
|
82
|
|
|
}; |