Index: other-projects/meddle/trunk/meddle-fixup.js
===================================================================
--- other-projects/meddle/trunk/meddle-fixup.js	(revision 31607)
+++ other-projects/meddle/trunk/meddle-fixup.js	(revision 31607)
@@ -0,0 +1,178 @@
+// https://en.wikipedia.org/wiki/List_of_precomposed_Latin_characters_in_Unicode
+// https://en.wikipedia.org/wiki/Typographic_ligature#Ligatures_in_Unicode_.28Latin_alphabets.29
+
+var ligature_map = {
+    
+    "\uA732": "AA" ,
+    "\uA733": "aa" ,
+    "\u00C6": "AE" ,
+    "\u00E6": "ae" ,
+    "\uA734": "AO" ,
+    "\uA735": "ao" ,
+    "\uA736": "AU" ,
+    "\uA737": "au" ,
+    "\uA738": "AV" ,
+    "\uA739": "av" ,
+    // as above but with bar
+    "\uA73A": "AV" ,
+    "\uA73B": "av" ,
+    "\uA73C": "AY" ,
+    "\uA73D": "ay" ,
+    "\u1F670": "et" ,
+    "\uFB00": "ff" ,
+    "\uFB03": "ffi" ,
+    "\uFB04": "ffl" ,
+    "\uFB01": "fi" ,
+    "\uFB02": "fl" ,
+    "\u0152": "OE" ,
+    "\u0153": "oe" ,
+    "\uA74E": "OO" ,
+    "\uA74F": "oo" ,
+    "\u00DF": "Å¿s" ,
+    "\u00DF": "Å¿z" ,
+    "\uFB06": "st" ,
+    "\uFB05": "Å¿t" ,
+    "\uA728": "TZ" ,
+    "\uA729": "tz" ,
+    "\u1D6B": "ue" ,
+    "\uAB50": "ui" ,
+    "\uA760": "VY" ,
+    "\uA761": "vy"
+};
+
+var ligature_re = null;
+
+function fixupEncodeInput(form) {
+    console.log( "amcm-dl-fixup fixupEncodeInput(form) called" );
+
+    if (ligature_re === null) {
+        var ligature_str = Object.keys(ligature_map).join("|");
+        ligature_re = new RegExp(ligature_str);
+    }
+
+    //console.log("*** ligature_str = " + ligature_str);
+
+    var query_box_val = form.elements['query'].value;
+
+    var detected_ligatures = ligature_re.test(query_box_val);
+    if (detected_ligatures) {
+      var do_replacement = confirm("Detected ligatures in query. Replace with individual characters?");
+      if (do_replacement) {
+         var query_chars = query_box_val.split("");
+         var query_chars_fixed = [];
+
+         for (var i=0; i<query_chars.length; i++) {
+            var c = query_chars[i];
+            if (ligature_map[c]) {
+		c = ligature_map[c];
+            }
+            query_chars_fixed.push(c);
+         }
+         query_box_val = query_chars_fixed.join("");
+      }
+    }
+
+    // e.g., content.ftsec:(+capisco) 
+
+    var query_box_val = query_box_val.replace(/^\s+/,"");
+    var query_box_words = query_box_val.split(/\s+/);
+    
+    var query_box_val_plus = "";
+    var query_box_val_double = "";
+    
+    for (var i=0; i<query_box_words.length; i++) {
+	if (i>0) {
+	    query_box_val_plus += " ";
+	}
+	query_box_val_plus += "+" + query_box_words[i];
+	
+	if (i>0) {
+	    query_box_val_double += " " + query_box_words[i-1]+query_box_words[i];
+	}
+    }
+
+
+    form.elements['query'].value = "content.ftsec:(" + query_box_val_plus + query_box_val_double + ")";
+
+    return encodeInput(form);
+}
+
+function fixupSubmitIt() {
+    var search_where = $("#fld0 option:selected").text();
+    console.log("**** search_where = " + search_where);
+    var x = 0;
+    var search_select = $("#fld"+x+" option:selected");
+    var search_where = search_select.text();    
+
+    while (search_where) {
+	if (search_where == "Any field") {
+	    //var sel_val = document.getElementById("fld" + x).selectedIndex].value;
+	    
+	    //var thisField = document.getElementById("fld" + x).options[document.getElementById("fld" + x).selectedIndex].value;
+	    
+	    $("#fld"+x).val('content.ftsec:');
+	    //$("#fld0 option[value='content.ftsec:']").prop('selected', true);
+	    //alert("changed menu");
+	}
+	x = x + 1;
+	search_select = $("#fld"+x+" option:selected");    
+	search_where = search_select.text();
+	//console.log("*** search select = " + search_select.text());
+	//alert("ddd");
+    }
+    buildQuery();
+
+    return submitIt();
+}
+
+//var acmdl_fixup_div = document.getElementById("acmdl-fixup");
+
+
+//window.onload = function(e) {
+
+function acmdlFixupInit() {
+
+    console.log("amc-dl-fixup initiated");
+
+    var query_form = document.getElementsByName("qiksearch")[0];
+    if (query_form) {
+	query_form.setAttribute("onsubmit", "fixupEncodeInput(this) ; _proxy_jslib_flush_write_buffers();");
+    }
+
+    //query_form.setAttribute("onsubmit", "encodeInput(this) ; _proxy_jslib_flush_write_buffers();");
+
+/*
+    var query_box_val = query_form.elements['query'].value;
+
+    //var ft_regex = /content.ftsec:\(\+(.*?)\)/g;
+    //var match = ft_regex.exec(query_box_val);
+
+    query_form.value = query_box_val.replace(/content.ftsec:\(\+(.*)\)/g,"$1");
+
+    //var query_box = document.getElementsByName("query")[0];
+    //var query_box_val = query_box.getAttribute("value");
+    //query_box.setAttribute("value", "Foo");
+*/
+    var adv_query_form = document.getElementById("theform");
+    if (adv_query_form) {
+	// javascript:submitIt();
+	// javascript:; _proxy_jslib_proxify_html(submitIt())[0]
+
+	adv_query_form.setAttribute("action","javascript:fixupSubmitIt();");
+    }
+
+    var query_box = document.getElementsByName("query")[0];
+    if (query_box) {
+	var query_box_val = query_box.getAttribute("value");
+	query_box.setAttribute("value", query_box_val.replace(/content\.ftsec:\(\+(.*)\)/g,"$1"));
+    }
+    
+    console.log("acm-dl-fixup DOM tweaks done");
+}
+
+
+$(document).ready(function() {
+  console.log( "jquery DOM ready" );
+  acmdlFixupInit()
+});
+
Index: other-projects/meddle/trunk/nph-proxy-meddle.cgi
===================================================================
--- other-projects/meddle/trunk/nph-proxy-meddle.cgi	(revision 31606)
+++ other-projects/meddle/trunk/nph-proxy-meddle.cgi	(revision 31607)
@@ -1085,5 +1085,5 @@
 $INSERT_HTML  = "<script  src=\"https://bedrock.resnet.cms.waikato.ac.nz/cgi-bin/wotlp/nph-proxy-acmdl.cgi/en/20/https/code.jquery.com/jquery-2.2.4.min.js\"></script>";
 
-$INSERT_HTML .= "\n<script src=\"/dl-acm-org-alt/acmdl-fixup.js\"></script>" ;
+$INSERT_HTML .= "\n<script src=\"/meddle/meddle-fixup.js\"></script>" ;
 #$INSERT_FILE= 'insert_file_name' ;
 #$INSERT_FILE= 'fixup.html' ;
