- Timestamp:
- 03/11/15 11:09:37 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/main/resources/assets/js/search.js
r6093 r6097 297 297 }, 298 298 299 getExportParams: function(corpusId, format ) {299 getExportParams: function(corpusId, format, filterLanguage) { 300 300 var params = corpusId ? {corpusId:corpusId}:{}; 301 301 if (format) params.format = format; 302 if (this.state.languageFilter === 'byGuess' || this.state.languageFilter === 'byMetaAndGuess') { 302 if (filterLanguage) { 303 params.filterLanguage = filterLanguage; 304 } else if (this.state.languageFilter === 'byGuess' || this.state.languageFilter === 'byMetaAndGuess') { 303 305 params.filterLanguage = this.state.language[0]; 304 306 } … … 307 309 308 310 getDownloadLink: function(corpusId, format) { 309 return 'rest/search/'+this.state.searchId+'/download?' + this.getExportParams(corpusId, format); 310 }, 311 312 getToWeblichtLink: function(corpusId) { 313 var params = corpusId ? {corpusId:corpusId}:{}; 314 return 'rest/search/'+this.state.searchId+'/toWeblicht?' + this.getExportParams(corpusId); 311 return 'rest/search/'+this.state.searchId+'/download?' + 312 this.getExportParams(corpusId, format); 313 }, 314 315 getToWeblichtLink: function(corpusId, forceLanguage) { 316 return 'rest/search/'+this.state.searchId+'/toWeblicht?' + 317 this.getExportParams(corpusId, null, forceLanguage); 315 318 }, 316 319 … … 469 472 layers.map(function(l) { 470 473 var cls = l.disabled ? 'disabled':''; 471 var handler = function() { if (!l.disabled) this.setLayer(l.id); } ;474 var handler = function() { if (!l.disabled) this.setLayer(l.id); }.bind(this); 472 475 return React.createElement("li", {key: l.id, className: cls}, " ", React.createElement("a", {tabIndex: "-1", href: "#", 473 476 onClick: handler}, " ", l.name, " ")); … … 753 756 }, 754 757 755 renderToWeblichtLinks: function(corpusId, error) {758 renderToWeblichtLinks: function(corpusId, forceLanguage, error) { 756 759 return ( 757 760 React.createElement("div", {className: "dropdown"}, … … 765 768 error ? 766 769 React.createElement("div", {className: "alert alert-danger", style: {margin:10, width:200}}, error) : 767 React.createElement("a", {href: this.props.getToWeblichtLink(corpusId ), target: "_blank"}, " ",770 React.createElement("a", {href: this.props.getToWeblichtLink(corpusId, forceLanguage), target: "_blank"}, " ", 768 771 "Send to Weblicht") 769 772 … … 834 837 return false; 835 838 } 836 var wlerror = null; 839 840 var forceLanguage = null, wlerror = null; 837 841 if (this.props.weblichtLanguages.indexOf(this.props.searchedLanguage[0]) < 0) { 838 wlerror = "Cannot use WebLicht: unsupported language"; 842 // the search language is either AnyLanguage or unsupported 843 if (this.props.searchedLanguage[0] === multipleLanguageCode) { 844 if (corpusHit.corpus.languages && corpusHit.corpus.languages.length === 1) { 845 forceLanguage = corpusHit.corpus.languages[0]; 846 } else { 847 var langs = corpusHit.kwics.map(function(kwic) {return kwic.language;}); 848 langs = _.uniq(langs.filter(function(l){ return l !== null; })); 849 console.log("languages:", langs); 850 if (langs.length === 1) { 851 forceLanguage = langs[0]; 852 } 853 } 854 } 855 if (!forceLanguage) { 856 wlerror = "Cannot use WebLicht: unsupported language ("+this.props.searchedLanguage[1]+")"; 857 } 839 858 } 840 859 var corpus = corpusHit.corpus; … … 852 871 this.renderDisplayKWIC(), 853 872 React.createElement("div", {className: "inline"}, " ", this.renderDownloadLinks(corpusHit.corpus.id), " "), 854 React.createElement("div", {className: "inline"}, " ", this.renderToWeblichtLinks(corpus.id, wlerror), " ")873 React.createElement("div", {className: "inline"}, " ", this.renderToWeblichtLinks(corpus.id, forceLanguage, wlerror), " ") 855 874 ) 856 875 ), … … 991 1010 return ret; 992 1011 }, 1012 1013 uniq: function(a) { 1014 var r = []; 1015 for (var i = 0; i < a.length; i++) { 1016 if (r.indexOf(a[i]) < 0) { 1017 r.push(a[i]); 1018 } 1019 } 1020 return r; 1021 }, 993 1022 }; 994 1023
Note: See TracChangeset
for help on using the changeset viewer.