|
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
|
|
|
var DashboardAPI = {}; |
|
9
|
|
|
|
|
10
|
|
|
DashboardAPI.yourApplications = {}; |
|
11
|
|
|
|
|
12
|
|
|
DashboardAPI.application = function(job_poster_id, job_poster_title, job_poster_close_date_time, user_id, user_manager_profile_id, department_details_name, application_status){ |
|
13
|
|
|
this.job_poster_id = job_poster_id; |
|
14
|
|
|
this.job_poster_title = job_poster_title; |
|
15
|
|
|
this.job_poster_close_date_time = job_poster_close_date_time; |
|
16
|
|
|
this.user_id = user_id; |
|
17
|
|
|
this.user_manager_profile_id = user_manager_profile_id; |
|
18
|
|
|
this.department_details_name = department_details_name; |
|
19
|
|
|
this.application_status = application_status; |
|
20
|
|
|
}; |
|
21
|
|
|
|
|
22
|
|
|
DashboardAPI.version = "v1"; |
|
23
|
|
|
//Live URL |
|
24
|
|
|
DashboardAPI.baseURL = "/tc/api/"+DashboardAPI.version+""; |
|
25
|
|
|
|
|
26
|
|
|
DashboardAPI.showDashboard = function(){ |
|
27
|
|
|
var stateInfo = {pageInfo: 'dashboard', pageTitle: 'Talent Cloud: Dashboard'}; |
|
28
|
|
|
document.title = stateInfo.pageTitle; |
|
29
|
|
|
history.pushState(stateInfo, stateInfo.pageInfo, '#Dashboard'); |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
EventsAPI.hideAllLayouts(); |
|
|
|
|
|
|
32
|
|
|
window.scrollTo(0,0); |
|
33
|
|
|
document.getElementById("skipNav").focus(); |
|
34
|
|
|
|
|
35
|
|
|
var dashboardSection = document.getElementById("dashboardSection"); |
|
36
|
|
|
dashboardSection.classList.remove("hidden"); |
|
37
|
|
|
|
|
38
|
|
|
var active = document.getElementById("navigationDashboardLinkWrapper"); |
|
|
|
|
|
|
39
|
|
|
navigationDashboardLinkWrapper.classList.add("active"); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
var inactive = document.getElementById("navigationBrowseLinkWrapper"); |
|
|
|
|
|
|
42
|
|
|
navigationBrowseLinkWrapper.classList.remove("active"); |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
DashboardAPI.getApplicationsByUuserId(); |
|
45
|
|
|
|
|
46
|
|
|
// New Subpage Hero Scripts |
|
47
|
|
|
|
|
48
|
|
|
Utilities.getHeroElements(); |
|
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
TalentCloudAPI.setNav("navigationDashboardLinkWrapper"); |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
var dashboardHeroTitle = document.getElementById("dashboardHeroTitle"); |
|
53
|
|
|
dashboardHeroTitle.classList.remove("hidden"); |
|
54
|
|
|
dashboardHeroTitle.setAttribute("aria-hidden", "false"); |
|
55
|
|
|
|
|
56
|
|
|
// Mobile Menu Overflow Release |
|
57
|
|
|
document.body.style.overflowY = "auto"; |
|
58
|
|
|
|
|
59
|
|
|
// Google Analytics |
|
60
|
|
|
|
|
61
|
|
|
ga('set', 'page', '/my-applications'); |
|
62
|
|
|
ga('send', 'pageview'); |
|
63
|
|
|
|
|
64
|
|
|
}; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* |
|
68
|
|
|
* @returns {undefined} |
|
69
|
|
|
*/ |
|
70
|
|
|
DashboardAPI.getApplicationsByUuserId = function(){ |
|
71
|
|
|
|
|
72
|
|
|
//does the request need to be secure? |
|
73
|
|
|
|
|
74
|
|
|
var user_id = ""; |
|
75
|
|
|
|
|
76
|
|
|
if(UserAPI.hasSessionUser()){ |
|
|
|
|
|
|
77
|
|
|
user_id = UserAPI.getSessionUserAsJSON().user_id; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
//what url am I connecting to get the data? - see tc/.htaccess file |
|
81
|
|
|
var dashboard_url = DashboardAPI.baseURL + "/" + locale + "/dashboard/" + user_id; |
|
|
|
|
|
|
82
|
|
|
DataAPI.sendRequest(dashboard_url, "GET", {'Content-type': 'application/json; charset=utf-8'}, null, function(request){ |
|
|
|
|
|
|
83
|
|
|
DashboardAPI.dashboardDataLoaded(request.responseText); |
|
84
|
|
|
}); |
|
85
|
|
|
}; |
|
86
|
|
|
|
|
87
|
|
|
DashboardAPI.dashboardDataLoaded = function(response){ |
|
88
|
|
|
var responseJSON = JSON.parse(response); |
|
89
|
|
|
DashboardAPI.populateDashboard(responseJSON); |
|
90
|
|
|
}; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* |
|
94
|
|
|
* @returns {undefined} |
|
95
|
|
|
*/ |
|
96
|
|
|
DashboardAPI.transferFailed = function(){ |
|
97
|
|
|
NetworkErrorMessage(); |
|
98
|
|
|
}; |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* |
|
102
|
|
|
* @returns {undefined} |
|
103
|
|
|
*/ |
|
104
|
|
|
DashboardAPI.transferAborted = function(){ |
|
105
|
|
|
|
|
106
|
|
|
}; |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* |
|
111
|
|
|
* @param {type} evt |
|
112
|
|
|
* @returns {undefined} |
|
113
|
|
|
*/ |
|
114
|
|
|
DashboardAPI.dashboardDataUpdateProgress = function(evt){ |
|
115
|
|
|
Utilities.debug?console.log(evt):null; |
|
|
|
|
|
|
116
|
|
|
if(evt.lengthComputable){ |
|
117
|
|
|
var total = evt.total; |
|
118
|
|
|
var value = evt.loaded; |
|
119
|
|
|
|
|
120
|
|
|
Utilities.debug?console.log(total + "=" + value):null; |
|
|
|
|
|
|
121
|
|
|
|
|
122
|
|
|
var percentComplete = Math.ceil((evt.loaded / evt.total) * 100); |
|
|
|
|
|
|
123
|
|
|
//var loadingProgress = document.getElementById("loadingProgress"); |
|
124
|
|
|
//loadingProgress.innerHTML = " " + percentComplete + "%"; |
|
125
|
|
|
} |
|
126
|
|
|
}; |
|
127
|
|
|
|
|
128
|
|
|
DashboardAPI.populateDashboard = function(dashboardJSON){ |
|
129
|
|
|
|
|
130
|
|
|
//get yourApplications section from DOM |
|
131
|
|
|
var yourApplicationsSection = document.getElementById("yourApplications"); |
|
132
|
|
|
yourApplicationsSection.setAttribute("tabIndex","0"); |
|
133
|
|
|
yourApplicationsSection.innerHTML = ""; |
|
134
|
|
|
for(var d = 0; d < dashboardJSON.length; d++){ |
|
135
|
|
|
var application = dashboardJSON[d]; |
|
136
|
|
|
|
|
137
|
|
|
var applicationRow = document.createElement("div"); |
|
138
|
|
|
applicationRow.setAttribute("id","ya_job_poster_id_"+application.job_poster_id); |
|
139
|
|
|
applicationRow.setAttribute("tabIndex","0"); |
|
140
|
|
|
if(d === (dashboardJSON.length - 1)){ |
|
141
|
|
|
applicationRow.setAttribute("class","dashboardJobSummaryLast"); |
|
142
|
|
|
}else{ |
|
143
|
|
|
applicationRow.setAttribute("class","dashboardJobSummary"); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
var applicationTitleDept = document.createElement("div"); |
|
147
|
|
|
applicationTitleDept.setAttribute("id","ya_title_dept_"+application.job_poster_id); |
|
148
|
|
|
applicationTitleDept.setAttribute("class","dashboardTitleDepartmentWrapper"); |
|
149
|
|
|
|
|
150
|
|
|
var applicationTitle = document.createElement("div"); |
|
151
|
|
|
applicationTitle.setAttribute("id","ya_title_"+application.job_poster_id); |
|
152
|
|
|
applicationTitle.setAttribute("class","dashboardJobSummaryTitle"); |
|
153
|
|
|
applicationTitle.setAttribute("tabIndex","0"); |
|
154
|
|
|
applicationTitle.innerHTML = application.job_poster_title; |
|
155
|
|
|
applicationTitleDept.appendChild(applicationTitle); |
|
156
|
|
|
|
|
157
|
|
|
var applicationDept = document.createElement("div"); |
|
158
|
|
|
applicationDept.setAttribute("id","ya_dept_"+application.job_poster_id); |
|
159
|
|
|
applicationDept.setAttribute("class","dashboardJobSummaryDepartment"); |
|
160
|
|
|
applicationDept.setAttribute("tabIndex","0"); |
|
161
|
|
|
applicationDept.innerHTML = " - " + application.department_details_name; |
|
162
|
|
|
applicationTitleDept.appendChild(applicationDept); |
|
163
|
|
|
|
|
164
|
|
|
applicationRow.appendChild(applicationTitleDept); |
|
165
|
|
|
|
|
166
|
|
|
var applicationManager = document.createElement("a"); |
|
167
|
|
|
applicationManager.setAttribute("id","ya_manager_"+application.job_poster_id); |
|
168
|
|
|
applicationManager.setAttribute("href","javascript:void(0)"); |
|
|
|
|
|
|
169
|
|
|
applicationManager.setAttribute("onclick","ManagerProfileAPI.showManagerProfile('"+application.manager_user_id+"');"); |
|
170
|
|
|
applicationManager.setAttribute("class","dashBoardHiringManagerWrapper"); |
|
171
|
|
|
|
|
172
|
|
|
applicationRow.appendChild(applicationManager); |
|
173
|
|
|
|
|
174
|
|
|
var applicationSubmitted = document.createElement("div"); |
|
175
|
|
|
applicationSubmitted.setAttribute("id","ya_submitted_"+application.job_poster_id); |
|
176
|
|
|
applicationSubmitted.setAttribute("class","dashboardJobSubmitted"); |
|
177
|
|
|
|
|
178
|
|
|
var applicationStatus = document.createElement("p"); |
|
179
|
|
|
applicationStatus.setAttribute("id","ya_status_"+application.job_poster_id); |
|
180
|
|
|
applicationStatus.setAttribute("class","dashboardJobStatus"); |
|
181
|
|
|
applicationStatus.setAttribute("tabIndex","0"); |
|
182
|
|
|
var statusInnerHTML = application.application_status; |
|
183
|
|
|
|
|
184
|
|
|
var closeStatus = document.createElement("span"); |
|
185
|
|
|
closeStatus.setAttribute("id","ya_close_status_"+application.job_poster_id); |
|
186
|
|
|
closeStatus.setAttribute("class","dashboardJobCloseStatus"); |
|
187
|
|
|
var closeInfo = Utilities.timeRemaining(application.job_poster_close_date_time); |
|
|
|
|
|
|
188
|
|
|
var closesIn = TalentCloudAPI.getLanguageFromCookie() === "en_CA"?"Closes in " : "Ferme dans "; |
|
|
|
|
|
|
189
|
|
|
var closed = TalentCloudAPI.getLanguageFromCookie() === "en_CA"?"Closed " : "Fermé "; |
|
190
|
|
|
var closeInnerHTML = closeInfo !== 0?closesIn + closeInfo:closed; |
|
191
|
|
|
closeStatus.innerHTML = closeInnerHTML; |
|
192
|
|
|
|
|
193
|
|
|
applicationStatus.innerHTML = statusInnerHTML + " - " + closeStatus.outerHTML; |
|
194
|
|
|
|
|
195
|
|
|
applicationSubmitted.appendChild(applicationStatus); |
|
196
|
|
|
|
|
197
|
|
|
applicationRow.appendChild(applicationSubmitted); |
|
198
|
|
|
|
|
199
|
|
|
yourApplicationsSection.appendChild(applicationRow); |
|
200
|
|
|
|
|
201
|
|
|
DashboardAPI.populateManagerProfile(application); |
|
202
|
|
|
} |
|
203
|
|
|
}; |
|
204
|
|
|
|
|
205
|
|
|
DashboardAPI.populateManagerProfile = function(application){ |
|
206
|
|
|
//console.log(application); |
|
207
|
|
|
|
|
208
|
|
|
|
|
209
|
|
|
var hiringManagerWidget = document.createElement("a") |
|
|
|
|
|
|
210
|
|
|
hiringManagerWidget.setAttribute("id","ya_manager_widget_"+application.job_poster_id); |
|
211
|
|
|
hiringManagerWidget.setAttribute("class","hiringManagerWidget"); |
|
212
|
|
|
|
|
213
|
|
|
var hiringManagerProfilePicSmall = document.createElement("img"); |
|
214
|
|
|
hiringManagerProfilePicSmall.setAttribute("id","ya_manager_profilepic_"+application.job_poster_id); |
|
215
|
|
|
hiringManagerProfilePicSmall.setAttribute("class","hiringManagerProfilePicSmall"); |
|
216
|
|
|
hiringManagerProfilePicSmall.setAttribute("tabIndex","0"); |
|
217
|
|
|
ProfilePicAPI.refreshProfilePic(application.manager_user_id, hiringManagerProfilePicSmall); |
|
|
|
|
|
|
218
|
|
|
hiringManagerWidget.appendChild(hiringManagerProfilePicSmall); |
|
219
|
|
|
|
|
220
|
|
|
var hiringManagerWidgetName = document.createElement("div") |
|
|
|
|
|
|
221
|
|
|
hiringManagerWidgetName.setAttribute("id","ya_manager_name_"+application.job_poster_id); |
|
222
|
|
|
hiringManagerWidgetName.setAttribute("class","hiringManagerName"); |
|
223
|
|
|
hiringManagerWidgetName.setAttribute("tabIndex","0"); |
|
224
|
|
|
hiringManagerWidget.appendChild(hiringManagerWidgetName); |
|
225
|
|
|
|
|
226
|
|
|
//Start requests for Hiring Manager data |
|
227
|
|
|
//Load Hiring Manager Name |
|
228
|
|
|
DataAPI.getManagerProfile(application.manager_user_id, function(response) { |
|
|
|
|
|
|
229
|
|
|
var managerProfile = JSON.parse(response); |
|
230
|
|
|
console.log(managerProfile); |
|
|
|
|
|
|
231
|
|
|
document.getElementById("ya_manager_name_"+application.job_poster_id).innerHTML = managerProfile.user.name; |
|
232
|
|
|
}); |
|
233
|
|
|
|
|
234
|
|
|
var ya_job_poster_manager_element = document.getElementById("ya_manager_"+application.job_poster_id); |
|
235
|
|
|
ya_job_poster_manager_element.appendChild(hiringManagerWidget); |
|
236
|
|
|
|
|
237
|
|
|
}; |
|
238
|
|
|
|
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.