Passed
Push — master ( 6f8171...7c2bcd )
by
unknown
48s
created

TeamCultureAPI.getTeamCulture   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 1
rs 10
1
var TeamCultureAPI = {};
2
3
TeamCultureAPI.baseURL = "/tc/api/v1";
4
5
TeamCultureAPI.TeamCulture = function(teamSize, gcDirUrl, narrativeText, operatingContext, whatWeValue, howWeWork) {
6
    this.team_size = teamSize;
7
    this.gc_directory_url = gcDirUrl;
8
    this.narrative_text = narrativeText;
9
    this.operating_context = operatingContext;
10
    this.what_we_value = whatWeValue;
11
    this.how_we_work = howWeWork;
12
};
13
14
TeamCultureAPI.parseTeamCultureResponse = function(responseText) {
15
    var json = JSON.parse(responseText);
16
    return new TeamCultureAPI.TeamCulture(json.team_size, json.gc_directory_url, json.narrative_text, json.operating_context, json.what_we_value, json.how_we_work);
17
};
18
19
TeamCultureAPI.localizeTeamCulture = function() {
20
    if (siteContent) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable siteContent is declared in the current environment, consider using typeof siteContent === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
21
        document.getElementById("jobPosterTeamCultureLabel").innerHTML = siteContent.teamCulture;
22
        document.getElementById("jobPosterTeamSize_label").innerHTML = siteContent.teamSize;
23
        document.getElementById("jobPosterGcDirLink_label").innerHTML = siteContent.gcDirectoryLink;
24
25
        //document.getElementById("jobPosterOperatingContext_label").innerHTML = siteContent.operatingContextLabel;
26
        //document.getElementById("jobPosterWhatWeValue_label").innerHTML = siteContent.whatWeValueLabel;
27
        //document.getElementById("jobPosterHowWeWork_label").innerHTML = siteContent.howWeWorkLabel;
28
    }
29
};
30
31
TeamCultureAPI.loadTeamCultureSummary = function(managerProfileId) {
32
    TeamCultureAPI.getTeamCulture(managerProfileId, function(response) {
33
        var teamCulture = TeamCultureAPI.parseTeamCultureResponse(response);
34
        TeamCultureAPI.populateTeamCultureSummary(teamCulture);
35
    });
36
};
37
38
TeamCultureAPI.populateTeamCultureSummary = function(teamCulture) {
39
    document.getElementById('jobPosterTeamSize').innerHTML = teamCulture.team_size;
40
    document.getElementById('jobPosterGcDirLink').href = teamCulture.gc_directory_url;
41
    document.getElementById('jobPosterTeamNarrativeText').innerHTML = teamCulture.narrative_text;
42
43
    document.getElementById('jobPosterOperatingContext_text').innerHTML = teamCulture.operating_context;
44
    document.getElementById('jobPosterWhatWeValue_text').innerHTML = teamCulture.what_we_value;
45
    document.getElementById('jobPosterHowWeWork_text').innerHTML = teamCulture.how_we_work;
46
};
47
48
TeamCultureAPI.getTeamCulture = function(managerProfileId, responseCallback) {
49
    var url = TeamCultureAPI.baseURL + '/' + TalentCloudAPI.getLanguageFromCookie() + '/getTeamCultureByManagerProfile/' + managerProfileId;
0 ignored issues
show
Bug introduced by
The variable TalentCloudAPI seems to be never declared. If this is a global, consider adding a /** global: TalentCloudAPI */ 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...
50
    DataAPI.sendRequest(url, "GET", {}, null, function(request) {
0 ignored issues
show
Bug introduced by
The variable DataAPI seems to be never declared. If this is a global, consider adding a /** global: DataAPI */ 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...
51
        responseCallback(request.response);
52
    });
53
};