diff --git a/offline.html b/offline.html index 9a04a21..2e05cd1 100644 --- a/offline.html +++ b/offline.html @@ -305,8 +305,8 @@ - Exceptions (Markdown-enabled) - + Notes (Markdown-enabled) + Orthography Notes (Markdown-enabled)Maximize diff --git a/src/constants.js b/src/constants.js index dca587e..d30aae9 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,6 +1,6 @@ import { getTimestampInSeconds } from "./helpers"; -export const MIGRATE_VERSION = '2.0.1'; +export const MIGRATE_VERSION = '2.1.0'; export const DEFAULT_DICTIONARY = { name: 'New', specification: 'Dictionary', diff --git a/src/js/dictionaryManagement.js b/src/js/dictionaryManagement.js index e48252b..3c609e1 100644 --- a/src/js/dictionaryManagement.js +++ b/src/js/dictionaryManagement.js @@ -13,8 +13,8 @@ export function updateDictionary () { export function openEditModal() { const { name, specification, description, partsOfSpeech } = window.currentDictionary; - const { consonants, vowels, blends, phonotactics } = window.currentDictionary.details.phonology; - const { orthography, grammar } = window.currentDictionary.details; + const { consonants, vowels, blends } = window.currentDictionary.details.phonology; + const { phonotactics, orthography, grammar } = window.currentDictionary.details; const { allowDuplicates, caseSensitive, sortByDefinition, theme, isPublic } = window.currentDictionary.settings; document.getElementById('editName').value = name; @@ -28,7 +28,7 @@ export function openEditModal() { document.getElementById('editOnset').value = phonotactics.onset.join(','); document.getElementById('editNucleus').value = phonotactics.nucleus.join(','); document.getElementById('editCoda').value = phonotactics.coda.join(','); - document.getElementById('editExceptions').value = phonotactics.exceptions; + document.getElementById('editPhonotacticsNotes').value = phonotactics.notes; document.getElementById('editOrthography').value = orthography.notes; document.getElementById('editGrammar').value = grammar.notes; @@ -54,10 +54,10 @@ export function saveEditModal() { window.currentDictionary.details.phonology.consonants = document.getElementById('editConsonants').value.split(' ').map(val => val.trim()).filter(val => val !== ''); window.currentDictionary.details.phonology.vowels = document.getElementById('editVowels').value.split(' ').map(val => val.trim()).filter(val => val !== ''); window.currentDictionary.details.phonology.blends = document.getElementById('editBlends').value.split(' ').map(val => val.trim()).filter(val => val !== ''); - window.currentDictionary.details.phonology.phonotactics.onset = document.getElementById('editOnset').value.split(',').map(val => val.trim()).filter(val => val !== ''); - window.currentDictionary.details.phonology.phonotactics.nucleus = document.getElementById('editNucleus').value.split(',').map(val => val.trim()).filter(val => val !== ''); - window.currentDictionary.details.phonology.phonotactics.coda = document.getElementById('editCoda').value.split(',').map(val => val.trim()).filter(val => val !== ''); - window.currentDictionary.details.phonology.phonotactics.exceptions = removeTags(document.getElementById('editExceptions').value.trim()); + window.currentDictionary.details.phonotactics.onset = document.getElementById('editOnset').value.split(',').map(val => val.trim()).filter(val => val !== ''); + window.currentDictionary.details.phonotactics.nucleus = document.getElementById('editNucleus').value.split(',').map(val => val.trim()).filter(val => val !== ''); + window.currentDictionary.details.phonotactics.coda = document.getElementById('editCoda').value.split(',').map(val => val.trim()).filter(val => val !== ''); + window.currentDictionary.details.phonotactics.notes = removeTags(document.getElementById('editPhonotacticsNotes').value.trim()); window.currentDictionary.details.orthography.notes = removeTags(document.getElementById('editOrthography').value.trim()); window.currentDictionary.details.grammar.notes = removeTags(document.getElementById('editGrammar').value.trim()); diff --git a/src/js/migration.js b/src/js/migration.js index 0b2d0bb..f716ef6 100644 --- a/src/js/migration.js +++ b/src/js/migration.js @@ -1,4 +1,5 @@ import { LOCAL_STORAGE_KEY, DEFAULT_DICTIONARY, MIGRATE_VERSION } from "../constants"; +import { saveDictionary } from "./dictionaryManagement"; export default function migrate() { if (window.location.pathname === '/') { @@ -103,7 +104,8 @@ export function migrateDictionary() { migrated = true; } else if (window.currentDictionary.version !== MIGRATE_VERSION) { switch (window.currentDictionary.version) { - case '2.0.1': { + default: console.error('Unknown version'); break; + case '2.0.0': { window.currentDictionary.details.phonotactics = Object.assign({}, window.currentDictionary.details.phonology.phonotactics); delete window.currentDictionary.details.phonology.phonotactics; window.currentDictionary.details.phonotactics.notes = window.currentDictionary.details.phonotactics.exceptions; @@ -111,10 +113,10 @@ export function migrateDictionary() { // Add window.currentDictionary.details.orthography.translations = []; // Add window.currentDictionary.custom.css = ''; window.currentDictionary = Object.assign({}, DEFAULT_DICTIONARY, window.currentDictionary); + window.currentDictionary.version = MIGRATE_VERSION; migrated = true; - break; + // break; By skipping the break, all migrations can happen in sequence. } - default: console.error('Unknown version'); break; } } diff --git a/src/js/render.js b/src/js/render.js index 9c45ff0..dcc025f 100644 --- a/src/js/render.js +++ b/src/js/render.js @@ -75,14 +75,14 @@ export function renderDescription() { export function renderDetails() { const { partsOfSpeech, alphabeticalOrder } = window.currentDictionary; - const { phonology, orthography, grammar } = window.currentDictionary.details; + const { phonology, phonotactics, orthography, grammar } = window.currentDictionary.details; const partsOfSpeechHTML = `Parts of Speech: ${partsOfSpeech.map(partOfSpeech => '' + partOfSpeech + '').join(' ')}`; const alphabeticalOrderHTML = `Alphabetical Order: ${ (alphabeticalOrder.length > 0 ? alphabeticalOrder : ['English Alphabet']).map(letter => `${letter}`).join(' ') }`; const generalHTML = `General${partsOfSpeechHTML}${alphabeticalOrderHTML}`; - const { consonants, vowels, blends, phonotactics } = phonology + const { consonants, vowels, blends } = phonology const consonantHTML = `Consonants: ${consonants.map(letter => `${letter}`).join(' ')}`; const vowelHTML = `Vowels: ${vowels.map(letter => `${letter}`).join(' ')}`; const blendHTML = blends.length > 0 ? `Polyphthongs / Blends: ${blends.map(letter => `${letter}`).join(' ')}` : ''; @@ -93,18 +93,18 @@ export function renderDetails() { ${blendHTML}`; - const { onset, nucleus, coda, exceptions } = phonotactics; + const { onset, nucleus, coda } = phonotactics; const onsetHTML = `Onset: ${onset.map(letter => `${letter}`).join(' ')}`; const nucleusHTML = `Nucleus: ${nucleus.map(letter => `${letter}`).join(' ')}`; const codaHTML = `Coda: ${coda.map(letter => `${letter}`).join(' ')}`; - const exceptionsHTML = exceptions.trim().length > 0 ? 'Exceptions:' + md(removeTags(exceptions)) + '' : ''; + const phonotacticsNotesHTML = phonotactics.notes.trim().length > 0 ? 'Notes:' + md(removeTags(phonotactics.notes)) + '' : ''; const phonotacticsHTML = `Phonotactics ${onsetHTML} ${nucleusHTML} ${codaHTML} - ${exceptionsHTML}`; + ${phonotacticsNotesHTML}`; const orthographyHTML = 'OrthographyNotes:' + md(removeTags(orthography.notes)) + ''; const grammarHTML = 'GrammarNotes:' + md(removeTags(grammar.notes)) + ''; diff --git a/src/php/api/Dictionary.php b/src/php/api/Dictionary.php index d48cc37..e701676 100644 --- a/src/php/api/Dictionary.php +++ b/src/php/api/Dictionary.php @@ -33,7 +33,7 @@ class Dictionary { $insert_dictionary = $this->db->execute($insert_dictionary_query, array($new_id, $user, 'A new dictionary.', time())); if ($insert_dictionary === true) { - $insert_linguistics_query = "INSERT INTO dictionary_linguistics (dictionary, parts_of_speech, exceptions, orthography_notes, grammar_notes) + $insert_linguistics_query = "INSERT INTO dictionary_linguistics (dictionary, parts_of_speech, phonotactics_notes, orthography_notes, grammar_notes) VALUES ($new_id, ?, ?, ?, ?)"; $insert_linguistics = $this->db->execute($insert_linguistics_query, array( $this->defaults['partsOfSpeech'], @@ -109,12 +109,12 @@ VALUES ($new_id, ?, ?, ?, ?)"; 'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(), 'vowels' => $result['vowels'] !== '' ? explode(' ', $result['vowels']) : array(), 'blends' => $result['blends'] !== '' ? explode(' ', $result['blends']) : array(), - 'phonotactics' => array( - 'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(), - 'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(), - 'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(), - 'exceptions' => $result['exceptions'], - ), + ), + 'phonotactics' => array( + 'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(), + 'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(), + 'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(), + 'notes' => $result['phonotactics_notes'], ), 'orthography' => array( 'notes' => $result['orthography_notes'], @@ -260,12 +260,12 @@ VALUES ($new_id, ?, ?, ?, ?)"; 'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(), 'vowels' => $result['vowels'] !== '' ? explode(' ', $result['vowels']) : array(), 'blends' => $result['blends'] !== '' ? explode(' ', $result['blends']) : array(), - 'phonotactics' => array( - 'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(), - 'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(), - 'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(), - 'exceptions' => $result['exceptions'], - ), + ), + 'phonotactics' => array( + 'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(), + 'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(), + 'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(), + 'notes' => $result['phonotactics_notes'], ), 'orthography' => array( 'notes' => $result['orthography_notes'], @@ -326,7 +326,7 @@ SET parts_of_speech=:parts_of_speech, onset=:onset, nucleus=:nucleus, coda=:coda, - exceptions=:exceptions, + phonotactics_notes=:phonotactics_notes, orthography_notes=:orthography_notes, grammar_notes=:grammar_notes WHERE dictionary=$dictionary"; @@ -337,10 +337,10 @@ WHERE dictionary=$dictionary"; ':consonants' => implode(' ', $linguistics['phonology']['consonants']), ':vowels' => implode(' ', $linguistics['phonology']['vowels']), ':blends' => implode(' ', $linguistics['phonology']['blends']), - ':onset' => implode(',', $linguistics['phonology']['phonotactics']['onset']), - ':nucleus' => implode(',', $linguistics['phonology']['phonotactics']['nucleus']), - ':coda' => implode(',', $linguistics['phonology']['phonotactics']['coda']), - ':exceptions' => $linguistics['phonology']['phonotactics']['exceptions'], + ':onset' => implode(',', $linguistics['phonotactics']['onset']), + ':nucleus' => implode(',', $linguistics['phonotactics']['nucleus']), + ':coda' => implode(',', $linguistics['phonotactics']['coda']), + ':phonotactics_notes' => $linguistics['phonotactics']['notes'], ':orthography_notes' => $linguistics['orthography']['notes'], ':grammar_notes' => $linguistics['grammar']['notes'], )); diff --git a/src/structure.sql b/src/structure.sql index 3772876..3511548 100644 --- a/src/structure.sql +++ b/src/structure.sql @@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS `dictionary_linguistics` ( `onset` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Comma-separated', `nucleus` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Comma-separated', `coda` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Comma-separated', - `exceptions` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown', + `phonotactics_notes` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown', `orthography_notes` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown', `grammar_notes` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown', UNIQUE KEY `dictionary` (`dictionary`) diff --git a/template-index.html b/template-index.html index 950744e..4272244 100644 --- a/template-index.html +++ b/template-index.html @@ -306,8 +306,8 @@ - Exceptions (Markdown-enabled) - + Notes (Markdown-enabled) + Orthography Notes (Markdown-enabled)Maximize
Parts of Speech: ${partsOfSpeech.map(partOfSpeech => '' + partOfSpeech + '').join(' ')}
Alphabetical Order: ${ (alphabeticalOrder.length > 0 ? alphabeticalOrder : ['English Alphabet']).map(letter => `${letter}`).join(' ') }
Consonants: ${consonants.map(letter => `${letter}`).join(' ')}
Vowels: ${vowels.map(letter => `${letter}`).join(' ')}
Polyphthongs / Blends: ${blends.map(letter => `${letter}`).join(' ')}
Onset: ${onset.map(letter => `${letter}`).join(' ')}
Nucleus: ${nucleus.map(letter => `${letter}`).join(' ')}
Coda: ${coda.map(letter => `${letter}`).join(' ')}
Exceptions:
Notes: