test15.html 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 015</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "de": "FORCEHYPHENOPOLY"
  10. },
  11. setup: {
  12. selectors: {
  13. ".hyphenate": {
  14. hyphen: "•"
  15. }
  16. }
  17. },
  18. handleEvent: {
  19. hyphenopolyEnd: function (e) {
  20. assert();
  21. },
  22. beforeElementHyphenation: function (e) {
  23. e.el.firstChild.data = e.lang + ": " + e.el.firstChild.data;
  24. },
  25. afterElementHyphenation: function (e) {
  26. e.el.firstChild.data = e.el.firstChild.data.split("").reverse().join("");
  27. }
  28. }
  29. };
  30. function assert() {
  31. var tests = 1;
  32. var i = 1;
  33. var test = "";
  34. var ref = "";
  35. var result = false;
  36. while (i <= tests) {
  37. test = document.getElementById("test" + i).innerHTML;
  38. ref = document.getElementById("ref" + i).innerHTML;
  39. if (test === ref) {
  40. document.getElementById("result").innerHTML += "<span style=\"background-color: #d6ffd6\">" + (function (i) {
  41. return (i < 10) ? "0" + i : i;
  42. }(i)) + "</span> ";
  43. result = result || true;
  44. } else {
  45. document.getElementById("result").innerHTML += "<span style=\"background-color: #ffd6d6\">" + (function (i) {
  46. return (i < 10) ? "0" + i : i;
  47. }(i)) + "</span> ";
  48. result = result || false;
  49. }
  50. i += 1;
  51. }
  52. if (parent != window) {
  53. parent.postMessage(JSON.stringify({
  54. desc: document.getElementById("desc").innerHTML,
  55. index: 15,
  56. result: (result ? "passed" : "failed")
  57. }), window.location.href);
  58. }
  59. }
  60. </script>
  61. <script src="../Hyphenopoly_Loader.js"></script>
  62. <style type="text/css">
  63. body {
  64. width:50%;
  65. margin-left:25%;
  66. margin-right:25%;
  67. }
  68. .test {
  69. background-color: #D8E2F9;
  70. }
  71. .ref {
  72. background-color: #FEEFC0;
  73. }
  74. .hyphenate {
  75. hyphens: auto;
  76. -ms-hyphens: auto;
  77. -moz-hyphens: auto;
  78. -webkit-hyphens: auto;
  79. }
  80. </style>
  81. </head>
  82. <body>
  83. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test14.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test16.html">Next&nbsp;&rarr;</a></div>
  84. <h1>Test 015</h1>
  85. <p id="desc">Check before-/onAfterElementHyphenation</p>
  86. <div id="result"></div>
  87. <hr>
  88. <p id="test1" class="test hyphenate" lang="de">Silbentrennungsalgorithmus</p>
  89. <p id="ref1" class="ref" lang="de">sum•htir•og•la•sgnun•nert•neb•liS :ed</p>
  90. <hr>
  91. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  92. </body>
  93. </html>