[31383] | 1 |
|
---|
| 2 | var langs_with_pos = [];
|
---|
| 3 | var langs_without_pos = [];
|
---|
| 4 |
|
---|
| 5 | function ajax_error(jqXHR, textStatus, errorThrown) {
|
---|
| 6 | alert('An error occurred... Look at the console (F12 or Ctrl+Shift+I, Console tab) for more information!');
|
---|
| 7 |
|
---|
| 8 | console.log('jqXHR:' + jqXHR);
|
---|
| 9 | console.log('textStatus:' + textStatus);
|
---|
| 10 | console.log('errorThrown:' + errorThrown);
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | $(function() {
|
---|
| 15 | //var luke_url="solr1.ischool.illinois.edu/solr/htrc-full-ef_shard6_replica1/admin/luke";
|
---|
| 16 | var luke_url="htrc-full-ef_shard6_replica1/admin/luke";
|
---|
| 17 |
|
---|
| 18 | $.ajax({
|
---|
| 19 | type: 'GET',
|
---|
| 20 | url: luke_url,
|
---|
| 21 | dataType: 'xml',
|
---|
| 22 | success: function(xml_data) {
|
---|
| 23 | var $fields = $(xml_data).find("lst[name='fields']");
|
---|
| 24 |
|
---|
| 25 | var langs_with_pos_keys = {};
|
---|
| 26 |
|
---|
| 27 | $fields.children().each(function() {
|
---|
| 28 | var name = $(this).attr("name");
|
---|
| 29 | if (name.endsWith("_htrctoken")) {
|
---|
| 30 | if (name.startsWith("xxxx")) {
|
---|
| 31 | var num_underscores = (name.match(/_/g) || []).length;
|
---|
| 32 | if (num_underscores == 2) {
|
---|
| 33 | var lang = name.replace(/^xxxx/,"").replace(/_.*?_htrctoken$/,"");
|
---|
| 34 | langs_with_pos_keys[lang]=1;
|
---|
| 35 | }
|
---|
| 36 | else {
|
---|
| 37 | var lang = name.replace(/^xxxx/,"").replace(/_htrctoken$/,"");
|
---|
| 38 | langs_without_pos.push(lang);
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | });
|
---|
| 44 |
|
---|
| 45 | // Get the keys
|
---|
| 46 | langs_with_pos = $.map(langs_with_pos_keys, function(v, i){
|
---|
| 47 | return i;
|
---|
| 48 | });
|
---|
| 49 |
|
---|
| 50 | var $js_excerpt = $('#js-excerpt');
|
---|
| 51 |
|
---|
| 52 | $js_excerpt.append("var langs_with_pos =" + JSON.stringify(langs_with_pos) + ";" + "<br/>");
|
---|
| 53 | $js_excerpt.append("var langs_without_pos =" + JSON.stringify(langs_without_pos) + ";");
|
---|
| 54 |
|
---|
| 55 | //console.log("xml_data = " + $fields.html());
|
---|
| 56 | },
|
---|
| 57 | error: ajax_error
|
---|
| 58 | });
|
---|
| 59 | });
|
---|