Changeset 31628


Ignore:
Timestamp:
2017-04-21T16:21:36+12:00 (7 years ago)
Author:
davidb
Message:

More refined test for when to ask about expand ligatures, and other code tidy up into routines. Commented out Google Scholar for now.

Location:
other-projects/meddle/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • other-projects/meddle/trunk/index.html

    r31627 r31628  
    4343      </a>
    4444    </li>
     45<!--
    4546    <li>
    4647      <a href="https://bedrock.resnet.cms.waikato.ac.nz/cgi-bin/meddle/nph-proxy-meddle.cgi/en/20/http/ieeexplore.ieee.org/">
     
    4849      </a>
    4950    </li>
     51-->
    5052    <li>
    5153      <a href="https://bedrock.resnet.cms.waikato.ac.nz/cgi-bin/meddle/nph-proxy-meddle.cgi/en/20/https/scholar.google.com/">
  • other-projects/meddle/trunk/meddle-fixup.js

    r31627 r31628  
    114114
    115115
    116 
    117 function fixupEncodeInput(form) {
    118     console.log( "amcm-dl-fixup fixupEncodeInput(form) called" );
     116function opt_ligature_replacement(query_box_val)
     117{
    119118
    120119    if (ligature_re === null) {
     
    125124    //console.log("*** ligature_str = " + ligature_str);
    126125
     126    var detected_ligatures = ligature_re.test(query_box_val);
     127    var do_replacement = $('#meddle-lig').is(":checked");
     128
     129    if (!do_replacement) {
     130    // option not on, but maybe the user hasn't realized their query contains ligatures
     131    if (detected_ligatures) {
     132        do_replacement = confirm("Detected ligatures in query. Replace with individual characters?");
     133    }
     134    }
     135
     136    if (do_replacement) {
     137        var query_chars = query_box_val.split("");
     138        var query_chars_fixed = [];
     139   
     140        for (var i=0; i<query_chars.length; i++) {
     141        var c = query_chars[i];
     142        if (ligature_map[c]) {
     143        c = ligature_map[c];
     144        }
     145        query_chars_fixed.push(c);
     146        }
     147        query_box_val = query_chars_fixed.join("");
     148    }
     149
     150    return query_box_val;
     151}
     152
     153function opt_accent_fold(query_box_val)
     154{
     155
     156    var do_accent_replacement = $('#meddle-acc').is(":checked");
     157
     158    if (do_accent_replacement) {
     159    query_box_val = accent_fold(query_box_val);
     160    }
     161
     162    return query_box_val;
     163}
     164
     165
     166function fixupEncodeInput(form) {
     167    console.log( "amcm-dl-fixup fixupEncodeInput(form) called" );
     168
     169    //if (ligature_re === null) {
     170     //   var ligature_str = Object.keys(ligature_map).join("|");
     171      //  ligature_re = new RegExp(ligature_str);
     172    //}
     173
     174    //console.log("*** ligature_str = " + ligature_str);
     175
    127176    var query_box_val = form.elements['query'].value;
    128 
     177    query_box_val = opt_ligature_replacement(query_box_val);
     178
     179/*
    129180    var detected_ligatures = ligature_re.test(query_box_val);
    130181    if (detected_ligatures) {
     
    146197    }
    147198    }
    148 
     199*/
     200
     201/*
    149202    var do_accent_replacement = $('#meddle-acc').is(":checked");
    150203    if (do_accent_replacement) {
    151204    query_box_val = accent_fold(query_box_val);
    152205    }
     206*/
     207
     208    query_box_val = opt_accent_fold(query_box_val);
    153209
    154210    // e.g., content.ftsec:(+capisco)
     
    174230    form.elements['query'].value = "content.ftsec:(" + query_box_val_plus + query_box_val_double + ")";
    175231
     232
    176233    return encodeInput(form);
    177234}
     
    207264function meddleInfoBox() {
    208265
    209     $('#_proxy_css_top_insertion').append('<form name="MeddleForm" style="padding-bottom: 20px;"><center><table cellpadding="5" border="1"><tbody><tr><td align="center"><img src="http://bedrock.resnet.cms.waikato.ac.nz/meddle/meddle-icon-large.png" width="64" height="64" /></td><td><b><font size="+1"><a href="https://bedrock.resnet.cms.waikato.ac.nz/meddle/">MEDDLE Proxy: ModifiED Digital Library Proxy</a></font></b><br /><div id="dlcontext"></div><div id="dlcontextoptions"</div></td></tr></tbody></table></center></form>');
     266    //$('#_proxy_css_top_insertion').append('<form name="MeddleForm" style="padding-bottom: 20px;"><center><table cellpadding="5" border="1"><tbody><tr><td align="center"><img src="http://bedrock.resnet.cms.waikato.ac.nz/meddle/meddle-icon-large.png" width="64" height="64" /></td><td><b><font size="+1"><a href="https://bedrock.resnet.cms.waikato.ac.nz/meddle/">MEDDLE Proxy: ModifiED Digital Library Proxy</a></font></b><br /><div id="dlcontext"></div><div id="dlcontextoptions"</div></td></tr></tbody></table></center></form>');
    210267
    211268    // Icon image
     
    279336
    280337function fixupGScholarSubmit(evt) {
    281     //alert("Bar");
    282     console.log( "gscholar-dl-fixup fixupEncodeInput(form) called" );
     338    console.log( "gscholar-dl-fixup fixupGScholarSubmit(form) called" );
    283339
    284340    var event = evt || window.event;
     
    287343    event.preventDefault(); // to stop the form from submitting
    288344
     345/*
    289346    if (ligature_re === null) {
    290347        var ligature_str = Object.keys(ligature_map).join("|");
    291348        ligature_re = new RegExp(ligature_str);
    292349    }
     350*/
    293351
    294352    //console.log("*** ligature_str = " + ligature_str);
     
    298356    var query_box_val = query_box.value;
    299357
     358    query_box_val = opt_ligature_replacement(query_box_val);
     359/*
    300360    var detected_ligatures = ligature_re.test(query_box_val);
    301361    if (detected_ligatures) {
     
    317377    }
    318378    }
    319 
     379*/
     380
     381/*
    320382    var do_accent_replacement = $('#meddle-acc').is(":checked");
    321383    if (do_accent_replacement) {
    322384    query_box_val = accent_fold(query_box_val);
    323385    }
    324 
     386*/
     387
     388    query_box_val = opt_accent_fold(query_box_val);
    325389
    326390    //form.elements['q'].value = query_box_val;
     
    356420
    357421    }
    358 
    359 
    360 
    361 /*
    362     //var query_box = document.getElementsByName("query")[0];
    363     //var query_box_val = query_box.getAttribute("value");
    364     //query_box.setAttribute("value", "Foo");
    365 */
    366     console.log("gscholar DOM tweaks done");
    367 }
    368 
    369 
    370 // Google Scholar
    371 // <input class="gs_in_txt" name="q" value="" data-iq="" id="gs_hp_tsi" size="57" maxlength="256" autocapitalize="off" autocomplete="off" aria-label="Search" dir="ltr" type="text">
     422}
     423
     424
     425function fixupXploreSubmit(evt) {
     426    console.log( "xplore-dl-fixup fixupXploreSubmit(evt) called" );
     427
     428    var event = evt || window.event;
     429    event.preventDefault(); // to stop the form from submitting
     430
     431    var query_box = document.getElementById("input-basic");
     432    var query_box_val = query_box.value;
     433
     434    query_box_val = opt_ligature_replacement(query_box_val);
     435
     436/*
     437    var do_accent_replacement = $('#meddle-acc').is(":checked");
     438    if (do_accent_replacement) {
     439    query_box_val = accent_fold(query_box_val);
     440    }
     441*/
     442
     443    query_box_val = opt_accent_fold(query_box_val);
     444
     445    query_box.value = query_box_val;
     446
     447    var query_form = document.getElementById("search_form");
     448
     449    _proxy_jslib_flush_write_buffers(); // is this needed?
     450    query_form.submit();
     451
     452
     453}
     454
     455
     456function xploreFixupInit() {
     457
     458    console.log("IEEE-Xpore DOM tweaks initiated");
     459
     460    var query_form = document.getElementById("search_form");
     461    if (query_form) {
     462    query_form.onsubmit = fixupXploreSubmit;
     463    }
     464   
     465    console.log("IEEE-Xplore DOM tweaks done");
     466}
     467
    372468
    373469$(document).ready(function() {
    374   console.log( "jquery DOM ready" );
    375   meddleInfoBox();
    376 
    377   acmdlFixupInit()
    378   gscholarFixupInit()
     470    console.log( "jquery DOM ready" );
     471    meddleInfoBox();
     472
     473    acmdlFixupInit();
     474    //gscholarFixupInit();
     475    xploreFixupInit();
    379476
    380477});
  • other-projects/meddle/trunk/nph-proxy-meddle.cgi

    r31612 r31628  
    10831083
    10841084$INSERT_HTML .= "\n<script src=\"/meddle/meddle-fixup.js\"></script>" ;
     1085
     1086$INSERT_HTML .= '<form name="MeddleForm" style="padding-bottom: 20px;"><center><table cellpadding="5" border="1" style="border-collapse: separate; border-spacing: 2px;"><tbody><tr><td align="center"><img src="//bedrock.resnet.cms.waikato.ac.nz/meddle/meddle-icon-large.png" width="64" height="64" /></td><td><b><font size="+1"><a href="https://bedrock.resnet.cms.waikato.ac.nz/meddle/">MEDDLE Proxy: ModifiED Digital Library Proxy</a></font></b><br /><div id="dlcontext"></div><div id="dlcontextoptions"</div></td></tr></tbody></table></center></form>';
     1087
    10851088#$INSERT_FILE= 'insert_file_name' ;
    10861089#$INSERT_FILE= 'fixup.html' ;
     
    10881091# If your insertion has links that you don't want anonymized along with the rest
    10891092#   of the downloaded HTML, then set this to 0.  Otherwise leave it at 1.
    1090 $ANONYMIZE_INSERTION= 1 ;
     1093#$ANONYMIZE_INSERTION= 1 ;
    10911094#### !!!! ACMDL-MOD
    10921095$ANONYMIZE_INSERTION= 0 ;
Note: See TracChangeset for help on using the changeset viewer.