PageSourceSearch

https://e-nrp.org/js/commonScript.js

js e-nrp.org collected 2026-10-03 23:52:24 UTC 7,554 bytes, 199 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3    var currentCiteDOI = null;
4
5    //
6    //
7    //
8
9    $( ".CrossrefCitationListLink").on("click", function() {
10        
11        var doi = $(this).data("bs-doi");
12
13        if  ( doi != "" ) {
14            $.ajax({
15                url: "/api/citationcount",
16                data: {
17                    id: doi,
18                    type: "CROSSREF",
19                },
20                dataType: "json",
21                beforeSend: function( xhr ) {
22                    xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
23                }
24            })
25            .done(function( data ) {
26
27                // Values come from CrossRef via the API: build DOM nodes instead of
28                // concatenating HTML. The API sends doi as null when it is not DOI-shaped
29                // (App\Support\Doi::filter); check it here as well.
30                var doiPattern = /^10\.[0-9]{4,9}\/[0-9a-zA-Z\/._-]+$/;
31                var list = $('<ol>');
32
33                $.each(data, function(index, item) {
34                    var itemURL = doiPattern.test( item.doi || "" ) ? "https://doi.org/" + item.doi : null;
35                    var title = $('<h6>');
36
37                    if  ( itemURL ) {
38                        title.append( $('<a>').attr({ href: itemURL, target: "_blank" }).text( item.title || "" ) );
39                    } else {
40                        title.text( item.title || "" );
41                    }
42
43                    var entry = $('<p>').append( title )
44                        .append( $('<div>').text( item.authors || "" ) )
45                        .append( $('<div>').text( item.publishinfo || "" ) );
46
47                    if  ( itemURL ) {
48                        entry.append( $('<div>').append(
49                            $('<a>').attr({ href: itemURL, target: "_blank" }).append(
50                                $('<img>').attr( 'src', 'image/icon_CrossRef.gif' ) ) ) );
51                    }
52
53                    list.append( $('<li>').append( entry ) );
54                });
55
56                $('#CrossrefCitationListModal .modal-body-citationlist').empty().append( list );
57
58                var myModal = new bootstrap.Modal(document.getElementById('CrossrefCitationListModal') );
59                myModal.show();                
60
61            });
62        }
63
64        return  false;
65    });    
66
67
68    $(".CiteDialog").on("click", function(){
69        var citationString = $(this).data( "article-citation" );
70        currentCiteDOI = $(this).data( "article-id" );
71
72        if  ( citationString ) {
73            citationString = decodeURIComponent(escape(window.atob(citationString)));
74            $('#CiteModalContent').html( citationString );
75            $('#CiteModal').modal('show');
76        }
77
78        return	false;
79    });
80
81
82    $(".article-figure-table-link").on("click", function(){
83        var itemFigureTableId = $(this).attr('data-id');
84        var itemType = $(this).data('type');
85        var itemAfn = escape( $("#" +itemFigureTableId+ ".article-figure-table-card").data('afn') );
86        var itemFn = $("#" +itemFigureTableId+ ".article-figure-table-card").data('fn');               
87        var itemURL = "/ViewImagePopup.php?Type="+itemType+"&id="+itemFigureTableId+"&afn="+itemAfn+"&fn="+itemFn;
88
89        $('#FigureTableModal .modal-body').load(itemURL);
90        $('#FigureTableModal').modal('show');
91
92        return	false;
93    });
94
95    $(".article-figure-table-btn").on("click", function(){
96        var itemType = $(this).data('type');
97        var itemId = escape( $(this).closest(".article-figure-table-card").attr('id') );
98        var itemAfn = escape( $(this).closest(".article-figure-table-card").data('afn') );
99        var itemFn = $(this).closest(".article-figure-table-card").data('fn');               
100        var itemURL = "/ViewImagePopup.php?Type="+itemType+"&id="+itemId+"&afn="+itemAfn+"&fn="+itemFn;
101
102        $('#FigureTableModal .modal-body').load(itemURL);
103        $('#FigureTableModal').modal('show');
104
105        return	false;
106    });
107
108  
109    $("#Portlet-MenuItem-CITATION-Copy").on("click", function(){
110        
111        $("#CiteModalCopyAlert").removeClass('d-none');
112
113        setTimeout(function() {                    
114            $("#CiteModalCopyAlert").addClass('d-none');
115            }, 3000);
116
117        if (document.selection) {
118            var range = document.body.createTextRange();
119            range.moveToElementText(document.getElementById("CiteModalContent"));
120            range.select().createTextRange();
121            document.execCommand("copy");                    
122        } else if (window.getSelection) {
123            var range = document.createRange();
124            range.selectNode(document.getElementById("CiteModalContent"));
125            window.getSelection().addRange(range);
126            document.execCommand("copy");
127        }
128
129        return	false;
130    });
131
132    $("#CiteModalButtons .dropdown-item").on('click', function() {
133        valueCR = $(this).data( "cr" );
134        valueEX = $(this).data( "ex" );
135        var citeURL = 'ExportCitation.php?id='+encodeURIComponent(currentCiteDOI)+'&type='+encodeURIComponent(valueEX)+'&cr='+encodeURIComponent(valueCR);
136
137        $.ajax({
138            url: citeURL,
139            method: 'GET',
140            xhrFields: {
141                responseType: 'blob'
142            },
143            success: function(blob, status, xhr) {
144                // check for a filename
145                var filename = "";
146                var disposition = xhr.getResponseHeader('Content-Disposition');
147                if (disposition && ( disposition.indexOf('inline') !== -1 || disposition.indexOf('attachment') !== -1 ) ) {
148                    var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
149                    var matches = filenameRegex.exec(disposition);
150                    if (matches != null && matches[1]) filename = matches[1].replace(/['"]/g, '');
151                }
152
153                if (typeof window.navigator.msSaveBlob !== 'undefined') {
154                    window.navigator.msSaveBlob(blob, filename);
155                } else {
156                    var URL = window.URL || window.webkitURL;
157                    var downloadUrl = URL.createObjectURL(blob);
158
159                    if (filename) {
160                        var a = document.createElement("a");
161                        if (typeof a.download === 'undefined') {
162                            window.location.href = downloadUrl;
163                        } else {
164                            a.href = downloadUrl;
165                            a.download = filename;
166                            document.body.appendChild(a);
167                            a.click();
168                        }
169                    } else {
170                        window.location.href = downloadUrl;
171                    }
172
173                    setTimeout(function () { URL.revokeObjectURL(downloadUrl); }, 100); // cleanup
174                }
175            }
176        });
177    });
178
179
180    $(".ShareContents").on("click", function(){
181        var valueTARGET = $(this).data( "target" );
182
183        if  (valueTARGET == 'FACEBOOK') {     
184            window.open("{{$aShareContents['FACEBOOK']['URL']}}");           
185        }
186        else if  (valueTARGET == 'TWITTER') {
187            window.open("{{$aShareContents['TWITTER']['URL']}}");
188        }
189
190        return  false;
191    });
192
193    
194    $('.article-portlet-carousel').on('slide.bs.carousel', function (e) {        
195        $(this).find('.carousel-current-page').text( e.to + 1 );
196        return  true;
197    });
198
199});    

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.