mirror of
				https://github.com/Mabbs/mabbs.github.io
				synced 2025-10-30 05:21:41 +08:00 
			
		
		
		
	Update 2 files
- /assets/css/style.scss - /assets/js/main.js
This commit is contained in:
		
							parent
							
								
									8f440b43dd
								
							
						
					
					
						commit
						8211f6d1a2
					
				| @ -77,3 +77,26 @@ h6:hover .octicon { | |||||||
|     margin-left: -16px; |     margin-left: -16px; | ||||||
|     vertical-align: middle; |     vertical-align: middle; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | div.highlight { | ||||||
|  |     position: relative; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | div.highlight:hover button { | ||||||
|  |     opacity: 1 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | div.highlight button { | ||||||
|  |     opacity: 0; | ||||||
|  |     position: absolute; | ||||||
|  |     top: 0.5rem; | ||||||
|  |     right: 1rem; | ||||||
|  |     height: 2em; | ||||||
|  |     transition: all 0.2s ease-out | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | div.highlight button:active, | ||||||
|  | div.highlight button:focus, | ||||||
|  | div.highlight button:hover { | ||||||
|  |     opacity: 1 | ||||||
|  | } | ||||||
| @ -77,6 +77,33 @@ $(function() { | |||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | var codeBlocks = document.querySelectorAll('div.highlight'); | ||||||
|  | 
 | ||||||
|  | codeBlocks.forEach(function (codeBlock) { | ||||||
|  |     var copyButton = document.createElement('button'); | ||||||
|  |     copyButton.className = 'copy'; | ||||||
|  |     copyButton.type = 'button'; | ||||||
|  |     copyButton.innerText = '📋'; | ||||||
|  | 
 | ||||||
|  |     codeBlock.append(copyButton); | ||||||
|  | 
 | ||||||
|  |     copyButton.addEventListener('click', function () { | ||||||
|  |         var code = codeBlock.querySelector('pre code').innerText.trim(); | ||||||
|  |         window.navigator.clipboard.writeText(code) | ||||||
|  |             .then(() => { | ||||||
|  |                 copyButton.innerText = '✅'; | ||||||
|  |             }) | ||||||
|  |             .catch(err => { | ||||||
|  |                 copyButton.innerText = '❌'; | ||||||
|  |                 console.error('Failed to copy:', err); | ||||||
|  |             }); | ||||||
|  | 
 | ||||||
|  |         setTimeout(function () { | ||||||
|  |             copyButton.innerText = '📋'; | ||||||
|  |         }, 1500); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| today = new Date(); | today = new Date(); | ||||||
| timeold = (today.getTime() - lastUpdated.getTime()); | timeold = (today.getTime() - lastUpdated.getTime()); | ||||||
| secondsold = Math.floor(timeold / 1000); | secondsold = Math.floor(timeold / 1000); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 mayx
						mayx