Compare commits

..

7 Commits

Author SHA1 Message Date
Robbie Antenesse d5ccd2e756 Change dictionary even if current_dictionary is selected 2019-07-03 16:35:44 -06:00
Robbie Antenesse 3ebc567c33 Add loading message when changing dictionaries 2019-07-03 16:04:11 -06:00
Robbie Antenesse 72a7429bfa Update public link when changing dictionaries 2019-07-03 15:34:31 -06:00
Robbie Antenesse da2c2639b1 Add some tweaks to help with upgrades 2019-07-02 12:21:26 -06:00
Robbie Antenesse 8a5aa23a50 Update styling for buttons and mobile 2019-07-02 12:02:51 -06:00
Robbie Antenesse c607c0cf16 Wait until externalID has been fetched to render "Make Public" 2019-07-02 10:07:08 -06:00
Robbie Antenesse bfb404575b Fix manifest.webmanifest start_url error 2019-07-02 09:38:55 -06:00
14 changed files with 123 additions and 63 deletions

View File

@ -33,7 +33,7 @@
"type": "image/png" "type": "image/png"
} }
], ],
"start_url": "/lexiconga/", "start_url": "/",
"display": "standalone", "display": "standalone",
"orientation": "portrait", "orientation": "portrait",
"background_color": "#e6cfaa", "background_color": "#e6cfaa",

View File

@ -11,7 +11,7 @@
"watch-js": "parcel watch template-index.html offline.html template-view.html template-passwordreset.html --no-hmr --public-url /lexiconga/", "watch-js": "parcel watch template-index.html offline.html template-view.html template-passwordreset.html --no-hmr --public-url /lexiconga/",
"watch-php": "cpx \"src/php/**/{*,.*}\" dist -v -w", "watch-php": "cpx \"src/php/**/{*,.*}\" dist -v -w",
"bundle": "npm run process-images && npm run bundle-js && npm run copy-files && npm run copy-php", "bundle": "npm run process-images && npm run bundle-js && npm run copy-files && npm run copy-php",
"bundle-js": "parcel build template-index.html offline.html template-view.html template-passwordreset.html", "bundle-js": "parcel build template-index.html offline.html template-view.html template-passwordreset.html --no-source-maps",
"copy-files": "cpx \"node_modules/upup/dist/*.min.js\" dist -v", "copy-files": "cpx \"node_modules/upup/dist/*.min.js\" dist -v",
"copy-php": "cpx \"src/php/**/{*,.*}\" dist", "copy-php": "cpx \"src/php/**/{*,.*}\" dist",
"process-images": "node dev/resize-images.js", "process-images": "node dev/resize-images.js",

View File

@ -18,6 +18,7 @@ export function createNewDictionary() {
export function changeDictionary(dictionary) { export function changeDictionary(dictionary) {
dictionary = typeof dictionary.target !== 'undefined' ? dictionary.target.value : dictionary; dictionary = typeof dictionary.target !== 'undefined' ? dictionary.target.value : dictionary;
if (dictionary !== window.currentDictionary.externalID) { if (dictionary !== window.currentDictionary.externalID) {
addMessage('Loading Dictionary...');
request({ request({
action: 'change-dictionary', action: 'change-dictionary',
dictionary, dictionary,

View File

@ -1,4 +1,5 @@
import { setupLoginModal, setupChangeDictionary, setupCreateNewDictionary, setupDeletedDictionaryChangeModal, setupMakePublic } from "./setupListeners"; import { setupLoginModal, setupChangeDictionary, setupCreateNewDictionary, setupDeletedDictionaryChangeModal, setupMakePublic } from "./setupListeners";
import { getPublicLink } from "./utilities";
import { request } from "./helpers"; import { request } from "./helpers";
export function renderLoginForm() { export function renderLoginForm() {
@ -56,20 +57,24 @@ export function renderLoginForm() {
export function renderMakePublic() { export function renderMakePublic() {
const editSettingsTab = document.getElementById('editSettingsTab'); const editSettingsTab = document.getElementById('editSettingsTab');
const { isPublic } = window.currentDictionary.settings; const { isPublic } = window.currentDictionary.settings;
const { externalID } = window.currentDictionary; let waitForSync = setInterval(() => {
if (window.currentDictionary.hasOwnProperty('externalID') && !isNaN(window.currentDictionary.externalID)) {
clearInterval(waitForSync);
const editSettingsTabHTML = `<label>Make Public const editSettingsTabHTML = `<label>Make Public
<input type="checkbox" id="editIsPublic"${isPublic ? ' checked' : ''}><br> <input type="checkbox" id="editIsPublic"${isPublic ? ' checked' : ''}><br>
<small>Checking this box will make this public via a link you can share with others.</small> <small>Checking this box will make this public via a link you can share with others.</small>
</label> </label>
<p id="publicLinkDisplay" style="${!isPublic ? 'display:none;': ''}margin-left:20px;"> <p id="publicLinkDisplay" style="${!isPublic ? 'display:none;': ''}margin-left:20px;">
<strong>Public Link:</strong><br> <strong>Public Link:</strong><br>
<input readonly id="publicLink" value="${document.domain + window.location.pathname + (externalID ? externalID.toString() : '')}"> <input readonly id="publicLink" value="${getPublicLink()}">
<a class="small button" id="publicLinkCopy">Copy</a> <a class="small button" id="publicLinkCopy">Copy</a>
</p> </p>
`; `;
editSettingsTab.innerHTML += editSettingsTabHTML; editSettingsTab.innerHTML += editSettingsTabHTML;
setupMakePublic(); setupMakePublic();
}
}, 100);
} }
export function renderAccountSettings() { export function renderAccountSettings() {

View File

@ -1,7 +1,7 @@
import { addMessage } from "../utilities"; import { addMessage } from "../utilities";
import { saveDictionary, clearDictionary } from "../dictionaryManagement"; import { saveDictionary, clearDictionary } from "../dictionaryManagement";
import { request } from "./helpers"; import { request } from "./helpers";
import { saveToken, dictionaryIsDefault } from "./utilities"; import { saveToken, dictionaryIsDefault, getPublicLink } from "./utilities";
import { renderAll } from "../render"; import { renderAll } from "../render";
import { sortWords } from "../wordManagement"; import { sortWords } from "../wordManagement";
import { getLocalDeletedWords, clearLocalDeletedWords, saveDeletedWordsLocally } from "./utilities"; import { getLocalDeletedWords, clearLocalDeletedWords, saveDeletedWordsLocally } from "./utilities";
@ -37,8 +37,14 @@ export function performSync(remoteDictionary) {
syncWords(remoteDictionary.words, remoteDictionary.deletedWords).then(success => { syncWords(remoteDictionary.words, remoteDictionary.deletedWords).then(success => {
if (success) { if (success) {
renderAll(); renderAll();
document.getElementById('accountSettingsChangeDictionary').value = window.currentDictionary.externalID; document.getElementById('accountSettingsChangeDictionary').value = window.currentDictionary.externalID;
if (document.getElementById('publicLink')) {
document.getElementById('publicLink').value = getPublicLink();
}
if (document.getElementById('publicLinkDisplay')) {
document.getElementById('publicLinkDisplay').style.display = window.currentDictionary.settings.isPublic ? '' : 'none'; document.getElementById('publicLinkDisplay').style.display = window.currentDictionary.settings.isPublic ? '' : 'none';
}
} else { } else {
console.error('word sync failed'); console.error('word sync failed');
} }

View File

@ -21,6 +21,22 @@ export function dictionaryIsDefault() {
return JSON.stringify(defaultDictionary) === JSON.stringify(currentDictionary); return JSON.stringify(defaultDictionary) === JSON.stringify(currentDictionary);
} }
export function getPublicLink() {
const { externalID } = window.currentDictionary;
let path;
if (externalID) {
path = window.location.pathname.match(new RegExp(externalID + '$'))
? window.location.pathname
: (window.location.pathname.indexOf(externalID) > -1
? window.location.pathname.substring(0, window.location.pathname.indexOf(externalID)) + externalID
: window.location.pathname + externalID
);
} else {
path = '';
}
return 'https://' + document.domain + path;
}
export function saveDeletedWordsLocally(wordIds) { export function saveDeletedWordsLocally(wordIds) {
let storedDeletedWords = getLocalDeletedWords(); let storedDeletedWords = getLocalDeletedWords();
wordIds.forEach(wordId => { wordIds.forEach(wordId => {

View File

@ -18,6 +18,7 @@ import { getPaginationData } from './pagination';
import { getOpenEditForms, parseReferences } from './wordManagement'; import { getOpenEditForms, parseReferences } from './wordManagement';
import { renderAd } from './ads'; import { renderAd } from './ads';
import ipaTableFile from './KeyboardFire/phondue/ipa-table.html'; import ipaTableFile from './KeyboardFire/phondue/ipa-table.html';
import { getPublicLink } from './account/utilities';
export function renderAll() { export function renderAll() {
renderTheme(); renderTheme();
@ -54,12 +55,13 @@ export function renderName() {
shareLink.id = 'dictionaryShare'; shareLink.id = 'dictionaryShare';
shareLink.classList.add('button'); shareLink.classList.add('button');
shareLink.style.float = 'right'; shareLink.style.float = 'right';
shareLink.href = window.location.pathname.match(new RegExp(window.currentDictionary.externalID + '$')) ? window.location.pathname shareLink.href = getPublicLink();
: window.location.pathname.substring(0, window.location.pathname.indexOf(window.currentDictionary.externalID)) + window.currentDictionary.externalID;
shareLink.target = '_blank'; shareLink.target = '_blank';
shareLink.title = 'Public Link to Dictionary'; shareLink.title = 'Public Link to Dictionary';
shareLink.innerHTML = '&#10150;'; shareLink.innerHTML = '&#10150;';
name.parentElement.insertBefore(shareLink, name); name.parentElement.insertBefore(shareLink, name);
} else if (isPublic && shareLinkElement) {
shareLinkElement.href = getPublicLink();
} else if (!isPublic && shareLinkElement) { } else if (!isPublic && shareLinkElement) {
shareLinkElement.parentElement.removeChild(shareLinkElement); shareLinkElement.parentElement.removeChild(shareLinkElement);
} }
@ -193,8 +195,7 @@ export function renderWords() {
wordId: originalWord.wordId, wordId: originalWord.wordId,
}); });
const homonymnNumber = getHomonymnNumber(originalWord); const homonymnNumber = getHomonymnNumber(originalWord);
const shareLink = window.currentDictionary.hasOwnProperty('externalID') const shareLink = window.currentDictionary.hasOwnProperty('externalID') ? getPublicLink() + '/' + word.wordId : '';
? window.location.pathname + window.currentDictionary.externalID + '/' + word.wordId : '';
wordsHTML += renderAd(displayIndex); wordsHTML += renderAd(displayIndex);

View File

@ -19,20 +19,3 @@
@import 'scss/themes/red'; @import 'scss/themes/red';
@import 'scss/themes/mint'; @import 'scss/themes/mint';
@import 'scss/themes/grape'; @import 'scss/themes/grape';
html, body {
margin: 0;
font-family: $font;
transition: all 0.2s ease-in;
* {
transition: all 0.2s ease-in;
box-sizing: border-box;
}
}
input:not([type="checkbox"]),
select,
textarea {
font-size: 16px;
}

View File

@ -59,7 +59,7 @@ VALUES ($new_id, ?, ?, ?, ?)";
public function changeCurrent ($user, $dictionary) { public function changeCurrent ($user, $dictionary) {
$update_query = 'UPDATE users SET current_dictionary=? WHERE id=?'; $update_query = 'UPDATE users SET current_dictionary=? WHERE id=?';
$update = $this->db->query($update_query, array($dictionary, $user)); $update = $this->db->query($update_query, array($dictionary, $user));
if ($update->rowCount() > 0) { if (trim($this->db->last_error_info[2]) == '') {
return $dictionary; return $dictionary;
} }
return false; return false;

View File

@ -1,5 +1,12 @@
<?php <?php
require_once(realpath(dirname(__FILE__) . '/./api/Response.php')); require_once(realpath(dirname(__FILE__) . '/./api/Response.php'));
$show_upgrade_screen = false;
if ($show_upgrade_screen) {
$html = '<h1>Code Update in Progress</h1><p>Please refresh the page in 10 minutes.</p>';
return Response::html($html);
}
$view = isset($_GET['view']) ? $_GET['view'] : false; $view = isset($_GET['view']) ? $_GET['view'] : false;
switch ($view) { switch ($view) {
@ -112,7 +119,7 @@ switch ($view) {
oldLoad && oldLoad(); oldLoad && oldLoad();
if (UpUp) { if (UpUp) {
UpUp.start({ UpUp.start({
'cache-version': '2.0.0', 'cache-version': '2.0.2',
'content-url': 'offline.html', 'content-url': 'offline.html',
'assets': [ 'assets': [
\"" . implode('","', $files) . "\" \"" . implode('","', $files) . "\"

View File

@ -1,3 +1,15 @@
html, body {
margin: 0;
font-family: $font;
font-size: 13pt;
transition: all 0.2s ease-in;
* {
transition: all 0.2s ease-in;
box-sizing: border-box;
}
}
header { header {
display: block; display: block;
padding: 5px $general-padding; padding: 5px $general-padding;

View File

@ -8,6 +8,12 @@ p, span {
} }
} }
input:not([type="checkbox"]),
select,
textarea {
font-size: 12pt;
}
label { label {
display: block; display: block;
font-weight: bold; font-weight: bold;
@ -24,7 +30,7 @@ label {
input:not([type="checkbox"]):not([type="radio"]) { input:not([type="checkbox"]):not([type="radio"]) {
padding-bottom: 2px; padding-bottom: 2px;
line-height: 130%; line-height: 1.3;
} }
input:not([type="checkbox"]):not([type="radio"]), input:not([type="checkbox"]):not([type="radio"]),
@ -33,23 +39,27 @@ label {
width: 100%; width: 100%;
} }
textarea {
min-height: 100px;
}
.label-button { .label-button {
display: inline-block; display: inline-block;
padding: 3px 9px; padding: 3px 9px;
border-radius: 3px; border-radius: 3px;
line-height: 30px; line-height: 1.5;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
font-size: 80%; font-size: 80%;
font-weight: normal; font-weight: normal;
float: right; float: right;
cursor: pointer; cursor: pointer;
line-height: 80% !important; line-height: 0.85 !important;
padding: 3px 3px 5px; padding: 3px 3px 5px;
&.small { &.small {
font-size: 80%; font-size: 80%;
line-height: 25px; line-height: 0.8;
} }
} }
@ -57,18 +67,18 @@ label {
display: inline-block; display: inline-block;
padding: 3px 9px; padding: 3px 9px;
border-radius: 3px; border-radius: 3px;
line-height: 30px; line-height: 1.5;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
font-size: 70%; font-size: 70%;
font-weight: normal; font-weight: normal;
cursor: pointer; cursor: pointer;
line-height: 70% !important; line-height: 0.8 !important;
padding: 2px 2px 4px; padding: 2px 2px 4px;
&.small { &.small {
font-size: 80%; font-size: 80%;
line-height: 25px; line-height: 0.8;
} }
} }
} }
@ -81,11 +91,15 @@ ul {
display: inline-block; display: inline-block;
padding: 3px 9px; padding: 3px 9px;
border-radius: 3px; border-radius: 3px;
line-height: 30px; line-height: 1.5;
&.small { &.small {
font-size: 80%; font-size: 80%;
line-height: 25px; line-height: 1.3;
}
&+.tag {
margin-top: 5px;
} }
} }
@ -95,24 +109,28 @@ span .tag {
display: inline-block; display: inline-block;
padding: 3px 9px; padding: 3px 9px;
border-radius: 3px; border-radius: 3px;
line-height: 30px; line-height: 1.5;
&.small { &.small {
font-size: 80%; font-size: 80%;
line-height: 25px; line-height: 1.3;
} }
&+.tag { &+.tag {
border-left: none; border-left: none;
border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0;
} }
&+span .tag {
margin-top: 5px;
}
} }
.button { .button {
display: inline-block; display: inline-block;
padding: 3px 9px; padding: 3px 9px;
border-radius: 3px; border-radius: 3px;
line-height: 30px; line-height: 1.5;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
text-decoration: none; text-decoration: none;
@ -120,7 +138,11 @@ span .tag {
&.small { &.small {
font-size: 80%; font-size: 80%;
line-height: 25px; line-height: 1.3;
}
&+.button {
margin-top: 5px;
} }
} }

View File

@ -1,8 +1,8 @@
@media (max-width: 750px) { @media (max-width: 750px) {
html, body { html, body {
font-size: 90%; font-size: 12pt;
line-height: 90%; line-height: 1;
} }
header { header {
@ -17,7 +17,6 @@ main {
#sideColumn { #sideColumn {
display: block; display: block;
width: 0; width: 0;
height: block;
margin: 0; margin: 0;
overflow: visible; overflow: visible;
} }

View File

@ -2,7 +2,7 @@
#top { #top {
#title { #title {
font-size: 13pt; width: 150px;
margin-right: 10px; margin-right: 10px;
} }
@ -27,12 +27,13 @@
} }
} }
$mobile-word-form-size: 32px;
#mobileWordFormShow { #mobileWordFormShow {
position: fixed; position: fixed;
top: $header-height; top: $header-height - ($mobile-word-form-size / 2);
left: 0; left: 0;
width: 32px; width: $mobile-word-form-size;
height: 32px; height: $mobile-word-form-size;
display: block; display: block;
border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0;
font-size: 30px; font-size: 30px;
@ -48,10 +49,15 @@
display: none; display: none;
width: 95%; width: 95%;
max-width: unset; max-width: unset;
top: $header-height + 32px; max-height: 85%;
top: $header-height + ($mobile-word-form-size / 2);
left: 0; left: 0;
right: 3%; right: 3%;
z-index: 1; z-index: 1;
label:not(:last-child) {
margin-bottom: 10px;
}
} }
#detailsSection { #detailsSection {
@ -60,7 +66,9 @@
} }
#detailsPanel { #detailsPanel {
width: 100%;
max-height: 300px; max-height: 300px;
padding: 10px 5px;
} }
} }