test27.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 027</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "fur": "probabilmentri"
  10. },
  11. setup: {
  12. selectors: {
  13. ".hyphenate": {
  14. hyphen: "|",
  15. minWordLength: 4
  16. }
  17. }
  18. },
  19. handleEvent: {
  20. engineReady: function (e) {
  21. /*async function hyphenate_de(text) {
  22. document.getElementById("test2").innerText = (await Hyphenopoly.hyphenators.fur)(text);
  23. assert();
  24. }*/
  25. function hyphenate_fur(text) {
  26. Hyphenopoly.hyphenators.fur.then(function (furhyph) {
  27. document.getElementById("test1").innerText = furhyph(text);
  28. assertAll();
  29. });
  30. }
  31. 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");
  32. },
  33. error: function (e) {
  34. assertError(e);
  35. }
  36. }
  37. };
  38. function assertError(e) {
  39. var result = false;
  40. if (e.msg.indexOf("Promises not supported in this engine") !== -1) {
  41. result = true;
  42. }
  43. if (parent != window) {
  44. parent.postMessage(JSON.stringify({
  45. desc: document.getElementById("desc").innerHTML,
  46. index: 27,
  47. result: (result ? "passed" : "failed")
  48. }), window.location.href);
  49. }
  50. }
  51. function assertAll() {
  52. var tests = 1;
  53. var i = 1;
  54. var test = "";
  55. var ref = "";
  56. var result = false;
  57. while (i <= tests) {
  58. test = document.getElementById("test" + i).innerHTML;
  59. ref = document.getElementById("ref" + i).innerHTML;
  60. if (test === ref) {
  61. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  62. result = result || true;
  63. } else {
  64. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  65. result = result || false;
  66. }
  67. i += 1;
  68. }
  69. if (parent != window) {
  70. parent.postMessage(JSON.stringify({
  71. desc: document.getElementById("desc").innerHTML,
  72. index: 27,
  73. result: (result ? "passed" : "failed")
  74. }), window.location.href);
  75. }
  76. }
  77. </script>
  78. <script src="../Hyphenopoly_Loader.js"></script>
  79. <style type="text/css">
  80. body {
  81. width:50%;
  82. margin-left:25%;
  83. margin-right:25%;
  84. }
  85. .test {
  86. background-color: #D8E2F9;
  87. hyphens: auto;
  88. }
  89. .ref {
  90. background-color: #FEEFC0;
  91. }
  92. </style>
  93. </head>
  94. <body>
  95. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test26.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test28.html">Next&nbsp;&rarr;</a></div>
  96. <h1>Test 027</h1>
  97. <p id="desc">Hyphenate manually (uses promises): check</p>
  98. <div id="result"></div>
  99. <hr>
  100. <h2>fur</h2>
  101. <p id="test1" lang="fur" class="test hyphenate"></p>
  102. <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>
  103. <hr>
  104. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  105. </body>
  106. </html>