// You can install a web browser that supports at least JavaScript 1.0 (1995) to use this tool or you may consider implementing a GemiWeb0 browser with JavaScript0 yourself according to the above specification. 'use strict'; var st = new Object; // JS1 function strEqual(u, v) { return !(u.length - v.length) && !u.indexOf(v); } // JS1 function String_substring(th, from, to) { if (th.substring) { return th.substring(from, to); } else { var o = ''; var c; if (to > th.length) { to = th.length; } from = from - 1; to = to - 1; while (to > from) { c = th.charAt(from = from + 1); o = o + c; } return o; } } function removeAfter(s, t) { var i = s.indexOf(t); if (i >= 0) { s = String_substring(s, 0, i + t.length); } return s; } function writeHtm(text) { if (st.docClosed) { var h = ''; if (document.documentElement && document.documentElement.innerHTML) { h = removeAfter(document.documentElement.innerHTML, '<' + '!-- --' + '>'); } h = '' + h + '' + text + '<' + '/body><' + '/html>'; document.write(h); document.close(); } else { document.write(text); } if (window.s && window.f.s && window.f.s.focus) { window.f.s.focus(); } } function updateGram(key, next) { var o = st.gram[key]; if (!o) { o = new Array; st.gram[key] = o; } o[o.length] = next; } function learnGrams(s) { if (strEqual(st.inText, s)) { return 0; } st.inText = s; st.gram = new Object; var i = 0; var w; var x = ''; var y = ''; var z = ''; while (s.length > i) { if (!(s.charCodeAt(i) - 32)) { while ((s.length > (i = i + 1)) && (!(s.charCodeAt(i) - 32))) { } if (i >= s.length) { return 0; } i = i - 1; } w = x; x = y; y = z; z = s.charAt(i); i = i + 1; updateGram(w + x + y + z, i); updateGram(x + y + z, i); updateGram(y + z, i); updateGram(z, i); } } function escapeHtmChar(c) { var n = c.charCodeAt(0); if (!(n - 34)) { return '&' + 'quot;'; } else if (!(n - 38)) { return '&' + 'amp;'; } else if (!(n - 39)) { return '&' + 'apos;'; } else if (!(n - 60)) { return '&' + 'lt;'; } else if (!(n - 62)) { return '&' + 'gt;'; } else { return c; } } // JS1 function getRandomBits(n) { var x = st.random; var i = n + 1; while (i = i - 1) { x = (((x >> 30) ^ (x >> 27)) & 1) ^ ((x & 1073741823) << 1); } st.random = x; if (n > 31) { n = 31; } return x & ((1 << n) - 1); } function getRandom(m) { return getRandomBits(8) % m; } function generateGrams(len) { if (!len) { return ''; } var s = st.inText; var i = getRandom(s.length); var h = ''; var o; var n; var w; var x = ''; var y = ''; var z = ''; var c; var n; var word = 0; len = len + 1; while (len = len - 1) { w = x; x = y; y = z; if (i >= s.length) { i = 0; } z = s.charAt(i); i = i + 1; n = z.charCodeAt(0); if (!(n - 10)) { h = h + '<' + 'br>'; word = 0; } else if (!(n - 32)) { h = h + ' '; word = 0; i = i - 1; while ((len = len - 1) && !(s.charCodeAt(i = i + 1) - 32)) { if (word = !word) { h = h + '&' + 'nbsp;'; } else { h = h + ' '; } if (i >= s.length) { i = 0; } } if (!len) { len = 1; } word = 0; } else { word = word + 1; if ((word > 32) || ((word > 13) && ((65 > n) || ((n > 90) && (97 > n)) || ((n > 122) && (127 > n))))) { h = h + ' '; word = 0; } c = escapeHtmChar(z); h = h + c; } o = st.gram[w + x + y + z]; if (!o || (!(o.length - 1) && !getRandom(8))) { o = st.gram[x + y + z]; if (!o) { o = st.gram[y + z]; if (!o) { o = st.gram[z]; } } } if (o) { i = o[getRandom(o.length)]; } } return h; } function escapeHtm(s) { var h = ''; var c; var i = -1; while (s.length > (i = i + 1)) { c = escapeHtmChar(s.charAt(i)); h = h + c; } return h; } function submit() { var s = window.f.t.value; learnGrams(s); var h = generateGrams(2 * s.length); h = '
' + h; if (st.docClosed) { s = escapeHtm(s); h = '
' + s + '<' + '/textarea>
bkil.gitlab.io/gemiweb0
' + h; } writeHtm(h); } function init() { st.random = (new Date) % 2147483648; if (!st.random) { st.random = 1; } getRandomBits(128); st.inText = ''; submit(); st.docClosed = 1; var app = new Object; app.submit = submit; return app; } init();
bkil.gitlab.io/gemiweb0