123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title>Test 026</title>
- <script>
- const Hyphenopoly = {
- require: {
- "de": "FORCEHYPHENOPOLY"
- },
- setup: {
- selectors: {
- ".hyphenate": {
- hyphen: "•"
- },
- ".usePipe": {
- hyphen: "|"
- }
- }
- },
- handleEvent: {
- hyphenopolyEnd: function (e) {
- /*async function hyphenate_de(text) {
- document.getElementById("test2").innerText = (await Hyphenopoly.hyphenators.de)(text);
- assert();
- }*/
- function hyphenate_de(text) {
- Hyphenopoly.hyphenators.de.then(function (dehyph) {
- document.getElementById("test2").innerText = dehyph(text, ".usePipe");
- assertAll();
- });
- }
- hyphenate_de("Silbentrennung verbessert den Blocksatz.");
- },
- error: function (e) {
- assertError(e);
- }
- }
- };
- function assertError(e) {
- var result = false;
- if (e.msg.indexOf("Promises not supported in this engine") !== -1) {
- result = true;
- }
- if (parent != window) {
- parent.postMessage(JSON.stringify({
- desc: document.getElementById("desc").innerHTML,
- index: 26,
- result: (result ? "passed" : "failed")
- }), window.location.href);
- }
- }
- function assertAll() {
- var tests = 2;
- var i = 1;
- var test = "";
- var ref = "";
- var result = false;
- while (i <= tests) {
- test = document.getElementById("test" + i).innerHTML;
- ref = document.getElementById("ref" + i).innerHTML;
- if (test === ref) {
- document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
- result = result || true;
- } else {
- document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
- result = result || false;
- }
- i += 1;
- }
- if (parent != window) {
- parent.postMessage(JSON.stringify({
- desc: document.getElementById("desc").innerHTML,
- index: 26,
- result: (result ? "passed" : "failed")
- }), window.location.href);
- }
- }
- </script>
- <script src="../Hyphenopoly_Loader.js"></script>
- <style type="text/css">
- body {
- width:50%;
- margin-left:25%;
- margin-right:25%;
- }
- .test {
- background-color: #D8E2F9;
- }
- .ref {
- background-color: #FEEFC0;
- }
- .hyphenate {
- hyphens: auto;
- -ms-hyphens: auto;
- -moz-hyphens: auto;
- -webkit-hyphens: auto;
- }
- </style>
- </head>
- <body>
- <div id="navigate"><a href="index.html">↞ Index</a> | <a href="test25.html">← Prev</a> | <a href="test27.html">Next →</a></div>
- <h1>Test 026</h1>
- <p id="desc">Hyphenate manually (uses promises): FORCE</p>
- <div id="result"></div>
- <hr>
- <p id="test1" class="test hyphenate" lang="de">Silbentrennungsalgorithmus</p>
- <p id="ref1" class="ref" lang="de">Sil•ben•tren•nungs•al•go•rith•mus</p>
- <p id="test2" class="test" lang="de"></p>
- <p id="ref2" class="ref" lang="de">Sil|ben|tren|nung ver|bes|sert den Block|satz.</p>
- <hr>
- <div><span class="test">Test</span> <span class="ref">Ref</span></div>
- </body>
- </html>
|