1class SitsNearTo extends Scr { 2 3 constructor(p) { 4 super(); 5 this.panels = this.getFullWidthDiv() 6 this.optionsPanel = new CollapsablePanel({title:'search options', target:this.panels}); 7 this.optionsDiv = this.optionsPanel.getInner(); 8 var areaDiv = PrefDiv.get('Area to search') 9 this.areaRadio = new RadioPref ( 10 {setting:"sitNearToArea", radios:[{label:"1 space", value:1}, {label:"2 spaces", value:2}, {label:"3 spaces", value:3}, {label:"4 spaces", value:4}], onChange:this.getSitNearTo.bind(this), default:2, target:areaDiv}) 11 this.optionsDiv.append(areaDiv) 12 this.dateFrom = new DateBox({label:'Date from', val:new Date().setDate(new Date().getDate() - 356), onChange:this.getSitNearTo.bind(this), width:'120px', target:this.optionsDiv}) 13 this.tableDiv = Table.getContainer() 14 this.table = new Table({target:this.tableDiv, callback:this.callbackFromTable.bind(this), isEditable:false}); 15 this.addContent(this.panels, this.tableDiv); 16 var navs = [] 17 navs.push({txt:'Back', click:function(){crumbs.back()}}); 18 this.addNav({navs:navs}); 19 } 20 21 set(p) { 22 this.userId = p.userId; 23 this.userName = p.firstName + " " + p.lastName; 24 this.show(); 25 this.getSitNearTo(); 26 } 27 28 resizeDivs() { 29 var h = this.getContentHeight()- this.tableDiv.position().top; 30 this.tableDiv.css('height', h + 'px'); 31 } 32 33 show() { 34 this.showScreen('Who ' + this.userName + ' sits near to', this.show.bind(this)) 35 } 36 37 getSitNearTo() { 38 doPost({action:'getWhoSitsNearTo', targetUserId:this.userId, area:this.areaRadio.getVal(), dateFrom:this.dateFrom.getVal()}, this.gotSitNearTo.bind(this)); 39 } 40 41 gotSitNearTo(d) { 42 var r = 0 43 //copy over seat plan info to each matching row. 44 while(r < d.tableData.rows.length) { 45 var match=false; 46 for(var i=(d.seatPlans.length-1);i>=0;i--) { 47 if(d.tableData.rows[r].seatPlanId==d.seatPlans[i].seatPlanId) { 48 match = true; 49 while (d.tableData.rows[r].seatPlanId==d.seatPlans[i].seatPlanId) { 50 var row = d.tableData.rows[r], sp = d.seatPlans[i] 51 row.planName = sp.planName 52 row.dateFrom = sp.dateFrom 53 row.dateTo = sp.dateTo 54 row.groupName = sp.groupName 55 row.groupId = sp.groupId 56 row.seatPlanId = sp.seatPlanId 57 r +=1 58 if(r==d.tableData.rows.length) break; 59 } 60 break; 61 } 62 } 63 if(match) { 64 d.seatPlans.splice(i,1); //speed up searching for the next one... 65 } else { 66 console.log('no match - should not happen.') 67 r +=1 68 } 69 } 70 this.table.makeTable(d.tableData) 71 } 72 73 callbackFromTable(e) { 74 Groups.showSeatingPlan({self:this, groupId:e.data.id.groupId, seatPlanId:e.data.id.seatPlanId}) 75 } 76}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.