test21.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 021</title>
  6. <script>
  7. var msgs = "";
  8. var Hyphenopoly = {
  9. require: {
  10. "de": "FORCEHYPHENOPOLY",
  11. "en-us": "FORCEHYPHENOPOLY"
  12. },
  13. setup: {
  14. selectors: {
  15. ".hyphenate": {
  16. hyphen: "•"
  17. }
  18. }
  19. },
  20. handleEvent: {
  21. hyphenopolyEnd: function (e) {
  22. assert(msgs);
  23. },
  24. fantasyEvent: function (e) {
  25. console.log(e);
  26. }
  27. }
  28. };
  29. function assert(e) {
  30. var ref = "Listener 1:unknown Event \"fantasyEvent\" discardedListener 1:unknown Event \"fantasyEvent\" discardedListener 1:unknown Event \"fantasyEvent\" discarded";
  31. var test = e;
  32. var result = false;
  33. if (test === ref) {
  34. document.getElementById("result").innerHTML += "<span style=\"background-color: #d6ffd6\">passed</span> ";
  35. result = result || true;
  36. } else {
  37. document.getElementById("result").innerHTML += "<span style=\"background-color: #ffd6d6\">failed</span> ";
  38. result = result || false;
  39. }
  40. if (parent != window) {
  41. parent.postMessage(JSON.stringify({
  42. desc: document.getElementById("desc").innerHTML,
  43. index: 21,
  44. result: (result ? "passed" : "failed")
  45. }), window.location.href);
  46. }
  47. }
  48. </script>
  49. <script src="../Hyphenopoly_Loader.js"></script>
  50. <script>
  51. Hyphenopoly.events.addListener("error", function (e) {
  52. e.preventDefault();
  53. msgs += "Listener 1:" + e.msg;
  54. console.log("Listener 1:" + e.msg)
  55. });
  56. Hyphenopoly.events.addListener("error", function (e) {
  57. e.preventDefault();
  58. msgs += "Listener 1:" + e.msg;
  59. console.log("Listener 2:" + e.msg)
  60. });
  61. Hyphenopoly.events.addListener("error", function (e) {
  62. e.preventDefault();
  63. msgs += "Listener 1:" + e.msg;
  64. console.log("Listener 3:" + e.msg)
  65. });
  66. </script>
  67. <style type="text/css">
  68. body {
  69. width:50%;
  70. margin-left:25%;
  71. margin-right:25%;
  72. }
  73. .test {
  74. background-color: #D8E2F9;
  75. }
  76. .ref {
  77. background-color: #FEEFC0;
  78. }
  79. .hyphenate {
  80. hyphens: auto;
  81. -ms-hyphens: auto;
  82. -moz-hyphens: auto;
  83. -webkit-hyphens: auto;
  84. }
  85. </style>
  86. </head>
  87. <body>
  88. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test20.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test22.html">Next&nbsp;&rarr;</a></div>
  89. <h1>Test 021</h1>
  90. <p id="desc">Register multiple error handlers (also watch console)</p>
  91. <div id="result"></div>
  92. <hr>
  93. <h2>1: en-us</h2>
  94. <p id="test1" class="test hyphenate" lang="en-us">hyphenation algorithm</p>
  95. <p id="ref1" class="ref" lang="en-us">hy•phen•ation al•go•rithm</p>
  96. <h2>2: de</h2>
  97. <p id="test2" class="test hyphenate" lang="de">Silbentrennungsalgorithmus</p>
  98. <p id="ref2" class="ref" lang="de">Sil•ben•tren•nungs•al•go•rith•mus</p>
  99. <hr>
  100. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  101. </body>
  102. </html>