-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.xsl
298 lines (247 loc) · 9.9 KB
/
profile.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- by Cathy Snider, Strategic Relations, CU Boulder -->
<!-- 9-20-2017: ADD CANVAS LINK -->
<xsl:template match="root">
<div id="mycuinfoprofile">
<script type="text/javascript">
$(document).ready(function() {
$("div#personalInfo").hide();
$("a#profileLink").click(function(){
var pglt_link_state = $(this).attr("aria-expanded");
$(this).toggleClass("closeProfile");
$(this).toggleClass("openProfile");
$("div#personalInfo").slideToggle();
if (pglt_link_state == "false") {
$(this).attr("aria-expanded","true");
$("div#personalInfo").attr("aria-hidden","false");
}
if (pglt_link_state == "true") {
$(this).attr("aria-expanded","false");
$("div#personalInfo").attr("aria-hidden","true");
}
});
$("#d2lLink").attr("href", document.location.href.replace(/\/psp\//, "/psc/").replace(/\/h\/.*$/, "/s/WEBLIB_CU_D2L.ISCRIPT1.FieldFormula.IScript_ShowD2LPagelet"));
});
</script>
<script type="text/javascript">
<xsl:comment> // without this the portal breaks the code
// This creates link for Canvas
var canvasURL = {
'iepdev' : 'https://cuboulder.beta.instructure.com',
'ieptst' : 'https://cuboulder.test.instructure.com',
'iepstg' : 'https://canvas.colorado.edu',
'iepprd' : 'https://canvas.colorado.edu'
};
var dbLocation = window.location.pathname.match(/\/psp\/([^\/]+)\//)[1];
$('#canvasLink').attr('href', canvasURL[dbLocation]);
var resDataLink = document.getElementById('profileLink');
resDataLink.onclick = getResidency;
function getResidency() {
csUrlBuilder = {
envList :
{"iepdev" : ["icsdev.dev", "icsdev"],
"ieptst" : ["icstst.qa", "icstst"],
"iepstg" : ["icsstg.qa", "icsstg"],
"iepsp3" : ["icssp3.dev", "icssp3"],
"portal" : ["isis-cs.prod", "csprod"]
},
env: function() {
var hostname = window.location.hostname;
hostname = hostname.substring(0, hostname.indexOf("."))
return hostname;
},
url : function() {
var hostname = window.location.hostname;
hostname = hostname.substring(0, hostname.indexOf("."));
var env = this.envList[hostname];
return "https://" + env[0] + ".cu.edu/psc/" + env[1] + "/EMPLOYEE/HRMS/s/WEBLIB_CU_EPVW.ISCRIPT1.FieldFormula.IScript_EPViewer";
}
}
var currentEnv = csUrlBuilder.env();
console.log(currentEnv);
$.ajax({
url: csUrlBuilder.url() + "?dataset=residency",
xhrFields: { withCredentials: true }
}).done(function(data){
var MyJsonObject = data; //entire json set
var mainResDataset = null;
var residencyValue = "We are unable to obtain your residency at this time";
var dataArrayLength = 0; // the number of objects in the dataset
dataArrayLength = MyJsonObject.datasets.residency.data.length;
if (dataArrayLength != 0) {
//first object in dataset contains almost everything we need
mainResDataset = MyJsonObject.datasets["residency"].data[0];
window.mainResDataset = mainResDataset;
//set student type to tuition_res
var studentType = mainResDataset.tuition_res;
// if student is not RES, look at every student group item in the array; if there's a hit change student type to INTL
if (studentType != "RES") {
for (var i = 0; i < dataArrayLength; i++) {
var studentGroupData = MyJsonObject.datasets.residency.data[i].student_group;
if (studentGroupData == "AITL") {studentType = "INTL";}
}
}
}
console.log("studentType: " + studentType);
if (mainResDataset == undefined || mainResDataset == null || mainResDataset.length == 0 ){
console.log("residency undefined"); //leave residencyValue at default
}
else { // do the switch statement
switch (studentType) {
case "RES": residencyValue = "In-state";
break;
case "INTL": residencyValue = "International";
break;
case "NRES": residencyValue = "Out-of-state";
break;
case "CEES": residencyValue = "Noncredit";
break;
default: residencyValue = "Your residency status has not been defined.";
}
} //end else
document.getElementById("myResidencyStatus").innerHTML = residencyValue;
}).fail(function(data, textStatus, errorThrown) {
console.log(textStatus);
console.log(errorThrown);
document.getElementById("myResidencyStatus").innerHTML = "No residency status is available.";
}).always(function() {});
}
// </xsl:comment>
</script>
<h2 class="element-invisible">Quick Links</h2>
<!-- process the affiliations for email -->
<xsl:apply-templates select="demographicData/affiliations" />
<!-- create Desire2Learn link -->
<xsl:if test="lms='CULEARN'">
<div class="link"><a href="#" id="d2lLink" target="_blank">Desire2Learn</a></div>
</xsl:if>
<!-- process personal info -->
<div class="link"><h2><a href="javascript:void(0);" id="profileLink" class="closeProfile" aria-controls="personalInfo" aria-expanded="false">Profile & Settings</a></h2></div>
<div class="toggle_content" id="personalInfo" aria-hidden="true">
<table class="tbl-profile" role="presentation">
<tr>
<td colspan="2">
<h3>Personal Info</h3>
</td>
</tr>
<xsl:apply-templates select="demographicData" />
<xsl:if test="hr_id">
<tr>
<td>
<strong>Employee ID:</strong>
</td>
<td>
<xsl:value-of select="hr_id" />
</td>
</tr>
</xsl:if>
<xsl:if test="cs_id">
<tr>
<td>
<strong>Student ID:</strong>
</td>
<td>
<xsl:value-of select="cs_id" />
</td>
</tr>
</xsl:if>
<xsl:apply-templates select="collegeDatas" />
<tr>
<td>
<strong>Residency for Tuition Purposes:</strong>
</td>
<td><div id="myResidencyStatus"></div>
</td>
</tr>
</table>
<!-- create helpful links -->
<table class="tbl-profile" role="presentation">
<tr>
<td><h3>Account Settings</h3>
<ul id="helpfullinks">
<li><a href="#">Gumbo beet greens corn soko endive gumbo gourd.</a></li>
<li><a href="#">Parsley shallot courgette tatsoi pea sprouts fava bean collard greens </a></li>
<li><a href="#">Dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</a></li>
</ul>
</td>
</tr>
</table>
</div>
</div>
</xsl:template>
<xsl:template match="demographicData">
<tr>
<td>
<strong>Name:</strong>
</td>
<td>
<xsl:value-of select="prefFirstName" />
<xsl:text> </xsl:text>
<xsl:value-of select="prefLastName" />
</td>
</tr>
</xsl:template>
<xsl:template match="collegeDatas">
<xsl:apply-templates select="collegeData"></xsl:apply-templates>
</xsl:template>
<xsl:template match="collegeDatas">
<xsl:for-each select="collegeData">
<tr>
<td>
<strong>College:</strong>
</td>
<td>
<xsl:value-of select="primaryCollege" />
</td>
</tr>
<xsl:if test="primaryMajor != '' ">
<tr>
<td>
<strong>Major:</strong>
</td>
<td>
<!-- test for improperly escaped ampersands in data field -->
<xsl:choose>
<xsl:when test="contains(primaryMajor, '&amp;')">
<xsl:value-of select="substring-before(primaryMajor, '&amp;')"></xsl:value-of>
<xsl:text> & </xsl:text>
<xsl:value-of select="substring-after(primaryMajor, '&amp;')"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="primaryMajor" />
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:if>
<xsl:if test="secondaryMinor != '' ">
<tr>
<td>
<strong>Minor:</strong>
</td>
<td>
<!-- test for improperly escaped ampersands in data field -->
<xsl:choose>
<xsl:when test="contains(secondaryMinor, '&amp;')">
<xsl:value-of select="substring-before(secondaryMinor, '&amp;')"></xsl:value-of>
<xsl:text> & </xsl:text>
<xsl:value-of select="substring-after(secondaryMinor, '&amp;')"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="secondaryMinor" />
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="demographicData/affiliations">
<xsl:if test="(affiliation = 'FACULTY') or (affiliation = 'ADVISOR')">
<div class="link"><a href="javascript:void(0);" id="canvasLink" target="_blank">Canvas</a></div>
<div class="link"><a href="https://outlook.office365.com/" target="_blank">Office 365 Outlook</a></div>
</xsl:if>
<xsl:if test="affiliation = 'STUDENT'"><div class="link"><a href="http://gmail.colorado.edu" target="_blank">Gmail</a></div></xsl:if>
</xsl:template>
</xsl:stylesheet>