diff --git a/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl b/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl index f418d58..60a5f6b 100755 --- a/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl +++ b/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl @@ -102,32 +102,55 @@ $doctd = $session->make_element( "td", valign=>"top", style=>"text-align:center" ); $doctr->appendChild( $doctd ); - $doctd->appendChild( $doc->render_icon_link( preview => 1 ) ); - - $doctd = $session->make_element( "td", valign=>"top" ); - $doctr->appendChild( $doctd ); - - # NJS 2007-07-30: Add Google Analytics tracking code to link. - my $rendered_cite = $doc->render_citation_link(); + + ## NJS 2008-07-10: Add Google Analytics tracking code to icon link. + my $rendered_icon = $doc->render_icon_link( preview => 1 ); # Strip the front off the URL to get just the document path. my $doc_url = $doc->get_url; $doc_url =~ m|^http://[^/]+(/.+)$|; my $docpath = $1; - # Ugh, DOM sucks... + # NJS 2008-07-10 # Find the first element in the DocumentFragment and add the - # onclick attribute to it. - $rendered_cite->getFirstChild()->getElementsByTagName('a')->item(0)->setAttribute( + # onclick attribute to it. Note that the DOM documentation says + # the NodeList is indexed from 0, but item(0) gives the wrong + # element (?!?!). + $rendered_icon->getElementsByTagName( 'a' )->item( 1 )->setAttribute( 'onclick', "javascript:urchinTracker( '" . $docpath . "' );" ); + + $doctd->appendChild( $rendered_icon ); + ## END NJS 2008-07-10 +# NJS 2008-07-10: !!! original code follows +# $doctd->appendChild( $doc->render_icon_link( preview => 1 ) ); + + $doctd = $session->make_element( "td", valign=>"top" ); + $doctr->appendChild( $doctd ); + ## NJS 2007-07-30: Add Google Analytics tracking code to text link. + my $rendered_cite = $doc->render_citation_link(); + + # Ugh, DOM sucks... + # NJS 2008-07-10: Updated to work with EPrints 3. + # Find the first element in the DocumentFragment and add the + # onclick attribute to it. Note that the DOM documentation says + # the NodeList is indexed from 0, but item(0) gives the last + # element instead of the first one; item(1)->(4) give the results + # we want here. + $rendered_cite->getElementsByTagName( 'a' )->item( 1 )->setAttribute( + 'onclick', + "javascript:urchinTracker( '" . + $docpath . + "' );" + ); + $doctd->appendChild( $rendered_cite ); - ##END -# !!! original code follows + ## END NJS 2007-07-30 +# NJS 2007-07-30: !!! original code follows # $doctd->appendChild( $doc->render_citation_link() ); my %files = $doc->files; if( defined $files{$doc->get_main} )