source: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js

Last change on this file was 31693, checked in by davidb, 7 years ago

Changes to workset information is pulled from sparql-endpoint for each item in the result set

File size: 20.9 KB
Line 
1
2var langs_with_pos = [ "en","de","pt","da","nl", "sv" ];
3
4var langs_without_pos = [
5 "af","ar","bg","bn","cs","el","es","et","fa","fi","fr","he","hi","hr","hu",
6 "id","it","ja","kn","ko","lt","lv","mk","ml","mr","ne","no","pa","pl",
7 "ro","ru","sk","sl","so","sq","sv","sw","ta","te","th","tl","tr",
8 "uk","ur","vi","zh-cn","zh-tw" ];
9
10var num_rows = 20;
11
12function lang_pos_toggle(event) {
13 var $this =$(this);
14 var checked_state = $this.prop("checked");
15
16 var id = $this.attr("id");
17 var split_id = id.split("-");
18 var related_id = split_id[0] + "-pos-choice";
19
20 var disable_state = !checked_state;
21 $('#'+related_id + " *").prop('disabled',disable_state);
22}
23
24function ajax_error(jqXHR, textStatus, errorThrown) {
25 alert('An error occurred... Look at the console (F12 or Ctrl+Shift+I, Console tab) for more information!');
26
27 console.log('jqXHR:' + jqXHR);
28 console.log('textStatus:' + textStatus);
29 console.log('errorThrown:' + errorThrown);
30}
31
32
33function add_titles(json_data) {
34 var itemURLs = [];
35
36 $.each( json_data, function( htid_with_prefix, htid_val ) {
37 var htid = htid_with_prefix.replace(/^htid:/,"");
38
39 $.each(htid_val.records, function( internalid, metadata ) {
40 var title = metadata.titles[0];
41 $("[name='"+htid+"']").each(function() {$(this).html(title)});
42 console.log(htid + ", title = " + metadata.titles[0]);
43 });
44
45 $.each(htid_val.items, function( item_index, item_val ) {
46 if (item_val.htid == htid) {
47 var itemURL = item_val.itemURL;
48 itemURL = itemURL.replace(/^https:/,"http:");
49
50 var ws_span = '<span style="display: none;"><br>[Workset: <span name="'+itemURL+'"></span>]</span>';
51 $("[name='"+htid+"']").each(function() {$(this).append(ws_span)});
52 console.log("itemURL = " + itemURL);
53 itemURLs.push(itemURL);
54 }
55 });
56 });
57
58 workset_enrich_results(itemURLs);
59
60}
61
62function add_worksets(json_data) {
63
64 //console.log("****" + JSON.stringify(json_data));
65 $.each( json_data["@graph"], function( ws_index, ws_val ) {
66 var workset_id = ws_val["@id"];
67 var workset_title = ws_val["http://purl.org/dc/terms/title"][0]["@value"];
68
69 // http://acbres224.ischool.illinois.edu:8890/sparql?query=describe <http://worksets.hathitrust.org/wsid/189324112>&format=text/x-html+ul
70 // http://acbres224.ischool.illinois.edu:8890/sparql?query=describe+%3Chttp%3A%2F%2Fworksets.hathitrust.org%2Fwsid%2F189324112%3E&format=text%2Fx-html%2Bul
71
72 var describe_url = "http://acbres224.ischool.illinois.edu:8890/sparql?query=describe+<"
73 + workset_id + ">&format=text%2Fx-html%2Bul";
74 var hyperlinked_workset_title = '<a target="_blank" href="'+describe_url+'">'+workset_title+'</a>';
75
76 var gathers = ws_val["http://www.europeana.eu/schemas/edm/gathers"]
77
78 $.each(gathers, function(gather_index,gather_val) {
79 var item_url = gather_val["@id"];
80
81 $("[name='"+item_url+"']").each(function() {
82 $(this).parent().show();
83 if ($(this).children().size()>=1) {
84 $(this).append("; ");
85 }
86
87 $(this).append("<span>" + hyperlinked_workset_title + "</span>")
88 });
89 });
90 });
91
92}
93
94
95function show_new_results(delta)
96{
97 $('.search-in-progress').css("cursor","wait");
98
99 var start = parseInt(store_search_args.start)
100
101 store_search_args.start = start + parseInt(delta);
102
103 $.ajax({
104 type: 'GET',
105 url: store_search_action,
106 data: store_search_args,
107 dataType: 'json',
108 success: show_results,
109 error: ajax_error
110 });
111}
112
113function generate_item(line,id,id_pages)
114{
115 var css_class = (line%2 == 0) ? 'class="evenline"' : 'class="oddline"';
116
117 var html_item = "";
118
119 var id_pages_len = id_pages.length;
120
121 for (var pi=0; pi<id_pages_len; pi++) {
122 var page = id_pages[pi];
123
124 var seqnum = (page==0) ? 1 : page;
125 var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+seqnum;
126
127 if (id_pages_len>1) {
128
129 if (pi==0) {
130 html_item += '<p ' + css_class + '>';
131 html_item += '<span style="font-style: italic;" name="'
132 +id+'"><span style="cursor: progress;">Loading ...</span></span><br>';
133 if (page > 0) {
134 html_item += id + ': <a target="_blank" href="' + babel_url + '">seq ' + seqnum + '</a> ';
135 }
136 else {
137 // skip linking to the 'phony' page 0
138 html_item += id;
139 }
140 }
141 else {
142 html_item += ', <a target="_blank" href="' + babel_url + '">seq ' + seqnum + '</a> ';
143 }
144 }
145 else {
146 html_item += '<p ' + css_class + '>';
147 html_item += ' <span style="font-style: italic;" name="'
148 +id+'"><span style="cursor: progress;">Loading ...</span></span><br>';
149
150 if (page > 0) {
151 html_item += '<a target="_blank" href="' + babel_url + '">' + id + ', seq ' + seqnum + '</a>';
152 }
153 else {
154 html_item += '<a target="_blank" href="' + babel_url + '">' + id + ', all pages</a>';
155 }
156
157 html_item += '</p>';
158 }
159
160 }
161
162 if (id_pages_len>1) {
163 html_item += "</p>";
164 }
165
166 return html_item;
167}
168
169
170function workset_enrich_results(itemURLs)
171{
172 // prefix dcterms: <http://purl.org/dc/terms/>
173 // prefix edm: <http://www.europeana.eu/schemas/edm/>
174 // prefix htrc: <http://wcsa.htrc.illinois.edu/>
175 // prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
176 // prefix xsd: <http://www.w3.org/2001/XMLSchema#>
177
178 // CONSTRUCT {
179 // ?wsid
180 // rdf:type htrc:Workset ;
181 // dcterms:title ?title ;
182 // dcterms:creator ?cre ;
183 // dcterms:created ?dat ;
184 // edm:gathers ?gar.}
185
186 // where {
187 // ?wsid
188 // rdf:type htrc:Workset ;
189 // dcterms:title ?title ;
190 // dcterms:creator ?cre ;
191 // dcterms:created ?dat ;
192 // edm:gathers ?gar
193
194 // FILTER ( ?gar = <http://hdl.handle.net/2027/uc2.ark:/13960/t4fn12212> || ?gar = <http://hdl.handle.net/2027/uva.x030825627> )
195 // }
196
197 var prefixes = "";
198 prefixes += "prefix dcterms: <http://purl.org/dc/terms/>\n";
199 prefixes += "prefix edm: <http://www.europeana.eu/schemas/edm/>\n";
200 prefixes += "prefix htrc: <http://wcsa.htrc.illinois.edu/>\n";
201 prefixes += "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n";
202 prefixes += "prefix xsd: <http://www.w3.org/2001/XMLSchema#>\n";
203
204 var graph_body = "";
205 graph_body += " ?wsid\n";
206 graph_body += " rdf:type htrc:Workset ;\n";
207 graph_body += " dcterms:title ?title ;\n";
208 graph_body += " dcterms:creator ?cre ;\n";
209 graph_body += " dcterms:created ?dat ;\n";
210 graph_body += " edm:gathers ?gar .\n";
211
212 var filter_array = [];
213 var item_urls_len = itemURLs.length;
214 for (var hi=0; hi<item_urls_len; hi++) {
215 var htid = itemURLs[hi];
216 filter_array.push("?gar = " + "<"+htid+">");
217 }
218 var filter = " FILTER ( " + filter_array.join(" || ") + " ) ";
219
220 var construct = "CONSTRUCT {\n" + graph_body + "}\n";
221 var where = "WHERE {\n" + graph_body + filter + "}\n";
222
223 var sparql_query = prefixes + construct + where;
224 //console.log("*** sparql query = " + sparql_query);
225
226 // http://acbres224.ischool.illinois.edu:8890/sparql?default-graph-uri=&query
227 // &format=application/x-json+ld&timeout=0&debug=on
228
229 var sparql_url = "http://acbres224.ischool.illinois.edu:8890/sparql";
230 var sparql_data = { "default-graph-uri": "",
231 "format": "application/x-json+ld",
232 "timeout": 0,
233 "debug": "on" };
234 sparql_data.query = sparql_query;
235
236 $.ajax({
237 type: "POST",
238 url: sparql_url,
239 data: sparql_data,
240 dataType: 'jsonp',
241 jsonpCallback: "add_worksets"
242 });
243
244
245
246}
247
248function show_results(jsonData) {
249 var response = jsonData.response;
250 var num_found = response.numFound;
251 var docs = response.docs;
252 var num_docs = docs.length;
253
254 $('.search-in-progress').css("cursor","auto");
255
256 var $search_results = $('#search-results');
257
258 if (num_docs>0) {
259 $search_results.html("<p>Results: " + num_found + doc_units + "matched</p>");
260 var from = parseInt(store_search_args.start)+1;
261 var to = from + num_rows -1;
262 if (to>num_found) {
263 // cap value
264 to = num_found;
265 }
266 var showing_matches = "<p>Showing matches: ";
267 showing_matches += '<span id="sm-from">'+from+'</span>';
268 showing_matches += "-";
269 showing_matches += '<span id="sm-to">'+to+'</span>';
270 showing_matches += "</p>";
271
272 $search_results.append(showing_matches);
273 }
274 else {
275 $search_results.html("<p>No pages matched your query</p>");
276 }
277
278 // Example form of URL
279 // https://babel.hathitrust.org/cgi/pt?id=hvd.hnnssu;view=1up;seq=11
280
281 var htids = [];
282
283 var prev_id = null;
284 var prev_pages = [];
285
286 var i=0;
287 var line_num = 1;
288 while ((i<num_docs) && (line_num < num_rows)) {
289 var doc = docs[i];
290 var id_and_page = doc.id.split(".page-");
291 var id = id_and_page[0];
292 var seqnum;
293 if (id_and_page.length>1) {
294 seqnum = parseInt(id_and_page[1]) +1; // fix up ingest error
295 }
296 else {
297 seqnum = 0;
298 }
299 var page = seqnum;
300
301 if ((!group_by_vol_checked && prev_id != null) || ((prev_id != null) && (id != prev_id))) {
302 // time to output previous item
303 var html_item = generate_item(line_num,prev_id,prev_pages);
304 $search_results.append(html_item);
305 line_num++;
306 prev_pages = [page];
307 }
308 else {
309 // accumulate pages
310 prev_pages.push(page)
311 }
312
313 htids.push("htid:"+id);
314
315 prev_id = id;
316 i++;
317 }
318 var num_pages = i;
319
320 var html_item = generate_item(line_num,prev_id,prev_pages);
321// console.log("*** html item = " + html_item);
322// if (html_item != "") {
323 $search_results.append(html_item);
324// line_num++;
325// }
326 console.log("*** line_num = " + line_num);
327
328 //else {
329// line_num--;
330 // }
331// if ((i == num_docs) && (line_num != num_rows)) {
332// line_num--;
333// }
334
335 document.location.href="#search-results-anchor";
336
337 var next_prev = '<p style="width:100%;"><div id="search-prev" style="float: left;"><a>&lt; Previous</a></div><div id="search-next" style="float: right;"><a>Next &gt;</a></div></p>';
338
339 $search_results.append(next_prev);
340 $('#search-prev').click(function(event) { show_new_results(-1*num_rows); });
341 $('#search-next').click(function(event) { show_new_results(num_rows); });
342
343 var search_start = parseInt(store_search_args.start);
344 if (search_start==0) {
345 $('#search-prev').hide();
346 }
347
348 var search_end = search_start + num_pages;
349 if (search_end >= num_found) {
350 $('#search-next').hide();
351 }
352
353 $('#sm-to').html(search_start + line_num);
354
355
356 // Example URL for catalog metadata (multiple items)
357 // http://catalog.hathitrust.org/api/volumes/brief/json/id:552;lccn:70628581|isbn:0030110408
358
359 var htids_str = htids.join("|",htids);
360 var cat_url = "http://catalog.hathitrust.org/api/volumes/brief/json/" + htids_str;
361 $.ajax({
362 url: cat_url,
363 dataType: 'jsonp',
364 jsonpCallback: "add_titles"
365 });
366
367
368}
369
370var store_search_args = null;
371var store_search_action = null;
372
373var group_by_vol_checked = 0;
374var doc_units = "";
375
376
377function expand_vfield(q_term,all_vfields)
378{
379 var vfields = [];
380 var metadata_fields = [ "accessProfile_t", "genre_t", "imprint_t", "isbn_t", "issn_t",
381 "issuance_t", "language_t", "lccn_t", "names_t", "oclc_t",
382 "pubPlace_t", "pubDate_t", "rightsAttributes_t", "title_t", "typeOfResource_t" ];
383
384 if (all_vfields) {
385 for (var fi=0; fi<metadata_fields.length; fi++) {
386 var vfield = metadata_fields[fi];
387 vfields.push(vfield+":"+q_term);
388 }
389 }
390 else {
391 if (q_term.match(/:/)) {
392 vfields.push(q_term);
393 }
394 else {
395 // make searching by title the default
396 vfields.push("title_t:"+q_term);
397 }
398 }
399
400
401 var vfields_str = vfields.join(" OR ");
402
403 return vfields_str;
404}
405
406function expand_vquery_field_and_boolean(query,all_vfields)
407{
408 // boolean terms
409 // => pos and lang field
410 if (query === "") { return "" }
411
412 var query_terms = query.split(/\s+/);
413 var query_terms_len = query_terms.length;
414
415 var bool_query_term = [];
416
417 var i=0;
418 var prev_bool = "";
419
420 for (var i=0; i<query_terms_len; i++) {
421 var term = query_terms[i];
422 if (term.match(/^(and|or)$/i)) {
423 prev_bool = term.toUpperCase();
424 }
425 else {
426 if (i>0) {
427 if (prev_bool == "") {
428 prev_bool = "AND";
429 }
430 }
431
432 var expanded_term = expand_vfield(term,all_vfields); // **** only difference to POS version
433
434 term = "(" + expanded_term + ")";
435
436 if (prev_bool != "") {
437 bool_query_term.push(prev_bool);
438 prev_bool = "";
439 }
440 bool_query_term.push(term);
441 }
442 }
443
444 var bool_query = bool_query_term.join(" ");
445
446 return bool_query;
447}
448
449
450function expand_field_lang_pos(q_text,langs_with_pos,langs_without_pos,search_all_checked)
451{
452 var fields = [];
453 var universal_pos_tags = [ "VERB", "NOUN", "ADJ", "ADV", "ADP", "CONJ", "DET", "NUM", "PRT", "X" ];
454
455 for (var li=0; li<langs_with_pos.length; li++) {
456 var lang = langs_with_pos[li];
457 var lang_enabled_id = lang + "-enabled";
458 var $lang_enabled_cb = $('#'+lang_enabled_id);
459 if ($lang_enabled_cb.is(':checked')) {
460 console.log("Extracting POS tags for: " + lang);
461
462 for (var ti=0; ti<universal_pos_tags.length; ti++) {
463 var tag = universal_pos_tags[ti];
464 var lang_tag_id = lang+"-"+tag+"-htrctoken-cb";
465 var $lang_tag_cb = $('#'+lang_tag_id);
466 if (search_all_checked || ($lang_tag_cb.is(':checked'))) {
467 var lang_tag_field = lang+"_"+tag+"_htrctoken";
468 fields.push(lang_tag_field+":"+q_text);
469 }
470 }
471 }
472 }
473
474 for (var li=0; li<langs_without_pos.length; li++) {
475 var lang = langs_without_pos[li];
476 var lang_enabled_id = lang + "-enabled";
477 var $lang_enabled_cb = $('#'+lang_enabled_id);
478
479 if (search_all_checked || ($lang_enabled_cb.is(':checked'))) {
480 console.log("Adding in non-POS field for: " + lang);
481 var lang_tag_field = lang+"_htrctoken";
482 fields.push(lang_tag_field+":"+q_text);
483 }
484 }
485
486 var fields_str = fields.join(" OR ");
487
488 return fields_str;
489}
490
491function expand_query_field_and_boolean(query,langs_with_pos,langs_without_pos,search_all_checked)
492{
493 // boolean terms
494 // => pos and lang field
495 if (query === "") { return "" }
496
497 var query_terms = query.split(/\s+/);
498 var query_terms_len = query_terms.length;
499
500 var bool_query_term = [];
501
502 var i=0;
503 var prev_bool = "";
504
505 for (var i=0; i<query_terms_len; i++) {
506 var term = query_terms[i];
507 if (term.match(/^(and|or)$/i)) {
508 prev_bool = term.toUpperCase();
509 }
510 else {
511 if (i>0) {
512 if (prev_bool == "") {
513 prev_bool = "AND";
514 }
515 }
516
517 var expanded_term = expand_field_lang_pos(term,langs_with_pos,langs_without_pos,search_all_checked)
518
519 term = "(" + expanded_term + ")";
520
521 if (prev_bool != "") {
522 bool_query_term.push(prev_bool);
523 prev_bool = "";
524 }
525 bool_query_term.push(term);
526 }
527 }
528
529 var bool_query = bool_query_term.join(" ");
530
531 return bool_query;
532}
533
534
535function submit_action(event)
536{
537 event.preventDefault();
538
539 $('.search-in-progress').css("cursor","wait");
540
541 store_search_action = $('#search-form').attr("action");
542
543 var arg_indent = $('#indent').attr('value');
544 var arg_wt = $('#wt').attr('value');
545 var arg_start = $('#start').attr('value');
546 var arg_rows = $('#rows').attr('value');
547
548 var q_text = $('#q').val().trim();
549 var vq_text = $('#vq').val().trim();
550
551 group_by_vol_checked = $('#group-results-by-vol:checked').length;
552
553 var search_all_langs_checked = $('#search-all-langs:checked').length;
554 var search_all_vfields_checked = $('#search-all-vfields:checked').length;
555
556 if ((q_text === "") && (vq_text === "")) {
557 $('.search-in-progress').css("cursor","auto");
558 alert("No query term(s) entered");
559 return;
560 }
561
562 arg_vq = expand_vquery_field_and_boolean(vq_text,search_all_vfields_checked);
563
564 arg_q = expand_query_field_and_boolean(q_text,langs_with_pos,langs_without_pos,search_all_langs_checked);
565
566 //console.log("*** arg_vq = " + arg_vq);
567 //console.log("*** arg_q = " + arg_q);
568
569 if (arg_q == "") {
570 if (arg_vq == "") {
571 // arg_vq was empty to start with, but attempt to expand non-empty arg_q
572 // lead to an empty arg_q being returned
573 $('.search-in-progress').css("cursor","auto");
574 alert("No languages selected");
575 return;
576 }
577 else {
578 arg_q = arg_vq;
579 doc_units = " volumes ";
580 }
581 }
582 else {
583 if (arg_vq != "") {
584 // join the two with an AND
585 arg_q = "(" + arg_vq + ")" + " OR " + "(" + arg_q + ")";
586
587 // also implies
588 group_by_vol_checked = true;
589 }
590 doc_units = " pages ";
591 }
592
593 //console.log("*** NOW arg_q = " + arg_q);
594
595 // Example search on one of the htrc-full-ef fields is:
596 // q=en_NOUN_htrctoken:farming
597
598 store_search_args = { q: arg_q, indent: arg_indent, wt: arg_wt, start: arg_start, rows: arg_rows };
599
600 if (group_by_vol_checked) {
601 store_search_args.sort="id asc";
602 }
603
604
605 $.ajax({
606 type: 'GET',
607 url: store_search_action,
608 data: store_search_args,
609 dataType: 'json',
610 success: show_results,
611 error: ajax_error
612 });
613
614}
615
616function generate_pos_langs()
617{
618 var pos_checkbox = [
619 { pos:"VERB", label:"Verbs", tooltip:"Verbs (all tenses and modes)" },
620 { pos:"NOUN", label:"Nouns", tooltip:"Nouns (common and proper)" },
621 { pos:"ADJ", label:"Adjectives", tooltip: null },
622 { pos:"ADV", label:"Adverbs", tooltip: null },
623 { pos:"ADP", label:"Adpositions", tooltip:"Adpositions (prepositions and postpositions)" },
624 { pos:"CONJ", label:"Conjunctions",tooltip: null },
625 { pos:"DET", label:"Determiners", tooltip: null },
626 { pos:"NUM", label:"Numbers", tooltip:"Cardinal numbers" },
627 { pos:"PRT", label:"Particles", tooltip:"Particles or other function words" },
628 { pos:"X", label:"Other", tooltip:"Other words, such as foreign words, typos, abbreviations"}
629 ];
630
631 var $pos_fieldsets = $('#pos-fieldsets');
632
633 for (var li=0; li<langs_with_pos.length; li++) {
634
635 var l = langs_with_pos[li];
636 var lang_full = isoLangs[l].name;
637 var lang_native_full = isoLangs[l].nativeName;
638 var opt_title = (lang_full !== lang_native_full) ? 'title="'+lang_native_full+'"' : "";
639
640 var opt_enabled = (l == "en") ? 'checked="checked"' : "";
641
642 var legend = "";
643 legend += ' <legend style="margin-bottom: 5px; padding-top: 15px;">\n';
644 legend += ' <input type="checkbox" name="'+l+'-enabled" id="'+l+'-enabled" ' + opt_enabled +'/>\n';
645 legend += ' <span ' + opt_title + '>'+lang_full+':</span>\n';
646 legend += ' </legend>\n';
647
648
649 var check_box_list = [];
650
651 for (var pi=0; pi<pos_checkbox.length; pi++) {
652 var pos_info = pos_checkbox[pi];
653 var pos = pos_info.pos;
654 var label = pos_info.label;
655 var tooltip = pos_info.tooltip;
656 var opt_tooltip = (tooltip != null) ? 'title="'+tooltip+'"' : "";
657
658 var check_box = "";
659 check_box += ' <input type="checkbox" name="'+l+'-'+pos+'-htrctoken-cb" id="'+l+'-'+pos+'-htrctoken-cb" checked="checked" />\n';
660 check_box += ' <label for="'+l+'-'+pos+'-htrctoken-cb" '+opt_tooltip+'>'+label+'</label>\n';
661
662 check_box_list.push(check_box);
663 }
664
665 var fieldset = "";
666 var opt_showhide_class = (li>0) ? 'class="show-hide-lang"' : "";
667
668 if (li==1) {
669 fieldset += '<button id="show-hide-lang">Show other languages ...</button>';
670 }
671
672 fieldset += '<fieldset ' + opt_showhide_class + '>\n';
673 fieldset += legend;
674 fieldset += ' <div id="'+l+'-pos-choice">\n';
675
676 var check_box_join = check_box_list.join('&nbsp;');
677 fieldset += check_box_join;
678
679 fieldset += ' </div>\n';
680 fieldset += '</fieldset>\n';
681
682 $pos_fieldsets.append(fieldset);
683 $('#'+l+'-enabled').click(lang_pos_toggle);
684
685 if (l == "en") {
686 $('#en-pos-choice *').prop('disabled',false);
687 }
688 else {
689 $('#'+l+'-pos-choice *').prop('disabled',true);
690 }
691 }
692
693 show_hide_lang()
694}
695
696function show_hide_lang()
697{
698 $( "#show-hide-lang" ).click(function(event) {
699 event.preventDefault();
700 if($('.show-hide-lang:visible').length) {
701 $('.show-hide-lang').hide("slide", {direction: "up" } , 1000);
702 $('#show-hide-lang').html("Show other languages ...");
703 }
704 else {
705 $('.show-hide-lang').show("slide", {direction: "up" } , 1000);
706 $('#show-hide-lang').html("Hide other languages ...");
707 }
708 });
709}
710
711function generate_other_langs()
712{
713 // setup other languages
714 // for each 'langs_without_pos' generate HTML of the form:
715 // <input type="checkbox" name="fr-enabled" id="fr-enabled" />French
716 var $other_langs = $('#other-langs');
717
718 for (var i=0; i<langs_without_pos.length; i++) {
719 var lang = langs_without_pos[i];
720 var labeled_checkbox = '<nobr>';
721
722 labeled_checkbox += '<input type="checkbox" name="'+lang+'-enabled" id="'+lang+'-enabled" />';
723 /*
724 if (lang === "zh-cn") {
725 console.log("Mapping zh-cn => zh");
726 lang = "zh";
727 }
728 if (lang === "zh-tw") {
729 console.log("Mapping zh-tw => zh");
730 lang = "zh";
731 }
732*/
733 var lang_full = isoLangs[lang].name;
734 var lang_native_full = isoLangs[lang].nativeName;
735 var opt_title = (lang_full !== lang_native_full) ? 'title="'+lang_native_full+'"' : "";
736
737 labeled_checkbox += '<label for="'+lang+'-enabled" style="padding-left: 5px; padding-right: 10px;" ' + opt_title + '>'+lang_full+'</label>';
738
739 labeled_checkbox += '</nobr> ';
740
741 $other_langs.append(labeled_checkbox);
742
743 }
744}
745
746$(function() {
747 generate_pos_langs();
748
749 generate_other_langs();
750
751 if ($('#search-submit').length>0) {
752 $('#search-submit').click(submit_action);
753 }
754
755});
Note: See TracBrowser for help on using the repository browser.