test36.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 036</title>
  6. <script>
  7. var mode = window.location.search.substring(1);
  8. var path = "../patterns/";
  9. if (mode === "fail") {
  10. path = "../pattern/"
  11. }
  12. var Hyphenopoly = {
  13. require: {
  14. "fur": "probabilmentri"
  15. },
  16. paths: {
  17. patterndir: path
  18. },
  19. setup: {
  20. selectors: {
  21. ".hyphenate": {
  22. hyphen: "|",
  23. minWordLength: 4
  24. }
  25. }
  26. }
  27. };
  28. window.onload = function () {
  29. function hyphenate_fur(text) {
  30. if (window.Promise) {
  31. Hyphenopoly.hyphenators.fur.then(
  32. function (furhyph) {
  33. document.getElementById("test1").innerText = furhyph(text);
  34. assertAll();
  35. }).catch(function(e) {
  36. assertError(e);
  37. });
  38. } else {
  39. var result = false
  40. if (parent != window) {
  41. parent.postMessage(JSON.stringify({
  42. desc: document.getElementById("desc").innerHTML,
  43. index: 36,
  44. result: (result ? "passed" : "failed")
  45. }), window.location.href);
  46. }
  47. }
  48. }
  49. hyphenate_fur("Il furlan e je une lenghe romanze de famee des lenghis retichis, che e je fevelade soredut intal Friûl, ma ancje vie pal mont. Cualchi volte al ven clamât Ladin orientâl, parcè che al à diviers ponts in comun cul ladin, ma si è svilupât in un altri mût cul passâ dal timp, sot de influence des lenghis ator dal Friûl");
  50. };
  51. function assertError(e) {
  52. var result = false;
  53. if (e.message.indexOf("File fur.hpb can't be loaded from ../pattern/") !== -1) {
  54. result = true;
  55. }
  56. if (result) {
  57. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + 1 + " passed</p>";
  58. }
  59. if (parent != window) {
  60. parent.postMessage(JSON.stringify({
  61. desc: document.getElementById("desc").innerHTML,
  62. index: 36,
  63. result: (result ? "passed" : "failed")
  64. }), window.location.href);
  65. }
  66. }
  67. function assertAll() {
  68. var tests = 1;
  69. var i = 1;
  70. var test = "";
  71. var ref = "";
  72. var result = false;
  73. while (i <= tests) {
  74. test = document.getElementById("test" + i).innerHTML;
  75. ref = document.getElementById("ref" + i).innerHTML;
  76. if (test === ref) {
  77. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  78. result = result || true;
  79. } else {
  80. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  81. result = result || false;
  82. }
  83. i += 1;
  84. }
  85. if (parent != window) {
  86. parent.postMessage(JSON.stringify({
  87. desc: document.getElementById("desc").innerHTML,
  88. index: 36,
  89. result: (result ? "passed" : "failed")
  90. }), window.location.href);
  91. }
  92. window.location = "test36.html?fail";
  93. }
  94. </script>
  95. <script src="../Hyphenopoly_Loader.js"></script>
  96. <style type="text/css">
  97. body {
  98. width:50%;
  99. margin-left:25%;
  100. margin-right:25%;
  101. }
  102. .test {
  103. background-color: #D8E2F9;
  104. hyphens: auto;
  105. }
  106. .ref {
  107. background-color: #FEEFC0;
  108. }
  109. </style>
  110. </head>
  111. <body>
  112. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test35.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test37.html">Next&nbsp;&rarr;</a></div>
  113. <h1>Test 036</h1>
  114. <p id="desc">Reject hyphenator-promise if pattern can't be loaded.</p>
  115. <div id="result"></div>
  116. <hr>
  117. <h2>fur</h2>
  118. <p id="test1" lang="fur" class="test hyphenate"></p>
  119. <p id="ref1" lang="fur" class="ref">Il fur|lan e je une len|ghe ro|man|ze de fa|mee des len|ghis re|ti|chis, che e je fe|ve|la|de so|re|dut in|tal Friûl, ma an|cje vie pal mont. Cual|chi vol|te al ven clamât La|din orientâl, parcè che al à di|viers ponts in co|mun cul la|din, ma si è svi|lupât in un al|tri mût cul pa|ssâ dal timp, sot de in|fluen|ce des len|ghis ator dal Friûl</p>
  120. <hr>
  121. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  122. </body>
  123. </html>