Ignore:
Timestamp:
03/20/17 19:56:14 (4 years ago)
Author:
davidb
Message:

Main changes: Fix for page/seqnum; group by id; show-hide other languages; sweedish pos language added

Location:
other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.css

    r31383 r31524  
     1.show-hide-lang {
     2    display: none;
     3}
     4
    15input:disabled {
    26    background:#dddddd;
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.html

    r31385 r31524  
    1313        <link href="HTRC_Mashup--Home_files/font-awesome.css" rel="stylesheet">
    1414        <link href="HTRC_Mashup--Home_files/tomorrow.css" rel="stylesheet">
    15 
     15    <link href="HTRC_Mashup--Home_files/jquery-ui-lightness-1.12.1/jquery-ui.min.css" rel="stylesheet">
     16   
    1617        <link href="index.css" rel="stylesheet">
    1718   
    1819        <script src="HTRC_Mashup--Home_files/highlight.js"></script>
    1920        <script src="HTRC_Mashup--Home_files/jquery.js"></script>
     21    <script src="HTRC_Mashup--Home_files/jquery-ui-lightness-1.12.1/jquery-ui.min.js"></script>
    2022        <script src="HTRC_Mashup--Home_files/stupidtable.js"></script>
    2123        <script src="HTRC_Mashup--Home_files/bootstrap.js"></script>
     
    162164            <div class="col-md-12">
    163165
    164           <h2>Paged-based Extracted Feature Search (Prototype)</h2>
    165           <form action="htrc-full-ef/select" id="search-form">
     166          <h2>Unigram Paged-based Extracted Feature Search (Prototype)</h2>
     167          <form action="htrc-full-ef20/select" id="search-form">
    166168        <input type="hidden" id="indent" name="indent" value="on"/>
    167169        <input type="hidden" id="wt" name="wt" value="json"/>
    168170        <input type="hidden" id="start" name="start" value="0"/>
    169171        <input type="hidden" id="rows" name="rows" value="20"/>
    170         <input type="text"   id="q" name="q" style="width: 600px;"/>
    171         <input type="submit" id="search-submit" />
    172 
     172        <input type="text"   class="search-in-progress" id="q" name="q" style="width: 600px;"/>
     173        <input type="submit" class="search-in-progress" id="search-submit" />
     174        <br><input type="checkbox" id="group-results-by-id" name="group-results-by-vol" value="on">Group by Volume
     175       
    173176        <div id="pos-fieldsets">
    174177        </div>
     
    268271        </div>
    269272
    270         <fieldset>
     273        <fieldset class="show-hide-lang">
    271274          <legend style="margin-bottom: 5px; padding-top: 15px;">
    272275            Other Languages (without modelled parts-of-speech)
     
    295298    <li><a href="admin.html">HTRC-EF Solr Admin UI (log in)</a></li>
    296299    <li><a href="luke_lang_mappings.html">Dynamically Generated Language Map (Part-of-Speech, and Other)</a></li>
     300    <!--
    297301    <li><a href="/solr/htrc-full-ef_shard6_replica1/admin/luke">Luke XML on shard</a></li>
     302-->
     303    <li><a href="/solr/htrc-full-ef20_shard6_replica1/admin/luke">Luke XML on shard</a></li>
    298304      </ul>
    299305    </div>
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js

    r31385 r31524  
    11
    22//var langs_with_pos =["da","de","en","nl","pt"];
    3 var langs_with_pos =["en","de","pt","da","nl"];
     3var langs_with_pos =["en","de","pt","da","nl", "sv"];
    44var langs_without_pos =["af","ar","bg","bn","cs","el","es","et","fa","fi","fr","he","hi","hr","hu","id","it","ja","kn","ko","lt","lv","mk","ml","mr","ne","no","pa","pl","ro","ru","sk","sl","so","sq","sv","sw","ta","te","th","tl","tr","uk","ur","vi","zh-cn","zh-tw"];
    55
     
    4343function show_new_results(delta)
    4444{
     45    $('.search-in-progress').css("cursor","wait");
     46   
    4547    store_search_args.start += delta;
    4648       
     
    5557}
    5658
     59
     60function generate_item(line,id,id_pages)
     61{
     62    var css_class = (line%2 == 0) ? 'class="evenline"' : 'class="oddline"';
     63   
     64    var html_item = "";
     65
     66    var id_pages_len = id_pages.length;
     67   
     68    for (var pi=0; pi<id_pages_len; pi++) {
     69    var page = id_pages[pi];
     70   
     71    var seqnum = page - 1;
     72    var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+seqnum;
     73
     74    if (id_pages_len>1) {
     75
     76        if (pi==0) {
     77        html_item += '<p ' + css_class + '>';
     78        html_item += '<span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span><br>';
     79
     80       
     81        html_item += id + ': <a target="_blank" href="' + babel_url + '">page ' + page + '</a> ';
     82        }
     83        else {
     84        html_item += ', <a target="_blank" href="' + babel_url + '">page ' + page + '</a> ';
     85       
     86        //var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
     87        //result_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span>';
     88        //html_item += '<p ' + css_class + '>'+result_item+'</p>';
     89        }
     90    }
     91    else {
     92        html_item += '<p ' + css_class + '>';
     93        html_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span><br>';
     94        html_item += '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
     95        html_item += '</p>';
     96    }
     97   
     98    }
     99
     100    if (id_pages_len>1) {
     101    html_item += "</p>";
     102    }
     103
     104    return html_item;
     105}
     106
    57107function show_results(jsonData) {
    58108    var response = jsonData.response;
     
    61111    var num_docs = docs.length;
    62112
     113    $('.search-in-progress').css("cursor","auto");
     114   
    63115    var $search_results = $('#search-results');
     116
    64117    if (num_docs>0) {
    65     $search_results.html("<p>Results: " + num_found + " volumes/documents matched</p>");
    66     var from = parseInt(store_search_args.start)+1;
     118    $search_results.html("<p>Results: " + num_found + " pages matched</p>");
     119    var from = parseInt(store_search_args.start);
    67120    var to = from + num_rows;
    68121    $search_results.append("<p>Showing matches: "+from+"-" + to + "</p>");
    69122    }
    70123    else {
    71     $search_results.html("<p>No volumes/documents matched your query</p>");
     124    $search_results.html("<p>No pages matched your query</p>");
    72125    }
    73126
     
    76129
    77130    var htids = [];
    78    
    79     for (var i=0; i<num_docs; i++) {
     131
     132    var prev_id = null;
     133    var prev_pages = [];
     134   
     135    var i=0;
     136    var line_num = 0;
     137    while (i<num_docs) {
     138//    for (var i=0; i<num_docs; i++) {
    80139    var doc = docs[i];
    81140    var id_and_page = doc.id.split(".page-");
    82141    var id = id_and_page[0];
    83     var page = parseInt(id_and_page[1]);
    84 
    85    
    86     var css_class = (i%2 == 0) ? 'class="evenline"' : 'class="oddline"';
    87     //var restful_safe_id = id.replace(/\./g,",").replace(/:/g, "+").replace(/\//g, "=");
    88    
    89     var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+page;
    90 
    91     var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
    92     result_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span>';
    93     $search_results.append('<p ' + css_class + '>'+result_item+'</p>');
     142    var seqnum = parseInt(id_and_page[1]);
     143    var page = seqnum+1;
     144
     145    if ((prev_id != null) && (id != prev_id)) {
     146        // time to output previous item
     147        var html_item = generate_item(line_num,prev_id,prev_pages);
     148        $search_results.append(html_item);
     149        line_num++;
     150        prev_pages = [page];
     151    }
     152    else {
     153        // accumulate pages
     154        prev_pages.push(page)
     155    }
     156   
     157//  var css_class = (i%2 == 0) ? 'class="evenline"' : 'class="oddline"';
     158//  //var restful_safe_id = id.replace(/\./g,",").replace(/:/g, "+").replace(/\//g, "=");
     159   
     160//  var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+seqnum;
     161
     162//  var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
     163//  result_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span>';
     164//  $search_results.append('<p ' + css_class + '>'+result_item+'</p>');
    94165
    95166    htids.push("htid:"+id);
    96167
    97     }
    98 
     168    prev_id = id;
     169    i++;
     170    }
     171   
     172    var html_item = generate_item(line_num,prev_id,prev_pages);
     173    $search_results.append(html_item);
     174
     175   
    99176    document.location.href="#search-results-anchor";
    100177   
     
    129206var store_search_action = null;
    130207
     208var group_by_vol_checked = 0;
     209
    131210function submit_action(event)
    132211{
    133212    event.preventDefault();
    134213
     214    $('.search-in-progress').css("cursor","wait");
     215   
    135216    store_search_action = $('#search-form').attr("action");
    136217   
     
    140221    var arg_rows   = $('#rows').attr('value');
    141222    var q_text     = $('#q').val();
     223
     224    group_by_vol_checked = $('#group-results-by-id:checked').length;
     225
    142226   
    143227    if (q_text === "") {
     228    $('.search-in-progress').css("cursor","auto");
    144229    alert("No query term entered");
    145230    return;
     
    162247        var $lang_tag_cb = $('#'+lang_tag_id);
    163248        if ($lang_tag_cb.is(':checked')) {
    164             var lang_tag_field = "xxxx"+lang+"_"+tag+"_htrctoken";
     249            //var lang_tag_field = "xxxx"+lang+"_"+tag+"_htrctoken";
     250            var lang_tag_field = lang+"_"+tag+"_htrctoken";
    165251            fields.push(lang_tag_field+":"+q_text);
    166252        }
     
    176262    if ($lang_enabled_cb.is(':checked')) {
    177263        console.log("Adding in non-POS field for: " + lang);
    178         var lang_tag_field = "xxxx"+lang+"_htrctoken";
     264        //var lang_tag_field = "xxxx"+lang+"_htrctoken";
     265        var lang_tag_field = lang+"_htrctoken";
    179266        fields.push(lang_tag_field+":"+q_text);     
    180267    }
     
    190277   
    191278    // Example search on one of the htrc-full-ef fields is:
    192     //  q=xxxxen_NOUN_htrctoken:farming
     279    //  q=en_NOUN_htrctoken:farming
    193280   
    194281    store_search_args = { q: arg_q, indent: arg_indent, wt: arg_wt, start: arg_start, rows: arg_rows };
     282
     283    if (group_by_vol_checked) {
     284    store_search_args.sort="id asc";
     285    }
     286   
    195287   
    196288    $.ajax({
     
    255347   
    256348    var fieldset = "";
    257     fieldset += '<fieldset>\n';
     349    var opt_showhide_class = (li>0) ? 'class="show-hide-lang"' : "";
     350
     351    if (li==1) {
     352        fieldset += '<button id="show-hide-lang">Show other languages ...</button>';
     353    }
     354   
     355    fieldset += '<fieldset ' + opt_showhide_class + '>\n';
    258356    fieldset += legend;
    259357    fieldset += '  <div id="'+l+'-pos-choice">\n';
     
    280378    //$('#de-enabled').click(lang_pos_toggle);
    281379    //$('#de-pos-choice *').prop('disabled',true);
     380
     381    show_hide_lang()
     382}
     383
     384function show_hide_lang()
     385{
     386    $( "#show-hide-lang" ).click(function(event) {
     387    event.preventDefault();
     388    if($('.show-hide-lang:visible').length) {
     389        $('.show-hide-lang').hide("slide", {direction: "up" } , 1000);
     390        $('#show-hide-lang').html("Show other languages ...");
     391    }
     392    else {
     393        $('.show-hide-lang').show("slide", {direction: "up" } , 1000);
     394        $('#show-hide-lang').html("Hide other languages ...");
     395    }
     396    });
    282397}
    283398
Note: See TracChangeset for help on using the changeset viewer.