test2.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 002</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "hu": "FORCEHYPHENOPOLY"
  10. },
  11. setup: {
  12. selectors: {
  13. ".hyphenate": {
  14. hyphen: "•"
  15. }
  16. }
  17. },
  18. handleEvent: {
  19. hyphenopolyEnd: function (e) {
  20. assert();
  21. }
  22. }
  23. };
  24. function assert() {
  25. var tests = 1;
  26. var i = 1;
  27. var test = "";
  28. var ref = "";
  29. var result = false;
  30. while (i <= tests) {
  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 = result || false;
  39. }
  40. i += 1;
  41. }
  42. if (parent != window) {
  43. parent.postMessage(JSON.stringify({
  44. desc: document.getElementById("desc").innerHTML,
  45. index: 2,
  46. result: (result ? "passed" : "failed")
  47. }), window.location.href);
  48. }
  49. }
  50. </script>
  51. <script src="../Hyphenopoly_Loader.js"></script>
  52. <style type="text/css">
  53. body {
  54. width:50%;
  55. margin-left:25%;
  56. margin-right:25%;
  57. }
  58. .test {
  59. background-color: #D8E2F9;
  60. }
  61. .ref {
  62. background-color: #FEEFC0;
  63. }
  64. .hyphenate {
  65. hyphens: auto;
  66. -ms-hyphens: auto;
  67. -moz-hyphens: auto;
  68. -webkit-hyphens: auto;
  69. }
  70. </style>
  71. </head>
  72. <body>
  73. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test1.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test3.html">Next&nbsp;&rarr;</a></div>
  74. <h1>Test 002</h1>
  75. <p id="desc">Force hyphenate an hungarian word. Use special hyphen character.</p>
  76. <div id="result"></div>
  77. <hr>
  78. <p id="test1" class="test hyphenate" lang="hu">automatikusan</p>
  79. <p id="ref1" class="ref" lang="hu">au•to•ma•ti•ku•san</p>
  80. <hr>
  81. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  82. </body>
  83. </html>