Added Public View option!
This commit is contained in:
parent
00e522849a
commit
b98f1750d9
|
@ -354,6 +354,11 @@ searchTerm {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#publicLink {
|
||||||
|
font-size:12px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
#dictionaryDescriptionEdit, #dictionaryPartsOfSpeechEdit {
|
#dictionaryDescriptionEdit, #dictionaryPartsOfSpeechEdit {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 360px;
|
max-width: 360px;
|
||||||
|
|
19
index.php
19
index.php
|
@ -164,6 +164,11 @@ require_once(SITE_LOCATION . '/php/notificationconditiontree.php');
|
||||||
<span class="checkboxlabel">Dictionary is Complete</span>
|
<span class="checkboxlabel">Dictionary is Complete</span>
|
||||||
<input type="checkbox" id="dictionaryIsComplete" />
|
<input type="checkbox" id="dictionaryIsComplete" />
|
||||||
</label>
|
</label>
|
||||||
|
<label class="inline">
|
||||||
|
<span class="checkboxlabel">Dictionary is Public</span>
|
||||||
|
<input type="checkbox" id="dictionaryIsPublic" onchange="TogglePublicLink()" />
|
||||||
|
</label> <span class="helperlink clickable" onclick='alert("If you save your settings with this checked, your dictionary will be viewable by anyone if they have the public link.");'>?</span>
|
||||||
|
<div id="publicLink"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="settingsCol">
|
<div class="settingsCol">
|
||||||
<label>
|
<label>
|
||||||
|
@ -266,6 +271,20 @@ require_once(SITE_LOCATION . '/php/notificationconditiontree.php');
|
||||||
<script src="js/dictionaryBuilder.js"></script>
|
<script src="js/dictionaryBuilder.js"></script>
|
||||||
<script src="js/ui.js"></script>
|
<script src="js/ui.js"></script>
|
||||||
<?php if ($_GET['adminoverride'] != "noadsortracking") { include_once("php/google/analytics.php"); } ?>
|
<?php if ($_GET['adminoverride'] != "noadsortracking") { include_once("php/google/analytics.php"); } ?>
|
||||||
|
<script>
|
||||||
|
var aboutText = termsText = privacyText = loginForm = forgotForm = "Loading...";
|
||||||
|
window.onload = function () {
|
||||||
|
LoadDictionary();
|
||||||
|
ClearForm();
|
||||||
|
LoadUserDictionaries();
|
||||||
|
|
||||||
|
GetTextFile("README.md", "aboutText", true);
|
||||||
|
GetTextFile("TERMS.md", "termsText", true);
|
||||||
|
GetTextFile("PRIVACY.md", "privacyText", true);
|
||||||
|
GetTextFile("LOGIN.form", "loginForm", false);
|
||||||
|
GetTextFile("FORGOT.form", "forgotForm", false);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -14,7 +14,8 @@ var currentDictionary = {
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
|
partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
|
||||||
sortByEquivalent: false,
|
sortByEquivalent: false,
|
||||||
isComplete: false
|
isComplete: false,
|
||||||
|
isPublic: false
|
||||||
},
|
},
|
||||||
externalID: 0
|
externalID: 0
|
||||||
}
|
}
|
||||||
|
@ -176,10 +177,6 @@ function DeleteWord(index) {
|
||||||
SaveAndUpdateDictionary(true);
|
SaveAndUpdateDictionary(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateFilter() {
|
|
||||||
ShowDictionary();
|
|
||||||
}
|
|
||||||
|
|
||||||
function ShowDictionary() {
|
function ShowDictionary() {
|
||||||
var filter = document.getElementById("wordFilter").value;
|
var filter = document.getElementById("wordFilter").value;
|
||||||
|
|
||||||
|
@ -245,6 +242,7 @@ function ShowDictionary() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function DictionaryEntry(itemIndex) {
|
function DictionaryEntry(itemIndex) {
|
||||||
|
displayPublic = (typeof displayPublic !== 'undefined' && displayPublic != null) ? displayPublic : false;
|
||||||
var entryText = "<entry><a name='" + currentDictionary.words[itemIndex].wordId + "'></a><a href='#" + currentDictionary.words[itemIndex].wordId + "' class='wordLink clickable'>🔗</a>";
|
var entryText = "<entry><a name='" + currentDictionary.words[itemIndex].wordId + "'></a><a href='#" + currentDictionary.words[itemIndex].wordId + "' class='wordLink clickable'>🔗</a>";
|
||||||
|
|
||||||
var searchTerm = document.getElementById("searchBox").value;
|
var searchTerm = document.getElementById("searchBox").value;
|
||||||
|
@ -344,6 +342,7 @@ function SaveSettings() {
|
||||||
currentDictionary.settings.sortByEquivalent = document.getElementById("dictionarySortByEquivalent").checked;
|
currentDictionary.settings.sortByEquivalent = document.getElementById("dictionarySortByEquivalent").checked;
|
||||||
|
|
||||||
currentDictionary.settings.isComplete = document.getElementById("dictionaryIsComplete").checked;
|
currentDictionary.settings.isComplete = document.getElementById("dictionaryIsComplete").checked;
|
||||||
|
currentDictionary.settings.isPublic = document.getElementById("dictionaryIsPublic").checked;
|
||||||
|
|
||||||
HideSettingsWhenComplete();
|
HideSettingsWhenComplete();
|
||||||
|
|
||||||
|
@ -463,7 +462,7 @@ function DataToSend(doSendWords, sendAll) {
|
||||||
if (currentDictionary.externalID == 0) {
|
if (currentDictionary.externalID == 0) {
|
||||||
data = "name=" + encodeURIComponent(currentDictionary.name) + "&description=" + encodeURIComponent(currentDictionary.description) + "&words=" + encodeURIComponent(JSON.stringify(currentDictionary.words));
|
data = "name=" + encodeURIComponent(currentDictionary.name) + "&description=" + encodeURIComponent(currentDictionary.description) + "&words=" + encodeURIComponent(JSON.stringify(currentDictionary.words));
|
||||||
data += "&nextwordid=" + currentDictionary.nextWordId + "&allowduplicates=" + ((currentDictionary.settings.allowDuplicates) ? "1" : "0") + "&casesensitive=" + ((currentDictionary.settings.caseSensitive) ? "1" : "0");
|
data += "&nextwordid=" + currentDictionary.nextWordId + "&allowduplicates=" + ((currentDictionary.settings.allowDuplicates) ? "1" : "0") + "&casesensitive=" + ((currentDictionary.settings.caseSensitive) ? "1" : "0");
|
||||||
data += "&partsofspeech=" + encodeURIComponent(currentDictionary.settings.partsOfSpeech) + "&sortbyequivalent=" + ((currentDictionary.settings.sortByEquivalent) ? "1" : "0") + "&iscomplete=" + ((currentDictionary.settings.isComplete) ? "1" : "0") + "&ispublic=0";
|
data += "&partsofspeech=" + encodeURIComponent(currentDictionary.settings.partsOfSpeech) + "&sortbyequivalent=" + ((currentDictionary.settings.sortByEquivalent) ? "1" : "0") + "&iscomplete=" + ((currentDictionary.settings.isComplete) ? "1" : "0") + "&ispublic=" + ((currentDictionary.settings.isPublic) ? "1" : "0") + "";
|
||||||
} else {
|
} else {
|
||||||
if (sendAll || currentDictionary.name != previousDictionary.name) {
|
if (sendAll || currentDictionary.name != previousDictionary.name) {
|
||||||
data += "name=" + encodeURIComponent(currentDictionary.name);
|
data += "name=" + encodeURIComponent(currentDictionary.name);
|
||||||
|
@ -492,7 +491,9 @@ function DataToSend(doSendWords, sendAll) {
|
||||||
if (sendAll || currentDictionary.settings.isComplete != previousDictionary.isComplete) {
|
if (sendAll || currentDictionary.settings.isComplete != previousDictionary.isComplete) {
|
||||||
data += ((data=="") ? "" : "&") + "iscomplete=" + ((currentDictionary.settings.isComplete) ? "1" : "0");
|
data += ((data=="") ? "" : "&") + "iscomplete=" + ((currentDictionary.settings.isComplete) ? "1" : "0");
|
||||||
}
|
}
|
||||||
data += ((data=="") ? "" : "&") + "ispublic=0";
|
if (sendAll || currentDictionary.settings.isPublic != previousDictionary.isPublic) {
|
||||||
|
data += ((data=="") ? "" : "&") + "ispublic=" + ((currentDictionary.settings.isPublic) ? "1" : "0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -585,7 +586,8 @@ function SavePreviousDictionary () {
|
||||||
caseSensitive: currentDictionary.settings.caseSensitive,
|
caseSensitive: currentDictionary.settings.caseSensitive,
|
||||||
partsOfSpeech: currentDictionary.settings.partsOfSpeech,
|
partsOfSpeech: currentDictionary.settings.partsOfSpeech,
|
||||||
sortByEquivalent: currentDictionary.settings.sortByEquivalent,
|
sortByEquivalent: currentDictionary.settings.sortByEquivalent,
|
||||||
isComplete: currentDictionary.settings.isComplete
|
isComplete: currentDictionary.settings.isComplete,
|
||||||
|
isPublic: currentDictionary.settings.isPublic
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
function IsValidPublicDicitonary() {
|
||||||
|
return typeof publicDictionary !== 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
function ShowPublicDictionary() {
|
||||||
|
if (IsValidPublicDicitonary()) {
|
||||||
|
var filter = document.getElementById("wordFilter").value;
|
||||||
|
|
||||||
|
var searchResults = [];
|
||||||
|
var search = htmlEntitiesParseForSearchEntry(document.getElementById("searchBox").value);
|
||||||
|
var searchByWord = document.getElementById("searchOptionWord").checked;
|
||||||
|
var searchBySimple = document.getElementById("searchOptionSimple").checked;
|
||||||
|
var searchByLong = document.getElementById("searchOptionLong").checked;
|
||||||
|
var searchIgnoreCase = !document.getElementById("searchCaseSensitive").checked; //It's easier to negate case here instead of negating it every use since ignore case is default.
|
||||||
|
var searchIgnoreDiacritics = document.getElementById("searchIgnoreDiacritics").checked;
|
||||||
|
if (search != "" && (searchByWord || searchBySimple || searchByLong)) {
|
||||||
|
var xpath = [];
|
||||||
|
var searchDictionaryJSON = htmlEntitiesParseForSearch(JSON.stringify(publicDictionary));
|
||||||
|
if (searchIgnoreCase) {
|
||||||
|
search = search.toLowerCase();
|
||||||
|
//searchDictionaryJSON = searchDictionaryJSON.toLowerCase();
|
||||||
|
}
|
||||||
|
if (searchIgnoreDiacritics) {
|
||||||
|
search = removeDiacritics(search);
|
||||||
|
searchDictionaryJSON = removeDiacritics(searchDictionaryJSON);
|
||||||
|
}
|
||||||
|
if (searchByWord) {
|
||||||
|
xpath.push('contains('+ ((searchIgnoreCase) ? 'name' : 'translate(name, "", "")') +', "'+ search +'")');
|
||||||
|
}
|
||||||
|
if (searchBySimple) {
|
||||||
|
xpath.push('contains('+ ((searchIgnoreCase) ? 'simpleDefinition' : 'translate(simpleDefinition, "", "")') +', "'+ search +'")');
|
||||||
|
}
|
||||||
|
if (searchByLong) {
|
||||||
|
xpath.push('contains('+ ((searchIgnoreCase) ? 'longDefinition' : 'translate(longDefinition, "", "")') +', "'+ search +'")');
|
||||||
|
}
|
||||||
|
var searchDictionary = JSON.parse(searchDictionaryJSON);
|
||||||
|
searchResults = JSON.search(searchDictionary, '//words['+ xpath.join(' or ') +']/wordId');
|
||||||
|
}
|
||||||
|
|
||||||
|
var dictionaryNameArea = document.getElementById("dictionaryName");
|
||||||
|
dictionaryNameArea.innerHTML = htmlEntitiesParse(publicDictionary.name) + " Dictionary";
|
||||||
|
|
||||||
|
var dictionaryByArea = document.getElementById("dictionaryBy");
|
||||||
|
dictionaryByArea.innerHTML = "created by " + htmlEntitiesParse(publicDictionary.createdBy);
|
||||||
|
|
||||||
|
var dictionaryDescriptionArea = document.getElementById("dictionaryDescription");
|
||||||
|
dictionaryDescriptionArea.innerHTML = marked(htmlEntitiesParse(publicDictionary.description));
|
||||||
|
|
||||||
|
var dictionaryArea = document.getElementById("theDictionary");
|
||||||
|
var dictionaryText = "";
|
||||||
|
|
||||||
|
if (publicDictionary.words.length > 0) {
|
||||||
|
for (var i = 0; i < publicDictionary.words.length; i++) {
|
||||||
|
if (filter == "" || (filter != "" && publicDictionary.words[i].partOfSpeech == filter)) {
|
||||||
|
if (search == "" || (search != "" && (searchByWord || searchBySimple || searchByLong) && searchResults.indexOf(publicDictionary.words[i].wordId) >= 0)) {
|
||||||
|
if (!publicDictionary.words[i].hasOwnProperty("pronunciation")) {
|
||||||
|
publicDictionary.words[i].pronunciation = ""; //Account for new property
|
||||||
|
}
|
||||||
|
if (!publicDictionary.words[i].hasOwnProperty("wordId")) {
|
||||||
|
publicDictionary.words[i].wordId = i + 1; //Account for new property
|
||||||
|
}
|
||||||
|
dictionaryText += PublicDictionaryEntry(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dictionaryText = "There are no entries in the dictionary."
|
||||||
|
}
|
||||||
|
dictionaryArea.innerHTML = dictionaryText;
|
||||||
|
} else {
|
||||||
|
document.getElementById("dictionaryContainer").innerHTML = publicDictionary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function PublicDictionaryEntry(itemIndex) {
|
||||||
|
var entryText = "<entry><a name='" + publicDictionary.words[itemIndex].wordId + "'></a><a href='#" + publicDictionary.words[itemIndex].wordId + "' class='wordLink clickable'>🔗</a>";
|
||||||
|
|
||||||
|
var searchTerm = document.getElementById("searchBox").value;
|
||||||
|
var searchByWord = document.getElementById("searchOptionWord").checked;
|
||||||
|
var searchBySimple = document.getElementById("searchOptionSimple").checked;
|
||||||
|
var searchByLong = document.getElementById("searchOptionLong").checked;
|
||||||
|
var searchIgnoreCase = !document.getElementById("searchCaseSensitive").checked; //It's easier to negate case here instead of negating it every use since ignore case is default.
|
||||||
|
var searchIgnoreDiacritics = document.getElementById("searchIgnoreDiacritics").checked;
|
||||||
|
|
||||||
|
var searchRegEx = new RegExp("(" + ((searchIgnoreDiacritics) ? removeDiacritics(searchTerm) + "|" + searchTerm : searchTerm) + ")", "g" + ((searchIgnoreCase) ? "i" : ""));
|
||||||
|
|
||||||
|
entryText += "<word>";
|
||||||
|
|
||||||
|
if (searchTerm != "" && searchByWord) {
|
||||||
|
entryText += htmlEntitiesParse(publicDictionary.words[itemIndex].name).replace(searchRegEx, "<searchTerm>$1</searchterm>");
|
||||||
|
} else {
|
||||||
|
entryText += publicDictionary.words[itemIndex].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
entryText += "</word>";
|
||||||
|
|
||||||
|
if (publicDictionary.words[itemIndex].pronunciation != "") {
|
||||||
|
entryText += "<pronunciation>";
|
||||||
|
entryText += marked(htmlEntitiesParse(publicDictionary.words[itemIndex].pronunciation)).replace("<p>","").replace("</p>","");
|
||||||
|
entryText += "</pronunciation>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publicDictionary.words[itemIndex].partOfSpeech != "") {
|
||||||
|
entryText += "<partofspeech>";
|
||||||
|
entryText += publicDictionary.words[itemIndex].partOfSpeech;
|
||||||
|
entryText += "</partofspeech>";
|
||||||
|
}
|
||||||
|
|
||||||
|
entryText += "<br>";
|
||||||
|
|
||||||
|
if (publicDictionary.words[itemIndex].simpleDefinition != "") {
|
||||||
|
entryText += "<simpledefinition>";
|
||||||
|
|
||||||
|
if (searchTerm != "" && searchBySimple) {
|
||||||
|
entryText += htmlEntitiesParse(publicDictionary.words[itemIndex].simpleDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>");
|
||||||
|
} else {
|
||||||
|
entryText += publicDictionary.words[itemIndex].simpleDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
entryText += "</simpledefinition>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publicDictionary.words[itemIndex].longDefinition != "") {
|
||||||
|
entryText += "<longdefinition>";
|
||||||
|
|
||||||
|
if (searchTerm != "" && searchByLong) {
|
||||||
|
entryText += marked(htmlEntitiesParse(publicDictionary.words[itemIndex].longDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>"));
|
||||||
|
} else {
|
||||||
|
entryText += marked(htmlEntitiesParse(publicDictionary.words[itemIndex].longDefinition));
|
||||||
|
}
|
||||||
|
|
||||||
|
entryText += "</longdefinition>";
|
||||||
|
}
|
||||||
|
|
||||||
|
entryText += "</entry>";
|
||||||
|
|
||||||
|
return entryText;
|
||||||
|
}
|
59
js/ui.js
59
js/ui.js
|
@ -1,17 +1,3 @@
|
||||||
var aboutText = termsText = privacyText = loginForm = forgotForm = "Loading...";
|
|
||||||
|
|
||||||
window.onload = function () {
|
|
||||||
LoadDictionary();
|
|
||||||
ClearForm();
|
|
||||||
LoadUserDictionaries();
|
|
||||||
|
|
||||||
GetTextFile("README.md", "aboutText", true);
|
|
||||||
GetTextFile("TERMS.md", "termsText", true);
|
|
||||||
GetTextFile("PRIVACY.md", "privacyText", true);
|
|
||||||
GetTextFile("LOGIN.form", "loginForm", false);
|
|
||||||
GetTextFile("FORGOT.form", "forgotForm", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function LoadUserDictionaries() {
|
function LoadUserDictionaries() {
|
||||||
var getDictionariesRequest = new XMLHttpRequest();
|
var getDictionariesRequest = new XMLHttpRequest();
|
||||||
var userDictionariesSelect = document.getElementById("userDictionaries");
|
var userDictionariesSelect = document.getElementById("userDictionaries");
|
||||||
|
@ -241,18 +227,20 @@ function EnableForm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ClearForm() {
|
function ClearForm() {
|
||||||
document.getElementById("word").value = "";
|
if (document.getElementById("wordEntryForm")) {
|
||||||
document.getElementById("pronunciation").value = "";
|
document.getElementById("word").value = "";
|
||||||
document.getElementById("partOfSpeech").value = "";
|
document.getElementById("pronunciation").value = "";
|
||||||
document.getElementById("simpleDefinition").value = "";
|
document.getElementById("partOfSpeech").value = "";
|
||||||
document.getElementById("longDefinition").value = "";
|
document.getElementById("simpleDefinition").value = "";
|
||||||
document.getElementById("editIndex").value = "";
|
document.getElementById("longDefinition").value = "";
|
||||||
|
document.getElementById("editIndex").value = "";
|
||||||
document.getElementById("newWordButtonArea").style.display = "block";
|
|
||||||
document.getElementById("editWordButtonArea").style.display = "none";
|
document.getElementById("newWordButtonArea").style.display = "block";
|
||||||
document.getElementById("errorMessage").innerHTML = "";
|
document.getElementById("editWordButtonArea").style.display = "none";
|
||||||
document.getElementById("updateConflict").style.display = "none";
|
document.getElementById("errorMessage").innerHTML = "";
|
||||||
EnableForm();
|
document.getElementById("updateConflict").style.display = "none";
|
||||||
|
EnableForm();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ToggleDescription() {
|
function ToggleDescription() {
|
||||||
|
@ -332,14 +320,27 @@ function ShowSettings() {
|
||||||
document.getElementById("dictionaryCaseSensitive").checked = currentDictionary.settings.caseSensitive;
|
document.getElementById("dictionaryCaseSensitive").checked = currentDictionary.settings.caseSensitive;
|
||||||
document.getElementById("dictionarySortByEquivalent").checked = currentDictionary.settings.sortByEquivalent;
|
document.getElementById("dictionarySortByEquivalent").checked = currentDictionary.settings.sortByEquivalent;
|
||||||
document.getElementById("dictionaryIsComplete").checked = currentDictionary.settings.isComplete;
|
document.getElementById("dictionaryIsComplete").checked = currentDictionary.settings.isComplete;
|
||||||
|
document.getElementById("dictionaryIsPublic").checked = currentDictionary.settings.isPublic;
|
||||||
|
TogglePublicLink();
|
||||||
document.getElementById("numberOfWordsInDictionary").innerHTML = currentDictionary.words.length.toString();
|
document.getElementById("numberOfWordsInDictionary").innerHTML = currentDictionary.words.length.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function HideSettingsWhenComplete() {
|
function HideSettingsWhenComplete() {
|
||||||
if (currentDictionary.settings.isComplete) {
|
if (document.getElementById("settingsScreen")) {
|
||||||
document.getElementById("hideIfComplete").style.display = "none";
|
if (currentDictionary.settings.isComplete) {
|
||||||
|
document.getElementById("hideIfComplete").style.display = "none";
|
||||||
|
} else {
|
||||||
|
document.getElementById("hideIfComplete").style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function TogglePublicLink() {
|
||||||
|
if (document.getElementById("dictionaryIsPublic").checked) {
|
||||||
|
var publicLink = "http://lexicon.ga/view/?dict=" + currentDictionary.externalID;
|
||||||
|
document.getElementById("publicLink").innerHTML = "<strong>Public Link:</strong><br>" + publicLink;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("hideIfComplete").style.display = "block";
|
document.getElementById("publicLink").innerHTML = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ function Get_Dictionaries($return_list = true) {
|
||||||
|
|
||||||
function Load_Current_Dictionary() {
|
function Load_Current_Dictionary() {
|
||||||
if ($_SESSION['user'] > 0) {
|
if ($_SESSION['user'] > 0) {
|
||||||
$query = "SELECT `d`.`id`, `d`.`name`, `d`.`description`, `u`.`public_name`, `d`.`words`, `d`.`next_word_id`, `d`.`allow_duplicates`, `d`.`case_sensitive`, `d`.`parts_of_speech`, `d`.`sort_by_equivalent`, `d`.`is_complete` ";
|
$query = "SELECT `d`.`id`, `d`.`name`, `d`.`description`, `u`.`public_name`, `d`.`words`, `d`.`next_word_id`, `d`.`allow_duplicates`, `d`.`case_sensitive`, `d`.`parts_of_speech`, `d`.`sort_by_equivalent`, `d`.`is_complete`, `d`.`is_public` ";
|
||||||
$query .= "FROM `dictionaries` AS `d` LEFT JOIN `users` AS `u` ON `user`=`u`.`id` WHERE `is_current`=1 AND `user`=" . $_SESSION['user'] . ";";
|
$query .= "FROM `dictionaries` AS `d` LEFT JOIN `users` AS `u` ON `user`=`u`.`id` WHERE `is_current`=1 AND `user`=" . $_SESSION['user'] . ";";
|
||||||
$dictionary = query($query);
|
$dictionary = query($query);
|
||||||
|
|
||||||
|
@ -75,7 +75,8 @@ function Load_Current_Dictionary() {
|
||||||
$json .= '"caseSensitive":' . (($dict['case_sensitive'] == 1) ? 'true' : 'false') . ',';
|
$json .= '"caseSensitive":' . (($dict['case_sensitive'] == 1) ? 'true' : 'false') . ',';
|
||||||
$json .= '"partsOfSpeech":"' . $dict['parts_of_speech'] . '",';
|
$json .= '"partsOfSpeech":"' . $dict['parts_of_speech'] . '",';
|
||||||
$json .= '"sortByEquivalent":' . (($dict['sort_by_equivalent'] == 1) ? 'true' : 'false') . ',';
|
$json .= '"sortByEquivalent":' . (($dict['sort_by_equivalent'] == 1) ? 'true' : 'false') . ',';
|
||||||
$json .= '"isComplete":' . (($dict['is_complete'] == 1) ? 'true' : 'false') . '},';
|
$json .= '"isComplete":' . (($dict['is_complete'] == 1) ? 'true' : 'false') . ',';
|
||||||
|
$json .= '"isPublic":' . (($dict['is_public'] == 1) ? 'true' : 'false') . '},';
|
||||||
$json .= '"externalID":' . $dict['id'] . '}';
|
$json .= '"externalID":' . $dict['id'] . '}';
|
||||||
echo $json;
|
echo $json;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
<?php
|
||||||
|
//require_once('../required.php');
|
||||||
|
require_once('../php/config.php');
|
||||||
|
require_once(SITE_LOCATION . '/php/functions.php');
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
$current_user = isset($_SESSION['user']) ? $_SESSION['user'] : 0;
|
||||||
|
|
||||||
|
$dictionary_to_load = (isset($_GET['dict'])) ? intval($_GET['dict']) : 0;
|
||||||
|
$the_public_dictionary = '"That dictionary doesn\'t exist."';
|
||||||
|
|
||||||
|
$announcement = get_include_contents(SITE_LOCATION . '/announcement.php');
|
||||||
|
$notificationMessage = "";
|
||||||
|
|
||||||
|
if ($current_user > 0 || !isset($_SESSION['loginfailures']) || (isset($_SESSION['loginlockouttime']) && time() - $_SESSION['loginlockouttime'] >= 3600)) {
|
||||||
|
// If logged in, never failed, or more than 1 hour has passed, reset login failures.
|
||||||
|
$_SESSION['loginfailures'] = 0;
|
||||||
|
} else {
|
||||||
|
$alertlockoutmessage = "You failed logging in 10 times. To prevent request flooding and hacking attempts, you may not log in or create an account for 1 hour.\\n\\nThe last time this page was loaded, you had been locked out for " . time_elapsed(time() - $_SESSION['loginlockouttime']) . "\\n\\nRefresh the page once the hour has passed.";
|
||||||
|
$hoverlockoutmessage = str_replace("\\n", "\n", $alertlockoutmessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "SELECT `d`.`id`, `d`.`name`, `d`.`description`, `u`.`public_name`, `d`.`words`, `d`.`parts_of_speech`, `d`.`is_complete` ";
|
||||||
|
$query .= "FROM `dictionaries` AS `d` LEFT JOIN `users` AS `u` ON `d`.`user`=`u`.`id` WHERE `d`.`is_public`=1 AND `d`.`id`=" . $dictionary_to_load . ";";
|
||||||
|
|
||||||
|
$dbconnection = new PDO('mysql:host=' . DATABASE_SERVERNAME . ';dbname=' . DATABASE_NAME . ';charset=utf8', DATABASE_USERNAME, DATABASE_PASSWORD);
|
||||||
|
$dbconnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$dbconnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
||||||
|
$dbconnection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||||
|
try {
|
||||||
|
$queryResults = $dbconnection->prepare($query);
|
||||||
|
$queryResults->execute();
|
||||||
|
if ($queryResults) {
|
||||||
|
if (num_rows($queryResults) === 1) {
|
||||||
|
while ($dict = fetch($queryResults)) {
|
||||||
|
$the_public_dictionary = '{"name":"' . $dict['name'] . '",';
|
||||||
|
$the_public_dictionary .= '"description":"' . $dict['description'] . '",';
|
||||||
|
$the_public_dictionary .= '"createdBy":"' . $dict['public_name'] . '",';
|
||||||
|
$the_public_dictionary .= '"words":' . $dict['words'] . ',';
|
||||||
|
$the_public_dictionary .= '"settings":{';
|
||||||
|
$the_public_dictionary .= '"partsOfSpeech":"' . $dict['parts_of_speech'] . '",';
|
||||||
|
$the_public_dictionary .= '"isComplete":' . (($dict['is_complete'] == 1) ? 'true' : 'false') . '},';
|
||||||
|
$the_public_dictionary .= '}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (PDOException $ex) {
|
||||||
|
print_r($dbconnection->errorInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<title>Lexiconga Dictionary Builder</title>
|
||||||
|
|
||||||
|
<link href="../css/styles.css" rel="stylesheet" />
|
||||||
|
<link href="../css/lexiconga.css" rel="stylesheet" />
|
||||||
|
<script>var publicDictionary = <?php echo $the_public_dictionary; ?></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div id="headerPadder">
|
||||||
|
<a href="./" id="siteLogo">Lexiconga Dictionary Builder</a>
|
||||||
|
<div style="float:right;margin: 16px 8px;font-size:12px;">
|
||||||
|
<span id="aboutButton" class="clickable" onclick="ShowInfo('aboutText')">About Lexiconga</span>
|
||||||
|
</div>
|
||||||
|
<div id="loginoutArea" style="font-size:12px;">
|
||||||
|
<?php if ($current_user > 0) { //If logged in, show the log out button. ?>
|
||||||
|
<a href="../" class="clickable">Back to My Account</span> <a href="?logout" id="logoutLink" class="clickable">Log Out</a>
|
||||||
|
<?php } elseif (!isset($_SESSION['loginfailures']) || (isset($_SESSION['loginfailures']) && $_SESSION['loginfailures'] < 10)) { ?>
|
||||||
|
<span id="loginLink" class="clickable" onclick="ShowInfo('loginForm')">Log In/Create Account</span>
|
||||||
|
<?php } else { ?>
|
||||||
|
<span id="loginLink" class="clickable" title="<?php echo $hoverlockoutmessage; ?>" onclick="alert('<?php echo $alertlockoutmessage; ?>');">Can't Login</span>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<contents>
|
||||||
|
<div id="announcementArea" style="display:<?php echo (($announcement) ? "block" : "none"); ?>;margin-bottom:10px;">
|
||||||
|
<span id="announcementCloseButton" class="clickable" onclick="document.getElementById('announcementArea').style.display='none';">Close</span>
|
||||||
|
<div id="announcement"><?php echo $announcement; ?></div>
|
||||||
|
</div>
|
||||||
|
<div id="notificationArea" style="display:<?php echo (($notificationMessage) ? "block" : "none"); ?>;">
|
||||||
|
<span id="notificationCloseButton" class="clickable" onclick="document.getElementById('notificationArea').style.display='none';">Close</span>
|
||||||
|
<div id="notificationMessage"><?php echo $notificationMessage; ?></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="dictionaryContainer">
|
||||||
|
<h1 id="dictionaryName"></h1>
|
||||||
|
<h4 id="dictionaryBy"></h4>
|
||||||
|
|
||||||
|
<span id="descriptionToggle" class="clickable" onclick="ToggleDescription();">Show Description</span>
|
||||||
|
<div id="dictionaryDescription" style="display:none;"></div>
|
||||||
|
|
||||||
|
<span id="searchFilterToggle" class="clickable" onclick="ToggleSearchFilter();">Search/Filter Options</span>
|
||||||
|
<div id="searchFilterArea" style="display:none;">
|
||||||
|
<div id="searchArea" style="display:block;">
|
||||||
|
<label style="margin-top:10px;">
|
||||||
|
<span>Search</span>
|
||||||
|
<div style="display:block;">
|
||||||
|
<input type="text" id="searchBox" onclick="this.select();" onchange="ShowPublicDictionary()" style="display:inline;" />
|
||||||
|
<span style="display:inline;cursor:pointer;font-size:10px;font-weight:bold;" onclick="document.getElementById('searchBox').value='';ShowPublicDictionary();">Clear Search</span>
|
||||||
|
</div>
|
||||||
|
<div id="searchOptions" style="font-size:12px;">
|
||||||
|
<label style="display:inline;margin:0;">Word <input type="checkbox" id="searchOptionWord" checked="checked" onchange="ShowPublicDictionary()" /></label>
|
||||||
|
<label style="display:inline;margin:0;">Equivalent <input type="checkbox" id="searchOptionSimple" checked="checked" onchange="ShowPublicDictionary()" /></label>
|
||||||
|
<label style="display:inline;margin:0;">Explanation <input type="checkbox" id="searchOptionLong" checked="checked" onchange="ShowPublicDictionary()" /></label>
|
||||||
|
<br />
|
||||||
|
<label style="display:inline;margin:0;">Search Case-Sensitive <input type="checkbox" id="searchCaseSensitive" onchange="ShowPublicDictionary()" /></label>
|
||||||
|
<label style="display:inline;margin:0;" title="Note: Matching diacritics will appear but may not highlight.">Ignore Diacritics/Accents <input type="checkbox" id="searchIgnoreDiacritics" onchange="ShowPublicDictionary()" /></label>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label style="display:block;"><b>Filter Words </b><select id="wordFilter" onchange="ShowPublicDictionary()">
|
||||||
|
<option value="">All</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="theDictionary"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="rightColumn" class="googleads" style="float:right;width:20%;max-width:300px;min-width:200px;overflow:hidden;">
|
||||||
|
<?php if ($_GET['adminoverride'] != "noadsortracking") { include_once("../php/google/adsense.php"); } ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="infoScreen" style="display:none;">
|
||||||
|
<div id="infoBackgroundFade" onclick="HideInfo()"></div>
|
||||||
|
<div id="infoPage">
|
||||||
|
<span id="infoScreenCloseButton" class="clickable" onclick="HideInfo()">Close</span>
|
||||||
|
<div id="infoText"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</contents>
|
||||||
|
<footer>
|
||||||
|
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('termsText')" style="font-size:12px;">Terms</span> <span class="clickable" onclick="ShowInfo('privacyText')" style="font-size:12px;">Privacy</span>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Markdown Parser -->
|
||||||
|
<script src="../js/marked.js"></script>
|
||||||
|
<!-- JSON Search -->
|
||||||
|
<script src="../js/defiant-js/defiant-latest.js"></script>
|
||||||
|
<!-- Diacritics Removal for Exports -->
|
||||||
|
<script src="../js/removeDiacritics.js"></script>
|
||||||
|
<!-- Main Script -->
|
||||||
|
<script src="../js/dictionaryBuilder.js"></script>
|
||||||
|
<script src="../js/ui.js"></script>
|
||||||
|
<script src="../js/publicView.js"></script>
|
||||||
|
<?php if ($_GET['adminoverride'] != "noadsortracking") { include_once("../php/google/analytics.php"); } ?>
|
||||||
|
<script>
|
||||||
|
var aboutText = termsText = privacyText = loginForm = forgotForm = "Loading...";
|
||||||
|
window.onload = function () {
|
||||||
|
ShowPublicDictionary();
|
||||||
|
|
||||||
|
GetTextFile("../README.md", "aboutText", true);
|
||||||
|
GetTextFile("../TERMS.md", "termsText", true);
|
||||||
|
GetTextFile("../PRIVACY.md", "privacyText", true);
|
||||||
|
GetTextFile("../LOGIN.form", "loginForm", false);
|
||||||
|
GetTextFile("../FORGOT.form", "forgotForm", false);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function get_include_contents($filename) {
|
||||||
|
if (is_file($filename)) {
|
||||||
|
ob_start();
|
||||||
|
include $filename;
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue