Merge branch 'prod' into php
Conflicts: .gitignore index.php js/dictionaryBuilder.js
This commit is contained in:
commit
6e88e55e12
|
@ -1,3 +1,2 @@
|
||||||
php/google/
|
php/google/
|
||||||
images/favicon.png
|
ipa_character_picker/
|
||||||
images/lexiconga.png
|
|
||||||
|
|
11
README.md
11
README.md
|
@ -11,8 +11,8 @@ It accepts Unicode characters so you can utilize whatever typable characters you
|
||||||
When you have a brand new, empty dictionary, the first thing you'll probably want to do is change the title to whatever your conlang is called and add at least a little description of what your language is like or how to use it. You can do this by clicking on the Settings button, which will open up the settings screen. Here, you will find all the fields you need to update your dictionary's Name and Description/Rules. The Description/Rules text area uses [Markdown](https://help.github.com/articles/markdown-basics/) to format any text you include, so brush up on how to do basic things in Markdown before you get started _(NOTE: a line break is done by adding 2 or more spaces to the end of the line and then going to the next line!)_. After this, make sure that the Parts of Speech are adequate for your language _(see below for more information about this)_. Update these fields to what you want them to say and click the "Save" button to keep the Settings menu open, or the "Save and Close" button to close the menu and start adding words!
|
When you have a brand new, empty dictionary, the first thing you'll probably want to do is change the title to whatever your conlang is called and add at least a little description of what your language is like or how to use it. You can do this by clicking on the Settings button, which will open up the settings screen. Here, you will find all the fields you need to update your dictionary's Name and Description/Rules. The Description/Rules text area uses [Markdown](https://help.github.com/articles/markdown-basics/) to format any text you include, so brush up on how to do basic things in Markdown before you get started _(NOTE: a line break is done by adding 2 or more spaces to the end of the line and then going to the next line!)_. After this, make sure that the Parts of Speech are adequate for your language _(see below for more information about this)_. Update these fields to what you want them to say and click the "Save" button to keep the Settings menu open, or the "Save and Close" button to close the menu and start adding words!
|
||||||
|
|
||||||
To add words, just use the form on the top left side of the window. Hopefully the form is self-explanatory, but if not, here's a little guide:
|
To add words, just use the form on the top left side of the window. Hopefully the form is self-explanatory, but if not, here's a little guide:
|
||||||
Enter the word in your language in the "Word" field, an equivalent word or short definition in the "Equivalent Word" field, a longer definition or fuller explanation of the word using [Markdown](https://help.github.com/articles/markdown-basics/) in the "Explanation" text area, choose a part of speech, and click "Add Word". Your word will instantly appear in your dictionary under the dictionary's name! You can add as many words as you want this way.
|
Enter the word in your language in the "Word" field, the pronunciation of the word in the "Pronunciation" field, choose a Part of Speech, enter an equivalent word/short definition in the "Equivalent Word(s)" field and/or a longer definition or fuller explanation of the word using [Markdown](https://help.github.com/articles/markdown-basics/) in the "Explanation/Long Definition" text area, and click "Add Word". Your word will instantly appear in your dictionary under the dictionary's name! You can add as many words as you want this way.
|
||||||
The only things to remember while adding new words is that the minimum information that you can enter is the Word itself and either the Equivalent Word OR the Explanation. You can have both of these or just one, but you need at least one. If you do not want to use the Parts of Speech, you do not need to, though you will miss out on the handy Filter feature of the dictionary.
|
The only things to remember while adding new words is that the minimum information that you can enter is the Word itself and either the Equivalent Word OR the Explanation. You can have both of these or just one, but you need at least one. If you do not want to use the Pronunciation or Parts of Speech then you do not need to, though if you leave out Part of Speech, you will miss out on the handy Filter feature of the dictionary.
|
||||||
|
|
||||||
And that's all you need to get started! Everything else should be pretty self-explanatory, but a full explanation of Dictionary Builder and all of its functions continues below.
|
And that's all you need to get started! Everything else should be pretty self-explanatory, but a full explanation of Dictionary Builder and all of its functions continues below.
|
||||||
|
|
||||||
|
@ -20,7 +20,9 @@ And that's all you need to get started! Everything else should be pretty self-ex
|
||||||
After you enter a markdown-formatted description/rules in the Settings menu, you can view the formatted version by clicking the "Show Description" button under your dictionary's name. You can hide it again by clicking "Hide Description" when the description is displayed.
|
After you enter a markdown-formatted description/rules in the Settings menu, you can view the formatted version by clicking the "Show Description" button under your dictionary's name. You can hide it again by clicking "Hide Description" when the description is displayed.
|
||||||
|
|
||||||
### Entry Management
|
### Entry Management
|
||||||
After adding some words to your dictionary, you'll notice an "Edit" and "Delete" button attached to each entry.
|
After adding some words to your dictionary, you'll notice a link icon (🔗) and an "Edit" and "Delete" button attached to each entry.
|
||||||
|
|
||||||
|
The link icon (🔗) is a link to that word. These links only work when there is nothing entered in the search box and no filters are set. Also note that the links are only intended for linking within the same dictionary and will only work properly when your dictionary is loaded, so only share them with friends if your friends also have your dictionary imported.
|
||||||
|
|
||||||
The **Edit** button will scroll to the top of the screen and fill the Word form with the current details of the word you edited. You can make any changes you want and click the "Edit Word" button. You will be asked to confirm your changes, and once you do, your word will be saved. If you do not want to make changes, just click the "Cancel" button.
|
The **Edit** button will scroll to the top of the screen and fill the Word form with the current details of the word you edited. You can make any changes you want and click the "Edit Word" button. You will be asked to confirm your changes, and once you do, your word will be saved. If you do not want to make changes, just click the "Cancel" button.
|
||||||
|
|
||||||
|
@ -47,6 +49,9 @@ The **Import Dictionary** form allows you to upload and view any previously-expo
|
||||||
|
|
||||||
The **Empty Current Dictionary** should only be used if you want to completely start over from scratch. It will ask you to confirm that you want to delete, and if you confirm, your dictionary will be gone forever. If you have not exported your dictionary before emptying it, there will be absolutely no way to get it back. Please be careful with this!
|
The **Empty Current Dictionary** should only be used if you want to completely start over from scratch. It will ask you to confirm that you want to delete, and if you confirm, your dictionary will be gone forever. If you have not exported your dictionary before emptying it, there will be absolutely no way to get it back. Please be careful with this!
|
||||||
|
|
||||||
|
## Problems or Requests
|
||||||
|
Please report any problems you come across to the [Dictionary Builder Issues page](https://github.com/Alamantus/DictionaryBuilder/issues). You can also submit enhancement requests to the same place if you have any requests for new features.
|
||||||
|
|
||||||
## Future Plans
|
## Future Plans
|
||||||
In the future, I'm planning to add the ability to save more than one dictionary at a time by allowing user accounts. Each account will be able to store a certain number of dictionaries and will be able to switch to any saved dictionary at any time without having to worry about exporting and importing .dict files. Along with this will also come the ability to easily share dictionaries if you want, but all dictionaries will be private by default.
|
In the future, I'm planning to add the ability to save more than one dictionary at a time by allowing user accounts. Each account will be able to store a certain number of dictionaries and will be able to switch to any saved dictionary at any time without having to worry about exporting and importing .dict files. Along with this will also come the ability to easily share dictionaries if you want, but all dictionaries will be private by default.
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,10 @@ input, textarea, select, option, button {
|
||||||
background: #efdfc0;
|
background: #efdfc0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#notificationArea {
|
||||||
|
background:#c0c088;
|
||||||
|
}
|
||||||
|
|
||||||
#dictionaryContainer {
|
#dictionaryContainer {
|
||||||
background: #bd7251;
|
background: #bd7251;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
@ -100,7 +104,8 @@ input, textarea, select, option, button {
|
||||||
#loginLink, #logoutLink,
|
#loginLink, #logoutLink,
|
||||||
#descriptionToggle, #settingsButton,
|
#descriptionToggle, #settingsButton,
|
||||||
.deleteCancelButton, .deleteConfirmButton,
|
.deleteCancelButton, .deleteConfirmButton,
|
||||||
#settingsScreenCloseButton, #infoScreenCloseButton {
|
#settingsScreenCloseButton, #infoScreenCloseButton,
|
||||||
|
.helperlink {
|
||||||
background: #e0c19c;
|
background: #e0c19c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ footer {
|
||||||
max-height: 32px; /* Update Dictionary Container's bottom margin to account for footer */
|
max-height: 32px; /* Update Dictionary Container's bottom margin to account for footer */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.inline {
|
||||||
|
display: inline !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* Smartphones (portrait and landscape) ----------- */
|
/* Smartphones (portrait and landscape) ----------- */
|
||||||
@media only screen
|
@media only screen
|
||||||
and (min-device-width : 320px)
|
and (min-device-width : 320px)
|
||||||
|
@ -63,6 +67,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;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +111,15 @@ input[type=checkbox] {
|
||||||
margin: 0 10px 0 0;
|
margin: 0 10px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#notificationArea {
|
||||||
|
text-align:center;
|
||||||
|
padding:10px;
|
||||||
|
border-radius:5px;
|
||||||
|
margin:0 auto;
|
||||||
|
width:50%;
|
||||||
|
min-width:200px;
|
||||||
|
}
|
||||||
|
|
||||||
#dictionaryContainer {
|
#dictionaryContainer {
|
||||||
margin: 15px 0 36px 15px; /* bottom margin must clear footer */
|
margin: 15px 0 36px 15px; /* bottom margin must clear footer */
|
||||||
width: 60%;
|
width: 60%;
|
||||||
|
@ -124,14 +141,18 @@ input[type=checkbox] {
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clickable {
|
.clickable, .helperlink {
|
||||||
|
display: inline;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
background: #dddddd;
|
background: #dddddd;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
#descriptionToggle {
|
#descriptionToggle {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
@ -151,14 +172,29 @@ entry {
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wordLink {
|
||||||
|
text-decoration: none;
|
||||||
|
float: right;
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 2px;
|
||||||
|
line-height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
word {
|
word {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
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 {
|
||||||
|
@ -263,6 +299,7 @@ searchTerm {
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#notificationCloseButton,
|
||||||
#settingsButton, #settingsScreenCloseButton,
|
#settingsButton, #settingsScreenCloseButton,
|
||||||
#settingsSaveButtons button, #infoScreenCloseButton {
|
#settingsSaveButtons button, #infoScreenCloseButton {
|
||||||
float: right;
|
float: right;
|
||||||
|
|
55
index.php
55
index.php
|
@ -110,25 +110,27 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<contents>
|
<contents>
|
||||||
<?php if ($notificationMessage != "") { ?>
|
<div id="notificationArea" style="display:<?php echo (($notificationMessage) ? "block" : "none"); ?>;">
|
||||||
<div id="notificationArea" style="text-align:center;background:#c0c088;padding:10px;border-radius:5px;margin:0 auto;width:50%;min-width:200px;">
|
<span id="notificationCloseButton" class="clickable" onclick="document.getElementById('notificationArea').style.display='none';">Close</span>
|
||||||
<?php echo $notificationMessage; ?>
|
<div id="notificationMessage"><?php echo $notificationMessage; ?></div>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
|
||||||
<div id="leftColumn">
|
<div id="leftColumn">
|
||||||
<form id="wordEntryForm">
|
<form id="wordEntryForm">
|
||||||
<label><span>Word</span>
|
<label><span>Word</span>
|
||||||
<input type="text" id="word" />
|
<input type="text" id="word" />
|
||||||
</label>
|
</label>
|
||||||
<label><span>Equivalent Word</span>
|
<label><span>Pronunciation <a class="helperlink" href="./ipa_character_picker/" target="_blank" title="IPA Character Picker backed up from http://r12a.github.io/pickers/ipa/">IPA Characters</a></span>
|
||||||
<input type="text" id="simpleDefinition" />
|
<input type="text" id="pronunciation" />
|
||||||
</label>
|
|
||||||
<label><span>Explanation</span>
|
|
||||||
<textarea id="longDefinition"></textarea>
|
|
||||||
</label>
|
</label>
|
||||||
<label><span>Part of Speech</span>
|
<label><span>Part of Speech</span>
|
||||||
<select id="partOfSpeech"></select>
|
<select id="partOfSpeech"></select>
|
||||||
</label>
|
</label>
|
||||||
|
<label><span>Equivalent Word(s)</span>
|
||||||
|
<input type="text" id="simpleDefinition" />
|
||||||
|
</label>
|
||||||
|
<label><span>Explanation/Long Definition</span>
|
||||||
|
<textarea id="longDefinition"></textarea>
|
||||||
|
</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;">
|
||||||
|
@ -174,7 +176,7 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="rightColumn" class="googleads" style="float:right;width:20%;max-width:300px;min-width:200px;overflow:hidden;">
|
<div id="rightColumn" class="googleads" style="float:right;width:20%;max-width:300px;min-width:200px;overflow:hidden;">
|
||||||
<?php //include_once("php/google/adsense.php"); ?>
|
<?php if ($_GET['adminoverride'] != "noadsortracking") { include_once("php/google/adsense.php"); } ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="settingsScreen" style="display:none;">
|
<div id="settingsScreen" style="display:none;">
|
||||||
|
@ -204,7 +206,12 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {
|
||||||
<input type="checkbox" id="dictionaryCaseSensitive" />
|
<input type="checkbox" id="dictionaryCaseSensitive" />
|
||||||
</label>
|
</label>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="inline">
|
||||||
|
<span class="checkboxlabel">Sort by Equivalent Word</span>
|
||||||
|
<input type="checkbox" id="dictionarySortByEquivalent" />
|
||||||
|
</label> <span class="helperlink clickable" onclick='alert("By default, your dictionary is organized alphabetically by word. Checking this box will organize it by the \"Equivalent Word\" field instead");'>?</span>
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
<label>
|
<label>
|
||||||
<span class="checkboxlabel">Dictionary is Complete</span>
|
<span class="checkboxlabel">Dictionary is Complete</span>
|
||||||
<input type="checkbox" id="dictionaryIsComplete" />
|
<input type="checkbox" id="dictionaryIsComplete" />
|
||||||
|
@ -218,9 +225,9 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {
|
||||||
<label>
|
<label>
|
||||||
<span>Import Dictionary</span>
|
<span>Import Dictionary</span>
|
||||||
<input type="file" id="importFile" />
|
<input type="file" id="importFile" />
|
||||||
<button type="button" onclick="ConfirmImportDictionary(); return false;">Import</button>
|
<button type="button" onclick="ImportDictionary(); return false;">Import</button>
|
||||||
</label>
|
</label>
|
||||||
<label><button type="button" onclick="ConfirmEmptyWholeDictionary()" style="cursor:pointer;">Empty Current Dictionary</button></label>
|
<label><button type="button" onclick="EmptyWholeDictionary()" style="cursor:pointer;">Empty Current Dictionary</button></label>
|
||||||
</div>
|
</div>
|
||||||
<div id="settingsSaveButtons">
|
<div id="settingsSaveButtons">
|
||||||
<span id="settingsErrorMessage"></span><br>
|
<span id="settingsErrorMessage"></span><br>
|
||||||
|
@ -240,7 +247,7 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {
|
||||||
</div>
|
</div>
|
||||||
</contents>
|
</contents>
|
||||||
<footer>
|
<footer>
|
||||||
Dictionary Builder only guaranteed to work with most up-to-date HTML5 browsers. <span class="clickable" onclick="ShowInfo('terms')" style="font-size:12px;">Terms</span> <span class="clickable" onclick="ShowInfo('privacy')" style="font-size:12px;">Privacy</span>
|
Dictionary Builder only guaranteed to work with most up-to-date HTML5 browsers. <a href="https://github.com/Alamantus/DictionaryBuilder/issues" target="_blank">Report a Problem</a> | <span class="clickable" onclick="ShowInfo('terms')" style="font-size:12px;">Terms</span> <span class="clickable" onclick="ShowInfo('privacy')" style="font-size:12px;">Privacy</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<!-- Markdown Parser -->
|
<!-- Markdown Parser -->
|
||||||
|
@ -249,13 +256,19 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {
|
||||||
<script src="js/defiant-js/defiant-latest.min.js"></script>
|
<script src="js/defiant-js/defiant-latest.min.js"></script>
|
||||||
<!-- Main Script -->
|
<!-- Main Script -->
|
||||||
<script src="js/dictionaryBuilder.js"></script>
|
<script src="js/dictionaryBuilder.js"></script>
|
||||||
<script>
|
<script src="js/ui.js"></script>
|
||||||
currentUser = <?php echo $current_user; ?>;
|
<?php if ($_GET['adminoverride'] != "noadsortracking") { include_once("php/google/analytics.php"); } ?>
|
||||||
publicName = "<?php echo Get_Public_Name($current_user); ?>";
|
|
||||||
<?php if (isset($_GET['loggedout']) && $current_user <= 0) { ?>
|
|
||||||
EmptyWholeDictionary();
|
|
||||||
<?php } ?>
|
|
||||||
</script>
|
|
||||||
<?php //include_once("php/google/analytics.php"); ?>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_include_contents($filename) {
|
||||||
|
if (is_file($filename)) {
|
||||||
|
ob_start();
|
||||||
|
include $filename;
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
?>
|
|
@ -9,18 +9,17 @@ var currentDictionary = {
|
||||||
description: "A new dictionary.",
|
description: "A new dictionary.",
|
||||||
createdBy: publicName,
|
createdBy: publicName,
|
||||||
words: [],
|
words: [],
|
||||||
|
nextWordId: 1,
|
||||||
settings: {
|
settings: {
|
||||||
allowDuplicates: false,
|
allowDuplicates: false,
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
|
partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
|
||||||
|
sortByEquivalent: false,
|
||||||
isComplete: false
|
isComplete: false
|
||||||
},
|
}
|
||||||
externalID: 0,
|
}
|
||||||
fileIdentifier: "Lexiconga Dictionary"
|
|
||||||
};
|
|
||||||
|
|
||||||
var defaultDictionaryJSON = JSON.stringify(currentDictionary); //Saves a stringifyed default dictionary.
|
var defaultDictionaryJSON = JSON.stringify(currentDictionary); //Saves a stringifyed default dictionary.
|
||||||
var previousDictionary = {};
|
|
||||||
|
|
||||||
var savedScroll = {
|
var savedScroll = {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -147,10 +146,11 @@ function GetTextFile(filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddWord() {
|
function AddWord() {
|
||||||
var word = htmlEntities(document.getElementById("word").value);
|
var word = htmlEntities(document.getElementById("word").value).trim();
|
||||||
var simpleDefinition = htmlEntities(document.getElementById("simpleDefinition").value);
|
var pronunciation = htmlEntities(document.getElementById("pronunciation").value).trim();
|
||||||
|
var partOfSpeech = htmlEntities(document.getElementById("partOfSpeech").value).trim();
|
||||||
|
var simpleDefinition = htmlEntities(document.getElementById("simpleDefinition").value).trim();
|
||||||
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 = "";
|
||||||
|
@ -160,14 +160,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 + ', \'' + htmlEntities(word) + '\', \'' + htmlEntities(pronunciation) + '\', \'' + htmlEntities(partOfSpeech) + '\', \'' + htmlEntities(simpleDefinition) + '\', \'' + htmlEntities(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 + "\"";
|
||||||
|
@ -176,7 +174,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";
|
||||||
|
@ -186,11 +184,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 + ', \'' + htmlEntities(word) + '\', \'' + htmlEntities(pronunciation) + '\', \'' + htmlEntities(partOfSpeech) + '\', \'' + htmlEntities(simpleDefinition) + '\', \'' + htmlEntities(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;
|
||||||
|
@ -201,11 +197,12 @@ 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, wordId: currentDictionary.nextWordId++});
|
||||||
SaveAndUpdateDictionary(false, true);
|
FocusAfterAddingNewWord();
|
||||||
|
NewWordNotification(word);
|
||||||
|
SaveAndUpdateDictionary(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
errorMessageArea.innerHTML = "";
|
errorMessageArea.innerHTML = "";
|
||||||
} else {
|
} else {
|
||||||
if (word == "") {
|
if (word == "") {
|
||||||
|
@ -223,12 +220,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() {
|
||||||
|
@ -248,18 +246,22 @@ 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
function SaveAndUpdateDictionary(keepFormContents, sendWords) {
|
function SaveAndUpdateDictionary(keepFormContents) {
|
||||||
sendWords = (typeof sendWords !== 'undefined') ? sendWords : false;
|
if (!currentDictionary.settings.sortByEquivalent) {
|
||||||
currentDictionary.words.sort(dynamicSort("name"));
|
currentDictionary.words.sort(dynamicSort("name"));
|
||||||
SaveDictionary(true, sendWords);
|
} else {
|
||||||
|
currentDictionary.words.sort(dynamicSort("simpleDefinition"));
|
||||||
|
}
|
||||||
|
SaveDictionary();
|
||||||
ShowDictionary();
|
ShowDictionary();
|
||||||
if (!keepFormContents) {
|
if (!keepFormContents) {
|
||||||
ClearForm();
|
ClearForm();
|
||||||
|
@ -267,13 +269,14 @@ function SaveAndUpdateDictionary(keepFormContents, sendWords) {
|
||||||
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(false, true);
|
SaveAndUpdateDictionary();
|
||||||
|
|
||||||
window.scroll(savedScroll.x, savedScroll.y);
|
window.scroll(savedScroll.x, savedScroll.y);
|
||||||
}
|
}
|
||||||
|
@ -284,24 +287,7 @@ function DeleteWord(index) {
|
||||||
|
|
||||||
currentDictionary.words.splice(index, 1);
|
currentDictionary.words.splice(index, 1);
|
||||||
|
|
||||||
SaveAndUpdateDictionary(true, true);
|
SaveAndUpdateDictionary(true);
|
||||||
}
|
|
||||||
|
|
||||||
function CloseUpdateConflictArea() {
|
|
||||||
document.getElementById("updateConflict").style.display = "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
function ClearForm() {
|
|
||||||
document.getElementById("word").value = "";
|
|
||||||
document.getElementById("simpleDefinition").value = "";
|
|
||||||
document.getElementById("longDefinition").value = "";
|
|
||||||
document.getElementById("partOfSpeech").value = "";
|
|
||||||
document.getElementById("editIndex").value = "";
|
|
||||||
|
|
||||||
document.getElementById("newWordButtonArea").style.display = "block";
|
|
||||||
document.getElementById("editWordButtonArea").style.display = "none";
|
|
||||||
document.getElementById("errorMessage").innerHTML = "";
|
|
||||||
document.getElementById("updateConflict").style.display = "none";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateFilter() {
|
function UpdateFilter() {
|
||||||
|
@ -314,28 +300,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");
|
||||||
|
@ -350,7 +325,13 @@ function ShowDictionary() {
|
||||||
if (currentDictionary.words.length > 0) {
|
if (currentDictionary.words.length > 0) {
|
||||||
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(htmlEntities(currentDictionary.words[i].name)) >= 0)) {
|
||||||
|
if (!currentDictionary.words[i].hasOwnProperty("pronunciation")) {
|
||||||
|
currentDictionary.words[i].pronunciation = ""; //Account for new property
|
||||||
|
}
|
||||||
|
if (!currentDictionary.words[i].hasOwnProperty("wordId")) {
|
||||||
|
currentDictionary.words[i].wordId = i + 1; //Account for new property
|
||||||
|
}
|
||||||
dictionaryText += DictionaryEntry(i);
|
dictionaryText += DictionaryEntry(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,27 +343,18 @@ function ShowDictionary() {
|
||||||
dictionaryArea.innerHTML = dictionaryText;
|
dictionaryArea.innerHTML = dictionaryText;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ToggleDescription() {
|
|
||||||
var descriptionToggle = document.getElementById("descriptionToggle");
|
|
||||||
var descriptionArea = document.getElementById("dictionaryDescription");
|
|
||||||
|
|
||||||
if (descriptionArea.style.display == "none") {
|
|
||||||
descriptionArea.style.display = "block";
|
|
||||||
descriptionToggle.innerHTML = "Hide Description";
|
|
||||||
} else {
|
|
||||||
descriptionArea.style.display = "none";
|
|
||||||
descriptionToggle.innerHTML = "Show Description";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function DictionaryEntry(itemIndex) {
|
function DictionaryEntry(itemIndex) {
|
||||||
var entryText = "<entry>";
|
var entryText = "<entry><a name='" + currentDictionary.words[itemIndex].wordId + "'></a><a href='#" + currentDictionary.words[itemIndex].wordId + "' class='wordLink clickable'>🔗</a>";
|
||||||
|
|
||||||
var searchTerm = htmlEntities(document.getElementById("searchBox").value);
|
var searchTerm = htmlEntities(document.getElementById("searchBox").value);
|
||||||
var searchRegEx = new RegExp(searchTerm, "gi");
|
var searchRegEx = new RegExp(searchTerm, "gi");
|
||||||
|
|
||||||
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(htmlEntitiesParse(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>";
|
||||||
}
|
}
|
||||||
|
@ -422,43 +394,6 @@ function ManagementArea(itemIndex) {
|
||||||
return managementHTML;
|
return managementHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShowInfo(text) {
|
|
||||||
if (text == "terms") {
|
|
||||||
document.getElementById("infoText").innerHTML = termsText;
|
|
||||||
} else if (text == "privacy") {
|
|
||||||
document.getElementById("infoText").innerHTML = privacyText;
|
|
||||||
} else if (text == "login" || text == "create") {
|
|
||||||
document.getElementById("infoText").innerHTML = loginForm;
|
|
||||||
} else {
|
|
||||||
document.getElementById("infoText").innerHTML = aboutText;
|
|
||||||
}
|
|
||||||
document.getElementById("infoPage").scrollTop = 0;
|
|
||||||
document.getElementById("infoScreen").style.display = "block";
|
|
||||||
}
|
|
||||||
|
|
||||||
function HideInfo() {
|
|
||||||
document.getElementById("infoScreen").style.display = "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
function ToggleCaseSensitiveOption() {
|
|
||||||
if (document.getElementById("dictionaryAllowDuplicates").checked) {
|
|
||||||
document.getElementById("dictionaryCaseSensitive").disabled = true;
|
|
||||||
} else {
|
|
||||||
document.getElementById("dictionaryCaseSensitive").disabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ShowSettings() {
|
|
||||||
document.getElementById("settingsScreen").style.display = "block";
|
|
||||||
document.getElementById("dictionaryNameEdit").value = htmlEntitiesParse(currentDictionary.name);
|
|
||||||
document.getElementById("dictionaryDescriptionEdit").value = htmlEntitiesParse(currentDictionary.description);
|
|
||||||
document.getElementById("dictionaryPartsOfSpeechEdit").value = htmlEntitiesParse(currentDictionary.settings.partsOfSpeech);
|
|
||||||
document.getElementById("dictionaryAllowDuplicates").checked = currentDictionary.settings.allowDuplicates;
|
|
||||||
document.getElementById("dictionaryCaseSensitive").checked = currentDictionary.settings.caseSensitive;
|
|
||||||
document.getElementById("dictionaryIsComplete").checked = currentDictionary.settings.isComplete;
|
|
||||||
document.getElementById("numberOfWordsInDictionary").innerHTML = currentDictionary.words.length.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
function SaveSettings() {
|
function SaveSettings() {
|
||||||
if (htmlEntities(document.getElementById("dictionaryNameEdit").value) != "") {
|
if (htmlEntities(document.getElementById("dictionaryNameEdit").value) != "") {
|
||||||
currentDictionary.name = htmlEntities(document.getElementById("dictionaryNameEdit").value);
|
currentDictionary.name = htmlEntities(document.getElementById("dictionaryNameEdit").value);
|
||||||
|
@ -471,19 +406,13 @@ function SaveSettings() {
|
||||||
currentDictionary.settings.allowDuplicates = document.getElementById("dictionaryAllowDuplicates").checked;
|
currentDictionary.settings.allowDuplicates = document.getElementById("dictionaryAllowDuplicates").checked;
|
||||||
currentDictionary.settings.caseSensitive = document.getElementById("dictionaryCaseSensitive").checked;
|
currentDictionary.settings.caseSensitive = document.getElementById("dictionaryCaseSensitive").checked;
|
||||||
|
|
||||||
|
currentDictionary.settings.sortByEquivalent = document.getElementById("dictionarySortByEquivalent").checked;
|
||||||
|
|
||||||
currentDictionary.settings.isComplete = document.getElementById("dictionaryIsComplete").checked;
|
currentDictionary.settings.isComplete = document.getElementById("dictionaryIsComplete").checked;
|
||||||
|
|
||||||
HideSettingsWhenComplete();
|
HideSettingsWhenComplete();
|
||||||
|
|
||||||
SaveAndUpdateDictionary(true, false);
|
SaveAndUpdateDictionary(true);
|
||||||
}
|
|
||||||
|
|
||||||
function HideSettingsWhenComplete() {
|
|
||||||
if (currentDictionary.settings.isComplete) {
|
|
||||||
document.getElementById("hideIfComplete").style.display = "none";
|
|
||||||
} else {
|
|
||||||
document.getElementById("hideIfComplete").style.display = "block";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckForPartsOfSpeechChange () {
|
function CheckForPartsOfSpeechChange () {
|
||||||
|
@ -495,48 +424,16 @@ function CheckForPartsOfSpeechChange () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetPartsOfSpeech () {
|
|
||||||
var partsOfSpeechSelect = document.getElementById("partOfSpeech");
|
|
||||||
var wordFilterSelect = document.getElementById("wordFilter");
|
|
||||||
if (partsOfSpeechSelect.options.length > 0) {
|
|
||||||
for (var i = partsOfSpeechSelect.options.length - 1; i >= 0; i--) {
|
|
||||||
partsOfSpeechSelect.removeChild(partsOfSpeechSelect.options[i]);
|
|
||||||
wordFilterSelect.removeChild(wordFilterSelect.options[i + 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newPartsOfSpeech = htmlEntitiesParse(currentDictionary.settings.partsOfSpeech).trim().split(",");
|
|
||||||
for (var j = 0; j < newPartsOfSpeech.length; j++) {
|
|
||||||
var partOfSpeechOption = document.createElement('option');
|
|
||||||
partOfSpeechOption.appendChild(document.createTextNode(newPartsOfSpeech[j].trim()));
|
|
||||||
partOfSpeechOption.value = newPartsOfSpeech[j].trim();
|
|
||||||
partsOfSpeechSelect.appendChild(partOfSpeechOption);
|
|
||||||
|
|
||||||
var wordFilterOption = document.createElement('option');
|
|
||||||
wordFilterOption.appendChild(document.createTextNode(newPartsOfSpeech[j].trim()));
|
|
||||||
wordFilterOption.value = newPartsOfSpeech[j].trim();
|
|
||||||
wordFilterSelect.appendChild(wordFilterOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function HideSettings() {
|
|
||||||
document.getElementById("settingsScreen").style.display = "none";
|
|
||||||
document.getElementById("wordEntryForm").style.display = (currentDictionary.settings.isComplete) ? "none" : "block";
|
|
||||||
}
|
|
||||||
|
|
||||||
function ConfirmEmptyWholeDictionary() {
|
|
||||||
if (confirm("This will delete the entire current dictionary. If you do not have a backed up export, you will lose it forever!\n\nDo you still want to delete?")) {
|
|
||||||
EmptyWholeDictionary();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function EmptyWholeDictionary() {
|
function EmptyWholeDictionary() {
|
||||||
|
if (confirm("This will delete the entire current dictionary. If you do not have a backed up export, you will lose it forever!\n\nDo you still want to delete?")) {
|
||||||
currentDictionary = JSON.parse(defaultDictionaryJSON);
|
currentDictionary = JSON.parse(defaultDictionaryJSON);
|
||||||
SaveAndUpdateDictionary(false, true);
|
SaveAndUpdateDictionary(false);
|
||||||
SetPartsOfSpeech();
|
SetPartsOfSpeech();
|
||||||
HideSettings();
|
HideSettings();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function SaveDictionary(sendToDatabase, sendWords) {
|
function SaveDictionary() {
|
||||||
localStorage.setItem('dictionary', JSON.stringify(currentDictionary));
|
localStorage.setItem('dictionary', JSON.stringify(currentDictionary));
|
||||||
|
|
||||||
//Always save local copy of current dictionary, but if logged in also send to database.
|
//Always save local copy of current dictionary, but if logged in also send to database.
|
||||||
|
@ -656,6 +553,10 @@ function LoadLocalDictionary() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcessLoad() {
|
function ProcessLoad() {
|
||||||
|
if (!currentDictionary.hasOwnProperty("nextWordId")) {
|
||||||
|
currentDictionary.nextWordId = currentDictionary.words.length + 1;
|
||||||
|
}
|
||||||
|
|
||||||
HideSettingsWhenComplete();
|
HideSettingsWhenComplete();
|
||||||
|
|
||||||
ShowDictionary();
|
ShowDictionary();
|
||||||
|
@ -690,13 +591,8 @@ function ExportDictionary() {
|
||||||
download(downloadName + ".dict", localStorage.getItem('dictionary'));
|
download(downloadName + ".dict", localStorage.getItem('dictionary'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function ConfirmImportDictionary() {
|
|
||||||
if (confirm("Importing this dictionary will overwrite your current one, making it impossible to retrieve if you have not already exported it! Do you still want to import?")) {
|
|
||||||
ImportDictionary();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ImportDictionary() {
|
function ImportDictionary() {
|
||||||
|
if (confirm("Importing this dictionary will overwrite your current one, making it impossible to retrieve if you have not already exported it! Do you still want to import?")) {
|
||||||
if (!window.FileReader) {
|
if (!window.FileReader) {
|
||||||
alert('Your browser is not supported');
|
alert('Your browser is not supported');
|
||||||
return false;
|
return false;
|
||||||
|
@ -710,7 +606,11 @@ 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 - 40) == '"fileIdentifier":"Lexiconga Dictionary"}') {
|
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 = "";
|
||||||
LoadLocalDictionary();
|
LoadLocalDictionary();
|
||||||
|
@ -718,8 +618,19 @@ function ImportDictionary() {
|
||||||
ProcessLoad();
|
ProcessLoad();
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -729,6 +640,7 @@ function ImportDictionary() {
|
||||||
alert("You must add a file to import.");
|
alert("You must add a file to import.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function WordIndex(word) {
|
function WordIndex(word) {
|
||||||
for (var i = 0; i < currentDictionary.words.length; i++)
|
for (var i = 0; i < currentDictionary.words.length; i++)
|
||||||
|
@ -758,7 +670,7 @@ function dynamicSort(property) {
|
||||||
property = property.substr(1);
|
property = property.substr(1);
|
||||||
}
|
}
|
||||||
return function (a, b) {
|
return function (a, b) {
|
||||||
var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;
|
var result = (a[property].toLowerCase() < b[property].toLowerCase()) ? -1 : (a[property].toLowerCase() > b[property].toLowerCase()) ? 1 : 0;
|
||||||
return result * sortOrder;
|
return result * sortOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
function CloseUpdateConflictArea() {
|
||||||
|
document.getElementById("updateConflict").style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function ClearForm() {
|
||||||
|
document.getElementById("word").value = "";
|
||||||
|
document.getElementById("pronunciation").value = "";
|
||||||
|
document.getElementById("partOfSpeech").value = "";
|
||||||
|
document.getElementById("simpleDefinition").value = "";
|
||||||
|
document.getElementById("longDefinition").value = "";
|
||||||
|
document.getElementById("editIndex").value = "";
|
||||||
|
|
||||||
|
document.getElementById("newWordButtonArea").style.display = "block";
|
||||||
|
document.getElementById("editWordButtonArea").style.display = "none";
|
||||||
|
document.getElementById("errorMessage").innerHTML = "";
|
||||||
|
document.getElementById("updateConflict").style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function ToggleDescription() {
|
||||||
|
var descriptionToggle = document.getElementById("descriptionToggle");
|
||||||
|
var descriptionArea = document.getElementById("dictionaryDescription");
|
||||||
|
|
||||||
|
if (descriptionArea.style.display == "none") {
|
||||||
|
descriptionArea.style.display = "block";
|
||||||
|
descriptionToggle.innerHTML = "Hide Description";
|
||||||
|
} else {
|
||||||
|
descriptionArea.style.display = "none";
|
||||||
|
descriptionToggle.innerHTML = "Show Description";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ShowInfo(text) {
|
||||||
|
if (text == "terms") {
|
||||||
|
document.getElementById("infoText").innerHTML = termsText;
|
||||||
|
} else if (text == "privacy") {
|
||||||
|
document.getElementById("infoText").innerHTML = privacyText;
|
||||||
|
} else {
|
||||||
|
document.getElementById("infoText").innerHTML = aboutText;
|
||||||
|
}
|
||||||
|
document.getElementById("infoPage").scrollTop = 0;
|
||||||
|
document.getElementById("infoScreen").style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
function HideInfo() {
|
||||||
|
document.getElementById("infoScreen").style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function ToggleCaseSensitiveOption() {
|
||||||
|
if (document.getElementById("dictionaryAllowDuplicates").checked) {
|
||||||
|
document.getElementById("dictionaryCaseSensitive").disabled = true;
|
||||||
|
} else {
|
||||||
|
document.getElementById("dictionaryCaseSensitive").disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ShowSettings() {
|
||||||
|
document.getElementById("settingsScreen").style.display = "block";
|
||||||
|
document.getElementById("dictionaryNameEdit").value = htmlEntitiesParse(currentDictionary.name);
|
||||||
|
document.getElementById("dictionaryDescriptionEdit").value = htmlEntitiesParse(currentDictionary.description);
|
||||||
|
document.getElementById("dictionaryPartsOfSpeechEdit").value = htmlEntitiesParse(currentDictionary.settings.partsOfSpeech);
|
||||||
|
document.getElementById("dictionaryAllowDuplicates").checked = currentDictionary.settings.allowDuplicates;
|
||||||
|
document.getElementById("dictionaryCaseSensitive").checked = currentDictionary.settings.caseSensitive;
|
||||||
|
document.getElementById("dictionarySortByEquivalent").checked = currentDictionary.settings.sortByEquivalent;
|
||||||
|
document.getElementById("dictionaryIsComplete").checked = currentDictionary.settings.isComplete;
|
||||||
|
document.getElementById("numberOfWordsInDictionary").innerHTML = currentDictionary.words.length.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function HideSettingsWhenComplete() {
|
||||||
|
if (currentDictionary.settings.isComplete) {
|
||||||
|
document.getElementById("hideIfComplete").style.display = "none";
|
||||||
|
} else {
|
||||||
|
document.getElementById("hideIfComplete").style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetPartsOfSpeech () {
|
||||||
|
var partsOfSpeechSelect = document.getElementById("partOfSpeech");
|
||||||
|
var wordFilterSelect = document.getElementById("wordFilter");
|
||||||
|
if (partsOfSpeechSelect.options.length > 0) {
|
||||||
|
for (var i = partsOfSpeechSelect.options.length - 1; i >= 0; i--) {
|
||||||
|
partsOfSpeechSelect.removeChild(partsOfSpeechSelect.options[i]);
|
||||||
|
wordFilterSelect.removeChild(wordFilterSelect.options[i + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newPartsOfSpeech = htmlEntitiesParse(currentDictionary.settings.partsOfSpeech).trim().split(",");
|
||||||
|
for (var j = 0; j < newPartsOfSpeech.length; j++) {
|
||||||
|
var partOfSpeechOption = document.createElement('option');
|
||||||
|
partOfSpeechOption.appendChild(document.createTextNode(newPartsOfSpeech[j].trim()));
|
||||||
|
partOfSpeechOption.value = newPartsOfSpeech[j].trim();
|
||||||
|
partsOfSpeechSelect.appendChild(partOfSpeechOption);
|
||||||
|
|
||||||
|
var wordFilterOption = document.createElement('option');
|
||||||
|
wordFilterOption.appendChild(document.createTextNode(newPartsOfSpeech[j].trim()));
|
||||||
|
wordFilterOption.value = newPartsOfSpeech[j].trim();
|
||||||
|
wordFilterSelect.appendChild(wordFilterOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function HideSettings() {
|
||||||
|
document.getElementById("settingsScreen").style.display = "none";
|
||||||
|
document.getElementById("wordEntryForm").style.display = (currentDictionary.settings.isComplete) ? "none" : "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
function NewWordNotification(word) {
|
||||||
|
var notificationArea = document.getElementById("notificationArea");
|
||||||
|
var notificationMessage = document.getElementById("notificationMessage");
|
||||||
|
var wordId = currentDictionary.nextWordId - 1;
|
||||||
|
notificationArea.style.display = "block";
|
||||||
|
notificationMessage.innerHTML = "New Word Added: <a href='#" + wordId.toString() + "'>" + word + "</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function FocusAfterAddingNewWord() {
|
||||||
|
document.getElementById("word").focus();
|
||||||
|
}
|
Loading…
Reference in New Issue