test1.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 001</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "en-us": "FORCEHYPHENOPOLY",
  10. "hy": "ձայնավորձայնավոր"
  11. },
  12. handleEvent: {
  13. hyphenopolyEnd: function (e) {
  14. assert();
  15. }
  16. }
  17. };
  18. function assert() {
  19. var tests = 2;
  20. var i = 1;
  21. var test = "";
  22. var ref = "";
  23. var result = true;
  24. var lang = "";
  25. while (i <= tests) {
  26. lang = document.getElementById("test" + i).lang;
  27. if (Hyphenopoly.cf.langs[lang] === "CSS") {
  28. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed (CSS)</p>";
  29. result = result && true;
  30. } else {
  31. test = document.getElementById("test" + i).innerHTML;
  32. ref = document.getElementById("ref" + i).innerHTML;
  33. if (test === ref) {
  34. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  35. result = result && true;
  36. } else {
  37. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  38. result = false;
  39. }
  40. }
  41. i += 1;
  42. }
  43. if (parent != window) {
  44. parent.postMessage(JSON.stringify({
  45. desc: document.getElementById("desc").innerHTML,
  46. index: 1,
  47. result: (result ? "passed" : "failed")
  48. }), window.location.href);
  49. }
  50. }
  51. </script>
  52. <script src="../Hyphenopoly_Loader.js"></script>
  53. <style type="text/css">
  54. body {
  55. width:50%;
  56. margin-left:25%;
  57. margin-right:25%;
  58. }
  59. .test {
  60. background-color: #D8E2F9;
  61. }
  62. .ref {
  63. background-color: #FEEFC0;
  64. }
  65. .hyphenate {
  66. hyphens: auto;
  67. -ms-hyphens: auto;
  68. -moz-hyphens: auto;
  69. -webkit-hyphens: auto;
  70. }
  71. </style>
  72. </head>
  73. <body>
  74. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="index.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test2.html">Next&nbsp;&rarr;</a></div>
  75. <h1>Test 001</h1>
  76. <p id="desc">Hyphenate two texts – en-us (where CSS-hyphenation is mostly supported) and hy (where CSS-hyphenation is unsupported).</p>
  77. <div id="result"></div>
  78. <hr>
  79. <h2>1: en-us</h2>
  80. <p id="test1" class="test hyphenate" lang="en-us">A hyphenation algorithm is a set of rules that decides at which points a word can be broken over two lines with a hyphen.</p>
  81. <p id="ref1" class="ref" lang="en-us">A hy&shy;phen&shy;ation al&shy;go&shy;rithm is a set of rules that de&shy;cides at which points a word can be bro&shy;ken over two lines with a hy&shy;phen.</p>
  82. <h2>2: hy (Armenian)</h2>
  83. <p id="test2" class="test hyphenate" lang="hy">Հայերենն ունի վեց ձայնավոր, մեկ կիսաձայն և երեսուն բաղաձայն հնչյուններ</p>
  84. <p id="ref2" class="ref" lang="hy">Հա&shy;յե&shy;րենն ունի վեց ձայնա&shy;վոր, մեկ կի&shy;սա&shy;ձայն և ե&shy;րե&shy;սուն բա&shy;ղա&shy;ձայն հնչյուններ</p>
  85. <hr>
  86. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  87. </body>
  88. </html>