refactoring unAPI span building
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 5 Mar 2006 16:07:23 +0000 (16:07 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 5 Mar 2006 16:07:23 +0000 (16:07 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3262 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/js/result_common.js

index 9c10ce2..c182bdc 100644 (file)
@@ -37,6 +37,21 @@ function rdetailDraw() {
        req.send();
 }
 
+function buildunAPISpan (span, type, id) {
+        var cgi = new CGI();
+        var d = new Date();
+
+        addCSSClass(span,'unapi-uri');
+
+        span.appendChild(text('unAPI'));
+        span.setAttribute(
+                'title',
+                'tag:' + cgi.server_name + ',' +
+                        d.getFullYear() +
+                        ':' + type + '/' + id
+        );
+}
+
 var rdeatilMarcFetched = false;
 function rdetailViewMarc(r,id) {
        hideMe($('rdetail_extras_loading'));
@@ -44,26 +59,13 @@ function rdetailViewMarc(r,id) {
 
        var d = new Date();
 
+       var div = elem('div', { class : 'hide_me' });
+       var span = div.appendChild( elem('span') );
+
+       buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
+
        /* add the unapi span inside a hidden div */
-       $('rdetail_view_marc_box').insertBefore(
-               elem('div', { class : 'hide_me' }).appendChild(
-                       elem(   'span',
-                               { class : 'unAPI',
-                                 title :
-                                       'tag:open-ils.org,' +
-                                       d.getFullYear() + '-' +
-                                       (1 + d.getMonth()) + '-' +
-                                       d.getDate() +
-                                       ':biblio-record_entry/' + id },
-                                 'tag:open-ils.org,' +
-                                 d.getFullYear() + '-' +
-                                 (1 + d.getMonth()) + '-' +
-                                 d.getDate() +
-                                 ':biblio-record_entry/' + id
-                       )
-               ),
-               $('rdetail_view_marc_box').firstChild
-       );
+       $('rdetail_view_marc_box').insertBefore(div, $('rdetail_view_marc_box').firstChild);
 }
 
 
@@ -235,7 +237,7 @@ function rdetailShowExtra(type) {
                        unHideMe($('rdetail_extras_loading'));
                        rdetailMarcFetched = true;
                        var req = new Request( FETCH_MARC_HTML, record.doc_id() );
-                       req.callback(rdetailViewMarc, record.doc_id()); 
+                       req.callback(rdetailViewMarc); 
                        req.send();
                        break;
 
index d7dbf0d..0e30bad 100644 (file)
@@ -229,6 +229,20 @@ function resultPaginate() {
        try{searchTimer.stop()}catch(e){}
 }
 
+function buildunAPISpan (span, type, id) {
+       var cgi = new CGI();
+       var d = new Date();
+
+       addCSSClass(span,'unapi-uri');
+
+       span.appendChild(text('unAPI'));
+       span.setAttribute(
+               'title',
+               'tag:' + cgi.server_name + ',' +
+                       d.getFullYear() +
+                       ':' + type + '/' + id
+       );
+}
 
 /* display the record info in the record display table 'pos' is the 
                zero based position the record should have in the display table */
@@ -254,30 +268,10 @@ function resultDisplayRecord(rec, pos, is_mr) {
        var title_link = $n(r, config.names.result.item_title);
        var author_link = $n(r, config.names.result.item_author);
 
-       var d = new Date();
-
        if( is_mr )  {
                var onlyrec = onlyrecord[ getOffset() + pos ];
                if(onlyrec) {
-                       var unapi_span = $n(r,'unapi');
-                       unapi_span.appendChild(
-                               text(
-                                       normalize( rec.title() ) +
-                                               ' (tag:open-ils.org,' +
-                                               d.getFullYear() + '-' +
-                                               (1 + d.getMonth()) + '-' + 
-                                               d.getDate() + 
-                                               ':biblio-record_entry/' + onlyrec + ')'
-                               )
-                       );
-                       unapi_span.setAttribute(
-                               'title',
-                               'tag:open-ils.org,' +
-                                       d.getFullYear() + '-' +
-                                       (1 + d.getMonth()) + '-' + 
-                                       d.getDate() + 
-                                       ':biblio-record_entry/' + onlyrec
-                       );
+                       buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', onlyrec);
 
                        var args = {};
                        args.page = RDETAIL;
@@ -289,25 +283,7 @@ function resultDisplayRecord(rec, pos, is_mr) {
                        title_link.appendChild(text(normalize(truncate(rec.title(), 65))));
                        
                } else {
-                       var unapi_span = $n(r,'unapi');
-                       unapi_span.appendChild(
-                               text(
-                                       normalize( rec.title() ) +
-                                               ' (tag:open-ils.org,' +
-                                               d.getFullYear() + '-' +
-                                               (1 + d.getMonth()) + '-' + 
-                                               d.getDate() + 
-                                               ':metabib-metarecord/' + rec.doc_id() + ')'
-                               )
-                       );
-                       unapi_span.setAttribute(
-                               'title',
-                               'tag:open-ils.org,' +
-                                       d.getFullYear() + '-' +
-                                       (1 + d.getMonth()) + '-' + 
-                                       d.getDate() + 
-                                       ':biblio-record_entry/' + rec.doc_id()
-                       );
+                       buildunAPISpan($n(r,'unapi'), 'metabib-metarecord', rec.doc_id());
 
                        buildTitleLink(rec, title_link); 
                        var args = {};
@@ -318,25 +294,7 @@ function resultDisplayRecord(rec, pos, is_mr) {
                }
 
        } else {
-               var unapi_span = $n(r,'unapi');
-               unapi_span.appendChild(
-                       text(
-                               normalize( rec.title() ) +
-                                       ' (tag:open-ils.org,' +
-                                       d.getFullYear() + '-' +
-                                       (1 + d.getMonth()) + '-' + 
-                                       d.getDate() + 
-                                       ':biblio-record_entry/' + rec.doc_id() + ')'
-                       )
-               );
-               unapi_span.setAttribute(
-                       'title',
-                       'tag:open-ils.org,' +
-                               d.getFullYear() + '-' +
-                               (1 + d.getMonth()) + '-' + 
-                               d.getDate() + 
-                               ':biblio-record_entry/' + rec.doc_id()
-               );
+               buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id());
 
                buildTitleDetailLink(rec, title_link); 
                var args = {};