Update JS
This commit is contained in:
		
							
								
								
									
										72
									
								
								js/script.js
									
									
									
									
									
								
							
							
						
						
									
										72
									
								
								js/script.js
									
									
									
									
									
								
							@@ -13,14 +13,14 @@ docReady(function() {
 | 
			
		||||
        "important": "Important",
 | 
			
		||||
        "caution": "Caution",
 | 
			
		||||
        "warning": "Warning"
 | 
			
		||||
    }
 | 
			
		||||
    };
 | 
			
		||||
    for (var className in boxesNames) {
 | 
			
		||||
        let boxes = document.querySelectorAll('div.' + className)
 | 
			
		||||
        let boxes = document.querySelectorAll('div.' + className);
 | 
			
		||||
 | 
			
		||||
        for (let box of boxes) {
 | 
			
		||||
            let boxTitle = document.createElement('p')
 | 
			
		||||
            boxTitle.className = "admonition-title " + className
 | 
			
		||||
            boxTitle.textContent = boxesNames[className]
 | 
			
		||||
            let boxTitle = document.createElement('p');
 | 
			
		||||
            boxTitle.className = "admonition-title " + className;
 | 
			
		||||
            boxTitle.textContent = boxesNames[className];
 | 
			
		||||
 | 
			
		||||
            box.parentNode.insertBefore(boxTitle, box);
 | 
			
		||||
        }
 | 
			
		||||
@@ -29,34 +29,36 @@ docReady(function() {
 | 
			
		||||
 | 
			
		||||
// Copy Source Block
 | 
			
		||||
docReady(function() {
 | 
			
		||||
    let srcContainers = document.querySelectorAll('pre.src')
 | 
			
		||||
    let srcContainers = document.querySelectorAll('pre.src');
 | 
			
		||||
 | 
			
		||||
    function copyClickFunction() {
 | 
			
		||||
        // Create a clone the node to not affect the original one
 | 
			
		||||
        let nodeClone = this.parentNode.cloneNode(true);
 | 
			
		||||
 | 
			
		||||
        // Remove Line Numbers and Copy Button
 | 
			
		||||
        let linenumNodes = nodeClone.querySelectorAll('.linenr,.src-copy');
 | 
			
		||||
        for (var i = linenumNodes.length - 1 ; i >= 0 ; --i) {
 | 
			
		||||
            nodeClone.removeChild(linenumNodes[i]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Copy the filetered content to the clipboard
 | 
			
		||||
        let srcText = nodeClone.textContent;
 | 
			
		||||
        navigator.clipboard.writeText(srcText).then(function() {
 | 
			
		||||
            boxCopy.textContent = "Copied";
 | 
			
		||||
            boxCopy.classList.add("src-copied");
 | 
			
		||||
            setTimeout(function() {
 | 
			
		||||
                boxCopy.textContent = "Copy";
 | 
			
		||||
                boxCopy.classList.remove("src-copied");
 | 
			
		||||
            }, 2000);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (let srcContrainer of srcContainers) {
 | 
			
		||||
        let boxCopy = document.createElement('div')
 | 
			
		||||
        boxCopy.className = "src-copy"
 | 
			
		||||
        boxCopy.textContent = "Copy"
 | 
			
		||||
        let boxCopy = document.createElement('div');
 | 
			
		||||
        boxCopy.className = "src-copy";
 | 
			
		||||
        boxCopy.textContent = "Copy";
 | 
			
		||||
 | 
			
		||||
        boxCopy.onclick = function() {
 | 
			
		||||
            // Create a clone the node to not affect the original one
 | 
			
		||||
            let nodeClone = this.parentNode.cloneNode(true)
 | 
			
		||||
 | 
			
		||||
            // Remove Line Numbers and Copy Button
 | 
			
		||||
            let linenumNodes = nodeClone.querySelectorAll('.linenr,.src-copy')
 | 
			
		||||
            for (var i = linenumNodes.length - 1 ; i >= 0 ; --i) {
 | 
			
		||||
                nodeClone.removeChild(linenumNodes[i])
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Copy the filetered content to the clipboard
 | 
			
		||||
            let srcText = nodeClone.textContent
 | 
			
		||||
            navigator.clipboard.writeText(srcText).then(function() {
 | 
			
		||||
                boxCopy.textContent = "Copied"
 | 
			
		||||
                boxCopy.classList.add("src-copied")
 | 
			
		||||
                setTimeout(function() {
 | 
			
		||||
                    boxCopy.textContent = "Copy"
 | 
			
		||||
                    boxCopy.classList.remove("src-copied")
 | 
			
		||||
                }, 2000);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        boxCopy.onclick = copyClickFunction;
 | 
			
		||||
 | 
			
		||||
        srcContrainer.prepend(boxCopy);
 | 
			
		||||
    }
 | 
			
		||||
@@ -64,14 +66,14 @@ docReady(function() {
 | 
			
		||||
 | 
			
		||||
// Wrap Images and Tables
 | 
			
		||||
docReady(function() {
 | 
			
		||||
    let wrap_elements = document.querySelectorAll('[float=wrap-right]')
 | 
			
		||||
    let wrap_elements = document.querySelectorAll('[float=wrap-right]');
 | 
			
		||||
    for (let wrap_el of wrap_elements) {
 | 
			
		||||
        wrap_el.closest('.figure').classList.add('wrap-right')
 | 
			
		||||
        wrap_el.closest('.figure').classList.add('wrap-right');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    wrap_elements = document.querySelectorAll('[float=wrap-left]')
 | 
			
		||||
    wrap_elements = document.querySelectorAll('[float=wrap-left]');
 | 
			
		||||
    for (let wrap_el of wrap_elements) {
 | 
			
		||||
        wrap_el.closest('.figure').classList.add('wrap-left')
 | 
			
		||||
        wrap_el.closest('.figure').classList.add('wrap-left');
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -126,7 +128,7 @@ scr.addEventListener('load', () => {
 | 
			
		||||
        var tocTitle = $('#table-of-contents').find('h2');
 | 
			
		||||
        tocTitle.append(closeBtn);
 | 
			
		||||
    });
 | 
			
		||||
})
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user