Sha256: f1755736a452fc08ab114c46ba10968fa877994f4731cef435b3129c0649df82
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
(function () { // Find peek element var peekElement = document.querySelector("#peek"); // Check existence of peek element if (!peekElement) return false; // Listener Class var Listener = function (target, handler) { this.target = new RegExp(target, "i"); this.queue = ""; this.handler = handler; this.compare = function () { if (this.queue.match(this.target)) { this.queue = ""; this.handler(); } }; }; // Target var target = "peek"; // Handler var handler = function () { peekElement.style.display = (localStorage.getItem("peekStatus") == "none") ? "block" : "none"; localStorage.setItem("peekStatus", peekElement.style.display); }; // Set peekStatus with localStorage if (!localStorage.getItem("peekStatus")) localStorage.setItem("peekStatus", "none"); // Give born to a Listener object var peekListener = new Listener(target, handler); peekElement.style.display = localStorage.getItem("peekStatus"); // Hook listener on window window.addEventListener("keydown", function (e) { peekListener.queue = peekListener.queue.concat(String.fromCharCode(e.keyCode)); peekListener.compare(); }); })();
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
peeker-0.1.3 | app/assets/javascripts/peeker.js |
peeker-0.1.2 | app/assets/javascripts/peeker.js |