Advertisement
Guest User

wtj2

a guest
Jan 19th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.              
  2.             Ext.ns('SearchJobsForm'); // register our namespace
  3.  
  4.         var serverAdd = 'localhost';
  5.         var port = '3000';
  6.         var dataReceivedFromServer=' ';
  7.  
  8.        
  9.             /* BUTTON HANDLERS */
  10.        
  11.        
  12.         var resetButtonHandler = function (btn, evt) {
  13.         this.getComponent('keywords').reset();
  14.         this.getComponent('dposted').reset();
  15.         this.getComponent('jtitle').reset();
  16.         this.getComponent('jcategory').reset();
  17.         this.getComponent('salaryf').reset();
  18.         this.getComponent('salaryt').reset();
  19.         this.getComponent('jscategory').reset();
  20.         this.getComponent('ptype').reset();
  21.                     }
  22.  
  23.         /*This function takes the search criteria and sends it to the server to receive filtered search results
  24.         */
  25.        
  26.         var submitButtonHandler = function(btn,evt) {
  27.        
  28.          var form = this.el.up('.x-panel');
  29.        
  30.         var searchCriteria = {
  31.                 'keywords':form.down('.x-input-text[name=keywords]').getValue(),
  32.                 'job_title': form.down('.x-input-text[name=jtitle]').getValue(),
  33.                 'job_category':form.down('.x-input-text[name=jcategory]').getValue(),
  34.                 'job_subcategory':form.down('.x-input-text[name=jscategory]').getValue(),                                
  35.                 'position_type':form.down('.x-input-text[name=ptype]').getValue(),
  36.                 'salary_from': form.down('.x-input-text[name=salaryf]').getValue(),
  37.                 'salary_to': form.down('.x-input-text[name=salaryto]').getValue(),
  38.                 'posting_age':form.down('.x-input-text[name=dposted]').getValue()
  39.                 };
  40.         globalvar = form;
  41.        
  42.         connect(searchCriteria);
  43.        
  44.        
  45.         }
  46.         var globalvar = null;
  47.         //connection to the server
  48.         var connect = function(searchCriteria){
  49.         Ext.util.JSONP.request({
  50.                     url: "http://"+serverAdd+":"+ port+"/users/searchresults.json",
  51.                     format: 'json',
  52.                     callbackKey: 'callback',
  53.                     params : searchCriteria,
  54.                     callback: function(data) {
  55.                     //Do something with the results. Construct another interface for showing the results.
  56.                     //alert(data);
  57.                     dataReceivedFromServer = data;
  58.                     Ext.apply(this, {jobsList: new SearchJobsForm.jobsList()});
  59.                    
  60.                     },
  61.                     failure: function ( result) {
  62.                     alert('Failed');
  63.                     }
  64.                 });
  65.        
  66.         }//end of connect function
  67.  
  68.                     /* THE LIST OF JOBS */
  69.  
  70.                     SearchJobsForm.jobsList = Ext.extend(Ext.Panel,{
  71.                     initComponent: function(){
  72.                    
  73.                     Ext.apply(this, {
  74.                     floating: true,
  75.                     width: 250,
  76.                     height: 370,
  77.                     scroll: 'vertical',
  78.                     centered: true,
  79.                     dockedItems : [ {
  80.                     xtype : 'toolbar',
  81.                     title : 'WTJ',
  82.                     dock : 'top',
  83.                     items : [ {
  84.                     xtype : 'button',
  85.                     text : 'Back',
  86.                     ui : 'back',
  87.                     handler : function() {
  88.                     //back button controller
  89.                     },
  90.                     scope : this
  91.                     } ]
  92.                     } ],
  93.                     items : [ {
  94.                     xtype : 'list',
  95.                     emptyText : 'No data available.',
  96.                     store : 'jobStore',
  97.                     itemTpl : '<div class="list-item-title">{title}</div>'
  98.                         +
  99.                           '<div class="list-item-narrative">{narrative}</div>',
  100.                     onItemDisclosure : function(record) {
  101.                     },
  102.                     grouped : false,
  103.                     scroll : 'vertical',
  104.                     fullscreen : true
  105.                     } ]
  106.                     });
  107.                     SearchJobsForm.jobsList.superclass.initComponent.apply(this, arguments);
  108.                     },
  109.                 });
  110.                
  111.  
  112.             /*    ****** MODEL ******  */
  113.  
  114.    
  115.         Ext.regModel('jobSummary', {
  116.         fields: [
  117.       {name: 'title',           type: 'string'}
  118.       /*
  119.       ,
  120.       {name: 'brief_description', type: 'string'},
  121.       {name: 'company',         type: 'string'},
  122.       {name: 'category',        type: 'string'},
  123.       {name: 'posting_date',    type: 'string' },
  124.       {name: 'sub_category',    type: 'string'},
  125.       {name: 'department',      type: 'string'},
  126.       {name: 'reference_num',   type: 'string'},
  127.       {name: 'province',        type: 'string'},
  128.       {name: 'country',         type: 'string'},
  129.       {name: 'full_description', type: 'string'},
  130.       {name: 'requirements',    type: 'string'},
  131.       {name: 'relocation_covered', type: 'string'},
  132.       {name: 'salary',          type: 'string'},
  133.       {name: 'travel_req',      type: 'string'},
  134.       {name: 'call_allowed',    type: 'string'},
  135.       {name: 'term',            type: 'string'},
  136.       {name: 'experience',      type: 'string'},
  137.       {name: 'call_allowed',    type: 'string'}
  138.       */
  139.     ]
  140. });
  141.  
  142.  
  143.             /* ****** STORE ****** */
  144.  
  145.         var store = new Ext.data.Store({
  146.             model: 'jobSummary',
  147.             storeId: 'jobStore',
  148.             /*
  149.             proxy: {
  150.                 type:'scripttag',
  151.                 url:'temp.json',
  152.                 reader: {
  153.                 type: 'json'
  154.                 }
  155.             },
  156.             */
  157.               data : [{title: 'This is test'},
  158.               {title: 'This is test2'},
  159.               {title: 'This is test3'}]
  160.             });
  161. /*
  162.         *******SEARCH FORM******
  163.    
  164. */
  165.             SearchJobsForm.form = Ext.extend(Ext.Panel,{
  166.        
  167.                 initComponent: function(){
  168.                    
  169.                     Ext.apply(this, {
  170.                         floating: true,
  171.             width: 250,
  172.             height: 370,
  173.             scroll: 'vertical',
  174.             centered: true,
  175.             modal: true,
  176.             hideOnMaskTap: false,
  177.                         items: [{  
  178.             xtype: 'textfield',
  179.             itemId: 'keywords',
  180.             label: 'Keywords',
  181.             labelAlign: 'top',
  182.             labelWidth: '100%',
  183.             name: 'keywords'
  184.             },{  
  185.             xtype: 'textfield',
  186.             label: 'Job Title',
  187.             itemId: 'jtitle',
  188.             labelAlign: 'top',
  189.             labelWidth: '100%',
  190.             name: 'jtitle'
  191.             },{
  192.             xtype: 'selectfield',
  193.             label: 'Job Category',
  194.              itemId: 'jcategory',
  195.             labelAlign: 'top',
  196.             labelWidth: '100%',
  197.             name: 'jcategory',
  198.                 options: [{
  199.                     text: 'Any', value: 'ANY'
  200.                 }, {
  201.                     text: 'Technical', value: 'Technical'
  202.                 }, {
  203.                     text: 'Non-Technical', value: 'Non-Technical'
  204.                 }, {
  205.                     text: 'Tech Start-up', value: 'Tech Start-up'
  206.                 }, {
  207.                     text: 'Life Science', value: 'Life Science'
  208.                 }, {
  209.                     text: 'Digital Media', value: 'Digital Media'
  210.                 }, {
  211.                     text: 'Accelerator Centre', value: 'Accelerator Centre'
  212.                 }
  213.                 ]
  214.                         },{
  215.             xtype: 'selectfield',
  216.             label: 'Job Sub-Category',
  217.              itemId: 'jscategory',
  218.             labelAlign: 'top',
  219.             labelWidth: '100%',
  220.             name: 'jscategory',
  221.                 options: [{
  222.                     text: 'Any', value: 'ANY'
  223.                 }, {
  224.                     text: 'Developer', value: 'Developer'
  225.                 }, {
  226.                     text: 'Quality Assurance', value: 'Quality Assurance'
  227.                 }, {
  228.                     text: 'Project Manager', value: 'Project Manager'
  229.                 }, {
  230.                     text: 'Tester', value: 'Tester'
  231.                 }, {
  232.                     text: 'IT Help Desk', value: 'IT Help Desk'
  233.                 }, {
  234.                     text: 'Health Care', value: 'Health Care'
  235.                 }, {
  236.                     text: 'Transportation and Logistics', value: 'Transportation and Logistics'
  237.                 }, {
  238.                     text: 'Management', value: 'Management'
  239.                 }, {
  240.                     text: 'Network', value: 'Network'
  241.                 }, {
  242.                     text: 'Administration', value: 'Administration'
  243.                 }, {
  244.                     text: 'General', value: 'General'
  245.                 }
  246.                 ]
  247.                         },{
  248.             xtype: 'selectfield',
  249.             label: 'Position Type',
  250.              itemId: 'ptype',
  251.             labelAlign: 'top',
  252.             labelWidth: '100%',
  253.             name: 'ptype',
  254.             options: [{
  255.                 text: 'Any', value: 'ANY'
  256.             }, {
  257.                 text: 'Part Time', value: 'Part Time'
  258.             }, {
  259.                 text: 'Part Time Contract', value: 'Part Time Contract'
  260.             }, {
  261.                 text: 'Full Time', value: 'Full Time'
  262.             }, {
  263.                 text: 'Full Time Contract', value: 'Full Time Contract'
  264.             }
  265.                 ]
  266.                         },{
  267.             xtype: 'selectfield',
  268.             label: 'Salary (CAD$): From',
  269.              itemId: 'salaryf',
  270.             labelAlign: 'top',
  271.             labelWidth: '100%',
  272.             name:'salaryf',
  273.             options: [{
  274.                 text: 'Any', value: 'ANY'
  275.             }, {
  276.                 text: '20000', value: '20000'
  277.             }, {
  278.                 text: '30000', value: '30000'
  279.             }, {
  280.                 text: '40000', value: '40000'
  281.             },{
  282.                 text: '50000', value: '50000'
  283.             }, {
  284.                 text: '60000', value: '60000'
  285.             }, {
  286.                 text: '70000', value: '70000'
  287.             }, {
  288.                 text: '80000', value: '80000'
  289.             }, {
  290.                 text: '90000', value: '90000'
  291.             }, {
  292.                 text: '100000', value: '100000'
  293.             }, {
  294.                 text: '100000+', value: '100000+'
  295.             }
  296.                
  297.                 ]
  298.                         },{
  299.             xtype: 'selectfield',
  300.             label: 'to',
  301.              itemId: 'salaryt',
  302.             labelAlign: 'top',
  303.             labelWidth: '100%',
  304.             name: 'salaryto',
  305.             options: [{
  306.                 text: 'Any', value: 'ANY'
  307.             }, {
  308.                 text: '20000', value: '20000'
  309.             }, {
  310.                 text: '30000', value: '30000'
  311.             }, {
  312.                 text: '40000', value: '40000'
  313.             },{
  314.                 text: '50000', value: '50000'
  315.             }, {
  316.                 text: '60000', value: '60000'
  317.             }, {
  318.                 text: '70000', value: '70000'
  319.             }, {
  320.                 text: '80000', value: '80000'
  321.             }, {
  322.                 text: '90000', value: '90000'
  323.             }, {
  324.                 text: '100000', value: '100000'
  325.             }, {
  326.                 text: '100000+', value: '100000+'
  327.             }
  328.                 ]
  329.                         },{
  330.             xtype: 'selectfield',
  331.             label: 'Posted in last (Days):',
  332.              itemId: 'dposted',
  333.             labelAlign: 'top',
  334.             labelWidth: '100%',
  335.             name:'dposted',
  336.                             options: [{
  337.                                 text: '30', value: '30'
  338.                             }, {
  339.                                 text: '60', value: '60'
  340.                             }, {
  341.                                 text: '90', value: '90'
  342.                             }
  343.                 ]
  344.                         }
  345.                             ],
  346.                 dockedItems: [{
  347.                         xtype: 'toolbar',
  348.                         itemId: 'toolbar',
  349.                         dock: 'bottom',
  350.                         height: '36',
  351.                         items: [
  352.                             { xtype: 'button', text: 'Reset',itemId: 'reset',scope: this,
  353.                             handler:  resetButtonHandler  },
  354.                             { xtype: 'spacer'},
  355.                             { xtype: 'button', text: 'Submit',
  356.                             handler: submitButtonHandler }                                                  
  357.                             ]
  358.                     }]
  359.             });
  360.                     SearchJobsForm.form.superclass.initComponent.call(this);
  361.                 }
  362.        
  363.             });
  364.          
  365.         Ext.setup({
  366.         tabletStartupScreen: 'tablet_startup.png',
  367.         phoneStartupScreen: 'phone_startup.png',
  368.         icon: 'icon.png',
  369.         glossOnIcon: false,
  370.         onReady: function(){
  371.             var form = new SearchJobsForm.form();
  372.             form.show();
  373.            //var jobList = new SearchJobsForm.jobsList;              
  374.            // jobList.show();
  375.         }
  376.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement