Changes

Jump to: navigation, search

JQuery HTML Updater

3,117 bytes added, 16:31, 6 May 2010
no edit summary
== Complete Example ==
For the purpose of this example, to avoid confusion, we use JHU Umlaut installation URLs. You would want to replace with URLs to your own Umlaut of course.
 
<pre>
<html>
 
<head>
<script type="text/javascript" src="http://findit.library.jhu.edu/javascripts/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
jQuery.noConflict();
</script>
<script type="text/javascript" src="http://findit.library.jhu.edu/javascripts/jquery/umlaut/update_html.js"></script>
<script type="text/javascript" src="http://findit.library.jhu.edu/js_helper/loader"></script>
 
<script type="text/javascript">
jQuery(document).ready(function($) {
var loader = new Umlaut.Loader();
loader.load();
var openurl_link = $("a.openurl_link").attr("href");
var ctx_object_kev = openurl_link.substring( openurl_link.indexOf("?") + 1);
var updater = new Umlaut.HtmlUpdater("http://findit.library.jhu.edu" , ctx_object_kev );
updater.add_section_target({ umlaut_section_id: "fulltext", selector:".my_full_text" , before_update: function(html, count) { return (count == 0); }});
updater.add_section_target({ umlaut_section_id: "search_inside", selector:".stuff", position: "append" });
updater.add_section_target({ umlaut_section_id: "excerpts", selector:".stuff", position: "append" });
updater.add_section_target({
umlaut_section_id: "holding",
selector:".stuff",
position: "append",
before_update: function(container_element) {
container_element.find("h3").after("<h4>We love these holdings.</h4>");
}
});
updater.add_section_target({
umlaut_section_id: "abstract",
selector:".stuff",
position: "append",
before_update: function(html, count) {
//only show if there are hits
return ( count == 0);
}
});
updater.add_section_target({ umlaut_section_id: "related_items", selector:".stuff", position: "append" });
updater.add_section_target({
umlaut_section_id: "highlighted_link",
selector:".only_if_content",
after_update: function(updated_content, count) {
if ( count > 0 ) {
updated_content.closest(".only_if_content").show();
}
}
});
updater.add_section_target({
umlaut_section_id: "export_citation",
selector:".stuff",
position:"append",
before_update: function(content, count) {
$(content).find(".section_heading h3").text("My own crazy export options");
}
});
updater.complete = function() { alert("Umlaut fully loaded") };
updater.update();
 
});
</script>
 
</head>
 
<body>
 
<a class="openurl_link" href="http://app01.mse.jhu.edu:3000/resolve?sid=google&auinit=N&aulast=Chomsky&title=Aspects+of+the+Theory+of+Syntax&genre=book&isbn=0262530074&date=1965">Find It @ JH</a>
 
<h2>Full Text</h2>
<div class="my_full_text">
Replace me.
</div>
 
<h2>More Stuff</h2>
<div class="stuff">
</div>
 
<div class="only_if_content" style="display:none">
This will be shown only if it actually contains content.
</div>
 
 
</body>
 
 
</html>
</pre>

Navigation menu