1/* 2 * Replace all SVG images with inline SVG 3 */ 4var replaceSVG = null; 5$(function () { 6 replaceSVG = function (selector) { 7 var $elements = $(selector); 8 $elements.each(function () { 9 var $img = $(this); 10 var imgId = $img.attr('id'); 11 var imgClass = $img.attr('class'); 12 var imgUrl = $img.attr('src'); 13 14 $.get(imgUrl, function (data) { 15 // Get the SVG tag, ignore the rest 16 var $svg = $(data).find('svg'); 17 18 // Add replaced image's ID to the new SVG 19 if (typeof imgId !== 'undefined') { 20 $svg = $svg.attr('id', imgId); 21 } 22 // Add replaced image's classes to the new SVG 23 if (typeof imgClass !== 'undefined') { 24 $svg = $svg.attr('class', imgClass + ' replaced-svg'); 25 } 26 27 // Remove any invalid XML tags as per http://validator.w3.org 28 $svg = $svg.removeAttr('xmlns:a'); 29 30 // Replace image with new SVG 31 $img.replaceWith($svg); 32 }, 'xml'); 33 }); 34 }; 35 36 replaceSVG('img.svg'); 37 setTimeout(function () { 38 replaceSVG('img.svg'); 39 }, 1000); 40 setTimeout(function () { 41 replaceSVG('img.svg'); 42 }, 2000); 43});
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.