Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/HTRC_Mashup--Home_files/main.css
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/HTRC_Mashup--Home_files/main.css	(revision 31601)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/HTRC_Mashup--Home_files/main.css	(revision 31613)
@@ -4,5 +4,5 @@
 }
 body {
-    padding-top: 60px;
+    padding-top: 160px;
     padding-bottom: 40px;
     background-color: rgba(0, 0, 0, 0);
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.html
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.html	(revision 31601)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.html	(revision 31613)
@@ -3,6 +3,8 @@
 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
 
-        <title>HTRC Extracted Feature Solr Search</title>
+<title>HTRC Extracted Feature Solr Search</title>
+<!--
         <link rel="shortcut icon" href="https://analytics.hathitrust.org/assets/images/favicon.ico">
+-->
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
@@ -270,6 +272,4 @@
 -->
 
-                <div id="search-results-anchor"> 
-		</div>
 
 		<fieldset class="show-hide-lang">
@@ -288,5 +288,10 @@
 
 	<hr />
-	<div id="search-results">
+	<div id="search-results-area" style="position: relative;">
+	  <div id="search-results-anchor" style="position: absolute; top: -90px;">
+	  </div>
+
+	  <div id="search-results">	    
+	  </div>
 	</div>
 	
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js	(revision 31601)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js	(revision 31613)
@@ -44,6 +44,8 @@
 {
     $('.search-in-progress').css("cursor","wait");
-    
-    store_search_args.start += delta;
+
+    var start = parseInt(store_search_args.start)
+    
+    store_search_args.start = start + parseInt(delta);
         
     $.ajax({
@@ -64,5 +66,5 @@
 
 
-    var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+0;
+    var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+1;
 
     html_item += '<p ' + css_class + '>';
@@ -86,5 +88,7 @@
 	var page = id_pages[pi];
 	
-	var seqnum = page - 1;
+	//var seqnum = page - 1;
+	//var seqnum = page + 1;
+	var seqnum = page;
 	var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+seqnum;
 
@@ -96,10 +100,10 @@
 
 		
-		html_item += id + ': <a target="_blank" href="' + babel_url + '">page ' + page + '</a> ';
+		html_item += id + ': <a target="_blank" href="' + babel_url + '">seq ' + seqnum + '</a> ';
 	    }
 	    else {
-		html_item += ', <a target="_blank" href="' + babel_url + '">page ' + page + '</a> ';
+		html_item += ', <a target="_blank" href="' + babel_url + '">seq ' + seqnum + '</a> ';
 		
-		//var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
+		//var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', seq ' + seqnum + '</a>';
 		//result_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span>';
 		//html_item += '<p ' + css_class + '>'+result_item+'</p>';
@@ -109,5 +113,5 @@
 	    html_item += '<p ' + css_class + '>';
 	    html_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span><br>';
-	    html_item += '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
+	    html_item += '<a target="_blank" href="' + babel_url + '">' + id + ', seq ' + seqnum + '</a>';
 	    html_item += '</p>';
 	}
@@ -165,6 +169,8 @@
 	var id_and_page = doc.id.split(".page-");
 	var id = id_and_page[0];
-	var seqnum = parseInt(id_and_page[1]);
-	var page = seqnum+1;
+	var seqnum = parseInt(id_and_page[1]) +1; // fix up ingest error
+	//var page = seqnum+1;
+	//var page = seqnum-1;
+	var page = seqnum;
 
 	if ((prev_id != null) && (id != prev_id)) {
@@ -255,6 +261,8 @@
 	var id_and_page = doc.id.split(".page-");
 	var id = id_and_page[0];
-	var seqnum = parseInt(id_and_page[1]);
-	var page = seqnum+1;
+	var seqnum = parseInt(id_and_page[1]) +1; // fix up ingest error
+	//var page = seqnum+1;
+	//var page = seqnum-1;
+	var page = seqnum;
 
 	if ((prev_id != null) && (id != prev_id)) {
@@ -322,4 +330,89 @@
 
 var group_by_vol_checked = 0;
+
+
+function expand_field_lang_pos(q_text,langs_with_pos,langs_without_pos,search_all_checked)
+{
+    var fields = [];
+    var universal_pos_tags = [ "VERB", "NOUN", "ADJ", "ADV", "ADP", "CONJ", "DET", "NUM", "PRT", "X" ];
+    
+    for (var li=0; li<langs_with_pos.length; li++) {
+	var lang = langs_with_pos[li];
+	var lang_enabled_id = lang + "-enabled";
+	var $lang_enabled_cb = $('#'+lang_enabled_id);
+	if ($lang_enabled_cb.is(':checked')) {
+	    console.log("Extracting POS tags for: " + lang);
+	    
+	    for (var ti=0; ti<universal_pos_tags.length; ti++) {
+		var tag = universal_pos_tags[ti];
+		var lang_tag_id = lang+"-"+tag+"-htrctoken-cb";
+		var $lang_tag_cb = $('#'+lang_tag_id);
+		if (search_all_checked || ($lang_tag_cb.is(':checked'))) {		    
+		    var lang_tag_field = lang+"_"+tag+"_htrctoken";
+		    fields.push(lang_tag_field+":"+q_text);
+		}
+	    }
+	}
+    }
+
+    for (var li=0; li<langs_without_pos.length; li++) {
+	var lang = langs_without_pos[li];
+	var lang_enabled_id = lang + "-enabled";
+	var $lang_enabled_cb = $('#'+lang_enabled_id);
+
+	if (search_all_checked || ($lang_enabled_cb.is(':checked'))) {
+	    console.log("Adding in non-POS field for: " + lang);
+	    var lang_tag_field = lang+"_htrctoken";
+	    fields.push(lang_tag_field+":"+q_text);	    
+	}
+    }
+
+    var fields_str = fields.join(" OR ");
+    
+    return fields_str;
+}
+
+function expand_query_field_and_boolean(query,langs_with_pos,langs_without_pos,search_all_checked)
+{
+    // boolean terms
+    //  => pos and lang field
+    
+    var query_terms = query.split(/\s+/);
+    var query_terms_len = query_terms.length;
+
+    var bool_query_term = [];
+
+    var i=0;
+    var prev_bool = "";
+
+    for (var i=0; i<query_terms_len; i++) {
+	var term = query_terms[i];
+	if (term.match(/^(and|or)$/i)) {
+	    prev_bool = term.toUpperCase();	    
+	}
+	else {
+	    if (i>0) {
+		if (prev_bool == "") {
+		    prev_bool = "AND";
+		}
+	    }
+	    
+	    var expanded_term = expand_field_lang_pos(term,langs_with_pos,langs_without_pos,search_all_checked)
+	    
+	    term = "(" + expanded_term + ")";
+
+	    if (prev_bool != "") {
+		bool_query_term.push(prev_bool);
+		prev_bool = "";
+	    }
+	    bool_query_term.push(term);
+	}
+    }
+
+    var bool_query = bool_query_term.join(" ");
+
+    return bool_query;
+}
+
 
 function stream_submit_action(event)
@@ -499,5 +592,14 @@
 	return;
     }
-    
+
+    arg_q = expand_query_field_and_boolean(q_text,langs_with_pos,langs_without_pos,search_all_checked);
+
+    if (arg_q == "") {
+	$('.search-in-progress').css("cursor","auto");
+	alert("No languages selected");
+	return;
+    }
+    
+    /*
     var fields = [];
     var universal_pos_tags = [ "VERB", "NOUN", "ADJ", "ADV", "ADP", "CONJ", "DET", "NUM", "PRT", "X" ];
@@ -533,5 +635,7 @@
 	}
     }
-
+    */
+
+    /*
     if (fields.length == 0) {
 	$('.search-in-progress').css("cursor","auto");
@@ -541,5 +645,5 @@
     
     var arg_q = fields.join(" OR ");
-    
+    */
     
     // Example search on one of the htrc-full-ef fields is: 
