test17.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 017</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "en-us": "FORCEHYPHENOPOLY"
  10. },
  11. setup: {
  12. selectors: {
  13. ".hyphenate": {}
  14. }
  15. },
  16. handleEvent: {
  17. error: function (e) {
  18. e.preventDefault();
  19. assert(e);
  20. }
  21. }
  22. };
  23. function assert(e) {
  24. var test1 = "engine for language 'en-us' loaded, but no elements found.";
  25. var test2 = "Element with 'en' found, but 'en.hpb' not loaded. Check language tags!";
  26. var ref = e.msg;
  27. var result = false;
  28. if (test1 === ref || test2 === ref) {
  29. document.getElementById("result").innerHTML += "<span style=\"background-color: #d6ffd6\">passed</span> ";
  30. result = result || true;
  31. } else {
  32. document.getElementById("result").innerHTML += "<span style=\"background-color: #ffd6d6\">failed</span> ";
  33. result = result || false;
  34. }
  35. if (parent != window) {
  36. parent.postMessage(JSON.stringify({
  37. desc: document.getElementById("desc").innerHTML,
  38. index: 17,
  39. result: (result ? "passed" : "failed")
  40. }), window.location.href);
  41. }
  42. }
  43. </script>
  44. <script src="../Hyphenopoly_Loader.js"></script>
  45. <style type="text/css">
  46. body {
  47. width:50%;
  48. margin-left:25%;
  49. margin-right:25%;
  50. }
  51. .test {
  52. background-color: #D8E2F9;
  53. }
  54. .ref {
  55. background-color: #FEEFC0;
  56. }
  57. .hyphenate {
  58. hyphens: auto;
  59. -ms-hyphens: auto;
  60. -moz-hyphens: auto;
  61. -webkit-hyphens: auto;
  62. }
  63. </style>
  64. </head>
  65. <body>
  66. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test16.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test18.html">Next&nbsp;&rarr;</a></div>
  67. <h1>Test 017</h1>
  68. <p id="desc">Error if no element found.</p>
  69. <div id="result"></div>
  70. <hr>
  71. <p id="test1" class="test hyphenate" lang="en">engine for language 'en-us' loaded, but no elements found.</p>
  72. <p id="ref1" class="ref" lang="en">engine for language 'en-us' loaded, but no elements found.</p>
  73. <hr>
  74. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  75. </body>
  76. </html>