mirror of
				https://github.com/Alamantus/Lexiconga.git
				synced 2025-11-04 10:17:01 +01:00 
			
		
		
		
	Added Pronunciation field, reorganized fields, optimized search code, improved imports.
Removed import tokens.
This commit is contained in:
		
							parent
							
								
									b418afafcb
								
							
						
					
					
						commit
						88dbe2fba8
					
				
					 3 changed files with 72 additions and 59 deletions
				
			
		| 
						 | 
					@ -41,6 +41,10 @@ label span {
 | 
				
			||||||
    font-weight: bold;
 | 
					    font-weight: bold;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					label span .helperlink {
 | 
				
			||||||
 | 
					    font-size: 10px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
label label {
 | 
					label label {
 | 
				
			||||||
    margin-left: 20px;
 | 
					    margin-left: 20px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -128,9 +132,16 @@ word {
 | 
				
			||||||
    font-size: 20px;
 | 
					    font-size: 20px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pronunciation {
 | 
				
			||||||
 | 
					    font-size: 12px;
 | 
				
			||||||
 | 
					    margin-left:10px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
partofspeech {
 | 
					partofspeech {
 | 
				
			||||||
    font-style: italic;
 | 
					    font-style: italic;
 | 
				
			||||||
 | 
					    font-weight: bold;
 | 
				
			||||||
    font-size: 10px;
 | 
					    font-size: 10px;
 | 
				
			||||||
 | 
					    margin-left:10px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
simpledefinition {
 | 
					simpledefinition {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										21
									
								
								index.html
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								index.html
									
										
									
									
									
								
							| 
						 | 
					@ -22,25 +22,18 @@
 | 
				
			||||||
        <label><span>Word</span>
 | 
					        <label><span>Word</span>
 | 
				
			||||||
            <input type="text" id="word" />
 | 
					            <input type="text" id="word" />
 | 
				
			||||||
        </label>
 | 
					        </label>
 | 
				
			||||||
 | 
					        <label><span>Pronunciation <a class="helperlink" href="ipa_character_picker.html" target="_blank" title="IPA Character Picker backed up from http://r12a.github.io/pickers/ipa/">IPA</a></span>
 | 
				
			||||||
 | 
					            <input type="text" id="pronunciation" />
 | 
				
			||||||
 | 
					        </label>
 | 
				
			||||||
 | 
					        <label><span>Part of Speech</span>
 | 
				
			||||||
 | 
					            <select id="partOfSpeech"></select>
 | 
				
			||||||
 | 
					        </label>
 | 
				
			||||||
        <label><span>Equivalent Word</span>
 | 
					        <label><span>Equivalent Word</span>
 | 
				
			||||||
            <input type="text" id="simpleDefinition" />
 | 
					            <input type="text" id="simpleDefinition" />
 | 
				
			||||||
        </label>
 | 
					        </label>
 | 
				
			||||||
        <label><span>Explanation</span>
 | 
					        <label><span>Explanation</span>
 | 
				
			||||||
            <textarea id="longDefinition"></textarea>
 | 
					            <textarea id="longDefinition"></textarea>
 | 
				
			||||||
        </label>
 | 
					        </label>
 | 
				
			||||||
        <label><span>Part of Speech</span>
 | 
					 | 
				
			||||||
            <select id="partOfSpeech">
 | 
					 | 
				
			||||||
                <!--
 | 
					 | 
				
			||||||
                    <option value="noun">Noun</option>
 | 
					 | 
				
			||||||
                    <option value="adjective">Adjective</option>
 | 
					 | 
				
			||||||
                    <option value="verb">Verb</option>
 | 
					 | 
				
			||||||
                    <option value="adverb">Adverb</option>
 | 
					 | 
				
			||||||
                    <option value="preposition">Preposition</option>
 | 
					 | 
				
			||||||
                    <option value="pronoun">Pronoun</option>
 | 
					 | 
				
			||||||
                    <option value="conjunction">Conjunction</option>
 | 
					 | 
				
			||||||
                -->
 | 
					 | 
				
			||||||
            </select>
 | 
					 | 
				
			||||||
        </label>
 | 
					 | 
				
			||||||
        <input type="hidden" id="editIndex" />
 | 
					        <input type="hidden" id="editIndex" />
 | 
				
			||||||
        <span id="errorMessage"></span>
 | 
					        <span id="errorMessage"></span>
 | 
				
			||||||
        <div id="newWordButtonArea" style="display: block;">
 | 
					        <div id="newWordButtonArea" style="display: block;">
 | 
				
			||||||
| 
						 | 
					@ -57,7 +50,7 @@
 | 
				
			||||||
    <div id="dictionaryContainer">
 | 
					    <div id="dictionaryContainer">
 | 
				
			||||||
        <span id="settingsButton" class="clickable" onclick="ShowSettings()">Settings</span>
 | 
					        <span id="settingsButton" class="clickable" onclick="ShowSettings()">Settings</span>
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        <h2 id="dictionaryName"></h2>
 | 
					        <h1 id="dictionaryName"></h1>
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        <span id="descriptionToggle" onclick="ToggleDescription();">Show Description</span>
 | 
					        <span id="descriptionToggle" onclick="ToggleDescription();">Show Description</span>
 | 
				
			||||||
        <div id="dictionaryDescription" style="display:none;"></div>
 | 
					        <div id="dictionaryDescription" style="display:none;"></div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,5 @@
 | 
				
			||||||
/* global markdown */
 | 
					/* global markdown */
 | 
				
			||||||
/* global Defiant */
 | 
					/* global Defiant */
 | 
				
			||||||
//Requires Markdown.js parser
 | 
					 | 
				
			||||||
var currentVersion = 0.2;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
var currentDictionary = {
 | 
					var currentDictionary = {
 | 
				
			||||||
    name: "New",
 | 
					    name: "New",
 | 
				
			||||||
| 
						 | 
					@ -12,8 +10,7 @@ var currentDictionary = {
 | 
				
			||||||
        caseSensitive: false,
 | 
					        caseSensitive: false,
 | 
				
			||||||
        partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
 | 
					        partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
 | 
				
			||||||
        isComplete: false
 | 
					        isComplete: false
 | 
				
			||||||
    },
 | 
					    }
 | 
				
			||||||
    dictionaryImportVersion: currentVersion     // This needs to always be last.
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var defaultDictionaryJSON = JSON.stringify(currentDictionary);  //Saves a stringifyed default dictionary.
 | 
					var defaultDictionaryJSON = JSON.stringify(currentDictionary);  //Saves a stringifyed default dictionary.
 | 
				
			||||||
| 
						 | 
					@ -39,9 +36,10 @@ window.onload = function () {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function AddWord() {
 | 
					function AddWord() {
 | 
				
			||||||
    var word = htmlEntities(document.getElementById("word").value);
 | 
					    var word = htmlEntities(document.getElementById("word").value);
 | 
				
			||||||
 | 
					    var pronunciation = htmlEntities(document.getElementById("pronunciation").value);
 | 
				
			||||||
 | 
					    var partOfSpeech = htmlEntities(document.getElementById("partOfSpeech").value);
 | 
				
			||||||
    var simpleDefinition = htmlEntities(document.getElementById("simpleDefinition").value);
 | 
					    var simpleDefinition = htmlEntities(document.getElementById("simpleDefinition").value);
 | 
				
			||||||
    var longDefinition = htmlEntities(document.getElementById("longDefinition").value);
 | 
					    var longDefinition = htmlEntities(document.getElementById("longDefinition").value);
 | 
				
			||||||
    var partOfSpeech = htmlEntities(document.getElementById("partOfSpeech").value);
 | 
					 | 
				
			||||||
    var editIndex = htmlEntities(document.getElementById("editIndex").value);
 | 
					    var editIndex = htmlEntities(document.getElementById("editIndex").value);
 | 
				
			||||||
    var errorMessageArea = document.getElementById("errorMessage");
 | 
					    var errorMessageArea = document.getElementById("errorMessage");
 | 
				
			||||||
    var errorMessage = "";
 | 
					    var errorMessage = "";
 | 
				
			||||||
| 
						 | 
					@ -51,14 +49,12 @@ function AddWord() {
 | 
				
			||||||
        var wordIndex = (!currentDictionary.settings.allowDuplicates) ? WordIndex(word) : -1;
 | 
					        var wordIndex = (!currentDictionary.settings.allowDuplicates) ? WordIndex(word) : -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (editIndex != "") {
 | 
					        if (editIndex != "") {
 | 
				
			||||||
            if (WordAtIndexWasChanged(editIndex, word, simpleDefinition, longDefinition, partOfSpeech)) {
 | 
					            if (WordAtIndexWasChanged(editIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition)) {
 | 
				
			||||||
                updateConflictArea.style.display = "block";
 | 
					                updateConflictArea.style.display = "block";
 | 
				
			||||||
                updateConflictArea.innerHTML = "<span id='updateConflictMessage'>Do you really want to change the word \"" + currentDictionary.words[parseInt(editIndex)].name + "\" to what you have set above?</span>";
 | 
					                updateConflictArea.innerHTML = "<span id='updateConflictMessage'>Do you really want to change the word \"" + currentDictionary.words[parseInt(editIndex)].name + "\" to what you have set above?</span>";
 | 
				
			||||||
                updateConflictArea.innerHTML += '<button type="button" id="updateConfirmButton" onclick="UpdateWord(' + editIndex + ', \'' +
 | 
					                updateConflictArea.innerHTML += '<button type="button" id="updateConfirmButton" \
 | 
				
			||||||
                                                                                                                    htmlEntities(word) + '\', \'' +
 | 
					                                                  onclick="UpdateWord(' + editIndex + ', \'' + word + '\', \'' + pronunciation + '\', \'' + partOfSpeech + '\', \'' + simpleDefinition + '\', \'' + longDefinition + '\'); \
 | 
				
			||||||
                                                                                                                    htmlEntities(simpleDefinition) + '\', \'' +
 | 
					                                                  return false;">Yes, Update it</button>';
 | 
				
			||||||
                                                                                                                    htmlEntities(longDefinition) + '\', \'' +
 | 
					 | 
				
			||||||
                                                                                                                    htmlEntities(partOfSpeech) + '\'); return false;">Yes, Update it</button>';
 | 
					 | 
				
			||||||
                updateConflictArea.innerHTML += '<button type="button" id="updateCancelButton" onclick="CloseUpdateConflictArea(); return false;">No, Leave it</button>';
 | 
					                updateConflictArea.innerHTML += '<button type="button" id="updateCancelButton" onclick="CloseUpdateConflictArea(); return false;">No, Leave it</button>';
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                errorMessage = "No change has been made to \"" + word + "\"";
 | 
					                errorMessage = "No change has been made to \"" + word + "\"";
 | 
				
			||||||
| 
						 | 
					@ -67,7 +63,7 @@ function AddWord() {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (wordIndex >= 0) {
 | 
					        } else if (wordIndex >= 0) {
 | 
				
			||||||
            if (currentDictionary.words[wordIndex].simpleDefinition != simpleDefinition || currentDictionary.words[wordIndex].longDefinition != longDefinition || currentDictionary.words[wordIndex].partOfSpeech != partOfSpeech) {
 | 
					            if (WordAtIndexWasChanged(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition)) {
 | 
				
			||||||
                updateConflictArea.style.display = "block";
 | 
					                updateConflictArea.style.display = "block";
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                var updateConflictText = "<span id='updateConflictMessage'>\"" + word + "\" is already in the dictionary";
 | 
					                var updateConflictText = "<span id='updateConflictMessage'>\"" + word + "\" is already in the dictionary";
 | 
				
			||||||
| 
						 | 
					@ -77,11 +73,9 @@ function AddWord() {
 | 
				
			||||||
                    updateConflictText += "."
 | 
					                    updateConflictText += "."
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                updateConflictText += "<br>Do you want to update it to what you have set above?</span>";
 | 
					                updateConflictText += "<br>Do you want to update it to what you have set above?</span>";
 | 
				
			||||||
                updateConflictText += '<button type="button" id="updateConfirmButton" onclick="UpdateWord(' + wordIndex + ', \'' +
 | 
					                updateConflictText += '<button type="button" id="updateConfirmButton" \
 | 
				
			||||||
                                                                                                            htmlEntities(word) + '\', \'' +
 | 
					                                                  onclick="UpdateWord(' + wordIndex + ', \'' + word + '\', \'' + pronunciation + '\', \'' + partOfSpeech + '\', \'' + simpleDefinition + '\', \'' + longDefinition + '\'); \
 | 
				
			||||||
                                                                                                            htmlEntities(simpleDefinition) + '\', \'' +
 | 
					                                                  return false;">Yes, Update it</button>';
 | 
				
			||||||
                                                                                                            htmlEntities(longDefinition) + '\', \'' +
 | 
					 | 
				
			||||||
                                                                                                            htmlEntities(partOfSpeech) + '\'); return false;">Yes, Update it</button>';
 | 
					 | 
				
			||||||
                updateConflictText += ' <button type="button" id="updateCancelButton" onclick="CloseUpdateConflictArea(); return false;">No, Leave it</button>';
 | 
					                updateConflictText += ' <button type="button" id="updateCancelButton" onclick="CloseUpdateConflictArea(); return false;">No, Leave it</button>';
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                updateConflictArea.innerHTML = updateConflictText;
 | 
					                updateConflictArea.innerHTML = updateConflictText;
 | 
				
			||||||
| 
						 | 
					@ -92,7 +86,7 @@ function AddWord() {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            currentDictionary.words.push({name: word, simpleDefinition: simpleDefinition, longDefinition: longDefinition, partOfSpeech: partOfSpeech});
 | 
					            currentDictionary.words.push({name: word, pronunciation: pronunciation, partOfSpeech: partOfSpeech, simpleDefinition: simpleDefinition, longDefinition: longDefinition});
 | 
				
			||||||
            SaveAndUpdateDictionary(false);
 | 
					            SaveAndUpdateDictionary(false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -114,12 +108,13 @@ function AddWord() {
 | 
				
			||||||
    errorMessageArea.innerHTML = errorMessage;
 | 
					    errorMessageArea.innerHTML = errorMessage;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function WordAtIndexWasChanged(indexString, word, simpleDefinition, longDefinition, partOfSpeech) {
 | 
					function WordAtIndexWasChanged(indexString, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
 | 
				
			||||||
     return (!currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name.toLowerCase() != word.toLowerCase()) ||
 | 
					     return (!currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name.toLowerCase() != word.toLowerCase()) ||
 | 
				
			||||||
            (currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name != word) ||
 | 
					            (currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name != word) ||
 | 
				
			||||||
 | 
					            currentDictionary.words[parseInt(indexString)].pronunciation != pronunciation ||
 | 
				
			||||||
 | 
					            currentDictionary.words[parseInt(indexString)].partOfSpeech != partOfSpeech ||
 | 
				
			||||||
            currentDictionary.words[parseInt(indexString)].simpleDefinition != simpleDefinition ||
 | 
					            currentDictionary.words[parseInt(indexString)].simpleDefinition != simpleDefinition ||
 | 
				
			||||||
            currentDictionary.words[parseInt(indexString)].longDefinition != longDefinition ||
 | 
					            currentDictionary.words[parseInt(indexString)].longDefinition != longDefinition;
 | 
				
			||||||
            currentDictionary.words[parseInt(indexString)].partOfSpeech != partOfSpeech;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function SaveScroll() {
 | 
					function SaveScroll() {
 | 
				
			||||||
| 
						 | 
					@ -139,9 +134,10 @@ function EditWord(index) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    document.getElementById("editIndex").value = index.toString();
 | 
					    document.getElementById("editIndex").value = index.toString();
 | 
				
			||||||
    document.getElementById("word").value = htmlEntitiesParse(currentDictionary.words[index].name);
 | 
					    document.getElementById("word").value = htmlEntitiesParse(currentDictionary.words[index].name);
 | 
				
			||||||
 | 
					    document.getElementById("pronunciation").value = htmlEntitiesParse(currentDictionary.words[index].pronunciation);
 | 
				
			||||||
 | 
					    document.getElementById("partOfSpeech").value = htmlEntitiesParse(currentDictionary.words[index].partOfSpeech);
 | 
				
			||||||
    document.getElementById("simpleDefinition").value = htmlEntitiesParse(currentDictionary.words[index].simpleDefinition);
 | 
					    document.getElementById("simpleDefinition").value = htmlEntitiesParse(currentDictionary.words[index].simpleDefinition);
 | 
				
			||||||
    document.getElementById("longDefinition").value = htmlEntitiesParse(currentDictionary.words[index].longDefinition);
 | 
					    document.getElementById("longDefinition").value = htmlEntitiesParse(currentDictionary.words[index].longDefinition);
 | 
				
			||||||
    document.getElementById("partOfSpeech").value = htmlEntitiesParse(currentDictionary.words[index].partOfSpeech);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    document.getElementById("newWordButtonArea").style.display = "none";
 | 
					    document.getElementById("newWordButtonArea").style.display = "none";
 | 
				
			||||||
    document.getElementById("editWordButtonArea").style.display = "block";
 | 
					    document.getElementById("editWordButtonArea").style.display = "block";
 | 
				
			||||||
| 
						 | 
					@ -157,11 +153,12 @@ function SaveAndUpdateDictionary(keepFormContents) {
 | 
				
			||||||
    CloseUpdateConflictArea();
 | 
					    CloseUpdateConflictArea();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function UpdateWord(wordIndex, word, simpleDefinition, longDefinition, partOfSpeech) {
 | 
					function UpdateWord(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
 | 
				
			||||||
    currentDictionary.words[wordIndex].name = word;
 | 
					    currentDictionary.words[wordIndex].name = word;
 | 
				
			||||||
 | 
					    currentDictionary.words[wordIndex].pronunciation = pronunciation;
 | 
				
			||||||
 | 
					    currentDictionary.words[wordIndex].partOfSpeech = partOfSpeech;
 | 
				
			||||||
    currentDictionary.words[wordIndex].simpleDefinition = simpleDefinition;
 | 
					    currentDictionary.words[wordIndex].simpleDefinition = simpleDefinition;
 | 
				
			||||||
    currentDictionary.words[wordIndex].longDefinition = longDefinition;
 | 
					    currentDictionary.words[wordIndex].longDefinition = longDefinition;
 | 
				
			||||||
    currentDictionary.words[wordIndex].partOfSpeech = partOfSpeech;
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    SaveAndUpdateDictionary();
 | 
					    SaveAndUpdateDictionary();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -183,9 +180,10 @@ function CloseUpdateConflictArea() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ClearForm() {
 | 
					function ClearForm() {
 | 
				
			||||||
    document.getElementById("word").value = "";
 | 
					    document.getElementById("word").value = "";
 | 
				
			||||||
 | 
					    document.getElementById("pronunciation").value = "";
 | 
				
			||||||
 | 
					    document.getElementById("partOfSpeech").value = "";
 | 
				
			||||||
    document.getElementById("simpleDefinition").value = "";
 | 
					    document.getElementById("simpleDefinition").value = "";
 | 
				
			||||||
    document.getElementById("longDefinition").value = "";
 | 
					    document.getElementById("longDefinition").value = "";
 | 
				
			||||||
    document.getElementById("partOfSpeech").value = "";
 | 
					 | 
				
			||||||
    document.getElementById("editIndex").value = "";
 | 
					    document.getElementById("editIndex").value = "";
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    document.getElementById("newWordButtonArea").style.display = "block";
 | 
					    document.getElementById("newWordButtonArea").style.display = "block";
 | 
				
			||||||
| 
						 | 
					@ -204,28 +202,17 @@ function ShowDictionary() {
 | 
				
			||||||
    var searchResults = [];
 | 
					    var searchResults = [];
 | 
				
			||||||
    var search = htmlEntities(document.getElementById("searchBox").value);
 | 
					    var search = htmlEntities(document.getElementById("searchBox").value);
 | 
				
			||||||
    if (search != "") {
 | 
					    if (search != "") {
 | 
				
			||||||
 | 
					        var xpath = [];
 | 
				
			||||||
        if (document.getElementById("searchOptionWord").checked) {
 | 
					        if (document.getElementById("searchOptionWord").checked) {
 | 
				
			||||||
            var wordNameSearch = JSON.search(currentDictionary, '//words[contains(name, "' + search + '")]/name');
 | 
					            xpath.push('contains(name, "'+ search +'")');
 | 
				
			||||||
            for (var i = 0; i < wordNameSearch.length; i++) {
 | 
					 | 
				
			||||||
                searchResults.push(wordNameSearch[i]);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (document.getElementById("searchOptionSimple").checked) {
 | 
					        if (document.getElementById("searchOptionSimple").checked) {
 | 
				
			||||||
            var simpleDefinitionSearch = JSON.search(currentDictionary, '//words[contains(simpleDefinition, "' + search + '")]/name');
 | 
					            xpath.push('contains(simpleDefinition, "'+ search +'")');
 | 
				
			||||||
            for (var i = 0; i < simpleDefinitionSearch.length; i++) {
 | 
					 | 
				
			||||||
                if (searchResults.indexOf(simpleDefinitionSearch[i]) < 0) {
 | 
					 | 
				
			||||||
                    searchResults.push(simpleDefinitionSearch[i]);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (document.getElementById("searchOptionLong").checked) {
 | 
					        if (document.getElementById("searchOptionLong").checked) {
 | 
				
			||||||
            var longDefinitionSearch = JSON.search(currentDictionary, '//words[contains(longDefinition, "' + search + '")]/name');
 | 
					            xpath.push('contains(longDefinition, "'+ search +'")');
 | 
				
			||||||
            for (var i = 0; i < longDefinitionSearch.length; i++) {
 | 
					 | 
				
			||||||
                if (searchResults.indexOf(longDefinitionSearch[i]) < 0) {
 | 
					 | 
				
			||||||
                    searchResults.push(longDefinitionSearch[i]);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        searchResults = JSON.search(currentDictionary, '//words['+ xpath.join(' or ') +']/name');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var dictionaryNameArea = document.getElementById("dictionaryName");
 | 
					    var dictionaryNameArea = document.getElementById("dictionaryName");
 | 
				
			||||||
| 
						 | 
					@ -241,6 +228,9 @@ function ShowDictionary() {
 | 
				
			||||||
        for (var i = 0; i < currentDictionary.words.length; i++) {
 | 
					        for (var i = 0; i < currentDictionary.words.length; i++) {
 | 
				
			||||||
            if (filter == "" || (filter != "" && currentDictionary.words[i].partOfSpeech == filter)) {
 | 
					            if (filter == "" || (filter != "" && currentDictionary.words[i].partOfSpeech == filter)) {
 | 
				
			||||||
                if (search == "" || (search != "" && searchResults.indexOf(currentDictionary.words[i].name) >= 0)) {
 | 
					                if (search == "" || (search != "" && searchResults.indexOf(currentDictionary.words[i].name) >= 0)) {
 | 
				
			||||||
 | 
					                    if (typeof currentDictionary.words[i].pronunciation === 'undefined') {
 | 
				
			||||||
 | 
					                        currentDictionary.words[i].pronunciation = "";  //Account for new property
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    dictionaryText += DictionaryEntry(i);
 | 
					                    dictionaryText += DictionaryEntry(i);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -273,6 +263,10 @@ function DictionaryEntry(itemIndex) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    entryText += "<word>" + ((searchTerm != "" && document.getElementById("searchOptionWord").checked) ? currentDictionary.words[itemIndex].name.replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : currentDictionary.words[itemIndex].name) + "</word>";
 | 
					    entryText += "<word>" + ((searchTerm != "" && document.getElementById("searchOptionWord").checked) ? currentDictionary.words[itemIndex].name.replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : currentDictionary.words[itemIndex].name) + "</word>";
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    if (currentDictionary.words[itemIndex].pronunciation != "") {
 | 
				
			||||||
 | 
					        entryText += "<pronunciation>" + markdown.toHTML(currentDictionary.words[itemIndex].pronunciation).replace("<p>","").replace("</p>","") + "</pronunciation>";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if (currentDictionary.words[itemIndex].partOfSpeech != "") {
 | 
					    if (currentDictionary.words[itemIndex].partOfSpeech != "") {
 | 
				
			||||||
        entryText += "<partofspeech>" + currentDictionary.words[itemIndex].partOfSpeech + "</partofspeech>";
 | 
					        entryText += "<partofspeech>" + currentDictionary.words[itemIndex].partOfSpeech + "</partofspeech>";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -462,14 +456,29 @@ function ImportDictionary() {
 | 
				
			||||||
        // When it's loaded, process it
 | 
					        // When it's loaded, process it
 | 
				
			||||||
        reader.onloadend = function () {
 | 
					        reader.onloadend = function () {
 | 
				
			||||||
            if (reader.result && reader.result.length) {
 | 
					            if (reader.result && reader.result.length) {
 | 
				
			||||||
                if (reader.result.substr(reader.result.length - 30) == '"dictionaryImportVersion":' + currentVersion + '}') {
 | 
					                var tmpDicitonary = JSON.parse(reader.result);
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                if (tmpDicitonary.hasOwnProperty("name") && tmpDicitonary.hasOwnProperty("description") &&
 | 
				
			||||||
 | 
					                    tmpDicitonary.hasOwnProperty("words") && tmpDicitonary.hasOwnProperty("settings"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    localStorage.setItem('dictionary', reader.result);
 | 
					                    localStorage.setItem('dictionary', reader.result);
 | 
				
			||||||
                    document.getElementById("importFile").value = "";
 | 
					                    document.getElementById("importFile").value = "";
 | 
				
			||||||
                    LoadDictionary();
 | 
					                    LoadDictionary();
 | 
				
			||||||
                    HideSettings();
 | 
					                    HideSettings();
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    alert("Uploaded file is not compatible.");
 | 
					                    var errorString = "File is missing:";
 | 
				
			||||||
 | 
					                    if (!tmpDicitonary.hasOwnProperty("name"))
 | 
				
			||||||
 | 
					                        errorString += " name";
 | 
				
			||||||
 | 
					                    if (!tmpDicitonary.hasOwnProperty("description"))
 | 
				
			||||||
 | 
					                        errorString += " description";
 | 
				
			||||||
 | 
					                    if (!tmpDicitonary.hasOwnProperty("words"))
 | 
				
			||||||
 | 
					                        errorString += " words";
 | 
				
			||||||
 | 
					                    if (!tmpDicitonary.hasOwnProperty("settings"))
 | 
				
			||||||
 | 
					                        errorString += " settings";
 | 
				
			||||||
 | 
					                    alert("Uploaded file is not compatible.\n\n" + errorString);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                tmpDicitonary = null;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                alert("Upload Failed");
 | 
					                alert("Upload Failed");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue