test16.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 016</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "en-us": "FORCEHYPHENOPOLY"
  10. },
  11. setup: {
  12. selectors: {
  13. ".hyphenate": {
  14. hyphen: "•"
  15. }
  16. }
  17. },
  18. handleEvent: {
  19. myFantasyEvent: function (e) {
  20. console.log(e);
  21. },
  22. error: function (e) {
  23. e.preventDefault();
  24. assert(e);
  25. }
  26. }
  27. };
  28. function assert(e) {
  29. var test = "unknown Event \"myFantasyEvent\" discarded";
  30. var ref = e.msg;
  31. var result = false;
  32. if (test === ref) {
  33. document.getElementById("result").innerHTML += "<span style=\"background-color: #d6ffd6\">passed</span> ";
  34. result = result || true;
  35. } else {
  36. document.getElementById("result").innerHTML += "<span style=\"background-color: #ffd6d6\">failed</span> ";
  37. result = result || false;
  38. }
  39. if (parent != window) {
  40. parent.postMessage(JSON.stringify({
  41. desc: document.getElementById("desc").innerHTML,
  42. index: 16,
  43. result: (result ? "passed" : "failed")
  44. }), window.location.href);
  45. }
  46. }
  47. </script>
  48. <script src="../Hyphenopoly_Loader.js"></script>
  49. <style type="text/css">
  50. body {
  51. width:50%;
  52. margin-left:25%;
  53. margin-right:25%;
  54. }
  55. .test {
  56. background-color: #D8E2F9;
  57. }
  58. .ref {
  59. background-color: #FEEFC0;
  60. }
  61. .hyphenate {
  62. hyphens: auto;
  63. -ms-hyphens: auto;
  64. -moz-hyphens: auto;
  65. -webkit-hyphens: auto;
  66. }
  67. </style>
  68. </head>
  69. <body>
  70. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test15.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test17.html">Next&nbsp;&rarr;</a></div>
  71. <h1>Test 016</h1>
  72. <p id="desc">Discard unknown Events</p>
  73. <div id="result"></div>
  74. <hr>
  75. <p id="test1" class="test hyphenate" lang="en-us">unknown Event "myFantasyEvent" discarded</p>
  76. <p id="ref1" class="ref" lang="en">unknown Event "myFantasyEvent" discarded</p>
  77. <hr>
  78. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  79. </body>
  80. </html>