-
-
Save splosch/ffcb3c154f4e7928d323f8b2aee5e9f1 to your computer and use it in GitHub Desktop.
JS: Bookmarklet for displaying QR code of current URL (good for presentations)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:void !function(e,t,n,r,i,s){while(n--&&(i=t[n])>e);s=r.style,s.position="fixed",s.zIndex=-1>>>1,s.top=s.left="50%",s.marginTop=s.marginLeft=i/-2+"px",r.src="http://chart.apis.google.com/chart?cht=qr&chld=H|0&chs="+i+"x"+i+"&chl="+escape(location)}(Math.min(top.innerHeight,top.innerWidth),[100,150,200,250,300,350,400,500],8,document.body.appendChild(new Image)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void( | |
!function(max,sizes,index,image,size,style){ | |
while(index--&&(size=sizes[index])>max); // choose largest QR code that will fit | |
style=image.style, style.position="fixed", | |
style.zIndex=-1>>>1, // ensure top z-index :) | |
style.top=style.left="50%", style.marginTop=style.marginLeft=size/-2+"px", // center image on viewport | |
image.src="http://chart.apis.google.com/chart?cht=qr&chld=H|0&chs="+size+"x"+size+"&chl="+escape(location) // load QR code via Google's Chart API | |
}( | |
Math.min(top.innerHeight,top.innerWidth), // max: maximum available viewing area | |
[100,150,200,250,300,350,400,500], // sizes: optional QR code sizes | |
8, // index: initial array pointer | |
document.body.appendChild(new Image) // image: append image to page | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment