Changeset 31385 for other-projects

Show
Ignore:
Timestamp:
02.02.2017 23:40:09 (2 years ago)
Author:
davidb
Message:

Next and previous pages

Location:
other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal
Files:
2 modified

Legend:

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

    r31384 r31385  
    167167        <input type="hidden" id="wt" name="wt" value="json"/> 
    168168        <input type="hidden" id="start" name="start" value="0"/> 
    169         <input type="hidden" id="rows" name="rows" value="25"/> 
     169        <input type="hidden" id="rows" name="rows" value="20"/> 
    170170        <input type="text"   id="q" name="q" style="width: 600px;"/> 
    171171        <input type="submit" id="search-submit" /> 
     
    265265--> 
    266266 
     267                <div id="search-results-anchor">  
     268        </div> 
     269 
    267270        <fieldset> 
    268271          <legend style="margin-bottom: 5px; padding-top: 15px;"> 
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js

    r31384 r31385  
    33var langs_with_pos =["en","de","pt","da","nl"]; 
    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"]; 
     5 
     6var num_rows = 20; 
    57 
    68function lang_pos_toggle(event) { 
     
    3941} 
    4042 
     43function show_new_results(delta) 
     44{ 
     45    store_search_args.start += delta; 
     46         
     47    $.ajax({ 
     48    type: 'GET', 
     49    url: store_search_action, 
     50    data: store_search_args, 
     51    dataType: 'json', 
     52    success: show_results, 
     53    error: ajax_error 
     54    }); 
     55} 
     56 
    4157function show_results(jsonData) { 
    4258    var response = jsonData.response; 
     
    4864    if (num_docs>0) { 
    4965    $search_results.html("<p>Results: " + num_found + " volumes/documents matched</p>"); 
    50     $search_results.append("<p>Showing matches: 1-" + num_docs + "</p>"); 
     66    var from = parseInt(store_search_args.start)+1; 
     67    var to = from + num_rows; 
     68    $search_results.append("<p>Showing matches: "+from+"-" + to + "</p>"); 
    5169    } 
    5270    else { 
     
    5472    } 
    5573 
     74     
    5675    // https://babel.hathitrust.org/cgi/pt?id=hvd.hnnssu;view=1up;seq=11 
    5776 
     
    7897    } 
    7998 
     99    document.location.href="#search-results-anchor"; 
     100     
     101    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>'; 
     102     
     103    $search_results.append(next_prev); 
     104    $('#search-prev').click(function(event) { show_new_results(-1*num_rows); }); 
     105    $('#search-next').click(function(event) { show_new_results(num_rows); }); 
     106 
     107    var search_start = store_search_args.start; 
     108    if (search_start==0) { 
     109    $('#search-prev').hide(); 
     110    } 
     111     
    80112    // Example URL for catalog metadata (multiple items) 
    81113    // http://catalog.hathitrust.org/api/volumes/brief/json/id:552;lccn:70628581|isbn:0030110408 
     
    94126} 
    95127 
     128var store_search_args = null; 
     129var store_search_action = null; 
     130 
    96131function submit_action(event) 
    97132{ 
    98133    event.preventDefault(); 
    99134 
    100     var action = $('#search-form').attr("action"); 
     135    store_search_action = $('#search-form').attr("action"); 
    101136     
    102137    var arg_indent = $('#indent').attr('value'); 
     
    157192    //  q=xxxxen_NOUN_htrctoken:farming 
    158193     
    159     var args = { q: arg_q, indent: arg_indent, wt: arg_wt, start: arg_start, rows: arg_rows }; 
     194    store_search_args = { q: arg_q, indent: arg_indent, wt: arg_wt, start: arg_start, rows: arg_rows }; 
    160195     
    161196    $.ajax({ 
    162197    type: 'GET', 
    163     url: action, 
    164     data: args, 
     198    url: store_search_action, 
     199    data: store_search_args, 
    165200    dataType: 'json', 
    166201    success: show_results, 
     
    256291    for (var i=0; i<langs_without_pos.length; i++) { 
    257292    var lang = langs_without_pos[i]; 
    258     $other_langs.append('<input type="checkbox" name="'+lang+'-enabled" id="'+lang+'-enabled" />'); 
     293    //var labeled_checkbox = '<span style="white-space:nowrap;">\n'; 
     294    var labeled_checkbox = '<nobr>'; 
     295     
     296    labeled_checkbox += '<input type="checkbox" name="'+lang+'-enabled" id="'+lang+'-enabled" />'; 
    259297    /* 
    260298    if (lang === "zh-cn") { 
     
    271309    var opt_title = (lang_full !== lang_native_full) ? 'title="'+lang_native_full+'"' : ""; 
    272310     
    273     $other_langs.append('<span style="padding-right: 10px;" ' + opt_title + '>'+lang_full+'</span> '); 
     311    labeled_checkbox += '<label for="'+lang+'-enabled" style="padding-left: 5px; padding-right: 10px;" ' + opt_title + '>'+lang_full+'</label>'; 
     312    //labeled_checkbox += '</span>\n'; 
     313    labeled_checkbox += '</nobr> '; 
     314     
     315    $other_langs.append(labeled_checkbox); 
    274316     
    275317    }