1balanceText(); 2 3document.addEventListener("DOMContentLoaded", function () { 4 /* Skip link */ 5 $("#skip_link").click(function (e) { 6 e.preventDefault(); 7 $("#main").attr("tabindex", "-1").focus(); 8 }); 9 10 /* Sitewide banner */ 11 if($('#sitewide-banner')) { 12 $(".sitewide-banner-content > p:last-child").addClass("mb-0"); 13 // balance text 14 balanceText($(".sitewide-banner-content > p"), { watch: true }); 15 // ensure links are styled per alert color 16 $("#sitewide-banner a").addClass("alert-link"); 17 } 18 19 /* External links 20 $('main a[target = "_blank"]').append('<svg class="icon" aria-label="(opens in new tab)"><use xlink:href="/assets/globus-css/icons/icons-sprite.svg#link-external"></use></svg>');*/ 21 22 /* More links */ 23 $("a.more-link").append( 24 '<svg class="icon icon-2x" aria-hidden="true"><use xlink:href="/assets/globus-css/icons/icons-sprite.svg#arrow-circle-right"></use></svg>' 25 ); 26 27 // swap for bold icons on hover 28 $("a.more-link,a.next-link").hover( 29 function () { 30 $(this) 31 .find("use") 32 .attr( 33 "xlink:href", 34 "/assets/globus-css/icons/icons-sprite.svg#arrow-circle-right-bold" 35 ); 36 }, 37 function () { 38 $(this) 39 .find("use") 40 .attr( 41 "xlink:href", 42 "/assets/globus-css/icons/icons-sprite.svg#arrow-circle-right" 43 ); 44 } 45 ); 46 47 $("a.previous-link").hover( 48 function () { 49 $(this) 50 .find("use") 51 .attr( 52 "xlink:href", 53 "/assets/globus-css/icons/icons-sprite.svg#arrow-circle-left-bold" 54 ); 55 }, 56 function () { 57 $(this) 58 .find("use") 59 .attr( 60 "xlink:href", 61 "/assets/globus-css/icons/icons-sprite.svg#arrow-circle-left" 62 ); 63 } 64 ); 65 66 /* Blockquotes in rich-text */ 67 $('.rich-text blockquote').addClass('media-body font-italic mt-2 mb-3'); 68 $('.rich-text blockquote p').addClass('m-0'); 69 $('.rich-text blockquote').wrap('<div class="media"></div>'); 70 $('.rich-text blockquote').before('<svg class="icon icon-2x fill-blue-400 mr-2" aria-label="quote"><use xlink:href="/assets/globus-css/icons/icons-sprite.svg#quotation-marks"></use></svg>'); 71 $('aside .rich-text [aria-label="quote"]').removeClass('icon-2x').addClass('icon-xl-2x'); 72 $(".rich-text blockquote cite").addClass('d-block text-right small font-normal'); 73 74 /* Accordions */ 75 // apply styling to items expanded by default 76 addExpandedStyling($('.accordion button[data-toggle="collapse"][aria-expanded="true"]')); 77 $('.accordion button[data-toggle="collapse"]').click( 78 function () { 79 removeExpandedStyling($(this).closest('.accordion').find('button[data-toggle="collapse"]').not(this)); 80 toggleExpandedStyling($(this)); 81 } 82 ); 83 84 // styling on expanded accordion items 85 function addExpandedStyling(elm) { 86 var imgpath = "/assets/globus-css/icons/icons-sprite.svg#caret-sm"; 87 $(elm).find('use').attr('xlink:href', imgpath + '-up'); 88 $(elm).addClass("font-weight-bold"); 89 $(elm).closest('.card-header').addClass("border-bottom-0"); 90 } 91 function removeExpandedStyling(elm) { 92 var imgpath = "/assets/globus-css/icons/icons-sprite.svg#caret-sm"; 93 $(elm).find('use').attr('xlink:href', imgpath + '-down'); 94 $(elm).removeClass("font-weight-bold"); 95 $(elm).closest(".card-header").removeClass("border-bottom-0"); 96 } 97 function toggleExpandedStyling(elm) { 98 toggleUpDown($(elm)); 99 $(elm).toggleClass("font-weight-bold"); 100 $(elm).closest(".card-header").toggleClass("border-bottom-0"); 101 } 102 103 /* Tables in rich-text */ 104 $('.rich-text table').not('.table').addClass('table table-bordered'); 105 $('.rich-text table').wrap('<div class="table-responsive"></div>'); 106 107 /* Toggle caret up/down on expand-btns */ 108 function toggleUpDown(elm) { 109 var imgpath = "/assets/globus-css/icons/icons-sprite.svg#caret-sm"; 110 if ($(elm).find('use').attr('xlink:href') == imgpath + '-down') { 111 $(elm).find('use').attr('xlink:href', imgpath + '-up'); 112 } else { 113 $(elm).find('use').attr('xlink:href', imgpath + '-down'); 114 } 115 } 116 117 // Flip Counter 118 if ($('#flip-counter').length) { 119 // Keep the counter section hidden until data becomes available 120 $("#counter").hide(); 121 122 var myCounter = new flipCounter("flip-counter", { inc: 13, pace: 1000 }); 123 function countReceived(_data) { 124 var data = null;
125 try { 126 data = JSON.parse(_data); 127 } catch (ex) { 128 try { 129 _data = _data.replace('"old"', ',"old"'); 130 data = JSON.parse(_data); 131 } catch (ex) {} 132 } 133 if (data) { 134 // for testing purposes we can change `data["old"].bytes` and 135 // `data["new"].bytes` to a hard values 136 // ie: 899999999999999999, 137 // Note: counter layout will break when we reach 14 places 138 // (or 10,000,000,000,000 MB transferred) 139 var oldCount = Math.round(data["old"].bytes / 1000000); 140 var newCount = Math.round(data["new"].bytes / 1000000); 141 myCounter.stop(); 142 myCounter.setValue(oldCount); 143 myCounter.incrementTo(newCount, 350, 250); 144 145 var counterLabel = newCount + " MB Transferred"; 146 $('#flip-counter').attr('aria-label',counterLabel) 147 148 // Since we have valid data now, show section. 149 $("#counter").show(); 150 } 151 } 152 153 function refreshCounts() { 154 $.ajax({ 155 url: "https://transfer.api.globus.org/v0.10/private/web_stats", 156 dataType: "text", 157 type: "GET", 158 success: function (_data) { 159 countReceived(_data); 160 }, 161 }); 162 } 163 164 // Retrieve counts immediately on page load and every ~5 minutes 165 // thereafter, even if Transfer API fails to respond w/ valid data 166 refreshCounts(); 167 setInterval(function () { 168 refreshCounts(); 169 }, 350000); 170 } 171});
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.