美文网首页js
复活节彩蛋(输入指定内容显示 )

复活节彩蛋(输入指定内容显示 )

作者: 干炸里脊不如你 | 来源:发表于2019-06-19 10:29 被阅读0次
<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>gg</title>
     <style type="text/css">
        #egggif {position: relative;top: 50%;transform: translateY(-50%);display: none; }
        .keys{width: 100%;}
        .keys span{line-height: 50px;font-size: 3em;}
      </style>
</head>
<body>
    <div class="htmleaf-container">
        <div class="htmleaf-content bgcolor-8">

            <div id="egggif">我要显示</div>
        </div>
    </div>

    <script src="https://olpnhrh8v.qnssl.com/201703291/js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script type="text/javascript" >
      function Egg(){this.eggs=[],this.hooks=[],this.kps=[],this.activeEgg="",this.ignoredKeys=[16],arguments.length&&this.AddCode.apply(this,arguments)}Egg.prototype.__execute=function(a){return"function"==typeof a&&a.call(this)},Egg.prototype.__toCharCodes=function(a){var b={up:38,down:40,left:37,right:39,enter:13,space:32,ctrl:17,alt:18,tab:9},c=Object.keys(b);"string"==typeof a&&(a=a.split(",").map(function(a){return a.trim()}));var d=a.map(function(a){return a===parseInt(a,10)?a:c.indexOf(a)>-1?b[a]:a.charCodeAt(0)});return d.join(",")},Egg.prototype.AddCode=function(a,b,c){return this.eggs.push({keys:this.__toCharCodes(a),fn:b,metadata:c}),this},Egg.prototype.AddHook=function(a){return this.hooks.push(a),this},Egg.prototype.handleEvent=function(a){var b=a.which,c=b>=65&&90>=b;if(!("keydown"!==a.type||a.metaKey||a.ctrlKey||a.altKey||a.shiftKey)){var d=a.target.tagName;if(("HTML"===d||"BODY"===d)&&c)return void a.preventDefault()}"keyup"===a.type&&this.eggs.length>0&&(c&&(a.shiftKey||(b+=32)),-1===this.ignoredKeys.indexOf(b)&&this.kps.push(b),this.eggs.forEach(function(a,b){var c=this.kps.toString().indexOf(a.keys)>=0;c&&(this.kps=[],this.activeEgg=a,this.__execute(a.fn,this),this.hooks.forEach(this.__execute,this),this.activeEgg="")},this))},Egg.prototype.Listen=function(){return void 0!==document.addEventListener&&(document.addEventListener("keydown",this,!1),document.addEventListener("keyup",this,!1)),this},Egg.prototype.listen=Egg.prototype.Listen,Egg.prototype.addCode=Egg.prototype.AddCode,Egg.prototype.addHook=Egg.prototype.AddHook;
    </script>
    <script type="text/javascript">
        var egg = new Egg();
        egg
          .addCode("s,o,n,k,w,o", function() {
            jQuery('#egggif').fadeIn(500, function() {
              window.setTimeout(function() { jQuery('#egggif').hide(); }, 5000);
            });
          })
          .addHook(function(){
            console.log("Hook called for: " + this.activeEgg.keys);
            console.log(this.activeEgg.metadata);
          }).listen();
    </script>
</body>
</html>

相关文章

网友评论

    本文标题:复活节彩蛋(输入指定内容显示 )

    本文链接:https://www.haomeiwen.com/subject/uhdhqctx.html