var comboIndustry = null; var comboWorkType = null; var comboLocation = null; var salarySwitchField = null; var keywordField = null; var salarySliderField = null; var jobSearchForm = null; var formIndField = null; var selectedLocation = null; var selectedndustry = null; var selectedWorkType = null; var fieldsReady = false; // SalaaryType: AnnualPackage HourlyRate //HourlyRate var perHourOrPerYear = "AnnualPackage"; var lowestHourMin = 0; var heighestHourMax = 100; var lowestYearMin = 0; var heighestYearMax = 200; function initHourMinAndMixDivs() { writeIntoDivMinAndMax(lowestHourMin, heighestHourMax); } function initYearMinAndMaxDivs() { if (!document.getElementById("min_and_max")) return; if(salarySliderField != null) { salarySliderField.setMinValue(lowestYearMin); salarySliderField.setMaxValue(heighestYearMax); } perHourOrPerYear = "AnnualPackage"; var minAndMaxStr = "$"+lowestYearMin; minAndMaxStr += " - "; minAndMaxStr += "$"; minAndMaxStr += heighestYearMax + "K"; minAndMaxStr += "+"; document.getElementById("min_and_max").innerHTML = minAndMaxStr; var switchStr = 'per year | hour'; document.getElementById("type_switch").innerHTML = switchStr; var sliderObj = Ext.getCmp("salary_slider_id"); if(sliderObj != null) { var salMin1 = sliderObj.setValue(0,lowestYearMin); var salMax1 = sliderObj.setValue(1,heighestYearMax); } writeIntoDivMinAndMax(lowestYearMin, heighestYearMax); } function myOnmouseOver(alink) { alink.style.cursor="pointer"; } function initHourMinAndMaxDivs() { salarySliderField.setMinValue(lowestHourMin); salarySliderField.setMaxValue(heighestHourMax); perHourOrPerYear = "HourlyRate"; var minAndMaxStr = "$"+lowestHourMin + " - "; minAndMaxStr += "$"+heighestHourMax+"+"; document.getElementById("min_and_max").innerHTML = minAndMaxStr; var switchStr = 'per hour | year'; document.getElementById("type_switch").innerHTML = switchStr; var sliderObj = Ext.getCmp("salary_slider_id"); var salMin1 = sliderObj.setValue(0,lowestHourMin); var salMax1 = sliderObj.setValue(1,heighestHourMax); writeIntoDivMinAndMax(lowestHourMin, heighestHourMax); } function writeIntoDivMinAndMax(min, max) { var minAndMaxStr = ""; if( perHourOrPerYear == "AnnualPackage" ) minAndMaxStr = "$"+min + "K" + " - " + "$" + max + "K"; else minAndMaxStr = "$"+min + " - " + "$"+max; document.getElementById("min_and_max").innerHTML = minAndMaxStr; } function hourAndPeryearSwitch() { if( perHourOrPerYear == "AnnualPackage" ) initHourMinAndMaxDivs(); else initYearMinAndMaxDivs(); //initHourMinAndMixDivs(lowestHourMin, heighestHourMax); //alert("1111a"); } function submitJobSearch() { //alert("1" + Ext.getCmp("salary_slider_id")); /* * var = 0; var = 0; */ var indId = ""; if( selectedndustry != null ) indId = selectedndustry; var locId = ""; if( selectedLocation != null ) locId = selectedLocation; var workTypeId = ""; if( selectedWorkType != null ) workTypeId = selectedWorkType; var keywordText = encodeURI(keywordField.getValue()); //alert(indId + "---" + locId + "=----" + workTypeId + "::::: " + keywordText + Ext.getCmp("salary_slider_id")); var sliderObj = Ext.getCmp("salary_slider_id"); var salMin1 = sliderObj.getValue(0); var salMax1 = sliderObj.getValue(1); if( perHourOrPerYear == 'AnnualPackage' ) { salMin1 *= 1000; salMax1 *= 1000; } //alert(indId + "---" + locId + "=----" + workTypeId + "::::: " + keywordText); /** alert(formIndField); alert(jobSearchForm.findField("indId")); alert(jobSearchForm.findField("indId").getValue()); **/ var myUrl = URL_CMSROOT + "JobSearchForm/jobSearch.php?" + "indId=" + indId + "&locId=" + locId + "&wtId=" + workTypeId + "&keyword=" + keywordText + "&salaryType=" + perHourOrPerYear + "&salaryMin=" + salMin1 + "&salaryMax=" + salMax1; //var encURL = encodeURI(myUrl); //alert(encURL); window.location = encodeURI(myUrl); } function myOnChange(slider) { var min = slider.getValue(0); var max = slider.getValue(1); writeIntoDivMinAndMax(min, max); } function myDragend(slider, e, thumb) { var min = slider.getValue(0); var max = slider.getValue(1); writeIntoDivMinAndMax(min, max); } function myDrag(slider, e) { var min = slider.getValue(0); var max = slider.getValue(1); writeIntoDivMinAndMax(min, max); } function clickHandler() { //alert("handler"); self.location=URL_CMSROOT+'JobSearchForm/jobSearch'; } Ext.BLANK_IMAGE_URL = URL_CMSROOT+'JobSearchForm/sencha-ext-js/resources/images/default/s.gif'; Ext.onReady( function() { // set the data store for the Industries (calls webservice to get // all industries for this recruiter) var industries = new Ext.data.Store({ url: URL_CMSROOT+'JobSearchForm/getAllIndustriesFlatList.php', autoLoad: true, // required for the combo that does not use Ajax reader: new Ext.data.XmlReader( { record: 'cla', id: 'id'}, [ { name: 'id', type: 'string', mapping: 'id' }, { name: 'displayName', type: 'string' }, { name: "sort", type: 'int', mapping: 'sort'}, { name: "searchKey", type: 'string', mapping: 'searchName'} , { name: "parent", type: 'string', mapping: 'parent'} ] )/*, sortInfo: {field: 'sort', direction: 'ASC'}*/ }); /** 54652 0 1 Accounting Accounting **/ // set the data store for the worktype (currently static XML) var worktype = new Ext.data.Store({ url: URL_CMSROOT+'JobSearchForm/getAllWorkTypesFlatList.php', autoLoad: true, // required for the combo that does not use Ajax reader: new Ext.data.XmlReader( { record: 'wor', id: 'id'}, [ { name: 'id', type: 'string', mapping: 'id' }, { name: 'name', type: 'string', mapping: 'displayName' } ] )/*, sortInfo: {field: 'sort', direction: 'ASC'}*/ }); // set the data store for the locations (currently static XML) var locations = new Ext.data.Store( { url: URL_CMSROOT+'JobSearchForm/getAllLocationsFlatList.php', autoLoad: true, // required for the combo that does not use Ajax reader: new Ext.data.XmlReader( {record: 'loc', id: 'id'}, [ { name: 'id', type: 'string', mapping: 'id' }, { name: 'displayName', type: 'string' }, { name: "sort", type: 'int', mapping: 'sort'}, { name: "searchKey", type: 'string', mapping: 'searchName'} , { name: "parent", type: 'string', mapping: 'parent'} ] ) /*, sortInfo: {field: 'sort', direction: 'ASC'}*/ } ); // var resultTpl_accountList = new Ext.XTemplate( '
', '
{displayName}
', '
{displayName}
', '
' ); function myQuery(q, forceAll) { if(q === undefined || q === null){ q = ''; } var qe = { query: q, forceAll: forceAll, combo: this, cancel:false }; if(this.fireEvent('beforequery', qe)===false || qe.cancel){ return false; } q = qe.query; forceAll = qe.forceAll; if(forceAll === true || (q.length >= this.minChars)){ if(this.lastQuery != q){ this.lastQuery = q; if(this.mode == 'local'){ this.selectedIndex = -1; if(forceAll){ this.store.clearFilter(); }else{ if (this.baseFilterFn != null) { // Apply the filter on top of the base filter this.store.filterBy(function(record, id) { var result = this.baseFilterFn.call(this.baseFilterScope, record, id); if (result) result = q.test(record.data[this.valueField]); return result; }, this); } else this.store.filter(this.valueField, q); } this.onLoad(); }else{ this.store.baseParams[this.queryParam] = q; this.store.load({ params: this.getParams(q) }); this.expand(); } }else{ this.selectedIndex = -1; this.onLoad(); } } } // build the location combo comboLocation = new Ext.form.ComboBox({ renderTo: 'location_div', fieldLabel: 'Location', name: 'locationCombo', id: 'locationCombo', listWidth: '350', width: '350', store: locations, mode: 'local', displayField: 'displayName', valueField: 'searchKey', selectOnFocus: true, emptyText: 'Start Typing...', triggerAction: 'all', lastQuery: '', maxHeight: 300, typeAhead: false, disableKeyFilter: true, forceSelection:true, lazyInit: false, tpl: resultTpl_accountList, doQuery : myQuery, listeners: { beforequery: function(e){ var len= e.query.length; e.forceAll = false; e.query = new RegExp((e.query), "i"); e.query.length = len; return 1; }, focus : function(comboLoc){ // uncomment this line for testing... //comboLoc.expand(); } } }); // build the location combo comboIndustry = new Ext.form.ComboBox({ renderTo: 'industry_div', fieldLabel: 'Industry', name: 'industryCombo', id:'industryCombo', listWidth: '350', width: '350', store: industries, mode: 'local', displayField: 'displayName', valueField: 'searchKey', selectOnFocus: true, emptyText: 'Start Typing...', triggerAction: 'all', lastQuery: '', typeAhead: false, disableKeyFilter: true, forceSelection:true, tpl: resultTpl_accountList, doQuery : myQuery, listeners: { beforequery: function(e){ var len= e.query.length; e.forceAll = false; e.query = new RegExp((e.query), "i"); e.query.length = len; return 1; } } }); function mySelectInd(combo, record, index ) { //alert(index + " .... " + record.get('id')); if( record != null ) { selectedndustry = record.get('id'); } } function mySelectLoc(combo, record, index ) { //alert(index + " .... " + record.get('id')); if( record != null ) { selectedLocation = record.get('id'); } } function mySelectWorkType(combo, record, index ) { //alert(index + " .... " + record.get('id')); if( record != null ) { selectedWorkType = record.get('id'); } } // build the worktype combo if (document.getElementById('worktype_div')) { comboWorkType = new Ext.form.ComboBox({ renderTo: "worktype_div", fieldLabel: 'Work Type', name: 'worktypeCombo', id: 'worktypeCombo', listWidth: '320', width: '200', store: worktype, mode: 'local', displayField: 'name', selectOnFocus: true, emptyText: 'Start Typing...', listeners: { beforequery: function(e){ var len= e.query.length; e.forceAll = false; e.query = new RegExp((e.query), "i"); e.query.length = len; return 1; } } }); comboWorkType.on('select', mySelectWorkType); } comboLocation.on('select', mySelectLoc); comboIndustry.on('select', mySelectInd); if (document.getElementById('keyword_div')) { keywordField = new Ext.form.TextField({ renderTo: "keyword_div", name: 'keyword', id: 'keyword', width: '160' }); } if (document.getElementById('mailname_div')) { new Ext.form.TextField({ renderTo: "mailname_div", name: 'name', id: 'mailname', width: '160' }); } if (document.getElementById('mailemail_div')) { new Ext.form.TextField({ renderTo: "mailemail_div", name: 'email', id: 'mailemail', width: '160' }); } if (document.getElementById('salary_slider_div')) { salarySliderField = new Ext.slider.MultiSlider({ renderTo: 'salary_slider_div', id: "salary_slider_id", width : 150, minValue: lowestYearMin, maxValue: heighestYearMax, thumbs: ['min','max'], values : [lowestYearMin, heighestYearMax], increment: heighestYearMax/10, keyIncrement: heighestYearMax/10, listeners: { drag: myDrag, change: myOnChange } }); } if (document.getElementById('searchjobsbutton_div')) { var searchjobsbutton = new Ext.Button({ renderTo: "searchjobsbutton_div", name: 'searchjobsbutton', text: 'Search Jobs', type: 'submit', handler: getSearchResultAjax }); } if (document.getElementById('searchAlljobsbutton_div')) { var searchAlljobsButton = new Ext.Button({ renderTo: "searchAlljobsbutton_div", name: 'searchAlljobsButton', text: 'List All Jobs', type: 'submit', //handler: clickHandler handler: getAllJobsAjax }); } //////////////////THE FORM for submiting search /////////////////////////////////////////////// //////////////////THE FORM for submiting search /////////////////////////////////////////////// //////////////////THE FORM for submiting search /////////////////////////////////////////////// ////////////////// THE FORM for submiting search /////////////////////////////////////////////// ////////////////// THE FORM for submiting search /////////////////////////////////////////////// ////////////////// THE FORM for submiting search /////////////////////////////////////////////// /* formIndField = new Ext.form.TextField({ renderTo: "indId", name: 'indId' }); */ /****************************************************************************************** jobSearchForm = new Ext.form.BasicForm({ //renderTo: "jobSearchFormDiv", standardSubmit: true, defaultType: 'textfield', items: [ { name: 'indId', id: 'indId' }, { name: 'locId', id: 'locId' }, { name: 'keyword', id: 'keyword' }, { name: 'payRate', id: 'payRate' }, { name: 'salMin', id: 'salMin' }, { name: 'salMax', id: 'salMax' } ] }); // render the form to the page jobSearchForm.render(jobSearchFormDiv); ******************************************************************************/ fieldsReady = true; }); function getIdFromCombo(combo) { if( combo.getValue() == "" ) { //alert("Empty"); return null; } //alert("In combot.getVAlue()" + combo.getValue() + "---"); var record = combo.findRecord(combo.valueField, combo.getValue()); var index = combo.store.indexOf(record); var rec = combo.store.getAt(index); //alert("2"); var retValue = rec.get('id'); //alert("The name of the column for this row is: " + retValue); return retValue; } $(document).ready(function(){ initYearMinAndMaxDivs(); $('a#send-me-jobs').click(function(){ var indId = ""; if( selectedndustry != null ) indId = selectedndustry; var locId = ""; if( selectedLocation != null ) locId = selectedLocation; var workTypeId = ""; if( selectedWorkType != null ) workTypeId = selectedWorkType; var keywordText = ""; if (keywordField) keywordText = encodeURI(keywordField.getValue()); var salType = ''; var salMin1 = ''; var salMax1 = ''; if (document.getElementById('salary_slider_id')) { var sliderObj = Ext.getCmp("salary_slider_id"); salMin1 = sliderObj.getValue(0); salMax1 = sliderObj.getValue(1); salType = perHourOrPerYear; } $.get( URL_CMSROOT+"JobSearchForm/subscribeJobAlertsWS.php", { name: $('#mailname_div input').val(), email: $('#mailemail_div input').val(), indId: indId, locId: locId, wtId: workTypeId, keyword: keywordText, salaryType: salType, salaryMin: salMin1, salaryMax: salMax1 }, function(resp) { var hasResp = new RegExp('^Response::','m'); var msg = resp.replace(/^Response::(.+)\nREQUEST::(.*\n?)+$/gm,'$1'); if ('OK'!=msg) { alert(msg ? msg : 'There was an unexpected error processing your request. Please try again later.'); } else { document.location = URL_CMSROOT + 'jobs-to-your-inbox/subscribed'; } $('#email-similar').fadeOut().slideUp(); } ); }); submitOrRenderEmailMeSimilar = function() { if ($('#refreshJobList').length > 0) { if (''==$('#refreshJobList').text()){ $('#email-similar').hide(); setTimeout(submitOrRenderEmailMeSimilar ,1000); } else { $('#email-similar').fadeIn('slow').slideDown('slow'); } } else { var indId = ""; if( selectedndustry != null ) indId = selectedndustry; var locId = ""; if( selectedLocation != null ) locId = selectedLocation; var workTypeId = ""; if( selectedWorkType != null ) workTypeId = selectedWorkType; var keywordText = encodeURI(keywordField.getValue()); var sliderObj = Ext.getCmp("salary_slider_id"); var salMin1 = sliderObj.getValue(0); var salMax1 = sliderObj.getValue(1); if( perHourOrPerYear == 'AnnualPackage' ) { salMin1 *= 1000; salMax1 *= 1000; } document.location.href = URL_CMSROOT+"job-search?" + "indId=" + indId + "&locId=" + locId + "&wtId=" + workTypeId + "&keyword=" + keywordText + "&salaryType=" + perHourOrPerYear + "&salaryMin=" + salMin1 + "&salaryMax=" + salMax1; return false; } } $('#email-similar').hide(); $('#searchjobsbutton_div button').live('click',submitOrRenderEmailMeSimilar); $('#industryCombo').live('change',function(){ if (!this.value || 'Start Typing...'==this.value) { if ('undefined'!=typeof(selectedndustry)) selectedndustry = null; } }); $('#locationCombo').live('change',function(){ if (!this.value || 'Start Typing...'==this.value) { if ('undefined'!=typeof(selectedLocation)) selectedLocation = null; } }); $('#worktypeCombo').live('change',function(){ if (!this.value || 'Start Typing...'==this.value) { if ('undefined'!=typeof(selectedWorkType)) selectedWorkType = null; } }); if ($('#hotJobList').length > 0) { $.get( URL_CMSROOT+'JobSearchForm/displayHotJobList.php', {}, function(data) { $('#hotJobList').html($('#hotJobList',data).html()); } ); } });