1 /** 2 * @author Amit Kumar 3 * @date 01/21/2009 4 * This component displays the result summary. 5 * @class Monk.component.SummaryComponent 6 * @description Provides Result Summary/ Work Selection tool. 7 * @extends Workbench.component.Component 8 * 9 */ 10 11 String.prototype.ellipse = function(maxLength){ 12 if(this.length > maxLength){ 13 return this.substr(0, maxLength-3) + '...'; 14 } 15 return this; 16 }; 17 18 19 Monk.component.SummaryComponent = function(args) { 20 this.queryParam = null; 21 this.viewport = null; 22 this.timelineWin = null; 23 this.chartWin = null; 24 this.eventSource = null; 25 this.saveDialog = null; 26 this.type = null; // "Result type -Similarity/Search or Browse" 27 this.refreshCharts = false; 28 this.featureLemmaGenderChart = {}; 29 this.featureSpellingGenderChart = {}; 30 this.summaryMessage = null; 31 // used to automatically select the items in the resultstore. 32 this.selectAll = false; 33 this.showSaveOption = false; 34 35 this.tableDataMap = {}; // tracks rows and checkboxes that have been selected. 36 this.workpartList = []; // stores workpart ids. used when loading a workset in order to select the workpart checkboxes. 37 this.getWorkparts = false; 38 39 // stores the workset information in a store -used nu the Select Workset widget 40 this.worksetStore = new Ext.data.Store({ 41 url: Monk.data.PROXY_URL + 'get/ProjectManager.getWorksets', 42 baseParams: {projectId: Monk.component.dataManager.getProjectId()}, 43 autoLoad: true, 44 reader : new Ext.data.XmlReader({record : 'workset', id : '@id'} 45 , new Ext.data.Record.create([ 46 {name : 'id', mapping : '@id'}, 47 'label', 48 'workList', 49 'trainingList', 50 'trainingListRating', 51 {name:'countWorks', mapping:'workList',convert: function(value){ 52 if(value==null){ 53 return 0; 54 } 55 return value.split(',').length; 56 }}, 57 {name: 'dateCreated', mapping:'date'}, 58 {name: 'dateAccessed', mapping:'date'} 59 ])) 60 }); 61 62 Monk.component.SummaryComponent.superclass.constructor.call(this, args); 63 } 64 65 66 Workbench.extend(Monk.component.SummaryComponent , Workbench.component.Component, { 67 label : "Result Summary", 68 description : "This component displays result summary", 69 "window" : this.window, 70 displayText: true, 71 beforeExit : function() { 72 // destroy the results grid and remove any listeners it might have set 73 var results = Ext.getCmp('document-results'); 74 results.getStore().un('load', this.onLoad, this); 75 results.getStore().un('loadexception', this.onLoadException, this); 76 results.destroy(); 77 }, 78 /*The popup window specific functions -displays existing worksets for the user to chose from*/ 79 80 // cache the workset information 81 lookup : {}, 82 //displays the worksetInformation 83 showWorksetChooser : function(el, callback){ 84 if(!this.win){ 85 this.initTemplates(); 86 87 var formatData = function(data){ 88 data.id=data.id; 89 data.name = data.label; 90 data.shortName = data.label.ellipse(15); 91 format="Y-m-d H:i:s.0"; 92 var dt = new Date(); 93 if(data.dateCreated!=null){ 94 try{ 95 dt = Date.parseDate(data.dateCreated,format); 96 }catch(err){ 97 98 } 99 } 100 data.date = dt; 101 this.lookup[data.id] = data; 102 return data; 103 }; 104 105 this.view = new Ext.DataView({ 106 tpl: this.thumbTemplate, 107 singleSelect: true, 108 overClass:'x-view-over', 109 itemSelector: 'div.thumb-wrap', 110 emptyText : '<div style="padding:10px;">No worksets match the specified filter</div>', 111 store: this.worksetStore, 112 listeners: { 113 'selectionchange': {fn:this.showDetails, scope:this, buffer:100}, 114 'dblclick' : {fn:this.doCallback, scope:this}, 115 'loadexception' : {fn:this.onLoadException, scope:this}, 116 'beforeselect' : {fn:function(view){ 117 return view.store.getRange().length > 0; 118 }} 119 }, 120 prepareData: formatData.createDelegate(this) 121 }); 122 123 this.win = new Ext.Window({ 124 title: 'Choose a Workset', 125 id: 'img-chooser-dlg', 126 layout: 'border', 127 width: 475, 128 height: 350, 129 minWidth: 400, 130 minHeight: 300, 131 modal: true, 132 closeAction: 'hide', 133 border: false, 134 items: [{ 135 id: 'img-chooser-view', 136 region: 'center', 137 autoScroll: true, 138 items: this.view, 139 tbar:[{ 140 text: 'Filter:' 141 },{ 142 xtype: 'textfield', 143 id: 'filter', 144 selectOnFocus: true, 145 width: 100, 146 listeners: { 147 'render': {fn:function(){ 148 Ext.getCmp('filter').getEl().on('keyup', function(){ 149 this.filter(); 150 }, this, {buffer:500}); 151 }, scope:this} 152 } 153 }, ' ', '-', { 154 text: 'Sort By:' 155 },{ 156 id: 'sortSelect', 157 xtype: 'combo', 158 typeAhead: true, 159 triggerAction: 'all', 160 width: 70, 161 listWidth: 70, 162 editable: false, 163 mode: 'local', 164 displayField: 'label', 165 valueField: 'value', 166 lazyInit: false, 167 store: new Ext.data.SimpleStore({ 168 fields: ['label', 'value'], 169 data : [['Label','label'], ['Date','dateCreated']] 170 }), 171 listeners: { 172 'select': {fn:this.sortWorksets, scope:this} 173 } 174 }] 175 },{ 176 id: 'img-detail-panel', 177 layout: 'border', 178 region: 'east', 179 split: true, 180 width: 150, 181 minWidth: 150, 182 maxWidth: 250, 183 items: [{ 184 id: 'img-panel', 185 region: 'center', 186 title: 'Details', 187 border: false 188 },{ 189 id: 'wset-option', 190 region: 'south', 191 height: 100, 192 border: false, 193 items:[{ 194 border: false, 195 title: 'Save options', 196 xtype: 'form', 197 id: 'save-option-form', 198 labelWidth: 0, 199 defaults: {labelSeparator: ''}, 200 defaultType: 'radio', 201 bodyStyle: 'margin-top: 3px;', 202 items: [{ 203 boxLabel: 'Overwrite', 204 name: 'saveoption', 205 inputValue: 'overwrite' 206 },{ 207 boxLabel: 'Overwrite Training', 208 name: 'saveoption', 209 inputValue: 'overwrite_training' 210 },{ 211 checked: true, 212 boxLabel: 'Append', 213 name: 'saveoption', 214 inputValue: 'append' 215 }] 216 }] 217 }] 218 }], 219 buttons: [{ 220 id: 'ok-btn', 221 text: 'Save', 222 handler: this.doCallback, 223 scope: this 224 },{ 225 text: 'Cancel', 226 handler: function(){ this.win.hide(); }, 227 scope: this 228 }], 229 keys: { 230 key: 27, // Esc key 231 handler: function(){ this.win.hide(); }, 232 scope: this 233 } 234 }); 235 } 236 237 this.reset(); 238 this.win.show(el); 239 this.callback = callback; 240 this.animateTarget = el; 241 }, 242 // Two templates are initied here -one for thumbnail view and other 243 // is a detailed view -NEEDS updating... Just trying to make it work for now. 244 initTemplates : function(){ 245 this.thumbTemplate = new Ext.XTemplate( 246 '<tpl for=".">', 247 '<div class="thumb-wrap" id="{id}">', 248 '<div class="thumb">{label}</div>', 249 '</div>', 250 '</tpl>' 251 ); 252 this.thumbTemplate.compile(); 253 this.detailsTemplate = new Ext.XTemplate( 254 '<div class="details">', 255 '<tpl for=".">', 256 '<b>Name:</b> ', 257 '<span>{label}</span><br/>', 258 '<b>Size:</b> ', 259 '<span>{countWorks} Work/Workparts</span><br/>', 260 '<b>Created:</b> ', 261 '<span>{dateCreated}</span>', 262 '</tpl>', 263 '</div>' 264 ); 265 this.detailsTemplate.compile(); 266 }, 267 // called when user clicks on a workset thumbnail 268 showDetails : function(){ 269 var selNode = this.view.getSelectedNodes(); 270 var detailEl = Ext.getCmp('img-panel').body; 271 if(selNode && selNode.length > 0){ 272 selNode = selNode[0]; 273 Ext.getCmp('ok-btn').enable(); 274 var data = this.lookup[selNode.id]; 275 this.detailsTemplate.overwrite(detailEl, data); 276 }else{ 277 Ext.getCmp('ok-btn').disable(); 278 detailEl.update(''); 279 } 280 }, 281 // filter function for searching a project for worksets 282 filter : function(){ 283 var filter = Ext.getCmp('filter'); 284 this.view.store.filter('label', filter.getValue()); 285 }, 286 // sort option for the workset 287 sortWorksets : function(){ 288 var v = Ext.getCmp('sortSelect').getValue(); 289 this.view.store.sort(v); 290 }, 291 // reset show all the worksets 292 reset : function(){ 293 if(this.win.rendered){ 294 Ext.getCmp('filter').reset(); 295 this.view.getEl().dom.scrollTop = 0; 296 } 297 this.view.store.clearFilter(); 298 }, 299 doCallback : function(){ 300 var selNode = this.view.getSelectedNodes()[0]; 301 var callback = this.callback; 302 var lookup = this.lookup; 303 this.win.hide(this.animateTarget, function(){ 304 if(selNode && callback){ 305 var data = lookup[selNode.id]; 306 callback(data); 307 } 308 }); 309 }, 310 onLoadException : function(v,o){ 311 this.view.getEl().update('<div style="padding:10px;">Error loading worksets.</div>'); 312 }, 313 314 /*end of the workset related popup*/ 315 316 showSummaryMessage: function(doGrowl) { 317 if (this.summaryMessage == null) { 318 var store = Monk.component.dataManager.getResultStore(); 319 320 var resultCount = store.getCount(); 321 if (resultCount == 1) { 322 resultCount += ' result'; 323 } else if (resultCount > 1) { 324 resultCount += ' results'; 325 } else { 326 resultCount = 0; 327 } 328 329 var authors = []; 330 store.each(function(record) { 331 var author = record.get('author'); 332 if (authors.indexOf(author) == -1) authors.push(author); 333 }, this); 334 var authorCount = authors.length; 335 if (authorCount == 1) authorCount += ' author'; 336 else authorCount += ' authors'; 337 338 var genres = []; 339 store.each(function(record) { 340 var genre = record.get('genre'); 341 if (genres.indexOf(genre) == -1) genres.push(genre); 342 }, this); 343 var genreCount = genres.length; 344 if (genreCount == 1) genreCount += ' genre'; 345 else genreCount += ' genres'; 346 347 var earliestCirculation = 0; 348 var latestCirculation = 0; 349 store.each(function(record) { 350 var circulationStart = record.get('circulationStart'); 351 var circulationEnd = record.get('circulationEnd'); 352 if (circulationStart < earliestCirculation || earliestCirculation == 0) earliestCirculation = circulationStart; 353 if (circulationEnd > latestCirculation) latestCirculation = circulationEnd; 354 }, this); 355 var circulationPeriod = earliestCirculation + '-' + latestCirculation; 356 357 if (resultCount == 0) { 358 this.summaryMessage = 'No results found.'; 359 } else { 360 this.summaryMessage = 'Found '+resultCount+' matching the search criterion, '+ 361 'with a total of '+authorCount+ ', comprising '+genreCount+'. The circulation period '+ 362 'of the documents is '+circulationPeriod+'.'; 363 } 364 } 365 if (doGrowl) { 366 Monk.component.messenger.growl( 367 'Results Summary', 368 this.summaryMessage, 369 this.window 370 ); 371 } else { 372 Monk.component.messenger.show({ 373 title: 'Results Summary', 374 msg: this.summaryMessage, 375 width: 470, 376 modal: false 377 }, this.window); 378 } 379 }, 380 381 //called by the event handler -actually does the search and displays the result 382 // need to make this general to work with other tools 383 setQueryParam: function(data){ 384 if(data==null){ 385 Workbench.console.error("data is null"); 386 return; 387 } 388 this.queryParam = data; 389 }, 390 // return the query parameters 391 getQueryParam: function(){ 392 return this.queryParam; 393 }, 394 395 // called to group work results 396 groupBy: function(item,checked){ 397 if (checked) { 398 var resultStore = Monk.component.dataManager.getResultStore(); 399 var field = item.value; 400 401 if (resultStore.getCount() > 0) { 402 // groupby option 403 var loadMask = Ext.getCmp('document-results').loadMask; 404 loadMask.show(); 405 406 resultStore.clearGrouping.defer(50, resultStore); 407 resultStore.on('datachanged', function(store) { 408 loadMask.hide(); 409 store.on('datachanged', function(store){ 410 this.showWorkparts(store); 411 }, this, {single: true}); 412 store.groupBy.defer(50, store, [field]); 413 }, this, {single: true}); 414 } else { 415 // set the field for later groupings 416 resultStore.groupField = field; 417 } 418 } else { 419 // no grouping necessary 420 } 421 }, 422 displayPieChart: function() { 423 var map = new Map; 424 Monk.component.dataManager.getResultStore().each(function(record,options){ 425 var key = record.data.circulationPeriod; 426 var val = map.get(key); 427 if(val==null){ 428 map.put(key,1); 429 }else{ 430 map.put(key,val+1); 431 } 432 433 i++; 434 },this); 435 436 var labelList= []; 437 var valueList=[]; 438 var totalCount=0; 439 for(var i = 0; i++ < map.size; map.next()){ 440 labelList.push(map.key()+ " ["+map.value()+"]"); 441 valueList.push(map.value()); 442 totalCount= totalCount + map.value(); 443 } 444 // Workbench.console.info(labelList.length +" " + valueList.length); 445 446 GChart.render({ 447 applyTo: 'piechart_img', 448 encoding:'e', 449 type: 'p3', 450 data: [valueList], 451 title: 'Search Results distributed by Circulation Period. '+ totalCount+ " works found.", 452 colors: ['FF0000','0000FF'], 453 pielabels:[labelList.join('|')], 454 size: '700x300' 455 }); 456 457 // Ext.getCmp('chartsTab').setActiveTab("circulationPeriodTab"); 458 459 }, 460 461 // displays timeline 462 displayTimeline: function(){ 463 //Workbench.console.info("here is displayTimeline "+ pressed); 464 this.eventSource = new Timeline.DefaultEventSource(); 465 //debugger; 466 var min=2000; 467 var max=0; 468 var jsonString = "{ 'events':["; 469 Monk.component.dataManager.getResultStore().each(function(record,options){ 470 if(record.data.circulationStart!=null){ 471 if(min> record.data.circulationStart){ 472 min=record.data.circulationStart; 473 } 474 if(max< record.data.circulationStart){ 475 max=record.data.circulationStart; 476 } 477 } 478 var description = record.data.author; 479 if(record.data.workLabel!=null){ 480 description = record.data.workLabel + " by " +description; 481 } 482 483 jsonString = jsonString +"{\ 484 'start' : "+record.data.circulationStart+",\ 485 'title' : "+Ext.util.JSON.encode(record.data.label)+",\ 486 'description' : "+Ext.util.JSON.encode(description)+",\ 487 },"; 488 },this); 489 jsonString = jsonString+"]}"; 490 491 var mid = max-min; 492 mid = parseInt(min)+parseInt(mid/2); 493 if(mid<0 || min<=0 || max<=0){ 494 mid=1750; 495 } 496 //alert("mid is " + mid+ " - " + min + " - " + max); 497 var bandInfos = [ 498 Timeline.createBandInfo({ 499 date: mid, 500 showEventText: true, 501 eventSource: this.eventSource, 502 width: "60%", 503 intervalUnit: Timeline.DateTime.YEAR, 504 intervalPixels: 50 505 }), 506 Timeline.createBandInfo({ 507 date: mid, 508 showEventText: false, 509 eventSource: this.eventSource, 510 width: "20%", 511 intervalUnit: Timeline.DateTime.DECADE, 512 intervalPixels: 300 513 }), 514 Timeline.createBandInfo({ 515 date: mid, 516 showEventText: false, 517 eventSource: this.eventSource, 518 width: "20%", 519 intervalUnit: Timeline.DateTime.CENTURY, 520 intervalPixels: 200 521 }) 522 523 ]; 524 525 bandInfos[1].syncWith = 0; 526 bandInfos[1].highlight = true; 527 528 bandInfos[2].syncWith = 1; 529 bandInfos[2].highlight = true; 530 531 532 //Workbench.console.info(jsonString); 533 if(Ext.get("my-timeline")!=null){ 534 var tl = Timeline.create(Ext.get("my-timeline").dom, bandInfos); 535 this.eventSource.loadJSON(Ext.util.JSON.decode(jsonString),"http://127.0.0.1"); 536 } 537 }, 538 initializeSaveDialog : function() { 539 var worksetName = new Ext.form.TextField({ 540 fieldLabel: 'Name', 541 name: 'name', 542 width: 175, 543 allowBlank: false 544 }); 545 546 var saveForm = new Ext.form.FormPanel({ 547 labelAlign: 'right', 548 labelWidth: 70, 549 border: false 550 }); 551 552 saveForm.add(worksetName); 553 554 this.saveDialog = new Ext.Window({ 555 title: 'Save Workset', 556 height: 100, 557 width: 300, 558 modal: true, 559 shadow: true, 560 plain: true, 561 border: false, 562 collapsible: false, 563 items: saveForm, 564 buttons: [{ 565 text: 'Save', 566 handler: function(){ 567 if (saveForm.getForm().isValid()) { 568 var values = saveForm.getForm().getValues(); 569 var worksetName = values.name; 570 this.createWorksetSkeleton(worksetName); 571 saveForm.getForm().reset(); 572 } 573 }, 574 scope: this 575 },{ 576 text: 'Cancel', 577 handler: function(){ 578 this.saveDialog.hide(); 579 }, 580 scope: this 581 }], 582 listeners: { 583 show: function(){ 584 worksetName.clearInvalid(); 585 worksetName.focus(false, 10); 586 } 587 } 588 }); 589 590 this.saveDialog.show(); 591 }, 592 createWorksetSkeleton : function(worksetName) { 593 var resultPanel = Ext.getCmp("document-results"); 594 var workList = []; 595 596 for (var id in this.tableDataMap) { 597 workList.push(id); 598 } 599 600 if (workList.length == 0) { 601 Monk.component.messenger.alert('Monk Workbench', 'You have not selected any works. Cannot create workset without \ 602 any selected works', 603 this.window.parent ? this.window.parent.window : this.window); 604 return; 605 } 606 Monk.component.dataManager.setWorksetName(worksetName); 607 Monk.component.dataManager.clearWorklist(); 608 Monk.component.dataManager.setWorklist(workList); 609 var workset = Monk.component.dataManager.getWorkset(); 610 Monk.data.workset.createWorkset(workset); 611 }, 612 613 newWorkset : function(){ 614 if (this.saveDialog == null){ 615 this.initializeSaveDialog(); 616 } else { 617 this.saveDialog.show(); 618 } 619 }, 620 621 showWorkparts: function(store) { 622 var rowsToExpand = []; 623 for (var id in this.tableDataMap) { 624 if (this.tableDataMap[id] == 'workpart') { 625 var workId = id.match(/(^[^-]+-[^-]+)/)[0]; 626 if (index != -1) { 627 this.workpartList.push(id); 628 if (rowsToExpand.indexOf(workId) == -1) rowsToExpand.push(workId); 629 } 630 } 631 } 632 for (var i = 0, len = rowsToExpand.length; i < len; i++) { 633 var index = store.indexOfId(rowsToExpand[i]); 634 if (index != -1) this.rowExpander.expandRow(index); 635 } 636 }, 637 638 // create the interface here 639 init: function(){ 640 var url = Monk.data.PROXY_URL + 'get/CorpusManager.getDocumentTOC?id='; 641 this.rowExpander = new AjaxRowExpander({}, url); 642 this.rowExpander.on('updated', function(expander, body) { 643 var links = Ext.DomQuery.select('a', body.dom); 644 for (var i = 0, len = links.length; i < len; i++) { 645 var link = links[i]; 646 if (i == 0) { 647 // remove the work link, we only want workparts 648 var linkEl = Ext.get(link); 649 linkEl.parent('ul', true).setAttribute('style', 'margin-left: -10px !important;'); 650 linkEl.remove(); 651 } else { 652 // make link clickable 653 Ext.get(link).on('click', function(event, element){ 654 var id = element.getAttribute('wpId'); 655 var text = element.firstChild.data; 656 this.notify(new Monk.event.chunk.ChunkSelected({ 657 label: 'Text workpart selected: '+'"'+id+'"' 658 }),{id: id, text: text, displayText: true}); 659 }, this); 660 // add checkbox 661 var id = link.getAttribute('wpId'); 662 var checked = false; 663 if (this.workpartList.indexOf(id) != -1) { 664 checked = true; 665 this.workpartList.remove(id); 666 } 667 var checkbox = Ext.DomHelper.insertBefore(link, '<input id="check-'+id+'" type="checkbox" class="x-form-checkbox x-form-field"/>'); 668 Ext.get(checkbox).on('click', function(event, element){ 669 var checked = element.checked; 670 var link = Ext.get(element).next('a', true); 671 var id = link.getAttribute('wpId'); 672 var label = link.firstChild.data; 673 674 if (checked) { 675 var workId = id.match(/(^[^-]+-[^-]+)/)[0]; 676 var showNotice = false; 677 if (this.tableDataMap[workId]) { 678 var grid = Ext.getCmp('document-results'); 679 var selections = grid.getSelectionModel().getSelections(); 680 for (var j = 0, len2 = selections.length; j < len2; j++) { 681 var selection = selections[j]; 682 if (selection.id == workId) { 683 grid.getSelectionModel().deselectRow(grid.getStore().indexOf(selection)); 684 showNotice = true; 685 } 686 } 687 } 688 if (showNotice) { 689 Monk.component.messenger.alert( 690 'Notice', 691 'Workparts belonging to same work cannot be selected along with the work. The work has been deselected.', 692 this.window 693 ); 694 } 695 this.tableDataMap[workId] = 'noselect'; 696 this.tableDataMap[id] = 'workpart'; 697 } else { 698 delete this.tableDataMap[id]; 699 } 700 701 this.notify(new Monk.event.chunk.ChunkChecked({ 702 label: 'Text workpart '+(checked ? "" : "un")+'checked: '+'"'+id+'"' 703 }), {id: id, text: label, chunkType: 'workpart', checked: checked}); 704 }, this); 705 if (checked) checkbox.click(); 706 } 707 } 708 }, this); 709 710 var rowListeners = { 711 rowselect: { 712 fn: function(sm, rowIdx, r) { 713 for (var id in this.tableDataMap) { 714 if (id.indexOf(r.data.id) == 0 && id != r.data.id) { 715 var input = Ext.get('check-'+id); 716 if (input) { 717 input.dom.checked = false; 718 input.dom.defaultChecked = false; 719 Monk.component.messenger.show({ 720 title: 'Notice', 721 msg: 'Workparts belonging to same work cannot be selected along with the work. The workpart has been deselected.', 722 width: 470, 723 modal: false 724 }, this.window); 725 } else { 726 Workbench.console.info('cant find input: '+id); 727 } 728 } 729 } 730 this.tableDataMap[r.data.id] = 'work'; 731 // Workbench.console.info("here in rowListener... : " + r.data.id +" "+this.displayText); 732 this.notify(new Monk.event.chunk.ChunkChecked({ 733 label: 'Text work checked: '+'"'+r.data.id+'"' 734 }), {id: r.data.id, text: r.data.label, chunkType: 'work', checked: true}); 735 736 this.notify(new Monk.event.chunk.ChunkSelected({ 737 label: 'Text work selected: '+'"'+r.data.id+'"' 738 }), {id: r.data.id, text: r.data.label, displayText: this.displayText}); 739 740 741 }, 742 scope: this 743 }, 744 rowdeselect: { 745 fn: function(sm, rowIdx, r) { 746 delete this.tableDataMap[r.data.id]; 747 748 this.notify(new Monk.event.chunk.ChunkChecked({ 749 label: 'Text work unchecked: '+'"'+r.data.id+'"' 750 }), {id: r.data.id, text: r.data.label, chunkType: 'work', checked: false}); 751 }, 752 scope: this 753 } 754 }; 755 756 var checkboxItemSelectModel = new Ext.ux.CheckboxSelectionModel({ 757 listeners: rowListeners 758 }); 759 760 this.onLoad = function(store){ 761 var append = store.lastOptions.add; 762 var isWorkset = store.baseParams.worksetIdCriterion != undefined; 763 if (append && isWorkset) { 764 // add original workparts 765 for (var id in this.tableDataMap) { 766 if (this.tableDataMap[id] == 'workpart') { 767 if (this.workpartList.indexOf(id) == -1) { 768 this.workpartList.push(id); 769 } 770 var record = store.getById(id); 771 if (record) store.remove(record); 772 } 773 } 774 this.getWorkparts = true; 775 } 776 var grid = Ext.getCmp('document-results'); 777 store.each(function(record){ 778 if (record.get('type') == 'workpart') { 779 // add workparts to the workpartList so we can expand their parent works later 780 var workpartId = record.get('id'); 781 this.workpartList.push(workpartId); 782 this.getWorkparts = true; 783 store.remove(record); 784 } else if (isWorkset) { 785 if (this.tableDataMap[record.id] != 'noselect') { 786 grid.getSelectionModel().selectRecords([record], true); 787 } 788 } 789 }, this); 790 this.tableDataMap = {}; 791 if (this.getWorkparts) { 792 // sometimes the workpartList is null 793 if(this.workpartList.join(',')!=""){ 794 // get the parent works for the workparts 795 var loadMask = grid.loadMask; 796 loadMask.show(); 797 Ext.Ajax.request({ 798 url: Monk.data.PROXY_URL + 'get/SearchManager.getWorksWithFeature', 799 params: {workpartIdCriterion: this.workpartList.join(',')}, 800 callback: function(options, success, response) { 801 store.on('load', function(store, records, options){ 802 for (var i = 0, len = records.length; i < len; i++) { 803 var index = store.indexOf(records[i]); 804 // expand the parent works then check off the workparts 805 this.rowExpander.expandRow(index); 806 } 807 }, this, {single: true}); 808 store.baseParams = {}; 809 store.loadData(response.responseXML, true); 810 loadMask.hide(); 811 }, 812 scope: this 813 }); 814 } 815 this.getWorkparts = false; 816 } else { 817 // select all by default 818 this.displayText=false; 819 Ext.getCmp("document-results").getSelectionModel().selectAll(); 820 this.displayText=true; 821 822 this.showSummaryMessage(true); 823 } 824 }; 825 this.onLoadException = function(proxy, data, callback, exception) { 826 Monk.component.messenger.show({ 827 title: 'Results Summary', 828 msg: 'An error occurred when loading the results:<br/>'+exception, 829 width: 350, 830 modal: true 831 }, this.window); 832 }; 833 834 var resultStore = Monk.component.dataManager.getResultStore(); 835 resultStore.on('load', this.onLoad, this); 836 resultStore.on('loadexception', this.onLoadException, this); 837 838 this.viewport = new Ext.Viewport({ 839 layout: 'fit', 840 renderTo: 'tab-container', 841 defaults: {border: false}, 842 items:{ 843 xtype: 'tabpanel', 844 activeTab: 0, 845 items:[{ 846 xtype: 'grid', 847 id: 'document-results', 848 title:'Table', 849 height:400, 850 width:600, 851 autoScroll:true, 852 store: resultStore, 853 loadMask: {msg:'Loading results, please wait.'}, 854 plugins: this.rowExpander, 855 listeners: { 856 rowmousedown: {fn: function(grid, rowI, e){ 857 var target = Ext.get(e.target); 858 if (target.hasClass('toc') || target.first('div[class=toc]') != null) { 859 e.stopPropagation(); 860 } else { 861 grid.fireEvent('doRowmousedown', grid, rowI, e); 862 } 863 }, scope: this}, 864 sortchange: {fn: function(grid, sortInfo) { 865 this.showWorkparts(grid.getStore()); 866 }, scope: this} 867 }, 868 columns: [ 869 checkboxItemSelectModel, 870 this.rowExpander, 871 {id:'title',header: "Title", width: 180, dataIndex: 'label', sortable: true}, 872 {id:'author',header: "Author", width: 120, dataIndex: 'author', sortable: true, 873 renderer:function(value,p,r){ 874 if(r.data['authorBirthYear'] !="null" && r.data['authorDeathYear'] !="null"){ 875 return value+" ["+r.data['authorBirthYear']+"-"+r.data['authorDeathYear']+"]"; 876 }else if(r.data['authorBirthYear'] != "null"){ 877 return value+" ["+r.data['authorBirthYear']+"]"; 878 }else if(r.data['authorDeathYear'] !="null"){ 879 return value+" [?-"+r.data['authorDeathYear']+"]"; 880 } 881 return value; 882 }}, 883 {id:'circulationStart',header: "Circulation Date", width: 100, dataIndex: 'circulationStart', sortable: true}, 884 {id:'circulationPeriod',header: "Circulation Period", width: 100, dataIndex: 'circulationPeriod', sortable: true, hidden:true}, 885 {id:'work',header: "Work", width: 180, dataIndex: 'workLabel', sortable: true, hidden:true}, 886 {id:'gender',header: "Gender", width: 180, dataIndex: 'authorGender', sortable: true, hidden:true}, 887 {id:'genre',header: "Genre", width: 180, dataIndex: 'genre', sortable: true, hidden:true, 888 renderer: function(value, p, r){ 889 if(r.data['genre'] !="null" && r.data['subgenre']!=null){ 890 return r.data['genre'] +","+r.data['subgenre']; 891 }else if(r.data['genre'] !="null"){ 892 return r.data['genre']; 893 } 894 return value; 895 } 896 897 }, 898 {id:'collection',header: 'Collection', width: 30, dataIndex: 'collection', sortable: true, hidden: true}, 899 {id:'scoreRange',header: "Score Range", width: 180, dataIndex: 'scoreRange', sortable: true, hidden: true}, 900 {id:'score', header: "Score", width: 100, dataIndex: 'score', sortable: true, hidden:false, 901 renderer: function(value, metadata, record){ 902 var rValue = 255; 903 var gbValue = Math.floor(record.data['score'] * -255 + 255); 904 metadata.attr = 'style = "background-color: rgb('+rValue+','+gbValue+','+gbValue+');"'; 905 return value; 906 }} 907 ], 908 sm: checkboxItemSelectModel, 909 910 viewConfig: { 911 forceFit: true 912 }, 913 view: new Ext.grid.GroupingView({ 914 forceFit:true, 915 groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})' 916 }), 917 918 tbar: [{ 919 text:'Save', 920 tooltip: {title:'Save As Workset', 921 text:'Save the result as a workset' 922 }, 923 iconCls: 'save', 924 menu:{ 925 width:175, 926 items: [{ 927 text:'Save as a New Workset', 928 handler: this.newWorkset, 929 scope:this, 930 iconCls:'saveas' 931 932 },{ 933 text:'Add to an Existing Workset', 934 handler: function (btn){ 935 this.showWorksetChooser(btn.getEl(), this.setWorkset.createDelegate(this)); 936 }, 937 scope:this, 938 iconCls:'save' 939 }] 940 } 941 }, 942 '-', 943 { 944 text: 'Results Summary', 945 tooltip: {title:'Result Summary',text:'Displays summary information about the search results.'}, 946 iconCls: 'summary-icon', 947 scope: this, 948 handler: function(){ 949 this.showSummaryMessage(false); 950 } 951 }, 952 '-',{ 953 text:'Group by...', 954 tooltip: {title:'Display Options',text:'Group options, Choose Timeplot and other Charts'}, 955 iconCls: 'tabs', 956 menu:{ 957 width: 180, 958 items:[ 959 { 960 text: 'Group by Circulation Date', 961 value:'circulationPeriod', 962 group: 'rp-group', 963 checked: true, 964 checkHandler: this.groupBy, 965 scope:this, 966 iconCls: 'groupbydate-preview' 967 },{ 968 text: 'Group by Author', 969 value: 'author', 970 checked: false, 971 checkHandler: this.groupBy, 972 group: 'rp-group', 973 scope:this, 974 iconCls: 'groupbyauthor-preview' 975 },{ 976 text: 'Group by Authors\' Gender', 977 value: 'authorGender', 978 checked: false, 979 checkHandler: this.groupBy, 980 group: 'rp-group', 981 scope: this, 982 iconCls: 'groupbywork-preview' 983 },{ 984 text: 'Group by Corpus', 985 value: 'collection', 986 checked: false, 987 checkHandler: this.groupBy, 988 group: 'rp-group', 989 scope: this, 990 iconCls: 'groupbycollection-preview' 991 },{ 992 text: 'Group by Genre', 993 value: 'genre', 994 checked: false, 995 checkHandler: this.groupBy, 996 group: 'rp-group', 997 scope: this, 998 iconCls: 'groupbygenre-preview' 999 },{ 1000 text: 'Group by Work', 1001 value: 'workLabel', 1002 checked: false, 1003 checkHandler: this.groupBy, 1004 group: 'rp-group', 1005 scope: this, 1006 iconCls: 'groupbywork-preview' 1007 },{ 1008 text: 'Group by Score', 1009 value: 'scoreRange', 1010 checked: false, 1011 checkHandler: this.groupBy, 1012 group: 'rp-group', 1013 scope: this, 1014 iconCls: 'groupbywork-preview' 1015 } 1016 ] 1017 }, 1018 scope:this 1019 }, 1020 '-', 1021 { 1022 text:'Select All', 1023 tooltip: {title:'Select All Documents', text:'Select all the documents'}, 1024 iconCls: 'summary', 1025 scope:this, 1026 handler: function(btn, event){ 1027 this.displayText=false; 1028 Ext.getCmp("document-results").getSelectionModel().selectAll(); 1029 this.displayText=true; 1030 } 1031 }, 1032 '-', 1033 { 1034 text:'Unselect All', 1035 tooltip: {title:'Unselect All Documents', text:'Unselect all the documents'}, 1036 iconCls: 'summary', 1037 scope:this, 1038 handler: function(btn, event){ 1039 var resultPanel = Ext.getCmp("document-results"); 1040 resultPanel.getSelectionModel().each(function(rec,rowNum){ 1041 resultPanel.getSelectionModel().deselectRow(rowNum); 1042 }); 1043 } 1044 },'-', 1045 { 1046 text: 'Remove All', 1047 tooltip:{title:'Remove All Documents',text:'Remove all the documents'}, 1048 iconCls: 'remove', 1049 scope:this, 1050 handler: function(btn,event){ 1051 Workbench.console.info("Came here to remove all"); 1052 var resultPanel = Ext.getCmp("document-results"); 1053 resultPanel.getStore().removeAll(); 1054 var store = Monk.component.dataManager.getResultStore(); 1055 } 1056 } 1057 ] 1058 }, 1059 { 1060 title: 'Timeline', 1061 tooltip: {title:'Timelne',text:'Displays Distribution of results over circulation period.'}, 1062 id: 'timelineTab', 1063 html: '<div id="my-timeline" style="height: 100%; border: 1px solid #aaa; width:100%"></div>', 1064 listeners: { 1065 activate: { 1066 // TODO only fire when new data is available 1067 fn: this.displayTimeline, 1068 scope: this 1069 } 1070 } 1071 1072 }, 1073 1074 /* { 1075 title: 'Feature Comparison Charts', 1076 tooltip: {title:'Feature Comparison Charts',text:'Displays distribution of similarity score over circulation period and author\'s gender.'}, 1077 id: 'featuresComparisonTab', 1078 xtype: 'tabpanel', 1079 activeItem: 0, 1080 listeners:{ 1081 activate:{ 1082 fn: function(tab){ 1083 if (tab.getActiveTab().id == 'spelling_comparison') { 1084 Workbench.console.info("clicked on tab spelling comparison"); 1085 this.displayGenderSpellingComparison(); 1086 }else if(tab.getActiveTab().id == 'lemma_comparison'){ 1087 Workbench.console.info("clicked on tab lemma comparison"); 1088 this.displayGenderLemmaComparison(); 1089 } 1090 }, 1091 scope: this 1092 } 1093 }, 1094 items:[ 1095 { 1096 title: 'Spelling Comparison -Gender', 1097 id: 'spelling_comparison', 1098 html: '<img id="spelling_comparison_img" src=""/>', 1099 listeners:{ 1100 activate:{ 1101 fn: this.displayGenderSpellingComparison, 1102 scope: this 1103 } 1104 } 1105 1106 1107 },{ 1108 title: 'Lemma Comparison -Gender', 1109 id: 'lemma_comparison', 1110 html: '<img id="lemma_comparison_img" src=""/>', 1111 listeners:{ 1112 activate:{ 1113 fn: this.displayGenderLemmaComparison, 1114 scope: this 1115 } 1116 } 1117 } 1118 ] 1119 1120 },*/ 1121 { 1122 title: 'Charts', 1123 tooltip: {title:'Circulation Pie Chart',text:'Distribution of results over the circulation period.'}, 1124 id: 'chartsTab', 1125 xtype: 'tabpanel', 1126 activeItem: 0, 1127 listeners: { 1128 activate: { 1129 fn: function(tab) { 1130 if (tab.getActiveTab().id == 'circulationPeriodTab') { 1131 this.displayPieChart(); 1132 }else if(tab.getActiveTab().id == 'dispersionDecadesTab'){ 1133 this.displayBoxWhiskerCirculation(); 1134 }else if(tab.getActiveTab().id == 'dispersionGenderTab'){ 1135 this.displayBoxWhiskerGender(); 1136 } 1137 }, 1138 scope: this 1139 } 1140 }, 1141 items: [ 1142 { 1143 title: 'Circulation Period', 1144 id: 'circulationPeriodTab', 1145 html: '<img id="piechart_img" src=""/>', 1146 listeners: { 1147 activate: { 1148 // TODO only fire when new data is available 1149 fn: this.displayPieChart, 1150 scope: this 1151 } 1152 } 1153 }/*,{ 1154 title: 'Dispersion and Skewness of Results -Decades', 1155 id: 'dispersionDecadesTab', 1156 html: '<img id="boxchart_img" alt="Valid only for Similarity Results" src=""/>', 1157 listeners:{ 1158 activate:{ 1159 fn: this.displayBoxWhiskerCirculation, 1160 scope: this 1161 } 1162 } 1163 },{ 1164 title: 'Dispersion and Skewness of Results -Gender', 1165 id: 'dispersionGenderTab', 1166 html: '<img id="boxchart_img1" alt="Valid only for Similarity Results" src=""/>', 1167 listeners:{ 1168 activate:{ 1169 fn: this.displayBoxWhiskerGender, 1170 scope: this 1171 } 1172 } 1173 } 1174 1175 */ 1176 ] 1177 }] 1178 } 1179 }); 1180 }, 1181 1182 //event handler 1183 handle : function(monkEvent, data) { 1184 1185 if (monkEvent.instanceOf(Workbench.event.ComponentLoaded)) { 1186 1187 if (monkEvent.component == this) { 1188 // don't empty the resultstore 1189 //Monk.component.dataManager.getResultStore().removeAll(); 1190 // send notification to the advanced viewer that it needs to show 1191 // up 1192 Workbench.component.manager.notify(new Monk.event.view.ShowSearchOption( 1193 { 'label': 'Show Search Option'})); 1194 1195 Workbench.component.manager.notify( 1196 new Monk.event.view.ShowAdvancedSearchLink({label: 'Show Advanced Search Link'}) 1197 ); 1198 1199 1200 } 1201 1202 }else if (monkEvent.instanceOf(Monk.event.chunk.ChunksSimilarRetrieved)) { 1203 this.refreshCharts=true; 1204 this.displayPieChart(); 1205 this.displayTimeline(); 1206 this.displayBoxWhiskerCirculation(); 1207 this.refreshCharts=false; 1208 this.summaryMessage = null; 1209 Workbench.console.info("got the event: ChunksSimilarRetrieved"); 1210 if(this.selectAll){ 1211 Ext.getCmp("document-results").getSelectionModel().selectAll(); 1212 this.selectAll = false; 1213 1214 if(this.showSaveOption){ 1215 this.newWorkset(); 1216 this.showSaveOption = false; 1217 } 1218 } 1219 }else if (monkEvent.instanceOf(Monk.event.workbench.SimilarSearchQuery)) { 1220 // store this information that the results that this app will recieve 1221 // are the similar search results i.e. with score 1222 this.type = "Similarity"; 1223 this.setQueryParam(data); 1224 this.summaryMessage = null; 1225 var colModel=Ext.getCmp("document-results").getColumnModel(); 1226 colModel.setHidden(colModel.getIndexById("score"),false); 1227 }else if (monkEvent.instanceOf(Monk.event.workbench.AdvancedSearchQuery)) { 1228 // store this information that the results that this app will recieve 1229 // are the similar search results i.e. with score 1230 this.type = "AdvancedSearch"; 1231 this.setQueryParam(data[0]); 1232 this.summaryMessage = null; 1233 1234 if(Ext.getCmp("dispersionDecadesTab")!=null){ 1235 var chartsTabPanel=Ext.getCmp("chartsTab"); 1236 chartsTabPanel.remove(Ext.getCmp("dispersionDecadesTab"),true); 1237 } 1238 if(Ext.getCmp("dispersionGenderTab")!=null){ 1239 Ext.getCmp("dispersionGenderTab").hide(); 1240 var chartsTabPanel=Ext.getCmp("chartsTab"); 1241 chartsTabPanel.remove(Ext.getCmp("dispersionGenderTab"),true); 1242 } 1243 var colModel=Ext.getCmp("document-results").getColumnModel(); 1244 colModel.setHidden(colModel.getIndexById("score"),true); 1245 }else if (monkEvent.instanceOf(Monk.event.workset.WorksetCreated)) { 1246 this.saveDialog.hide(); 1247 var recordDef = Ext.data.Record.create([{ 1248 name: 'id' 1249 }, { 1250 name: 'label' 1251 }, { 1252 name: 'workList' 1253 }]); 1254 var workset = Monk.component.dataManager.getWorkset(); 1255 workset.id = workset.worksetId; 1256 workset.label = workset.worksetName; 1257 var record = new recordDef(workset); // creates a record with auto-ID 1258 var recordCopy = record.copy(workset.id); // make a copy with the correct ID 1259 this.worksetStore.add(recordCopy); 1260 var worksetName = Monk.component.dataManager.getWorksetName(); 1261 Monk.component.messenger.growl('Monk Workbench', 'Workset Created: ' + worksetName); 1262 }else if (monkEvent.instanceOf(Monk.event.workset.WorksetSaved)) { 1263 // reload data 1264 Monk.data.project.getWorksets(Monk.component.dataManager.getProjectId()); 1265 Monk.component.messenger.growl('Monk Workbench', 'Workset Saved'); 1266 }else if(monkEvent.instanceOf(Monk.event.workset.WorksetSelected)){ 1267 1268 }else if(monkEvent.instanceOf(Monk.event.chart.FeatureComparisonChartRetrieved)){ 1269 if(data.featureType=="spelling"){ 1270 this.featureSpellingGenderChart = {"url":data.imgUrl}; 1271 this.displayGenderSpellingComparison(); 1272 }else if(data.featureType=="lemma"){ 1273 this.featureLemmaGenderChart = {"url":data.imgUrl}; 1274 this.displayGenderLemmaComparison(); 1275 } 1276 }else if (monkEvent.instanceOf(Monk.event.chunk.AllChunksChecked)){ 1277 Workbench.console.info("Selected all now... "+data.showSaveOption); 1278 this.selectAll =true; 1279 this.showSaveOption =data.showSaveOption; 1280 } 1281 1282 1283 }, 1284 isValid: function(){ 1285 return true; 1286 }, 1287 //associate a workset with the search -works will be saved to the 1288 // selected workset 1289 setWorkset: function (data){ 1290 var option = Ext.getCmp('save-option-form').getForm().getValues()['saveoption']; 1291 var resultPanel = Ext.getCmp('document-results'); 1292 var documentArray = []; 1293 for (var id in this.tableDataMap) { 1294 documentArray.push(id); 1295 } 1296 // Workbench.console.info('new works'); 1297 // Workbench.console.info(documentArray); 1298 if (option == 'overwrite') { 1299 var workset = { 1300 'projectId': Monk.component.dataManager.getProjectId(), 1301 'worksetId': data.id, 1302 'worksetName': data.label, 1303 'workList': documentArray.join(",") 1304 } 1305 Monk.data.workset.saveWorkset(workset); 1306 } else if (option == 'append') { 1307 this.worklistConflicts = []; 1308 var conflict = false; 1309 var existingWorkList = data.workList.split(','); 1310 // Workbench.console.info('old worklist'); 1311 // Workbench.console.info(existingWorkList); 1312 // appending to the worlist 1313 if (existingWorkList != null) { 1314 for (var i = 0, len = existingWorkList.length; i < len; i++) { 1315 var existingWorkId = existingWorkList[i]; 1316 //Workbench.console.info('testing '+existingWorkId); 1317 // detect work/workpart conflict 1318 var canAddExisting = true; 1319 for (var j = 0, len2 = documentArray.length; j < len2; j++) { 1320 var newWorkId = documentArray[j]; 1321 if ((existingWorkId.indexOf(newWorkId) == 0 || newWorkId.indexOf(existingWorkId) == 0) && newWorkId != existingWorkId) { 1322 Workbench.console.info(existingWorkId+' conflicts with '+newWorkId); 1323 this.worklistConflicts.push(newWorkId); 1324 conflict = true; 1325 canAddExisting = false; 1326 } 1327 } 1328 if (canAddExisting) { 1329 // detect if duplicate... 1330 if (documentArray.indexOf(existingWorkId) == -1) { 1331 //Workbench.console.info('adding '+existingWorkId); 1332 documentArray.push(existingWorkId); 1333 } 1334 } 1335 } 1336 } 1337 1338 var saveWorkset = function(data, documentArray) { 1339 var workset = { 1340 'projectId': Monk.component.dataManager.getProjectId(), 1341 'worksetId': data.id, 1342 'worksetName': data.label, 1343 'trainingList':data.trainingList, 1344 'trainingListRating':data.trainingListRating, 1345 'workList': documentArray.join(",") 1346 } 1347 Monk.data.workset.saveWorkset(workset); 1348 } 1349 // Workbench.console.info('new worklist'); 1350 // Workbench.console.info(documentArray); 1351 // Workbench.console.info('conflicts'); 1352 // Workbench.console.info(this.worklistConflicts); 1353 if (conflict) { 1354 var conflictWindow = new Ext.Window({ 1355 title: 'Workset Conflict', 1356 modal: true, 1357 width: 300, 1358 height: 200, 1359 plain: true, 1360 border: false, 1361 items: { 1362 border: false, 1363 html: '<div class="x-form-item">'+ 1364 'You are trying to add work(part)s to a workset which contains conflicting work(part)s. '+ 1365 'A workset cannot contain both a work and its child workparts.<br/><br/>Do you want to override the work(part)s in your workset '+ 1366 'with the new work(part)s? (Choosing no will cancel the save and unselect the conflicting work(part)s).' 1367 +'</div>' 1368 }, 1369 buttonAlign: 'center', 1370 buttons: [{ 1371 text: 'Yes', 1372 id: 'conflictYesButton' 1373 },{ 1374 text: 'No', 1375 handler: function() { 1376 var grid = Ext.getCmp('document-results'); 1377 var sm = grid.getSelectionModel(); 1378 for (var i = 0, len = this.worklistConflicts.length; i < len; i++) { 1379 var workId = this.worklistConflicts[i]; 1380 var workRecord = grid.getStore().getById(workId); 1381 if (sm.isSelected(workRecord)) { 1382 sm.deselectRow(workRecord); 1383 } else { 1384 var checkEl = Ext.get('check-'+workId); 1385 checkEl.dom.checked = false; 1386 checkEl.dom.defaultChecked = false; 1387 } 1388 } 1389 conflictWindow.close(); 1390 }, 1391 scope: this 1392 },{ 1393 text: 'Cancel', 1394 handler: function() { 1395 conflictWindow.close(); 1396 } 1397 }] 1398 }); 1399 Ext.getCmp('conflictYesButton').on('click', function(){ 1400 conflictWindow.close(); 1401 saveWorkset.createDelegate(this, [data, documentArray])(); 1402 }); 1403 conflictWindow.show(); 1404 } else { 1405 saveWorkset(data, documentArray); 1406 } 1407 } else if (option = 'overwrite_training') { 1408 var workset = { 1409 'projectId': Monk.component.dataManager.getProjectId(), 1410 'worksetId': data.id, 1411 'worksetName': data.label, 1412 'workList': data.workList, 1413 'trainingList': documentArray.join(",") 1414 } 1415 Monk.data.workset.saveWorkset(workset); 1416 } 1417 }, 1418 1419 /** 1420 *display the gender spelling comparison chart 1421 */ 1422 displayGenderSpellingComparison: function(){ 1423 if(Ext.getCmp('spelling_comparison')==null){ 1424 return; 1425 } 1426 if (!Ext.getCmp('spelling_comparison').isVisible()) {return;} 1427 //Workbench.console.info("here in display spelling comparison"); 1428 var spelling_comparison_img = Ext.get("spelling_comparison_img"); 1429 1430 if(spelling_comparison_img.dom.src!=this.featureSpellingGenderChart.url){ 1431 spelling_comparison_img.dom.alt="Loading..."; 1432 spelling_comparison_img.dom.src=this.featureSpellingGenderChart.url; 1433 } 1434 1435 }, 1436 1437 displayGenderLemmaComparison: function(){ 1438 if(Ext.getCmp('lemma_comparison')==null){ 1439 return; 1440 } 1441 if (!Ext.getCmp('lemma_comparison').isVisible()) {return;} 1442 Workbench.console.info("here in display lemma comparison"); 1443 var lemma_comparison_img = Ext.get("lemma_comparison_img"); 1444 // make the call only if not showing already 1445 if(lemma_comparison_img.dom.src!=this.featureLemmaGenderChart.url){ 1446 lemma_comparison_img.dom.alt="Loading..."; 1447 lemma_comparison_img.dom.src=this.featureLemmaGenderChart.url; 1448 } 1449 1450 }, 1451 1452 displayBoxWhiskerCirculation: function() { 1453 if(Ext.getCmp('dispersionDecadesTab')==null){return;} 1454 // confirm that this tab is visible 1455 if (!Ext.getCmp('dispersionDecadesTab').isVisible()) {return;} 1456 //if (!Ext.getCmp('dispersionGenderTab').isVisible()) {return;} 1457 1458 // display the whisker chart here 1459 if(this.type==null){ 1460 return; 1461 } 1462 1463 if(this.type=="Similarity"){ 1464 // now display the box whisker stuff 1465 //Workbench.console.info("display the box whiskers..."); 1466 var data = this.getQueryParam(); 1467 1468 if(data==null){ 1469 Workbench.console.error("Query Param is null"); 1470 return; 1471 } 1472 1473 1474 var chartURL = Monk.data.PROXY_URL+'get/AnalyticsManager.getMoreLikeThisWorksetChart'; 1475 1476 1477 var urlInfo="?"; 1478 var countParam=0; 1479 for(key in data){ 1480 if (countParam == 0) { 1481 urlInfo = urlInfo + key + "=" + escape(data[key]); 1482 }else{ 1483 urlInfo = urlInfo+ "&"+ key +"="+ escape(data[key]); 1484 } 1485 countParam++; 1486 //Workbench.console.info("===> " + key+ " value:--> " + data[key]); 1487 } 1488 //Workbench.console.info("URL "+ urlInfo); 1489 1490 // TODO: this should be moved to a workbench call, something like: Monk.data.workset.getMoreLike(urlInfo) 1491 var boxchart_img = Ext.get("boxchart_img"); 1492 boxchart_img.dom.alt="Loading..."; 1493 boxchart_img.dom.src=Monk.data.PROXY_URL+"get/AnalyticsManager.getMoreLikeThisWorksetChart"+urlInfo; 1494 1495 return; 1496 } 1497 1498 1499 1500 }, 1501 displayBoxWhiskerGender: function() { 1502 if(Ext.getCmp('dispersionGenderTab')==null){return;} 1503 // confirm that this tab is visible 1504 //if (!Ext.getCmp('dispersionDecadesTab').isVisible()) {return;} 1505 if (!Ext.getCmp('dispersionGenderTab').isVisible()) {return;} 1506 1507 // display the whisker chart here 1508 if(this.type==null){ 1509 return; 1510 } 1511 1512 if(this.type=="Similarity"){ 1513 // now display the box whisker stuff 1514 //Workbench.console.info("display the box whiskers..."); 1515 var data = this.getQueryParam(); 1516 1517 if(data==null){ 1518 Workbench.console.error("Query Param is null"); 1519 return; 1520 } 1521 1522 1523 var chartURL = Monk.data.PROXY_URL+'get/AnalyticsManager.getMoreLikeThisWorksetChart'; 1524 1525 1526 var urlInfo="?"; 1527 var countParam=0; 1528 for(key in data){ 1529 if (countParam == 0) { 1530 urlInfo = urlInfo + key + "=" + escape(data[key]); 1531 }else{ 1532 urlInfo = urlInfo+ "&"+ key +"="+ escape(data[key]); 1533 } 1534 countParam++; 1535 //Workbench.console.info("===> " + key+ " value:--> " + data[key]); 1536 } 1537 //Workbench.console.info("URL "+ urlInfo); 1538 1539 urlInfo=urlInfo+"&chartType="+escape("gender"); 1540 var boxchart_img = Ext.get("boxchart_img1"); 1541 boxchart_img.dom.alt="Loading"; 1542 boxchart_img.dom.src=Monk.data.PROXY_URL+"get/AnalyticsManager.getMoreLikeThisWorksetChart"+urlInfo; 1543 1544 return; 1545 } 1546 1547 1548 1549 } 1550 1551 1552 }); 1553