diff --git a/projects/transliteration/js/alpha.lib.js b/projects/transliteration/js/alpha.lib.js
new file mode 100644
index 0000000..e565122
--- /dev/null
+++ b/projects/transliteration/js/alpha.lib.js
@@ -0,0 +1,99 @@
+o = require('./alpha.objects')
+
+/**
+ * @param {string} id
+ * @returns {string}
+ */
+function valueOfSelection(id) {
+ let selObj = document.getElementById(id)
+ return selObj.options[selObj.selectedIndex].text
+}
+
+/**
+ * @param {string} string
+ */
+function printResult(string) {
+ document.getElementById('result').innerHTML = string.replace(/\n\r?/g, '
')
+}
+
+/**
+ * @param {string} fromScript script name
+ * @param {string} toScript script name
+ * @param {string} value material for transliteration
+ * @returns {string} result of transliteration
+ */
+function transliteration(fromScript, toScript, value) {
+ let params = getConstParams(fromScript, toScript)
+ for (letter of o.scripts) {
+ if (typeof letter[fromScript] == 'object') {}
+
+
+ }
+}
+
+const rmDup = e => [...new Set(e)].sort().join("");
+
+function simpleChange(from, to) {
+}
+
+// function getConstParams(from, to) {
+// let softLetters = rmDup(letters([from, to], 'Soft'))
+
+// /**
+// * Big Letters
+// * Lower Soft Letters
+// * Upper Softt Letter
+// */
+// let params = {
+// 'bl': '[-0-9' + rmDup(letters([from, to]).toUpperCase()) + ']',
+// 'ls': new RegExp('([' + softLetters + softLetters.toUpperCase() + '])', 'g'),
+// 'us': new RegExp('([' + softLetters.toUpperCase() + '])', 'g'),
+// }
+// return params
+// }
+
+// function getVarParams(from, to) {
+// /**
+// * Full In Before
+// * Full In After
+// */
+// return {
+// 'fib': new RegExp('(' + p['bl'] + '{0,})' + from.toUpperCase() + '(' + p['bl'] + '{1,})', g),
+// 'fia': new RegExp('(' + p['bl'] + '{1,})' + from.toUpperCase() + '(' + p['bl'] + '{0,})', g)
+// }
+
+// // value = value
+// // .replace(new RegExp(upCase(from, letter[from], false), 'g'), upCase(to, letter[to], false))
+// // .replace(new RegExp(letter[from], 'g'), letter[to])
+// }
+
+function letters(calls, param = true) {
+ let string = ''
+ if (typeof calls == "string") {
+ calls = [calls]
+ }
+ for (call of calls) {
+ for (letter of o.scripts) {
+ let params = {
+ "boolean": true,
+ "string": letter['Param'] && letter['Param'].includes(param)
+ }
+ if (!params[typeof param]) { continue }
+ switch (typeof letter[call]) {
+ case 'string': {
+ string += letter[call]
+ break
+ }
+ case 'object': {
+ string += Object.values(letter[call]).join('')
+ }
+ }
+ }
+ }
+ return string
+}
+
+// console.log(letters(['Cyrillic', 'Latin'],'Soft'))
+// console.log(o.scripts)
+
+transliteration('Latin', 'Cyrillic', 'Hello')
\ No newline at end of file
diff --git a/projects/transliteration/js/back.objects.js b/projects/transliteration/js/alpha.objects.js
similarity index 84%
rename from projects/transliteration/js/back.objects.js
rename to projects/transliteration/js/alpha.objects.js
index f9b8ecb..3ba6403 100644
--- a/projects/transliteration/js/back.objects.js
+++ b/projects/transliteration/js/alpha.objects.js
@@ -1,4 +1,4 @@
-scripts = [
+exports.scripts = [
// Long sounds
{
'Param': [
@@ -84,52 +84,73 @@ scripts = [
},
{
'Cyrillic': 'є',
- 'Glagolitic': 'ⰹⰅ',
+ 'Glagolitic': {
+ 'Common': 'ⰹⰅ',
+ 'Soft': 'ⱐⰅ'
+ },
'Latin': 'je',
- 'Shavian': '𐑘𐑧',
+ 'Shavian': {
+ 'Common': '𐑘𐑧',
+ 'Soft': '𐑢𐑧'
+ }
},
{
'Cyrillic': 'ї'.normalize('NFD'),
'Glagolitic': 'ⱑ',
'Latin': 'ji',
- 'Shavian': '𐑘𐑰',
+ 'Shavian': {
+ 'Common': '𐑘𐑰',
+ 'Soft': '𐑢𐑰'
+ }
},
{
'Cyrillic': 'ю',
'Glagolitic': 'ⱓ',
'Latin': 'ju',
- 'Shavian': '𐑘𐑵',
+ 'Shavian': {
+ 'Common': '𐑘𐑵',
+ 'Soft': '𐑢𐑵'
+ }
},
{
'Cyrillic': 'я',
'Glagolitic': 'ⱔ',
'Latin': 'ja',
- 'Shavian': '𐑘𐑨',
+ 'Shavian': {
+ 'Common': '𐑘𐑨',
+ 'Soft': '𐑢𐑨'
+ }
},
{
- 'Cyrillic': 'йо'.normalize('NFD'),
+ 'Cyrillic': {
+ 'Common': 'йо'.normalize('NFD'),
+ 'Soft': 'ьо'
+ },
'Glagolitic': 'ⱖ',
'Latin': 'jo',
- 'Shavian': '𐑘𐑴',
+ 'Shavian': {
+ 'Common': '𐑘𐑴',
+ 'Soft': '𐑢𐑴'
+ }
},
// Specific
{
'Param': [
- 'Iota sign',
+ 'Palatal sign',
],
- 'Cyrillic': 'й'.normalize('NFD'),
- 'Glagolitic': 'ⰹ',
+ 'Cyrillic': {
+ 'Common': 'й'.normalize('NFD'),
+ 'Soft': 'ь'
+ },
+ 'Glagolitic': {
+ 'Common': 'ⰹ',
+ 'Soft': 'ⱐ'
+ },
'Latin': 'j',
- 'Shavian': '𐑘',
- },
- {
- 'Param': [
- 'Soft sign',
- ],
- 'Cyrillic': 'ь',
- 'Glagolitic': 'ⱐ',
- 'Latin': 'j',
- 'Shavian': '𐑢',
+ 'Shavian': {
+ 'Common': '𐑘',
+ 'Soft': '𐑢'
+ },
},
{
'Cyrillic': 'ґ',
diff --git a/projects/transliteration/js/back.lib.js b/projects/transliteration/js/back.lib.js
deleted file mode 100644
index 037addc..0000000
--- a/projects/transliteration/js/back.lib.js
+++ /dev/null
@@ -1,89 +0,0 @@
-function valueOfSelection(id) { // string
- let selObj = document.getElementById(id)
- return selObj.options[selObj.selectedIndex].text
-} // string
-
-function printResult(string) { // string
- document.getElementById('result').innerHTML = string.replace(/\n\r?/g, '
')
-}
-
-function transliteration(from, to, value) { // string, string, string
- let exception = '[0-9' + upCase(from, getLetters(from)) + upCase(to, getLetters(to)) + '\-]'
-
- for (letter of scripts) {
- if (isUnderfined([letter[from], letter[to]])) { continue }
- // Uppercase: partly & full
- let fullInBefore = '(' + exception + '{0,})' + upCase(from) + '(' + exception + '{1,})'
- let fullInAfter = '(' + exception + '{1,})' + upCase(from) + '(' + exception + '{0,})'
-
- value = value
- .replace(new RegExp(fullInBefore, 'g'), '$1' + upCase(to) + '$2')
- .replace(new RegExp(fullInAfter, 'g'), '$1' + upCase(to) + '$2')
- .replace(new RegExp(upCase(from, letter[from], false), 'g'), upCase(to, letter[to], false))
- .replace(new RegExp(letter[from], 'g'), letter[to])
- }
- // Iotation
- let softLetters = getLetters(to, 'Soft');
- let iotaSign = getLetters(to, 'Iota sign')
- let softSign = getLetters(to, 'Soft sign')
- let lowerSoft = '([' + softLetters + upCase(to, softLetters) + '])' + iotaSign
- let upperSoft = '([' + upCase(to, softLetters) + '])' + upCase(to, iotaSign)
-
- return value
- .replace(new RegExp(lowerSoft, 'g'), '$1' + softSign)
- .replace(new RegExp(upperSoft, 'g'), '$1' + upCase(to, softSign))
-} // string
-
-function upCase(script, symbol = letter[script], all = true) { // string, string, boolean
- if (isUnderfined(symbol)) {
- console.log('Err @ upCase(): `symbol` = ', symbol)
- return ''
- }
- switch (script) {
- case 'Shavian': {
- symbol = all ? '·' + [...symbol].join('·') : '·' + symbol
- break
- }
- default: {
- symbol = all ? symbol.toUpperCase() : symbol[0].toUpperCase() + symbol.slice(1)
- break
- }
- }
- return symbol
-} // string (can be empty)
-
-function isUnderfined(value) { // any
- switch (typeof value) {
- case 'object': {
- if (value === undefined) { return true }
- for (i of value) if (i === undefined) { return true }
- return false
- }
- default: {
- return value === undefined ? true : false
- }
- }
-} // boolean
-
-function getLetters(script, param = 'all') { // array, string
- var string = ''
- switch (param) {
- case 'all': {
- for (letter of scripts) {
- if (isUnderfined(letter[script])) { continue }
- string += letter[script]
- }
- break
- }
- default: {
- for (letter of scripts) {
- if (isUnderfined(letter[script])
- || isUnderfined(letter['Param'])
- || letter['Param'].indexOf(param) < 0) { continue }
- string += letter[script]
- }
- break
- }
- }
- return string
-} // string
\ No newline at end of file
diff --git a/projects/transliteration/js/lib.js b/projects/transliteration/js/lib.js
index b7114b2..037addc 100644
--- a/projects/transliteration/js/lib.js
+++ b/projects/transliteration/js/lib.js
@@ -1,99 +1,89 @@
-o = require('./objects')
-
-/**
- * @param {string} id
- * @returns {string}
- */
-function valueOfSelection(id) {
+function valueOfSelection(id) { // string
let selObj = document.getElementById(id)
return selObj.options[selObj.selectedIndex].text
-}
+} // string
-/**
- * @param {string} string
- */
-function printResult(string) {
+function printResult(string) { // string
document.getElementById('result').innerHTML = string.replace(/\n\r?/g, '
')
}
-/**
- * @param {string} fromScript script name
- * @param {string} toScript script name
- * @param {string} value material for transliteration
- * @returns {string} result of transliteration
- */
-function transliteration(fromScript, toScript, value) {
- let params = getConstParams(fromScript, toScript)
- for (letter of o.scripts) {
- if (typeof letter[fromScript] == 'object') {}
-
-
- }
-}
-
-const rmDup = e => [...new Set(e)].sort().join("");
-
-function simpleChange(from, to) {
-}
+function transliteration(from, to, value) { // string, string, string
+ let exception = '[0-9' + upCase(from, getLetters(from)) + upCase(to, getLetters(to)) + '\-]'
-// function getConstParams(from, to) {
-// let softLetters = rmDup(letters([from, to], 'Soft'))
+ for (letter of scripts) {
+ if (isUnderfined([letter[from], letter[to]])) { continue }
+ // Uppercase: partly & full
+ let fullInBefore = '(' + exception + '{0,})' + upCase(from) + '(' + exception + '{1,})'
+ let fullInAfter = '(' + exception + '{1,})' + upCase(from) + '(' + exception + '{0,})'
-// /**
-// * Big Letters
-// * Lower Soft Letters
-// * Upper Softt Letter
-// */
-// let params = {
-// 'bl': '[-0-9' + rmDup(letters([from, to]).toUpperCase()) + ']',
-// 'ls': new RegExp('([' + softLetters + softLetters.toUpperCase() + '])', 'g'),
-// 'us': new RegExp('([' + softLetters.toUpperCase() + '])', 'g'),
-// }
-// return params
-// }
+ value = value
+ .replace(new RegExp(fullInBefore, 'g'), '$1' + upCase(to) + '$2')
+ .replace(new RegExp(fullInAfter, 'g'), '$1' + upCase(to) + '$2')
+ .replace(new RegExp(upCase(from, letter[from], false), 'g'), upCase(to, letter[to], false))
+ .replace(new RegExp(letter[from], 'g'), letter[to])
+ }
+ // Iotation
+ let softLetters = getLetters(to, 'Soft');
+ let iotaSign = getLetters(to, 'Iota sign')
+ let softSign = getLetters(to, 'Soft sign')
+ let lowerSoft = '([' + softLetters + upCase(to, softLetters) + '])' + iotaSign
+ let upperSoft = '([' + upCase(to, softLetters) + '])' + upCase(to, iotaSign)
-// function getVarParams(from, to) {
-// /**
-// * Full In Before
-// * Full In After
-// */
-// return {
-// 'fib': new RegExp('(' + p['bl'] + '{0,})' + from.toUpperCase() + '(' + p['bl'] + '{1,})', g),
-// 'fia': new RegExp('(' + p['bl'] + '{1,})' + from.toUpperCase() + '(' + p['bl'] + '{0,})', g)
-// }
+ return value
+ .replace(new RegExp(lowerSoft, 'g'), '$1' + softSign)
+ .replace(new RegExp(upperSoft, 'g'), '$1' + upCase(to, softSign))
+} // string
-// // value = value
-// // .replace(new RegExp(upCase(from, letter[from], false), 'g'), upCase(to, letter[to], false))
-// // .replace(new RegExp(letter[from], 'g'), letter[to])
-// }
+function upCase(script, symbol = letter[script], all = true) { // string, string, boolean
+ if (isUnderfined(symbol)) {
+ console.log('Err @ upCase(): `symbol` = ', symbol)
+ return ''
+ }
+ switch (script) {
+ case 'Shavian': {
+ symbol = all ? '·' + [...symbol].join('·') : '·' + symbol
+ break
+ }
+ default: {
+ symbol = all ? symbol.toUpperCase() : symbol[0].toUpperCase() + symbol.slice(1)
+ break
+ }
+ }
+ return symbol
+} // string (can be empty)
-function letters(calls, param = true) {
- let string = ''
- if (typeof calls == "string") {
- calls = [calls]
+function isUnderfined(value) { // any
+ switch (typeof value) {
+ case 'object': {
+ if (value === undefined) { return true }
+ for (i of value) if (i === undefined) { return true }
+ return false
+ }
+ default: {
+ return value === undefined ? true : false
+ }
}
- for (call of calls) {
- for (letter of o.scripts) {
- let params = {
- "boolean": true,
- "string": letter['Param'] && letter['Param'].includes(param)
+} // boolean
+
+function getLetters(script, param = 'all') { // array, string
+ var string = ''
+ switch (param) {
+ case 'all': {
+ for (letter of scripts) {
+ if (isUnderfined(letter[script])) { continue }
+ string += letter[script]
}
- if (!params[typeof param]) { continue }
- switch (typeof letter[call]) {
- case 'string': {
- string += letter[call]
- break
- }
- case 'object': {
- string += Object.values(letter[call]).join('')
- }
+ break
+ }
+ default: {
+ for (letter of scripts) {
+ if (isUnderfined(letter[script])
+ || isUnderfined(letter['Param'])
+ || letter['Param'].indexOf(param) < 0) { continue }
+ string += letter[script]
}
+ break
}
}
return string
-}
-
-// console.log(letters(['Cyrillic', 'Latin'],'Soft'))
-// console.log(o.scripts)
-
-transliteration('Latin', 'Cyrillic', 'Hello')
\ No newline at end of file
+} // string
\ No newline at end of file
diff --git a/projects/transliteration/js/objects.js b/projects/transliteration/js/objects.js
index 3ba6403..f9b8ecb 100644
--- a/projects/transliteration/js/objects.js
+++ b/projects/transliteration/js/objects.js
@@ -1,4 +1,4 @@
-exports.scripts = [
+scripts = [
// Long sounds
{
'Param': [
@@ -84,73 +84,52 @@ exports.scripts = [
},
{
'Cyrillic': 'є',
- 'Glagolitic': {
- 'Common': 'ⰹⰅ',
- 'Soft': 'ⱐⰅ'
- },
+ 'Glagolitic': 'ⰹⰅ',
'Latin': 'je',
- 'Shavian': {
- 'Common': '𐑘𐑧',
- 'Soft': '𐑢𐑧'
- }
+ 'Shavian': '𐑘𐑧',
},
{
'Cyrillic': 'ї'.normalize('NFD'),
'Glagolitic': 'ⱑ',
'Latin': 'ji',
- 'Shavian': {
- 'Common': '𐑘𐑰',
- 'Soft': '𐑢𐑰'
- }
+ 'Shavian': '𐑘𐑰',
},
{
'Cyrillic': 'ю',
'Glagolitic': 'ⱓ',
'Latin': 'ju',
- 'Shavian': {
- 'Common': '𐑘𐑵',
- 'Soft': '𐑢𐑵'
- }
+ 'Shavian': '𐑘𐑵',
},
{
'Cyrillic': 'я',
'Glagolitic': 'ⱔ',
'Latin': 'ja',
- 'Shavian': {
- 'Common': '𐑘𐑨',
- 'Soft': '𐑢𐑨'
- }
+ 'Shavian': '𐑘𐑨',
},
{
- 'Cyrillic': {
- 'Common': 'йо'.normalize('NFD'),
- 'Soft': 'ьо'
- },
+ 'Cyrillic': 'йо'.normalize('NFD'),
'Glagolitic': 'ⱖ',
'Latin': 'jo',
- 'Shavian': {
- 'Common': '𐑘𐑴',
- 'Soft': '𐑢𐑴'
- }
+ 'Shavian': '𐑘𐑴',
},
// Specific
{
'Param': [
- 'Palatal sign',
+ 'Iota sign',
],
- 'Cyrillic': {
- 'Common': 'й'.normalize('NFD'),
- 'Soft': 'ь'
- },
- 'Glagolitic': {
- 'Common': 'ⰹ',
- 'Soft': 'ⱐ'
- },
+ 'Cyrillic': 'й'.normalize('NFD'),
+ 'Glagolitic': 'ⰹ',
'Latin': 'j',
- 'Shavian': {
- 'Common': '𐑘',
- 'Soft': '𐑢'
- },
+ 'Shavian': '𐑘',
+ },
+ {
+ 'Param': [
+ 'Soft sign',
+ ],
+ 'Cyrillic': 'ь',
+ 'Glagolitic': 'ⱐ',
+ 'Latin': 'j',
+ 'Shavian': '𐑢',
},
{
'Cyrillic': 'ґ',