tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

doc_markup_events_03.html (3108B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8">
      5    <style>
      6    #es6-method,
      7    #generator,
      8    #anon-generator,
      9    #named-function-expression,
     10    #anon-function-expression,
     11    #returned-function {
     12      border: 1px solid #000;
     13      width: 200px;
     14      min-height: 1em;
     15      cursor: pointer;
     16    }
     17    </style>
     18    <script type="application/javascript">
     19      "use strict";
     20 
     21      const namedFunctionExpression =
     22      function foo() {
     23        alert("namedFunctionExpression");
     24      }
     25 
     26      const anonFunctionExpression = function() {
     27        alert("anonFunctionExpression");
     28      };
     29 
     30      const returnedFunction = (function() {
     31        return function bar() {
     32          alert("returnedFunction");
     33        }
     34      })();
     35 
     36      /* exported init */
     37      function init() {
     38        const em = new Es6Method();
     39        const es6Method = document.getElementById("es6-method");
     40        es6Method.addEventListener("click", em.es6Method);
     41 
     42        const generatorNode = document.getElementById("generator");
     43        generatorNode.addEventListener("click", generator);
     44 
     45        const anonGenerator = document.getElementById("anon-generator");
     46        // eslint-disable-next-line require-yield
     47        anonGenerator.addEventListener("click", function* () {
     48          alert("anonGenerator");
     49        });
     50 
     51        const namedFunctionExpressionNode =
     52          document.getElementById("named-function-expression");
     53        namedFunctionExpressionNode.addEventListener("click",
     54                                                     namedFunctionExpression);
     55 
     56        const anonFunctionExpressionNode =
     57          document.getElementById("anon-function-expression");
     58        anonFunctionExpressionNode.addEventListener("click",
     59                                                     anonFunctionExpression);
     60 
     61        const returnedFunctionNode = document.getElementById("returned-function");
     62        returnedFunctionNode.addEventListener("click", returnedFunction);
     63      }
     64 
     65      function Es6Method(hehe) {
     66 
     67      }
     68 
     69      Es6Method.prototype = {
     70        es6Method(foo, bar) {
     71          alert("obj.es6Method");
     72        }
     73      };
     74 
     75      function HandleEvent() {
     76        const handleEventNode = document.getElementById("handleEvent");
     77        handleEventNode.addEventListener("click", this);
     78      }
     79 
     80      HandleEvent.prototype = {
     81        // eslint-disable-next-line object-shorthand
     82        handleEvent: function(event) {
     83          switch (event.type) {
     84            case "click":
     85              alert("handleEvent click");
     86          }
     87        }
     88      };
     89 
     90      // eslint-disable-next-line require-yield
     91      function* generator() {
     92        alert("generator");
     93      }
     94    </script>
     95  </head>
     96  <body onload="init();">
     97    <h1>Events test 3</h1>
     98    <div id="es6-method">ES6 method</div>
     99    <div id="generator">Generator</div>
    100    <div id="anon-generator">Anonymous Generator</div>
    101    <div id="named-function-expression">Named Function Expression</div>
    102    <div id="anon-function-expression">Anonymous Function Expression</div>
    103    <div id="returned-function">Returned Function</div>
    104  </body>
    105 </html>