Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Last active January 2, 2019 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zemnmez/414911c7f0d26e3ca0620a8516f0fd22 to your computer and use it in GitHub Desktop.
Save Zemnmez/414911c7f0d26e3ca0620a8516f0fd22 to your computer and use it in GitHub Desktop.
function byid(id) {
return document.getElementById(id);
}
function valof(id) {
return byid(id).checked ? 1 : 0;
}
function text(e) {
if (e == null) {
return "";
}
var s = e.value;
return s;
}
var lastQ = null
var ticking = false
var ticksSinceChange = 0
function update() {
var q = theImage();
// byid("xxx").innerHTML = "<img src=\"" + q + "\" />"
// alert(q)
// return;
var req = new XMLHttpRequest()
req.onreadystatechange = function() {
if(req.readyState == 4 && req.status == 200) {
byid("output").innerHTML = req.responseText
// if(history && history.replaceState)
// history.replaceState(null, null, "?q=" + encodeURIComponent(q))
}
}
req.open("GET", q, true)
req.send(null)
_gaq.push(['_trackEvent', 'QR', 'Generate', q])
}
function theImage() {
const u = byid("url").value,
i = img,
c = valof("control"),
r = valof("rand"),
d = valof("data"),
t = valof("dither"),
s = Math.floor(Math.random()*1e9),
o = rotation,
x = dx
y = dy;
return "/qr/draw?" + Object.entries({i, u, m, x, y, v, c, r, d , r, s, z, o})
.map(([key, value]) => [key, value].map(encodeURIComponent).join("=")).join("&");
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3319603-5']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
var dx=4
var dy=4
var url="http://research.swtch.com/qart"
var m=2
var v=6
var z=0
var img="pjw"
var cheat=0
var rotation=0
function up() { dy++; update(); }
function down() { dy--; update(); }
function left() { dx++; update(); }
function right() { dx--; update(); }
function bigger() { if(v < 8) { v++; update(); } }
function smaller() { if(v > 1) { v--; update(); } }
function setimg(s) { img=s; update(); }
function togglemask() { if(m>=0) m=-1; else m=2; update(); }
function ibigger() { z++; update(); }
function ismaller() { z--; update(); }
function rotate() { rotation = (rotation+1) & 3; update(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment