- Timestamp:
- 02/24/15 16:58:55 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/main/resources/assets/js/search.js
r5971 r6043 62 62 corpus.selected = true; // selected in the corpus view 63 63 corpus.expanded = false; // not expanded in the corpus view 64 corpus.priority = 1; // priority in corpus view64 corpus.priority = 1; // used for ordering search results in corpus view 65 65 corpus.index = index; // original order, used for stable sort 66 66 }); … … 164 164 }, 165 165 166 timeout: 0,167 166 nohits: { 168 167 requests: [], … … 182 181 183 182 searchId: null, 184 hits: this.nohits, 183 timeout: 0, 184 hits: this.nohits, 185 185 }; 186 186 }, … … 195 195 url: 'rest/corpora', 196 196 success: function(json, textStatus, jqXHR) { 197 this.setState({corpora : new Corpora(json, this.updateCorpora)}); 197 if (this.isMounted()) { 198 this.setState({corpora : new Corpora(json, this.updateCorpora)}); 199 } 198 200 }.bind(this), 199 201 }); … … 204 206 url: 'rest/languages', 205 207 success: function(json, textStatus, jqXHR) { 206 this.setState({languageMap : json}); 208 if (this.isMounted()) { 209 this.setState({languageMap : json}); 210 } 207 211 }.bind(this), 208 212 }); … … 233 237 success: function(searchId, textStatus, jqXHR) { 234 238 // console.log("search ["+query+"] ok: ", searchId, jqXHR); 235 this.setState({searchId : searchId});236 this.timeout = 250;237 setTimeout(this.refreshSearchResults, this.timeout);239 var timeout = 250; 240 setTimeout(this.refreshSearchResults, timeout); 241 this.setState({ searchId: searchId, timeout: timeout }); 238 242 }.bind(this), 239 243 }); … … 241 245 242 246 refreshSearchResults: function() { 243 if (!this.state.searchId ) {247 if (!this.state.searchId || !this.isMounted()) { 244 248 return; 245 249 } … … 247 251 url: 'rest/search/'+this.state.searchId, 248 252 success: function(json, textStatus, jqXHR) { 253 var timeout = this.state.timeout; 249 254 if (json.requests.length > 0) { 250 if (t his.timeout < 10000) {251 t his.timeout = 1.5 * this.timeout;255 if (timeout < 10000) { 256 timeout = 1.5 * timeout; 252 257 } 253 setTimeout(this.refreshSearchResults, t his.timeout);254 // console.log("new search in: " + this.timeout + "ms");258 setTimeout(this.refreshSearchResults, timeout); 259 // console.log("new search in: " + this.timeout + "ms"); 255 260 } else { 256 261 console.log("search ended; hits:", json); 257 262 } 258 this.setState({ hits:json});263 this.setState({ hits: json, timeout: timeout }); 259 264 }.bind(this), 260 265 }); … … 656 661 }, 657 662 658 renderToolbox: function() {659 if (this.props.requests.length > 0) {660 return false;661 }662 return React.createElement("div", {className: "toolbox float-left"},663 React.createElement("a", {className: "btn btn-default", href: this.props.getDownloadLink("text")},664 React.createElement("span", {className: "glyphicon glyphicon-download-alt", 'aria-hidden': "true"}), " Download"665 )666 );667 },668 669 663 renderProgressBar: function() { 670 664 var percents = 100 * this.props.results.length / (this.props.requests.length + this.props.results.length); … … 693 687 }, 694 688 695 renderKwicCheckbox: function() { 696 return React.createElement("div", {className: "float-right", style: {marginRight:17}}, 697 React.createElement("div", {className: "btn-group", style: {display:"inline-block"}}, 698 React.createElement("label", {forHtml: "inputKwic", className: "btn-default"}, 699 this.state.displayKwic ? 700 React.createElement("input", {id: "inputKwic", type: "checkbox", value: "kwic", checked: true, onChange: this.toggleKwic}) : 701 React.createElement("input", {id: "inputKwic", type: "checkbox", value: "kwic", onChange: this.toggleKwic}), 702 703 "Â " + ' ' + 704 "Display as Key Word In Context" 689 renderDownloadLinks: function() { 690 return ( 691 React.createElement("div", {className: "dropdown"}, 692 React.createElement("button", {className: "btn btn-default", 'aria-expanded': "false", 'data-toggle': "dropdown"}, 693 React.createElement("span", {className: "glyphicon glyphicon-download-alt", 'aria-hidden': "true"}), 694 " ", " Download ", " ", 695 React.createElement("span", {className: "caret"}) 696 ), 697 React.createElement("ul", {className: "dropdown-menu"}, 698 React.createElement("li", null, " ", React.createElement("a", {href: this.props.getDownloadLink("csv")}, 699 " ", " As CSV file")), 700 React.createElement("li", null, " ", React.createElement("a", {href: this.props.getDownloadLink("excel")}, 701 " ", " As Excel file")), 702 React.createElement("li", null, " ", React.createElement("a", {href: this.props.getDownloadLink("tcf")}, 703 " ", " As TCF file")), 704 React.createElement("li", null, " ", React.createElement("a", {href: this.props.getDownloadLink("text")}, 705 " ", " As Plain Text file")) 706 ) 707 ) 708 ); 709 }, 710 711 renderToolbox: function(hits) { 712 if (hits <= 0) { 713 return false; 714 } 715 return React.createElement("div", {key: "-toolbox-", style: {marginBottom:10}}, 716 React.createElement("div", {className: "toolbox float-left inline"}, 717 this.renderDownloadLinks() 718 ), 719 React.createElement("div", {className: "float-right inline", style: {marginTop:15}}, 720 React.createElement("div", {className: "btn-group", style: {display:"inline-block"}}, 721 React.createElement("label", {forHtml: "inputKwic", className: "btn-default"}, 722 this.state.displayKwic ? 723 React.createElement("input", {id: "inputKwic", type: "checkbox", value: "kwic", checked: true, onChange: this.toggleKwic}) : 724 React.createElement("input", {id: "inputKwic", type: "checkbox", value: "kwic", onChange: this.toggleKwic}), 725 726 "Â " + ' ' + 727 "Display as Key Word In Context" 728 ) 705 729 ) 706 730 ) … … 719 743 React.createElement("div", {key: "-found-message-", style: margintop}, this.renderFoundMessage(hits), " "), 720 744 React.createElement("div", {key: "-progress-", style: margintop}, this.renderProgressBar()), 721 hits > 0 ? 722 React.createElement("div", {key: "-option-KWIC-", className: "row"}, 723 this.renderToolbox(), 724 this.renderKwicCheckbox() 725 ) 726 : false, 745 this.renderToolbox(hits), 727 746 this.props.results.map(this.renderResultPanels) 728 747 )
Note: See TracChangeset
for help on using the changeset viewer.