test32.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 032</title>
  6. <script>
  7. var result = false;
  8. let assertRuns = 0;
  9. function assert() {
  10. const mql = window.matchMedia("(max-width: 600px)");
  11. var tests = 4;
  12. var i = 1;
  13. var test = "";
  14. var ref = "";
  15. while (i <= tests) {
  16. test = document.getElementById("test" + i).innerHTML;
  17. if (mql.matches) {
  18. ref = document.getElementById("ref" + i).innerHTML;
  19. } else {
  20. ref = document.getElementById("ref" + i + "_u").innerHTML;
  21. }
  22. if (test === ref) {
  23. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  24. result = result || true;
  25. } else {
  26. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  27. result = result || false;
  28. }
  29. i += 1;
  30. }
  31. assertRuns += 1;
  32. if (assertRuns === 2 && parent != window) {
  33. parent.postMessage(JSON.stringify({
  34. desc: document.getElementById("desc").innerHTML,
  35. index: 32,
  36. result: (result ? "passed" : "failed")
  37. }), window.location.href);
  38. }
  39. }
  40. (function selectiveLoad() {
  41. let H9YLisLoaded = false;
  42. function handleSize(mql) {
  43. if (mql.matches) {
  44. if (H9YLisLoaded) {
  45. window.Hyphenopoly.events.dispatch(
  46. "contentLoaded",
  47. {"msg": ["contentLoaded"]}
  48. );
  49. } else {
  50. window.Hyphenopoly = {
  51. require: {
  52. "de": "FORCEHYPHENOPOLY",
  53. "en-us": "FORCEHYPHENOPOLY"
  54. },
  55. setup: {
  56. selectors: {
  57. ".hyphenate": {
  58. hyphen: "•"
  59. }
  60. }
  61. },
  62. handleEvent: {
  63. hyphenopolyEnd: function (e) {
  64. assert();
  65. if (parent != window) {
  66. window.parent.document.getElementById("testframe").width = "800px";
  67. }
  68. }
  69. }
  70. };
  71. const loaderScript = document.createElement("script");
  72. loaderScript.src = "../Hyphenopoly_Loader.js";
  73. document.head.appendChild(loaderScript);
  74. H9YLisLoaded = true;
  75. }
  76. } else {
  77. if (H9YLisLoaded) {
  78. window.Hyphenopoly.unhyphenate();
  79. assert();
  80. } else {
  81. window.onload = function() {
  82. assert();
  83. }
  84. }
  85. }
  86. }
  87. const mql = window.matchMedia("(max-width: 600px)");
  88. mql.addListener(handleSize);
  89. handleSize(mql);
  90. }());
  91. </script>
  92. <style type="text/css">
  93. body {
  94. width:50%;
  95. margin-left:25%;
  96. margin-right:25%;
  97. }
  98. .test {
  99. background-color: #D8E2F9;
  100. }
  101. .ref {
  102. background-color: #FEEFC0;
  103. }
  104. @media (max-width: 600px) {
  105. .hyphenate {
  106. hyphens: auto;
  107. -ms-hyphens: auto;
  108. -moz-hyphens: auto;
  109. -webkit-hyphens: auto;
  110. }
  111. }
  112. </style>
  113. </head>
  114. <body>
  115. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test31.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test33.html">Next&nbsp;&rarr;</a></div>
  116. <h1>Test 032</h1>
  117. <p id="desc">Make hyphenation viewport dependent (resize window!)</p>
  118. <div id="result"></div>
  119. <hr>
  120. <p id="test1" class="test hyphenate" lang="de">Silbentrennungsalgorithmus</p>
  121. <p id="ref1" class="ref" lang="de">Sil•ben•tren•nungs•al•go•rith•mus</p>
  122. <p id="ref1_u" class="ref" lang="de">Silbentrennungsalgorithmus</p>
  123. <p id="test2" class="test hyphenate" lang="de">Silbentrennungsalgorithmus <span>Donaudampfschiff</span></p>
  124. <p id="ref2" class="ref" lang="de">Sil•ben•tren•nungs•al•go•rith•mus <span>Do•nau•dampf•schiff</span></p>
  125. <p id="ref2_u" class="ref" lang="de">Silbentrennungsalgorithmus <span>Donaudampfschiff</span></p>
  126. <p id="test3" class="test hyphenate" lang="de">Silbentrennungsalgorithmus <span class="donthyphenate">Donaudampfschiff</span></p>
  127. <p id="ref3" class="ref" lang="de">Sil•ben•tren•nungs•al•go•rith•mus <span class="donthyphenate">Donaudampfschiff</span></p>
  128. <p id="ref3_u" class="ref" lang="de">Silbentrennungsalgorithmus <span class="donthyphenate">Donaudampfschiff</span></p>
  129. <p id="test4" class="test hyphenate" lang="de">Silbentrennungsalgorithmus <span lang="en-us">hyphenation</span></p>
  130. <p id="ref4" class="ref" lang="de">Sil•ben•tren•nungs•al•go•rith•mus <span lang="en-us">hy•phen•ation</span></p>
  131. <p id="ref4_u" class="ref" lang="de">Silbentrennungsalgorithmus <span lang="en-us">hyphenation</span></p>
  132. <hr>
  133. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  134. </body>
  135. </html>