Repos / hi.imnhan.com / da4d718d67
commit da4d718d67e24712c3d37f8ccef91d5449f77c08
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Mon Dec 7 11:47:29 2020 +0700
konami code easter egg
diff --git a/.rgignore b/.rgignore
new file mode 100644
index 0000000..1f57b97
--- /dev/null
+++ b/.rgignore
@@ -0,0 +1 @@
+/output
diff --git a/nhanb-theme/static/konami.js b/nhanb-theme/static/konami.js
new file mode 100644
index 0000000..d472e79
--- /dev/null
+++ b/nhanb-theme/static/konami.js
@@ -0,0 +1,50 @@
+(function () {
+ function konamiCode(callback) {
+ // The famous Konami sequence in keycodes
+ // up up down down left right left right b a
+ var sequence = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
+ var ko = Array.from(sequence);
+
+ // Get the rest of this function's arguments (if any).
+ // These will be used as the callback's arguments.
+ var args = [];
+ for (var i = 1; i < arguments.length; i++) {
+ args.push(arguments[i]);
+ }
+
+ document.addEventListener("keydown", function (e) {
+ if (e.keyCode === ko[0]) {
+ ko.splice(0, 1);
+ if (ko.length === 0) {
+ callback.apply(null, args);
+ }
+ } else {
+ ko = Array.from(sequence);
+ }
+ });
+ }
+
+ function showClip() {
+ var video = document.createElement("video");
+ video.setAttribute("controls", "");
+ video.setAttribute("autoplay", "autoplay");
+ video.style.position = "fixed";
+ video.style.right = "0";
+ video.style.bottom = "0";
+ video.style.width = "100%";
+ video.style.height = "100%";
+ video.style["object-fit"] = "cover";
+ video.style.opacity = "0.6";
+
+ var src = document.createElement("source");
+ src.setAttribute("src", "https://junk.imnhan.com/rain-480-cropped.mp4");
+ src.setAttribute("type", "video/mp4");
+ video.appendChild(src);
+
+ document.body.appendChild(video);
+ }
+
+ window.addEventListener("DOMContentLoaded", function () {
+ konamiCode(showClip);
+ });
+})();
diff --git a/nhanb-theme/templates/base.html b/nhanb-theme/templates/base.html
index 5068677..b299e80 100644
--- a/nhanb-theme/templates/base.html
+++ b/nhanb-theme/templates/base.html
@@ -49,5 +49,8 @@ <h1 id="site-name"><a href="/">{{ SITENAME }}</a></h1>
{{ FOOTER_TEXT }}
</footer>
</div>
+
+ <script src="/theme/konami.js"></script>
+
</body>
</html>