MCPcopy Create free account
hub / github.com/frank-lam/fullstack-tutorial / imgAdd

Function imgAdd

notes/docsify/js/main.js:50–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48 }
49
50 function imgAdd() {
51 var imgs = document.querySelectorAll('.markdown-section img');
52 // var imgs = document.getElementsByTagName('medium-zoom-image');
53
54 for (let j = 0; j < imgs.length; j++) {
55 // console.log('zheshi')
56 let img = imgs[j];
57 // console.log(img);
58 if (img.src) {
59 console.log(img.src);
60 if (!img.getAttribute('hadassets')) {
61 let hasharr = window.location.hash.split('/');
62 // console.log(hasharr);
63 let origin = window.location.origin;
64 img.setAttribute('hadassets', 1);
65 var hasharrPath = "";
66 for(var i = 1; i < hasharr.length - 1 ; i++){
67 hasharrPath += hasharr[i] + "/";
68 }
69
70 // img.src = origin + '/' + hasharrPath + img.src.substring(origin.length + 1);
71 var imgSrc = img.getAttribute("src");
72 if(!imgSrc.includes(hasharrPath)){
73 img.setAttribute("src", hasharrPath + imgSrc);
74 }
75 // img.src = origin + '/' + hasharrPath + img.getAttribute("src");
76 }
77 }
78 }
79 }
80 function initStyleSwitcher() {
81 var isInitialzed = false;
82 var sessionStorageKey = 'activeStylesheetHref';

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected