source: SRUAggregator/trunk/src/main/resources/assets/js/main.js @ 6197

Last change on this file since 6197 was 6197, checked in by emanuel.dima@uni-tuebingen.de, 9 years ago
  1. beta-48 (same): bug fix (deleting window.$)
File size: 23.4 KB
Line 
1/** @jsx React.DOM */
2(function() {
3"use strict";
4
5var VERSION = window.MyAggregator.VERSION = "v.2.0.0-beta-48";
6
7var URLROOT = window.MyAggregator.URLROOT =
8        window.location.pathname.substring(0, window.location.pathname.indexOf("/",2)) ||
9        "/Aggregator";
10
11var PT = React.PropTypes;
12
13var ErrorPane = window.MyReact.ErrorPane;
14var AggregatorPage = window.MyAggregator.AggregatorPage;
15
16/**
17The FCS Aggregator UI is based on reactjs.
18- index.html: describes the general page structure, with a push-down footer;
19  on that structure the Main and Footer components are plugged.
20- main.jsx: defines the simple top components (Main, HelpPage, AboutPage, StatisticsPage)
21- search.jsx: defines
22        - the Corpora store of collections
23        - the AggregatorPage component which deals with search and displays the search results
24- corpora.jsx: defines the CorpusView, rendered when the user views the available collections
25- components.jsx: various general usage React components
26
27The top-most component, Main, tracks of the window's location URL and, depending on the value,
28  renders various components inside its frame:
29        - AggregatorPage is the view corresponding to the normal search UI (search bar and all)
30          This is the most complex component.
31        - HelpPage renders the help page
32        - About renders the about page
33        - Statistics renders the stats page
34        - another URL, /Aggregator/embed, determines Main and AggregatorPage to render just the search bar.
35          The embedded view is supposed to work like a YouTube embedded clip.
36*/
37
38var Main = React.createClass({displayName: 'Main',
39        componentWillMount: function() {
40                routeFromLocation.bind(this)();
41        },
42
43        getInitialState: function () {
44                return {
45                        navbarCollapse: false,
46                        navbarPageFn: this.renderAggregator,
47                        errorMessages: [],
48                };
49        },
50
51        error: function(errObj) {
52                var err = "";
53                if (typeof errObj === 'string' || errObj instanceof String) {
54                        err = errObj;
55                } else if (typeof errObj === 'object' && errObj.statusText) {
56                        console.log("ERROR: jqXHR = ", errObj);
57                        err = errObj.statusText;
58                } else {
59                        return;
60                }
61
62                var that = this;
63                var errs = this.state.errorMessages.slice();
64                errs.push(err);
65                this.setState({errorMessages: errs});
66
67                setTimeout(function() {
68                        var errs = that.state.errorMessages.slice();
69                        errs.shift();
70                        that.setState({errorMessages: errs});
71                }, 10000);
72        },
73
74        ajax: function(ajaxObject) {
75                var that = this;
76                if (!ajaxObject.error) {
77                        ajaxObject.error = function(jqXHR, textStatus, error) {
78                                if (jqXHR.readyState === 0) {
79                                        that.error("Network error, please check your internet connection");
80                                } else if (jqXHR.responseText) {
81                                        that.error(jqXHR.responseText + " ("+error+")");
82                                } else  {
83                                        that.error(error + " ("+textStatus+")");
84                                }
85                                console.log("ajax error, jqXHR: ", jqXHR);
86                        };
87                }
88                // console.log("ajax", ajaxObject);
89                jQuery.ajax(ajaxObject);
90        },
91
92        toggleCollapse: function() {
93                this.setState({navbarCollapse: !this.state.navbarCollapse});
94        },
95
96        renderAggregator: function() {
97                return React.createElement(AggregatorPage, {ajax: this.ajax, error: this.error});
98        },
99
100        renderHelp: function() {
101                return React.createElement(HelpPage, null);
102        },
103
104        renderAbout: function() {
105                return React.createElement(AboutPage, null);
106        },
107
108        renderStatistics: function() {
109                return React.createElement(StatisticsPage, {ajax: this.ajax});
110        },
111
112        renderEmbedded: function() {
113                return React.createElement(AggregatorPage, {ajax: this.ajax, error: this.error, embedded: true});
114        },
115
116        getPageFns: function() {
117                return {
118                        '': this.renderAggregator,
119                        'help': this.renderHelp,
120                        'about': this.renderAbout,
121                        'stats': this.renderStatistics,
122                        'embed': this.renderEmbedded,
123                };
124        },
125
126        gotoPage: function(doPushHistory, pageFnName) {
127                var pageFn = this.getPageFns()[pageFnName];
128                if (this.state.navbarPageFn !== pageFn) {
129                        if (doPushHistory) {
130                                window.history.pushState({page:pageFnName}, '', URLROOT+"/"+pageFnName);
131                        }
132                        this.setState({navbarPageFn: pageFn});
133                        console.log("new page: " + document.location + ", name: " + pageFnName);
134                }
135        },
136
137        toAggregator: function(doPushHistory) { this.gotoPage(doPushHistory, ''); },
138        toHelp: function(doPushHistory) { this.gotoPage(doPushHistory, 'help'); },
139        toAbout: function(doPushHistory) { this.gotoPage(doPushHistory, 'about'); },
140        toStatistics: function(doPushHistory) { this.gotoPage(doPushHistory, 'stats'); },
141        toEmbedded: function(doPushHistory) { this.gotoPage(doPushHistory, 'embed'); },
142
143        renderLogin: function() {
144                return false;
145                // return  <li className="unauthenticated">
146                //                      <a href="login" tabIndex="-1"><span className="glyphicon glyphicon-log-in"></span> LOGIN</a>
147                //              </li>;
148        },
149
150        renderCollapsible: function() {
151                var classname = "navbar-collapse collapse " + (this.state.navbarCollapse?"in":"");
152                return (
153                        React.createElement("div", {className: classname}, 
154                                React.createElement("ul", {className: "nav navbar-nav"}, 
155                                        React.createElement("li", {className: this.state.navbarPageFn === this.renderAggregator ? "active":""}, 
156                                                React.createElement("a", {className: "link", tabIndex: "-1", onClick: this.toAggregator.bind(this, true)}, "Aggregator")
157                                        ), 
158                                        React.createElement("li", {className: this.state.navbarPageFn === this.renderHelp ? "active":""}, 
159                                                React.createElement("a", {className: "link", tabIndex: "-1", onClick: this.toHelp.bind(this, true)}, "Help")
160                                        )
161                                ), 
162                                React.createElement("ul", {className: "nav navbar-nav navbar-right"}, 
163                                        React.createElement("li", null, " ", React.createElement("div", {id: "clarinservices", style: {padding:4}}), " "), 
164                                        this.renderLogin()
165                                )
166                        )
167                );
168        },
169
170        renderTop: function() {
171                if (this.state.navbarPageFn === this.renderEmbedded) {
172                        return false;
173                }
174                return  (
175                        React.createElement("div", null, 
176                                React.createElement("div", {className: "navbar navbar-default navbar-static-top", role: "navigation"}, 
177                                        React.createElement("div", {className: "container"}, 
178                                                React.createElement("div", {className: "navbar-header"}, 
179                                                        React.createElement("button", {type: "button", className: "navbar-toggle", onClick: this.toggleCollapse}, 
180                                                                React.createElement("span", {className: "sr-only"}, "Toggle navigation"), 
181                                                                React.createElement("span", {className: "icon-bar"}), 
182                                                                React.createElement("span", {className: "icon-bar"}), 
183                                                                React.createElement("span", {className: "icon-bar"})
184                                                        ), 
185                                                        React.createElement("a", {className: "navbar-brand", href: URLROOT, tabIndex: "-1"}, 
186                                                                React.createElement("img", {width: "28px", height: "28px", src: "img/magglass1.png"}), 
187                                                                React.createElement("header", {className: "inline"}, " Content Search ")
188                                                        )
189                                                ), 
190                                                this.renderCollapsible()
191                                        )
192                                ), 
193
194                                React.createElement(ErrorPane, {errorMessages: this.state.errorMessages})
195
196                        )
197                );
198        },
199
200        render: function() {
201                return  (
202                        React.createElement("div", null, 
203                                React.createElement("div", null, " ",  this.renderTop(), " "), 
204
205                                React.createElement("div", {id: "push"}, 
206                                        React.createElement("div", {className: "container"}, 
207                                                this.state.navbarPageFn()
208                                        ), 
209                                        React.createElement("div", {className: "top-gap"})
210                                )
211                        )
212                );
213        }
214});
215
216
217var StatisticsPage = React.createClass({displayName: 'StatisticsPage',
218        propTypes: {
219                ajax: PT.func.isRequired,
220        },
221
222        getInitialState: function () {
223                return {
224                        stats: {},
225                        activeTab: 0,
226                        // searchStats: {},
227                        // lastScanStats: {},
228                };
229        },
230
231        componentDidMount: function() {
232                this.refreshStats();
233        },
234
235        refreshStats: function() {
236                this.props.ajax({
237                        url: 'rest/statistics',
238                        success: function(json, textStatus, jqXHR) {
239                                this.setState({stats: json});
240                                // console.log("stats:", json);
241                        }.bind(this),
242                });
243        },
244
245        renderWaitTimeSecs: function(t) {
246                var hue = t * 4;
247                if (hue > 120) {
248                        hue = 120;
249                }
250                var a = hue/120;
251                hue = 120 - hue;
252                var shue = "hsla("+hue+",100%,80%,"+a+")";
253                return  React.createElement("span", {className: "badge", style: {backgroundColor:shue, color:"black"}}, 
254                                        t.toFixed(3), "s"
255                                );
256        },
257
258        renderCollections: function(colls) {
259                return  React.createElement("div", {style: {marginLeft:40}}, 
260                                         colls.length === 0 ?
261                                                React.createElement("div", {style: {color:"#a94442"}}, "NO collections found")
262                                                :
263                                                React.createElement("div", null, 
264                                                        colls.length, " root collection(s):", 
265                                                        React.createElement("ul", {className: "list-unstyled", style: {marginLeft:40}}, 
266                                                                 colls.map(function(name, i) { return React.createElement("div", {key: i}, name); }) 
267                                                        )
268                                                )
269                                       
270                                );
271        },
272
273        renderDiagnostic: function(d) {
274                var classes = "inline alert alert-warning " + (d.diagnostic.uri === 'LEGACY' ? "legacy" : "");
275                return  React.createElement("div", {key: d.diagnostic.uri}, 
276                                        React.createElement("div", {className: classes}, 
277                                                React.createElement("div", null, 
278                                                         d.counter <= 1 ? false :
279                                                                React.createElement("div", {className: "inline", style: {margin:"5px 5px 5px 5px"}}, 
280                                                                        React.createElement("span", {className: "badge", style: {backgroundColor:'#ae7241'}}, "x ", d.counter)
281                                                                ), 
282                                                       
283                                                        "Diagnostic: ", d.diagnostic.message, ": ", d.diagnostic.diagnostic
284                                                ), 
285                                                React.createElement("div", null, "Context: ", React.createElement("a", {href: d.context}, d.context))
286                                        )
287                                );
288        },
289
290        renderError: function(e) {
291                var xc = e.exception;
292                return  React.createElement("div", {key: xc.message}, 
293                                        React.createElement("div", {className: "inline alert alert-danger", role: "alert"}, 
294                                                React.createElement("div", null, 
295                                                         e.counter <= 1 ? false :
296                                                                React.createElement("div", {className: "inline", style: {margin:"5px 5px 5px 5px"}}, 
297                                                                        React.createElement("span", {className: "badge", style: {backgroundColor:'#c94442'}}, "x ", e.counter, " ")
298                                                                ), 
299                                                       
300                                                        "Exception: ", xc.message
301                                                ), 
302                                                React.createElement("div", null, "Context: ", React.createElement("a", {href: e.context}, e.context)), 
303                                                 xc.cause ? React.createElement("div", null, "Caused by: ", xc.cause) : false
304                                        )
305                                );
306        },
307
308        renderEndpoint: function(isScan, endpoint) {
309                var stat = endpoint[1];
310                var errors = _.values(stat.errors);
311                var diagnostics = _.values(stat.diagnostics);
312                return React.createElement("div", {style: {marginTop:10}, key: endpoint[0]}, 
313                                        React.createElement("ul", {className: "list-inline list-unstyled", style: {marginBottom:0}}, 
314                                                React.createElement("li", null, 
315                                                         stat.version == "LEGACY" ?
316                                                                React.createElement("span", {style: {color:'#a94442'}}, "legacy ", React.createElement("i", {className: "glyphicon glyphicon-thumbs-down"}), " ")
317                                                                : React.createElement("span", {style: {color:'#3c763d'}}, React.createElement("i", {className: "glyphicon glyphicon-thumbs-up"}), " "), 
318                                                       
319                                                         " "+endpoint[0]
320                                                )
321                                        ), 
322                                        React.createElement("div", {style: {marginLeft:40}}, 
323                                         isScan ?
324                                                React.createElement("div", null, "Max concurrent scan requests:", " ", " ", stat.maxConcurrentRequests, " ") :
325                                                React.createElement("div", null, "Max concurrent search requests:", " ", " ", stat.maxConcurrentRequests, " ")
326                                       
327                                        ), 
328                                        React.createElement("div", {style: {marginLeft:40}}, 
329                                                React.createElement("span", null, stat.numberOfRequests), " request(s)," + ' ' +
330                                                "average:", this.renderWaitTimeSecs(stat.avgExecutionTime), "," + ' ' +
331                                                "max: ", this.renderWaitTimeSecs(stat.maxExecutionTime)
332                                        ), 
333                                         isScan ? this.renderCollections(stat.rootCollections) : false, 
334                                                (errors && errors.length) ?
335                                                React.createElement("div", {className: "inline", style: {marginLeft:40}}, 
336                                                         errors.map(this.renderError) 
337                                                ) : false, 
338                                       
339                                                (diagnostics && diagnostics.length) ?
340                                                React.createElement("div", {className: "inline", style: {marginLeft:40}}, 
341                                                         diagnostics.map(this.renderDiagnostic) 
342                                                ) : false
343                                       
344                                );
345        },
346
347        renderInstitution: function(isScan, inst) {
348                return  React.createElement("div", {style: {marginTop:30}, key: inst[0]}, 
349                                        React.createElement("h4", null, inst[0]), 
350                                        React.createElement("div", {style: {marginLeft:20}}, " ", _.pairs(inst[1]).map(this.renderEndpoint.bind(this, isScan)) )
351                                );
352        },
353
354        renderStatistics: function(stats) {
355                return  React.createElement("div", {className: "container statistics", style: {marginTop:20}}, 
356                                        React.createElement("div", null, 
357                                                React.createElement("div", null, "Start date: ", new Date(stats.date).toLocaleString()), 
358                                                React.createElement("div", null, "Timeout: ", " ", React.createElement("kbd", null, stats.timeout, " seconds"))
359                                        ), 
360                                        React.createElement("div", null, " ",  _.pairs(stats.institutions).map(this.renderInstitution.bind(this, stats.isScan)), " ")
361                                )
362                                 ;
363        },
364
365        setTab: function(idx) {
366                this.setState({activeTab:idx});
367        },
368
369        render: function() {
370                return  (
371                        React.createElement("div", null, 
372                                React.createElement("div", {className: "top-gap"}, 
373                                        React.createElement("h1", null, "Statistics"), 
374                                        React.createElement("p", null), 
375                                        React.createElement("div", {role: "tabpanel"}, 
376                                                React.createElement("ul", {className: "nav nav-tabs", role: "tablist"}, 
377                                                         _.pairs(this.state.stats).map(function(st, idx){
378                                                                        var classname = idx === this.state.activeTab ? "active":"";
379                                                                        return  React.createElement("li", {role: "presentation", className: classname, key: st[0]}, 
380                                                                                                React.createElement("a", {href: "#", role: "tab", onClick: this.setTab.bind(this, idx)}, st[0])
381                                                                                        );
382                                                                }.bind(this))
383                                                       
384                                                ), 
385
386                                                React.createElement("div", {className: "tab-content"}, 
387                                                         _.pairs(this.state.stats).map(function(st, idx){
388                                                                        var classname = idx === this.state.activeTab ? "tab-pane active" : "tab-pane";
389                                                                        return  React.createElement("div", {role: "tabpanel", className: classname, key: st[0]}, 
390                                                                                                this.renderStatistics(st[1])
391                                                                                        );
392                                                                }.bind(this))
393                                                       
394                                                )
395                                        )
396                                )
397                        )
398                        );
399        },
400});
401
402var HelpPage = React.createClass({displayName: 'HelpPage',
403        openHelpDesk: function() {
404                window.open('http://support.clarin-d.de/mail/form.php?queue=Aggregator&lang=en',
405                        '_blank', 'height=560,width=370');
406        },
407
408        render: function() {
409                return  (
410                        React.createElement("div", null, 
411                                React.createElement("div", {className: "top-gap"}, 
412                                        React.createElement("h1", null, "Help"), 
413                                        React.createElement("h3", null, "Performing search in FCS corpora"), 
414                                        React.createElement("p", null, "To perform simple keyword search in all CLARIN-D Federated Content Search centres" + ' ' +
415                                        "and their corpora, go to the search field at the top of the page," + ' ' +
416                                        "enter your query, and click 'search' button or press the 'Enter' key."), 
417
418                                        React.createElement("p", null, "When the search starts, the page will start filling in with the corpora responses." + ' ' +
419                                        "After the entire search process has ended you have the option to download the results" + ' ' +
420                                        "in various formats."
421                                        ), 
422
423                                        React.createElement("p", null, "If you are particularly interested in the results returned by a corpus, you have" + ' ' +
424                                        "the option to focus only on the results of that corpus, by clicking on the 'Watch' button." + ' ' +
425                                        "In this view mode you can also download the results of use the WebLicht processing services" + ' ' +
426                                        "to further analyse the results."), 
427
428
429                                        React.createElement("h3", null, "Adjusting search criteria"), 
430                                        React.createElement("p", null, "The FCS Aggregator makes possible to select specific corpora based on their name" + ' ' +
431                                        "or language and to specify the number of search results (hits) per corpus per page." + ' ' +
432                                        "The user interface controls that allows to change these options are located" + ' ' +
433                                        "right below the search fiels on the main page. The current options are" + ' ' +
434                                        "to filter resources based on their language, to select specific resources, and" + ' ' +
435                                        "to set the maximum number of hits."), 
436
437
438                                        React.createElement("h3", null, "More help"), 
439                                        React.createElement("p", null, "More detailed information on using FCS Aggregator is available at the  ", 
440                                        React.createElement("a", {href: "http://weblicht.sfs.uni-tuebingen.de/weblichtwiki/index.php/FCS_Aggregator"}, 
441                                                "Aggregator wiki page"
442                                        ), "." + ' ' +
443                                        "If you still cannot find an answer to your question," + ' ' +
444                                        "or if want to send a feedback, you can write to Clarin-D helpdesk: "), 
445                                        React.createElement("button", {type: "button", className: "btn btn-default btn-lg", onClick: this.openHelpDesk}, 
446                                                React.createElement("span", {className: "glyphicon glyphicon-question-sign", 'aria-hidden': "true"}), 
447                                                " HelpDesk"
448                                        )
449                                )
450                        )
451                );
452        }
453});
454
455var AboutPage = React.createClass({displayName: 'AboutPage',
456        render: function() {
457                return  React.createElement("div", null, 
458                                        React.createElement("div", {className: "top-gap"}, 
459                                                React.createElement("h1", {style: {padding:15}}, "About"), 
460
461                                                React.createElement("div", {className: "col-md-6"}, 
462                                                React.createElement("h3", null, "People"), 
463
464                                                React.createElement("ul", null, 
465                                                        React.createElement("li", null, "Emanuel Dima"), 
466                                                        React.createElement("li", null, "Yana Panchenko"), 
467                                                        React.createElement("li", null, "Oliver Schonefeld"), 
468                                                        React.createElement("li", null, "Dieter Van Uytvanck")
469                                                ), 
470
471                                                React.createElement("h3", null, "Statistics"), 
472                                                React.createElement("button", {type: "button", className: "btn btn-default btn-lg", onClick: function() {main.toStatistics(true);}}, 
473                                                        React.createElement("span", {className: "glyphicon glyphicon-cog", 'aria-hidden': "true"}, " "), 
474                                                        "View server log"
475                                                )
476                                                ), 
477
478                                                React.createElement("div", {className: "col-md-6"}, 
479                                                React.createElement("h3", null, "Technology"), 
480
481                                                React.createElement("p", null, "The Aggregator uses the following software components:"), 
482
483                                                React.createElement("ul", null, 
484                                                        React.createElement("li", null, 
485                                                                React.createElement("a", {href: "http://dropwizard.io/"}, "Dropwizard"), " ", 
486                                                                "(", React.createElement("a", {href: "http://www.apache.org/licenses/LICENSE-2.0"}, "Apache License 2.0"), ")"
487                                                        ), 
488                                                        React.createElement("li", null, 
489                                                                React.createElement("a", {href: "http://eclipse.org/jetty/"}, "Jetty"), " ", 
490                                                                "(", React.createElement("a", {href: "http://www.apache.org/licenses/LICENSE-2.0"}, "Apache License 2.0"), ")"
491                                                        ), 
492                                                        React.createElement("li", null, 
493                                                                React.createElement("a", {href: "http://jackson.codehaus.org/"}, "Jackson"), " ", 
494                                                                "(", React.createElement("a", {href: "http://www.apache.org/licenses/LICENSE-2.0"}, "Apache License 2.0"), ")"
495                                                        ), 
496                                                        React.createElement("li", null, 
497                                                                React.createElement("a", {href: "https://jersey.java.net/"}, "Jersey"), " ", 
498                                                                "(", React.createElement("a", {href: "https://jersey.java.net/license.html#/cddl"}, "CCDL 1.1"), ")"
499                                                        ), 
500                                                        React.createElement("li", null, 
501                                                                React.createElement("a", {href: "https://github.com/optimaize/language-detector"}, "Optimaize Language Detector"), " ", 
502                                                                "(", React.createElement("a", {href: "http://www.apache.org/licenses/LICENSE-2.0"}, "Apache License 2.0"), ")"
503                                                        ), 
504                                                        React.createElement("li", null, 
505                                                                React.createElement("a", {href: "http://poi.apache.org/"}, "Apache POI"), " ", 
506                                                                "(", React.createElement("a", {href: "http://www.apache.org/licenses/LICENSE-2.0"}, "Apache License 2.0"), ")"
507                                                        )
508                                                ), 
509
510                                                React.createElement("ul", null, 
511                                                        React.createElement("li", null, 
512                                                                React.createElement("a", {href: "http://facebook.github.io/react/"}, "React"), " ", 
513                                                                "(", React.createElement("a", {href: "https://github.com/facebook/react/blob/master/LICENSE"}, "BSD license"), ")"
514                                                        ), 
515                                                        React.createElement("li", null, 
516                                                                React.createElement("a", {href: "http://getbootstrap.com/"}, "Bootstrap"), " ", 
517                                                                "(", React.createElement("a", {href: "http://opensource.org/licenses/mit-license.html"}, "MIT license"), ")"
518                                                        ), 
519                                                        React.createElement("li", null, 
520                                                                React.createElement("a", {href: "http://jquery.com/"}, "jQuery"), " ", 
521                                                                "(", React.createElement("a", {href: "http://opensource.org/licenses/mit-license.html"}, "MIT license"), ")"
522                                                        ), 
523                                                        React.createElement("li", null, 
524                                                                React.createElement("a", {href: "http://glyphicons.com/"}, "GLYPHICONS free"), " ", 
525                                                                "(", React.createElement("a", {href: "https://creativecommons.org/licenses/by/3.0/"}, "CC-BY 3.0"), ")"
526                                                        ), 
527                                                        React.createElement("li", null, 
528                                                                React.createElement("a", {href: "http://fortawesome.github.io/Font-Awesome/"}, "FontAwesome"), " ", 
529                                                                "(", React.createElement("a", {href: "http://opensource.org/licenses/mit-license.html"}, "MIT"), ", ", React.createElement("a", {href: "http://scripts.sil.org/OFL"}, "SIL Open Font License"), ")"
530                                                        )
531                                                ), 
532
533                                                React.createElement("p", null, "The content search icon is made by", 
534                                                        React.createElement("a", {href: "http://www.freepik.com", title: "Freepik"}, " Freepik "), 
535                                                        "from", 
536                                                        React.createElement("a", {href: "http://www.flaticon.com", title: "Flaticon"}, " www.flaticon.com "), 
537                                                        "and licensed under", 
538                                                        React.createElement("a", {href: "http://creativecommons.org/licenses/by/3.0/", title: "Creative Commons BY 3.0"}, " CC BY 3.0 ")
539                                                )
540                                                )
541
542                                        )
543                                );
544        }
545});
546
547var Footer = React.createClass({displayName: 'Footer',
548        toAbout: function(e) {
549                main.toAbout(true);
550                e.preventDefault();
551                e.stopPropagation();
552        },
553
554        render: function() {
555                return (
556                        React.createElement("div", {className: "container", style: {textAlign:'center'}}, 
557                                React.createElement("div", {className: "row"}, 
558                                        React.createElement("div", {style: {position:'relative', float:'left'}}, 
559                                                React.createElement("div", {className: "leftist", style: {position:'absolute'}}, 
560                                                        React.createElement("div", null, 
561                                                                React.createElement("a", {title: "about", href: "about", onClick: this.toAbout}, "About")
562                                                        ), 
563                                                        React.createElement("div", {style: {color:'#777'}}, VERSION)
564                                                )
565                                        ), 
566                                        React.createElement("a", {title: "CLARIN ERIC", href: "https://www.clarin.eu/"}, 
567                                                React.createElement("img", {src: "img/clarindLogo.png", alt: "CLARIN ERIC logo", style: {height:60}})
568                                        ), 
569                                        React.createElement("div", {style: {position:'relative', float:'right'}}, 
570                                                React.createElement("div", {className: "rightist", style: {position:'absolute', right:'0'}}, 
571                                                        React.createElement("a", {title: "contact", href: "mailto:fcs@clarin.eu"}, "Contact")
572                                                )
573                                        )
574                                )
575                        )
576                );
577        }
578});
579
580function isEmbeddedView() {
581        var path = window.location.pathname.split('/');
582        return (path.length >= 3 && path[2] === 'embed');
583}
584
585function endsWith(str, suffix) {
586    return str.indexOf(suffix, str.length - suffix.length) !== -1;
587}
588
589var routeFromLocation = function() {
590        // console.log("routeFromLocation: " + document.location);
591        if (!this) throw "routeFromLocation must be bound to main";
592        var path = window.location.pathname.split('/');
593        if (path.length === 3) {
594                var p = path[2];
595                if (p === 'help') {
596                        this.toHelp(false);
597                } else if (p === 'about') {
598                        this.toAbout(false);
599                } else if (p === 'stats') {
600                        this.toStatistics(false);
601                } else if (p === 'embed') {
602                        this.toEmbedded(false);
603                } else {
604                        this.toAggregator(false);
605                }
606        } else {
607                this.toAggregator(false);
608        }
609};
610
611var main = React.render(React.createElement(Main, null),  document.getElementById('body'));
612if (!isEmbeddedView()) {
613        React.render(React.createElement(Footer, null), document.getElementById('footer') );
614} else if (jQuery) {
615        jQuery("#footer").remove();
616}
617
618window.onpopstate = routeFromLocation.bind(main);
619window.MyAggregator.main = main;
620
621})();
Note: See TracBrowser for help on using the repository browser.