var lidx; var json; var preselectedRegion; var preselectedCountryIds; var preselectedDepartmentIds; var preselectedExperienceIds; $(document).ready(function(){ lidx = $('#language').val(); if(lidx){ lidx = parseInt(lidx); } json = { "regions": { "region": [ { "id": "id2", "name":"Europe and Russia", "countries": [ { "countryid":"aaaaaaaaaaafpyc", "countryname":"Albania" } , { "countryid":"aaaaaaaaaaafpya", "countryname":"Austria" } , { "countryid":"aaaaaaaaaaafpxy", "countryname":"Belarus" } , { "countryid":"aaaaaaaaaaafpxs", "countryname":"Belgium" } , { "countryid":"aaaaaaaaaaafpxp", "countryname":"Bulgaria" } , { "countryid":"aaaaaaaaaaafpxl", "countryname":"Croatia" } , { "countryid":"aaaaaaaaaaafpxj", "countryname":"Cyprus" } , { "countryid":"aaaaaaaaaaafpxi", "countryname":"Czech Republic" } , { "countryid":"aaaaaaaaaaafpxh", "countryname":"Denmark" } , { "countryid":"aaaaaaaaaaafpxe", "countryname":"Estonia" } , { "countryid":"aaaaaaaaaaafpxa", "countryname":"Finland" } , { "countryid":"aaaaaaaaaaafpxd", "countryname":"France" } , { "countryid":"aaaaaaaaaaafpsz", "countryname":"Germany" } , { "countryid":"aaaaaaaaaaafpwx", "countryname":"Greece" } , { "countryid":"aaaaaaaaaaafpwv", "countryname":"Hungary\u00A0" } , { "countryid":"aaaaaaaaaaafpws", "countryname":"Iceland" } , { "countryid":"aaaaaaaaaaafpwo", "countryname":"Ireland" } , { "countryid":"aaaaaaaaaaafpwn", "countryname":"Israel" } , { "countryid":"aaaaaaaaaaafpwm", "countryname":"Italy" } , { "countryid":"aaaaaaaaaaafpwe", "countryname":"Latvia" } , { "countryid":"aaaaaaaaaaafpwc", "countryname":"Lithuania" } , { "countryid":"aaaaaaaaaaafpwb", "countryname":"Macedonia" } , { "countryid":"aaaaaaaaaaafpwa", "countryname":"Moldova" } , { "countryid":"aaaaaaaaaaafpxt", "countryname":"Netherlands" } , { "countryid":"aaaaaaaaaaafpux", "countryname":"Norway" } , { "countryid":"aaaaaaaaaaafpuu", "countryname":"Poland" } , { "countryid":"aaaaaaaaaaafput", "countryname":"Portugal" } , { "countryid":"aaaaaaaaaaafpus", "countryname":"Romania" } , { "countryid":"aaaaaaaaaaafpur", "countryname":"Russia" } , { "countryid":"aaaaaaaaaaafpuq", "countryname":"Serbia" } , { "countryid":"aaaaaaaaaaafpun", "countryname":"Slovakia" } , { "countryid":"aaaaaaaaaaafpum", "countryname":"Slovenia" } , { "countryid":"aaaaaaaaaaafpup", "countryname":"Spain" } , { "countryid":"aaaaaaaaaaafpuj", "countryname":"Suisse" } , { "countryid":"aaaaaaaaaaafpuo", "countryname":"Sweden" } , { "countryid":"aaaaaaaaaaafpui", "countryname":"Turkey" } , { "countryid":"aaaaaaaaaaafpue", "countryname":"Ukraine" } , { "countryid":"aaaaaaaaaaafpud", "countryname":"United Kingdom" } ] } , { "id": "id5", "name":"Africa", "countries": [ { "countryid":"aaaaaaaaaaafpyb", "countryname":"Algeria" } , { "countryid":"aaaaaaaaaaafpwg", "countryname":"Kenia" } , { "countryid":"aaaaaaaaaaafpvz", "countryname":"Marocco" } , { "countryid":"aaaaaaaaaaafpuk", "countryname":"Sudan" } , { "countryid":"aaaaaaaaaaafpuh", "countryname":"Tunisia" } ] } , { "id": "id3", "name":"Asia", "countries": [ { "countryid":"aaaaaaaaaaafpxm", "countryname":"China" } , { "countryid":"aaaaaaaaaaafpwl", "countryname":"Japan" } , { "countryid":"aaaaaaaaaaafpwi", "countryname":"Kazakhstan" } , { "countryid":"aaaaaaaaaaafpwf", "countryname":"Kyrgyzstan" } ] } , { "id": "id4", "name":"Middle East", "countries": [ { "countryid":"aaaaaaaaaaafpwr", "countryname":"Iran" } , { "countryid":"aaaaaaaaaaafpwp", "countryname":"Iraq" } , { "countryid":"aaaaaaaaaaafpwd", "countryname":"Lebanon" } , { "countryid":"aaaaaaaaaaafpuv", "countryname":"Pakistan" } , { "countryid":"aaaaaaaaaaafpuw", "countryname":"Palestine" } ] } , { "id": "id0", "name":"North America", "countries": [ { "countryid":"aaaaaaaaaaafpxo", "countryname":"Canada" } , { "countryid":"aaaaaaaaaaafptw", "countryname":"USA" } ] } , { "id": "id1", "name":"Central & South America", "countries": [ { "countryid":"aaaaaaaaaaafpxz", "countryname":"Argentina" } , { "countryid":"aaaaaaaaaaafpxw", "countryname":"Brazil" } , { "countryid":"aaaaaaaaaaafpxn", "countryname":"Chile" } , { "countryid":"aaaaaaaaaaahmia", "countryname":"Peru" } ] } ]} }; var deptJson = { "departments": { "department": [ { "id": "aaaaaaaaaaafpfr", "name":"Marketing & Sales\u00A0" } , { "id": "aaaaaaaaaaafpft", "name":"Research & Development" } , { "id": "aaaaaaaaaaafptg", "name":"General Management" } , { "id": "aaaaaaaaaaafpth", "name":"Communication" } , { "id": "aaaaaaaaaaafpti", "name":"Strategy & Planning\u00A0" } , { "id": "aaaaaaaaaaafptj", "name":"Health, Safety & Environment\u00A0" } , { "id": "aaaaaaaaaaafptk", "name":"Seed Production\u00A0" } , { "id": "aaaaaaaaaaafptl", "name":"Quality Management" } , { "id": "aaaaaaaaaaafptm", "name":"Regulatory Affairs" } , { "id": "aaaaaaaaaaafptn", "name":"Human Resources" } , { "id": "aaaaaaaaaaafpto", "name":"Finance & Accounting\u00A0" } , { "id": "aaaaaaaaaaafptp", "name":"Controlling\u00A0" } , { "id": "aaaaaaaaaaafptq", "name":"Legal, Tax, IP" } , { "id": "aaaaaaaaaaafptr", "name":"IT\u00A0" } , { "id": "aaaaaaaaaaafpts", "name":"Supply Chain Management\u00A0" } , { "id": "aaaaaaaaaaafptt", "name":"Procurement\u00A0" } , { "id": "aaaaaaaaaaafptu", "name":"Facility Management\u00A0" } , { "id": "aaaaaaaaaaafptv", "name":"Breeding" } , { "id": "aaaaaaaaaaafptx", "name":"New GM Features / Novel Traits" } , { "id": "aaaaaaaaaaafpty", "name":"Basic technologies / Metabolism" } , { "id": "aaaaaaaaaaafptz", "name":"Breeding stations" } , { "id": "aaaaaaaaaaafpua", "name":"Laborservices" } , { "id": "aaaaaaaaaaafpub", "name":"Business Development" } , { "id": "aaaaaaaaaaafpuc", "name":"Data Management" } ] } }; var expJson = { "experiences": { "experience": [ { "id": "aaaaaaaaaaafpfo", "name":"Work Experience Position" } , { "id": "aaaaaaaaaaafpfp", "name":"Entry Level Position (incl. Formation)" } , { "id": "aaaaaaaaaaafpfq", "name":"Trainee" } , { "id": "aaaaaaaaaaafpsw", "name":"Internships" } , { "id": "aaaaaaaaaaafpsx", "name":"Thesis" } ] } }; //get all offers without filter = empty parameter Obj //objParam: { country: "de", region: "id02", department: "sales" } //var expJson = {"experiences":{"experience":[{"id":"aaaaaaaaaaaaaaa","name":"Erfahrung1"},{"id":"aaaaaaaaaaaaaab","name":"Erfahrung2"}]}}; fillRegionsDropDown(json); setCountriesChkBoxesByRegion(json, null); fillscrollCheckDepartments(deptJson); fillscrollCheckExperiences(expJson); var mymap; mymap = new jvm.WorldMap({ container:$('#regions-map'), map: 'kwsmap', backgroundColor: 'white', regionsSelectable:false, regionsSelectableOne:true, regionStyle:{ initial: { "fill": '#CCC', "fill-opacity": 1, stroke: '#AAA', "stroke-width": 1, "stroke-opacity": 1 }, hover: { "fill-opacity": .8, "fill":'#888888' }, selected: { "fill-opacity":1, fill: '#F17F00' } /* ,selectedHover: { stroke: '#038547', "stroke-width": 1, "stroke-opacity": 1 } */ }, onRegionLabelShow: function(e, el, code){ if(code === 'id6' || code === 'id7'){ //dont show labels for greenland and australia e.preventDefault(); } if (el.html() === '') { e.preventDefault(); } }, onRegionOver:function(e, code){ if(code === 'id6' || code === 'id7'){ //dont highlight greenland and australia e.preventDefault(); } else{ $(this).css('cursor', 'pointer'); } }, onRegionOut:function(e, code){ $(this).css('cursor', 'default') }, onRegionClick:function(e, code){ if(code === 'id6' || code === 'id7'){ //dont bind click event for greenland and australia e.preventDefault(); } else{ $("#regions").val(code).prop('selected',true); $("#regions").trigger("change"); } } }); preselectedCountryIds = $('#preselectedcountries').val(); if(preselectedCountryIds == undefined || preselectedCountryIds == '000000000000000'){ getJobOffers({}); } preselectedRegion = $('#preselectedregion').val(); if(preselectedRegion != ''){ setRegion($('#regions'), preselectedRegion, mymap, preselectedCountryIds, false); } preselectedDepartmentIds = $('#preselecteddepartments').val(); preselectedExperienceIds = $('#preselectedexperiences').val(); $('#regions').on('change', function(){ var me, code; me = $(this); code = me.val(); setRegion(me, code, mymap, preselectedCountryIds, true); }); //Scrollable Checkboxes: $('#chk_departments input[type="checkbox"]').on('change',function(){ var regionVal = $('#regions').val(); var countryVal = $('input[name="countries[]"]:checked').map(function() {return this.value;}).get().join(','); var departmentsVal = $('input[name="departments[]"]:checked').map(function() {return this.value;}).get().join(','); var experienceVal = $('input[name="experiences[]"]:checked').map(function() {return this.value;}).get().join(','); var objSearch = provideSearchObject(countryVal,regionVal,departmentsVal,experienceVal); getJobOffers(objSearch); var containerdiv = $(this).parent().parent(); if(containerdiv.hasClass('highlight')){ containerdiv.removeClass('highlight'); } else{ containerdiv.addClass('highlight'); } }); //Scrollable Checkboxes $('#chk_experiences input[type="checkbox"]').on('change',function(){ var regionVal = $('#regions').val(); var countryVal = $('input[name="countries[]"]:checked').map(function() {return this.value;}).get().join(','); var departmentsVal = $('input[name="departments[]"]:checked').map(function() {return this.value;}).get().join(','); var experienceVal = $('input[name="experiences[]"]:checked').map(function() {return this.value;}).get().join(','); var objSearch = provideSearchObject(countryVal,regionVal,departmentsVal,experienceVal); getJobOffers(objSearch); var containerdiv = $(this).parent().parent(); if(containerdiv.hasClass('highlight')){ containerdiv.removeClass('highlight'); } else{ containerdiv.addClass('highlight'); } }); //setzen der checkboxen bei preselection if(preselectedCountryIds){ preselectCountry(preselectedCountryIds); } if(preselectedDepartmentIds){ preselectDepartments(preselectedDepartmentIds); } if(preselectedExperienceIds){ preselectExperiences(preselectedExperienceIds); } //suche von aussen ueber urlparameter var objSearch = provideSearchObject(preselectedCountryIds,preselectedRegion,preselectedDepartmentIds,preselectedExperienceIds); getJobOffers(objSearch); var joblink = ''; if(joblink){ displayJoboffer(joblink); } }); //end ready function setRegion(obj, code, mymap, preselectedCountryIds, bSearch){ obj.val(code); var departmentsVal = $('input[name="departments[]"]:checked').map(function() {return this.value;}).get().join(','); var experienceVal = $('input[name="experiences[]"]:checked').map(function() {return this.value;}).get().join(','); var objSearch = provideSearchObject('',code,departmentsVal,experienceVal); if(bSearch){ //suche nur feuern wenn kein country ├╝bergeben wurde! getJobOffers(objSearch); } mymap.clearSelectedRegions(); if (code){ mymap.setSelectedRegions(code); } else{ code = null; } //mit code = null bei leeren regions alle laender holen wie initial setCountriesChkBoxesByRegion(json, code); } function preselectCountry(countryids){ if(countryids && countryids != '000000000000000'){ makeChkBoxSelectionCountry(countryids); //var countryVal = countryids; //var regionVal = $('#regions').val(); //var departmentsVal = $('input[name="departments[]"]:checked').map(function() {return this.value;}).get().join(','); //var experienceVal = $('input[name="experiences[]"]:checked').map(function() {return this.value;}).get().join(','); //var objSearch = provideSearchObject(countryVal,regionVal,departmentsVal,experienceVal); //getJobOffers(objSearch); } } function preselectDepartments(ids){ if(ids && ids != '000000000000000'){ makeChkBoxSelectionDepartment(ids); //var countryVal = $('input[name="countries[]"]:checked').map(function() {return this.value;}).get().join(','); //var regionVal = $('#regions').val(); //var departmentsVal = ids; //var experienceVal = $('input[name="experiences[]"]:checked').map(function() {return this.value;}).get().join(','); //var objSearch = provideSearchObject(countryVal,regionVal,departmentsVal,experienceVal); //getJobOffers(objSearch); } } function preselectExperiences(ids){ if(ids && ids != '000000000000000'){ makeChkBoxSelectionExperience(ids); //var countryVal = $('input[name="countries[]"]:checked').map(function() {return this.value;}).get().join(','); //var regionVal = $('#regions').val(); //var departmentsVal = $('input[name="departments[]"]:checked').map(function() {return this.value;}).get().join(','); //var experienceVal = ids; //var objSearch = provideSearchObject(countryVal,regionVal,departmentsVal,experienceVal); //getJobOffers(objSearch); } } function makeChkBoxSelectionCountry(countriyids){ if(countriyids.indexOf(',') > -1){ aryCountryIDs = countriyids.split(','); for(var i=0; i -1){ var aryIDs = ids.split(','); for(var i=0; i < aryIDs.length; i++){ if (aryIDs[i]){ var theID = aryIDs[i].trim(); var containerTop = $('#chk_departments').position().top; var elementTop = $('input[name="departments[]"][value='+theID+']').position().top; $('input[name="departments[]"][value='+theID+']').attr('checked','checked').parent().parent().addClass('highlight'); } } } else{ var containerTop = $('#chk_departments').position().top; var elementTop = $('input[name="departments[]"][value='+ids+']').position().top; $('input[name="departments[]"][value='+ids+']').attr('checked','checked').parent().parent().addClass('highlight'); } var differenz = parseInt(elementTop - containerTop); $('#chk_departments').scrollTop(differenz-10); } function makeChkBoxSelectionExperience(ids){ if(ids.indexOf(',') > -1){ var aryIDs = ids.split(','); for(var i=0; i < aryIDs.length; i++){ if (aryIDs[i]){ var theID = aryIDs[i].trim(); var containerTop = $('#chk_experiences').position().top; var elementTop = $('input[name="experiences[]"][value='+theID+']').position().top; $('input[name="experiences[]"][value='+theID+']').attr('checked','checked').parent().parent().addClass('highlight'); } } } else{ var containerTop = $('#chk_experiences').position().top; var elementTop = $('input[name="experiences[]"][value='+ids+']').position().top; $('input[name="experiences[]"][value='+ids+']').attr('checked','checked').parent().parent().addClass('highlight'); } var differenz = parseInt(elementTop - containerTop); $('#chk_experiences').scrollTop(differenz-10); } function provideSearchObject(countryVal,regionVal,departmentsVal,experienceVal){ if(countryVal){ countryVal = countryVal.toString(); } if(regionVal){ regionVal = regionVal.toString(); } if(departmentsVal){ departmentsVal = departmentsVal.toString(); } if(experienceVal){ experienceVal = experienceVal.toString(); } if (regionVal === null){regionVal = ''} if (countryVal === null){countryVal = ''} if (departmentsVal === null){departmentsVal = ''} if (experienceVal === null){experienceVal = ''} return {region: regionVal, country: countryVal, department: departmentsVal, experience: experienceVal, lidx: lidx}; } function getJobOffers(objParam){ var url, el, counter, resHTML, descr, href, offercontainer, list; offercontainer = $("#joboffercontainer"); list = $("#listcontainer"); el = $("#resultset"); counter = $("#jobcounter"); url = "/custom/kws/jobportal/joboffers.asp?jpid=aaaaaaaaaaafqnj"; resHTML = ''; displayFiltersettings(objParam); $.ajax({ type: "GET", url: url, data: objParam , beforeSend:function(){ list.show(); offercontainer.hide(); el.html(''); el.append('
  • loading
  • '); //console.log(this.url); }, success:function(data){ el.html(''); counter.html(data.joboffers.joboffer.length); //console.log(data); $.each(data.joboffers.joboffer, function(idx,val){ var myID, myProcessID, myClass, mytitle, mydescription, mydate, mylink, dynTitle, dynDescr, dynDate, dynLink; dynTitle = 'title' + lidx; dynDescr = 'description' + lidx; dynDate = 'date' + lidx; dynLink = 'link' + lidx; //Language 0 also englisch ist IMMER vorhanden und der fallback, falls keine Translation myID = val.awidentity; myProcessID = val.awprocessid; myClass = val.ceclass; if(val[dynTitle]){ mytitle = val[dynTitle]; mydescription = val[dynDescr]; mydate = val[dynDate]; mylink = val[dynLink]+'?style=' + data.joboffers.style; } else{ mytitle = val.title0; mydescription = val.description0; mydate = val.date0; mylink = val.link0+'?style=' + data.joboffers.style; } if(mydescription){ mydescription = ''+ mydescription +''; } resHTML += '
  • '+ mydate +''+ mytitle +''+mydescription+'
  • '; //console.log('link0: ' + val.link0 + ' link1:' + val[dynLink]); }); el.append(resHTML); $('.jobofferlink').on('click', function(e){ e.preventDefault(); var me = $(this); var link = me.attr('data-href'); displayJoboffer(link); }); }, error:function(xhr, status, errorThrown){ el.html(''); counter.parent().html('Error occured'); el.append('
  • ' + errorThrown + '
  • '); } }); } function displayJoboffer(link){ var offer, offercontainer, list; console.log(link); offercontainer = $("#joboffercontainer"); offer = $('#joboffer'); list = $("#listcontainer"); if(link){ $.ajax({ beforeSend: function(jqXHR) { jqXHR.overrideMimeType('text/html;charset=iso-8859-1'); offer.html(''); offer.append('
    loading
    '); list.hide(); offercontainer.show(); }, type: "GET", dataType: "html", url: link, success: function (htmlcontent) { offer.html(''); var blockhtml = $(htmlcontent).find("#block_1_large > div"); if (blockhtml.length == 0) { blockhtml = $(htmlcontent).find("#block_1 > div"); } if (blockhtml.length > 0) { offer.html(blockhtml); } else{ //nach relaunch andere div struktur offer.html($(htmlcontent).find(".jobprofile")); } //Download PDF not open in new window !!! $('.download_bar form').attr('target','_self'); }, error:function(x, textStatus, errorThrown){ if (errorThrown != ''){ offer.html('

    ' + textStatus + ', ' + errorThrown+'

    '); } } }); } $('#btnback').on('click',function(){ offercontainer.hide(); list.show(); }); } function fillscrollCheckDepartments(deptJson){ var chk; var sortedDepartments = sortJSON(deptJson.departments.department, 'name'); $.each(sortedDepartments, function(i, value) { chk = '
    '; $('#chk_departments').append(chk); }); } function fillscrollCheckExperiences(expJson){ var chk; var sortedExperiences = sortJSON(expJson.experiences.experience, 'name'); $.each(expJson.experiences.experience, function(i, value) { chk = '
    '; $('#chk_experiences').append(chk); }); } function fillRegionsDropDown(json){ var opt; var sortedRegions = sortJSON(json.regions.region, 'name'); $.each(sortedRegions, function(i, value) { opt = ''; $('#regions').append(opt); }); } function sortJSON(data, key) { return data.sort(function(a, b) { var x = a[key]; var y = b[key]; return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }); } //country Scrollable checkboxes function setCountriesChkBoxesByRegion(json, code){ var chk = ''; $('#chk_countries').html(''); if(code){ var sortedRegions = sortJSON(json.regions.region, 'name'); $.each(sortedRegions, function(i, value) { if (value.id === code) { var sortedCountries = sortJSON(value.countries, 'countryname'); $.each(sortedCountries, function(j, value){ chk += '
    '; }); $('#chk_countries').append(chk); } }); } if(code === null){ var sortedRegions = sortJSON(json.regions.region, 'name'); $.each(sortedRegions, function(i, value) { chk += '
    ' + value.name + '
    '; var sortedCountries = sortJSON(value.countries, 'countryname'); $.each(sortedCountries, function(j, value){ chk += '
    '; }); chk += "
    "; }); $('#chk_countries').append(chk); } //eventbinding country checkboxes $('#chk_countries input[type="checkbox"]').on('change',function(){ var regionVal = $('#regions').val(); var countryVal = $('input[name="countries[]"]:checked').map(function() {return this.value;}).get().join(','); var departmentsVal = $('input[name="departments[]"]:checked').map(function() {return this.value;}).get().join(','); var experienceVal = $('input[name="experiences[]"]:checked').map(function() {return this.value;}).get().join(','); var objSearch = provideSearchObject(countryVal,regionVal,departmentsVal,experienceVal); var containerdiv = $(this).parent().parent(); getJobOffers(objSearch); if(containerdiv.hasClass('highlight')){ containerdiv.removeClass('highlight'); } else{ containerdiv.addClass('highlight'); } }); } function displayFiltersettings(objParam){ var fEl = $('#filtersettings'); fEl.html('
    Filter
    '+getFilterText(objParam, 'region', null)+ getFilterText(objParam, 'country', 5) +getFilterText(objParam, 'department', 3)+getFilterText(objParam, 'experience', 3)+'
    '); if($('.filtersettings-inner').html() == ''){ //$('#filtersettings').hide(); $('.filtersettings-inner').html('

    No active filter.

    '); } else{ //$('#filtersettings').show(); } } function getFilterText(objParam, name, iMax){ var filter, filterText; filterText = ''; if(name == 'country'){ filter = objParam.country; outputTitle = 'Countries:'; } if(name == 'department'){ filter = objParam.department; outputTitle = 'Fields of work:'; } if(name == 'experience'){ filter = objParam.experience; outputTitle = 'Experience:'; } if(name == 'region'){ filter = objParam.region; outputTitle = 'Regions:'; } if(filter != undefined){ if (name != 'region'){ if(filter.indexOf(',') > -1){ var arycis = filter.split(','); for(var i=0; i= iMax){ var others = arycis.length - iMax; filterText += ' and ' + others + ' others'; break; } else{ if (i==0){ filterText = $('.jobportal input[type="checkbox"][value="'+theID+'"]').attr('data-text'); } else{ filterText += ', ' + $('.jobportal input[type="checkbox"][value="'+theID+'"]').attr('data-text'); } } } } } else{ filterText = $('.jobportal input[type="checkbox"][value="'+filter+'"]').attr('data-text'); } } else{ //name = region filterText = $('#regions :selected').attr('data-text'); } } else{ filterText = undefined; } if(filterText != undefined){ filterText = '

    ' + outputTitle + ' ' + filterText + '

    '; } else{ filterText = ''; } return filterText; }