Compare commits

..

No commits in common. "258e172761dbaf4766f1ef923d940acec5e9d5b4" and "54aa0e26673730be1a3711848b05ec5efd227f07" have entirely different histories.

8 changed files with 4 additions and 92 deletions

View File

@ -113,7 +113,7 @@
<footer id="bottom">
<a href="https://liberapay.com/robbieantenesse" target="_blank" class="small button">Support Lexiconga</a>
<a href="https://blog.lexicon.ga" target="_blank" class="small button">Blog</a>
<a href="." target="_blank" class="small button">Advertise</a>
<a href="./" target="_blank" class="small button">Advertise</a>
<a href="https://github.com/Alamantus/Lexiconga/issues" target="_blank" class="small button">Issues</a>
<a href="https://github.com/Alamantus/Lexiconga/releases" target="_blank" class="small button">Updates</a>
<span class="separator">|</span>

View File

@ -16,8 +16,8 @@
"copy-php": "cpx \"src/php/**/{*,.*}\" dist",
"serve-frontend-only": "parcel template-index.html",
"clear": "npm run clear-dist && npm run clear-cache",
"clear-dist": "rimraf dist/{*,.*}",
"clear-cache": "rimraf .cache/{*,.*}"
"clear-dist": "rimraf dist/*",
"clear-cache": "rimraf .cache/*"
},
"devDependencies": {
"autoprefixer": "^9.5.1",

View File

@ -1,4 +1,3 @@
import migrate from './js/migration';
import setupListeners from './js/setupListeners';
import { renderAll } from './js/render';
import { hasToken, addMessage } from './js/utilities';
@ -11,8 +10,6 @@ function initialize() {
addMessage('<strong>You are using the Offline version of Lexiconga.</strong><br>Refresh the page while connected to the internet to enable using accounts.', 0);
}
migrate();
loadSettings();
loadDictionary();
setupListeners();

View File

@ -1,77 +0,0 @@
import { LOCAL_STORAGE_KEY } from "../constants";
export default function migrate() {
if (window.location.pathname === '/') {
if (isNotSecure()) {
sendDictionaryToHTTPS();
} else {
checkForReceived();
}
}
}
function isNotSecure() {
return window.location.host !== 'localhost' && window.location.protocol !== 'https';
}
function sendDictionaryToHTTPS() {
const storedDictionary = window.localStorage.getItem(LOCAL_STORAGE_KEY);
const httpsURL = 'https://' + window.location.host;
if (storedDictionary) {
if (!dictionaryIsOldDefault(storedDictionary)) {
const form = document.createElement('form');
form.action = httpsURL;
form.method = 'POST';
form.hidden = true;
const field = document.createElement('input');
field.name = 'oldDictionaryFromHTTP';
field.value = storedDictionary;
form.appendChild(field);
const blackoutShield = document.createElement('div');
blackoutShield.classList.add('modal-background');
document.body.appendChild(form);
document.body.appendChild(blackoutShield);
alert('You are about to be redirected to the secure https version of Lexiconga. Please update your bookmarks.')
form.submit();
return;
}
}
window.location = httpsURL;
}
function dictionaryIsOldDefault(dictionaryJSON) {
const defaultDictionary = {
name: "New",
description: "A new dictionary.",
// createdBy: publicName,
words: [],
nextWordId: 1,
settings: {
allowDuplicates: false,
caseSensitive: false,
partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
sortByEquivalent: false,
isComplete: false,
isPublic: false
},
externalID: 0
}
const dictionary = JSON.parse(dictionaryJSON);
delete dictionary.createdBy;
return JSON.stringify(defaultDictionary) === JSON.stringify(dictionary);
}
function checkForReceived() {
if (window.hasOwnProperty('dictionaryImportedFromHTTP')) {
let saveOld = true;
const storedDictionary = window.localStorage.getItem(LOCAL_STORAGE_KEY);
if (storedDictionary) {
saveOld = confirm('You have an old local dictionary to import. Would you like to overwrite your current local dictionary?');
}
if (saveOld) {
window.localStorage.setItem(LOCAL_STORAGE_KEY, window.dictionaryImportedFromHTTP);
delete window.dictionaryImportedFromHTTP;
}
}
}

View File

@ -1,5 +1,4 @@
<?php
require_once(realpath(dirname(__FILE__) . '/./config.php'));
require_once(realpath(dirname(__FILE__) . '/./Response.php'));
require_once(realpath(dirname(__FILE__) . '/./User.php'));

View File

@ -123,12 +123,6 @@ switch ($view) {
</script>";
$html = str_replace('{{upup_insert}}', $upup_insert, $html);
$imported_from_http = '';
if (isset($_POST['oldDictionaryFromHTTP'])) {
$imported_from_http = '<script>window.dictionaryImportedFromHTTP = "' . addslashes($_POST['oldDictionaryFromHTTP']) . '";</script>';
}
$html = str_replace('{{imported_from_http}}', $imported_from_http, $html);
return Response::html($html);
break;

View File

@ -2,7 +2,7 @@
#title {
display: inline-block;
margin: 3px $general-padding 3px 0;
width: 180px;
width: auto;
max-height: $header-height - $general-padding;
vertical-align: middle;
}

View File

@ -7,7 +7,6 @@
<title>Lexiconga</title>
<link rel="icon" href="src/images/favicon.png" type="image/x-icon" />
<link rel="stylesheet" href="src/main.scss" />
{{imported_from_http}}
<script src="src/index.js"></script>
</head>
<body id="defaultTheme">