Changes

Umlaut partial html API javascript helper

2,662 bytes added, 16:22, 19 June 2012
no edit summary
If you want to include Umlaut-generated HTML directly on a third party page via javascript, there is a javascript helper script to make that very easy. =WARNING: This helper uses the [[Umlaut partial html API]], but does everything for you. The helper will update your divs, and keep polling Umlaut for new results, continuing to re-update your divs until Umlaut is finished. How often it polls is configured by application config 'poll_wait_seconds', which defaults to 4 seconds. Outdated Documentation!!!!=
Hey! Great Stuff!, '''THIS IS OUTDATED DOCUMENTATION''' See new Umlaut documentation at http://www.mlivegithub.com/forumsteam-umlaut/profileumlaut/wiki--------- THE CODE DOCUMENTED HERE IS DEPRECATED.ssf?nickname=drawntoget4 drawn together uncensoredPLEASE SEE INSTEAD: [[JQuery HTML Updater]] If you want to include [[Umlaut]]-generated HTML directly on a third party page via javascript, there is a javascript helper script to make that very easy. This helper uses the [[Umlaut partial html API]], but does everything for you. 8The helper will update your divs, and keep polling Umlaut for new results, continuing to re-DDDupdate your divs until Umlaut is finished. How often it polls is configured by application config 'poll_wait_seconds', http://wwwwhich defaults to 4 seconds.mlive == Overview == Your page needs to include the JS Prototype library.com/forums/profile Currently, automatic inclusion of the Prototype library isn't working, so you'll need to include a <script> line to do so.ssf?nickname=foxxyloveu2 foxxy love uncensoredYou can link to the prototype library in Umlaut, 0725see example below.  You will then include an Umlaut javascript file, httpand then call the embedUmlaut() js function it supplies. You'll need to pass some arguments to embedUmlaut=== Umlaut base URL === The first argument is your Umlaut base URL. This is not your link resolver base url which for Umlaut ends in /resolve, but the actual Umlaut application base URL, which should be the same, without the /wwwresolve.mlive.com (Link to JHU example removed, because i think it was attracting malicious bot/forums/profilespider traffic) === Context object === The second argument is a URL-formatted (KEV) [[OpenURL]] context object.ssf?nickname =ppoppinunc5 p poppin uncensored== Display section mappings === The third argument is a javascript hash providing mappings from Umlaut html sections to HTML divs on your page. Umlaut html sections are configured in Umlaut in the "partial_html_map" configuration param, 235238which by default is set to the "bg_update_map" config params :divs key. To see the sections in a default Umlaut installation, see: AppConfig::Base.bg_update_map [http://wwwumlaut.mliverubyforge.comorg/forumssvn/profiletrunk/config/initializers/umlaut/resolve_views.ssf?nickname=lilkimunce1 lil kim uncensoredrb in resolve_views in svn]. The :divs key of the hash there is an array of hashes, 0520each individual hash has a :div_id key that corresponds to the html_sections id in this api response. For Umlaut developers, httpthe ://wwwpartial key tells you what [[Rails]] partial is used to generate this section.mlive This mapping hash can also optionally use some javascript callbacks to perform behavior after or during loading of a particular section.com/forums/profileIn the following example, we'll demo using a javascript callback to only show a div for search_inside functionality if there are search_inside tools provided.ssf?nickname =jennyfromt2 jenny from == General options === The fourth argument is a hash of additional options to embedUmlaut.  === Other Details === The umlaut_embed.js script will check if the block uncensored videojavascript Prototype library is loaded into the host page, 8-PPand load it if not. Among other things,this means you can use Prototype in your callbacks.  The html loaded will sometimes include a "spinner" with a message "loading more", if the content is not yet loaded.  An example is best:
== Example ==
<script type="text/javascript">
// You have to generate an OpenURL context object somehow, and set it in a js global var.
// Normally this would be generated dynamically, not static HTML like this, of course.
// You may want to include a rfr_id to identify your application as a source, demo below.
umlaut_openurl_kev_co = 'url_ver=Z39.88-2004&rft_val_fmt=info:ofi/fmt:kev:mtx:journal&rft_id=info:doi/10.1002/jez.1401770202&rfr_id=info:sid/university.edu:myapplication&rft.genre=article&rft.jtitle=J.%20Exp.%20Zool&rft.date=1971&rft.atitle=Cytoplasmic%20control%20of%20nuclear%20behavior&rft.aulast=Masui';
// set global js var to tell script where to find umlaut
umlaut_base = 'http://umlaut.university.edu';
umlaut_section_map = {
'fulltext_wrapperfulltext': 'my_fulltext',
'highlighted_links': 'my_see_also',
'excerpts_wrapperexcerpts': 'my_excerpts',
'cover_image': 'my_cover',
'search_inside_wrappersearch_inside': {'host_div_id': 'my_search_inside',
'after_update':
function(count) {
}
}
};
 
//global embedUmlaut options
//demonstrate putting up an alert when Umlaut is done loading all content, which you
//wouldn't want to do, but anyway.
umlaut_options = {
'all-complete-callback': function() { alert('All done!'); }
};
</script>
 
<!-- include the prototype library -->
<script type="text/javascript" src="http://umlaut.university.edu/javascripts/prototype.js"></script>
 
<!-- now actually load the umlaut js helper, which will do the magic for you -->
<script type="text/javascript" src="http://umlaut.university.edu/javascripts/embed/umlaut-embed-func.js"></script>  <!-- and call embedUmlaut --> <script type="text/javascript"> embedUmlaut(umlaut_base, umlaut_openurl_kev_co, umlaut_section_map, umlaut_options); </script>