Changeset 31618 for other-projects

Show
Ignore:
Timestamp:
20.04.2017 20:41:04 (2 years ago)
Author:
davidb
Message:

Code tidy up

Files:
1 modified

Legend:

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

    r31614 r31618  
    11 
    2 //var langs_with_pos =["da","de","en","nl","pt"]; 
    32var langs_with_pos =["en","de","pt","da","nl", "sv"]; 
    43var 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"]; 
     
    7069    var page = id_pages[pi]; 
    7170     
    72     //var seqnum = page - 1; 
    73     //var seqnum = page + 1; 
    7471    var seqnum = page; 
    7572    var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+seqnum; 
     
    8683        else { 
    8784        html_item += ', <a target="_blank" href="' + babel_url + '">seq ' + seqnum + '</a> '; 
    88          
    89         //var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', seq ' + seqnum + '</a>'; 
    90         //result_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span>'; 
    91         //html_item += '<p ' + css_class + '>'+result_item+'</p>'; 
    9285        } 
    9386    } 
     
    130123    } 
    131124 
    132      
    133     // https://babel.hathitrust.org/cgi/pt?id=hvd.hnnssu;view=1up;seq=11 
     125    // Example form of URL 
     126    //   https://babel.hathitrust.org/cgi/pt?id=hvd.hnnssu;view=1up;seq=11 
    134127 
    135128    var htids = []; 
     
    141134    var line_num = 0; 
    142135    while (i<num_docs) { 
    143 //    for (var i=0; i<num_docs; i++) { 
    144136    var doc = docs[i]; 
    145137    var id_and_page = doc.id.split(".page-"); 
    146138    var id = id_and_page[0]; 
    147139    var seqnum = parseInt(id_and_page[1]) +1; // fix up ingest error 
    148     //var page = seqnum+1; 
    149     //var page = seqnum-1; 
    150140    var page = seqnum; 
    151141 
     
    162152    } 
    163153     
    164 //  var css_class = (i%2 == 0) ? 'class="evenline"' : 'class="oddline"'; 
    165 //  //var restful_safe_id = id.replace(/\./g,",").replace(/:/g, "+").replace(/\//g, "="); 
    166      
    167 //  var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+seqnum; 
    168  
    169 //  var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>'; 
    170 //  result_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span>'; 
    171 //  $search_results.append('<p ' + css_class + '>'+result_item+'</p>'); 
    172  
    173154    htids.push("htid:"+id); 
    174155 
     
    195176     
    196177    // Example URL for catalog metadata (multiple items) 
    197     // http://catalog.hathitrust.org/api/volumes/brief/json/id:552;lccn:70628581|isbn:0030110408 
     178    //   http://catalog.hathitrust.org/api/volumes/brief/json/id:552;lccn:70628581|isbn:0030110408 
    198179 
    199180    var htids_str = htids.join("|",htids); 
     
    204185        jsonpCallback: "add_titles" 
    205186    }); 
    206  
    207  
    208     //var json_pretty = JSON.stringify(jsonData.response, null, '\t'); 
    209     //$('#search-results').text(json_pretty) 
    210187} 
    211188 
     
    332309    } 
    333310     
    334     /* 
    335     var fields = []; 
    336     var universal_pos_tags = [ "VERB", "NOUN", "ADJ", "ADV", "ADP", "CONJ", "DET", "NUM", "PRT", "X" ]; 
    337      
    338     for (var li=0; li<langs_with_pos.length; li++) { 
    339     var lang = langs_with_pos[li]; 
    340     var lang_enabled_id = lang + "-enabled"; 
    341     var $lang_enabled_cb = $('#'+lang_enabled_id); 
    342     if ($lang_enabled_cb.is(':checked')) { 
    343         console.log("Extracting POS tags for: " + lang); 
    344          
    345         for (var ti=0; ti<universal_pos_tags.length; ti++) { 
    346         var tag = universal_pos_tags[ti]; 
    347         var lang_tag_id = lang+"-"+tag+"-htrctoken-cb"; 
    348         var $lang_tag_cb = $('#'+lang_tag_id); 
    349         if (search_all_checked || ($lang_tag_cb.is(':checked'))) {           
    350             var lang_tag_field = lang+"_"+tag+"_htrctoken"; 
    351             fields.push(lang_tag_field+":"+q_text); 
    352         } 
    353         } 
    354     } 
    355     } 
    356  
    357     for (var li=0; li<langs_without_pos.length; li++) { 
    358     var lang = langs_without_pos[li]; 
    359     var lang_enabled_id = lang + "-enabled"; 
    360     var $lang_enabled_cb = $('#'+lang_enabled_id); 
    361  
    362     if (search_all_checked || ($lang_enabled_cb.is(':checked'))) { 
    363         console.log("Adding in non-POS field for: " + lang); 
    364         var lang_tag_field = lang+"_htrctoken"; 
    365         fields.push(lang_tag_field+":"+q_text);      
    366     } 
    367     } 
    368     */ 
    369  
    370     /* 
    371     if (fields.length == 0) { 
    372     $('.search-in-progress').css("cursor","auto"); 
    373     alert("No languages selected"); 
    374     return; 
    375     } 
    376      
    377     var arg_q = fields.join(" OR "); 
    378     */ 
    379311     
    380312    // Example search on one of the htrc-full-ef fields is:  
     
    476408    } 
    477409 
    478  
    479     //$('#en-enabled').click(lang_pos_toggle); 
    480     //$('#de-enabled').click(lang_pos_toggle); 
    481     //$('#de-pos-choice *').prop('disabled',true); 
    482  
    483410    show_hide_lang() 
    484411} 
     
    527454     
    528455    labeled_checkbox += '<label for="'+lang+'-enabled" style="padding-left: 5px; padding-right: 10px;" ' + opt_title + '>'+lang_full+'</label>'; 
    529     //labeled_checkbox += '</span>\n'; 
     456 
    530457    labeled_checkbox += '</nobr> '; 
    531458