test30.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 030</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "en-us": "FORCEHYPHENOPOLY"
  10. },
  11. setup: {
  12. classnames: {
  13. "hyphenopoly": {}
  14. },
  15. selectors: {
  16. ".hyphenate": {
  17. hyphen: "|"
  18. },
  19. "#test2": {
  20. hyphen: "•"
  21. },
  22. "p#test3": {
  23. hyphen: "·"
  24. },
  25. "h2+p": {
  26. hyphen: "⁄"
  27. }
  28. }
  29. },
  30. handleEvent: {
  31. hyphenopolyEnd: function (e) {
  32. assert();
  33. }
  34. }
  35. };
  36. function assert() {
  37. var tests = 4;
  38. var i = 1;
  39. var test = "";
  40. var ref = "";
  41. var result = true;
  42. while (i <= tests) {
  43. test = document.getElementById("test" + i).innerHTML;
  44. ref = document.getElementById("ref" + i).innerHTML;
  45. if (test === ref) {
  46. document.getElementById("result").innerHTML += "<span style=\"background-color: #d6ffd6\">" + (function (i) {
  47. return (i < 10) ? "0" + i : i;
  48. }(i)) + "</span> ";
  49. result = result && true;
  50. } else {
  51. document.getElementById("result").innerHTML += "<span style=\"background-color: #ffd6d6\">" + (function (i) {
  52. return (i < 10) ? "0" + i : i;
  53. }(i)) + "</span> ";
  54. result = false;
  55. }
  56. i += 1;
  57. }
  58. if (parent != window) {
  59. parent.postMessage(JSON.stringify({
  60. desc: document.getElementById("desc").innerHTML,
  61. index: 30,
  62. result: (result ? "passed" : "failed")
  63. }), window.location.href);
  64. }
  65. }
  66. </script>
  67. <script src="../Hyphenopoly_Loader.js"></script>
  68. <style type="text/css">
  69. body {
  70. width:50%;
  71. margin-left:25%;
  72. margin-right:25%;
  73. }
  74. .test {
  75. background-color: #D8E2F9;
  76. }
  77. .ref {
  78. background-color: #FEEFC0;
  79. }
  80. </style>
  81. </head>
  82. <body>
  83. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test29.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test31.html">Next&nbsp;&rarr;</a></div>
  84. <h1>Test 030</h1>
  85. <p id="desc">Select elements with selectors instead of classes.</p>
  86. <div id="result">R: </div>
  87. <hr>
  88. <h2>1: use classname to select</h2>
  89. <p id="test1" class="test hyphenate">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>
  90. <p id="ref1" class="ref">A hy|phen|ation al|go|rithm is a set of rules that de|cides at which points a word can be bro|ken over two lines with a hy|phen.</p>
  91. <h2>2: use id to select</h2>
  92. <p id="test2" class="test">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>
  93. <p id="ref2" class="ref">A hy•phen•ation al•go•rithm is a set of rules that de•cides at which points a word can be bro•ken over two lines with a hy•phen.</p>
  94. <h2>3: use element and id to select</h2>
  95. <p id="test3" class="test">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>
  96. <p id="ref3" class="ref">A hy·phen·ation al·go·rithm is a set of rules that de·cides at which points a word can be bro·ken over two lines with a hy·phen.</p>
  97. <h2>4: use siblings to select</h2>
  98. <p id="test4" class="test">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>
  99. <p id="ref4" class="ref">A hy⁄phen⁄ation al⁄go⁄rithm is a set of rules that de⁄cides at which points a word can be bro⁄ken over two lines with a hy⁄phen.</p>
  100. <hr>
  101. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  102. </body>
  103. </html>