2019-05-28 17:01:29 -06:00
import { setupLoginModal , setupChangeDictionary , setupCreateNewDictionary , setupDeletedDictionaryChangeModal , setupMakePublic } from "./setupListeners" ;
2019-05-23 17:00:13 -06:00
import { request } from "./helpers" ;
2019-05-13 14:02:10 -06:00
export function renderLoginForm ( ) {
const loginModal = document . createElement ( 'section' ) ;
loginModal . classList . add ( 'modal' ) ;
loginModal . id = 'loginModal' ;
loginModal . innerHTML = ` <div class="modal-background"></div>
< div class = "modal-content" > < a class = "close-button" > & times ; & # xFE0E ; < / a >
< section >
< div class = "split two" >
< div >
< h2 > Log In < / h 2 >
< label > Email < br >
2019-05-17 11:39:00 -06:00
< input type = "email" required id = "loginEmail" maxlength = "100" >
2019-05-13 14:02:10 -06:00
< / l a b e l >
< label > Password < br >
2019-05-17 11:39:00 -06:00
< input type = "password" required id = "loginPassword" maxlength = "100" >
2019-05-13 14:02:10 -06:00
< / l a b e l >
< section id = "loginErrorMessages" > < / s e c t i o n >
2019-05-24 16:38:08 -06:00
< button id = "loginSubmit" class = "button" > Log In < / b u t t o n > < b r >
2019-05-13 14:02:10 -06:00
< a id = "forgotPasswordButton" class = "small button" > Forgot Password ? < / a >
< / d i v >
< div >
< h2 > Create a New Account < / h 2 >
< p > Creating an account allows you to save and switch between as many dictionaries as you need and access them from any device for free ! If you have a dictionary you ' ve been working on loaded already , it will automatically be uploaded to your account when you log in for the first time . < / p >
< p > Plus if you allow us to send you emails , we 'll make sure that you' re the first to hear about any new features that get added or if any of our policies change for any reason . We ' ll never spam you or sell your information . < / p >
< p > By creating an account , you are indicating that you agree to the Terms of Service and that you understand Lexiconga ' s Privacy Policy . < / p >
< label > Email < br >
2019-05-17 11:39:00 -06:00
< input type = "email" id = "createNewEmail" maxlength = "100" >
2019-05-13 14:02:10 -06:00
< / l a b e l >
< label > Password < br >
2019-05-17 11:39:00 -06:00
< input type = "password" id = "createNewPassword" maxlength = "100" >
2019-05-13 14:02:10 -06:00
< / l a b e l >
< label > Confirm Password < br >
2019-05-17 11:39:00 -06:00
< input type = "password" id = "createNewConfirm" maxlength = "100" >
2019-05-13 14:02:10 -06:00
< / l a b e l >
< label > Public Name < br >
2019-05-17 11:39:00 -06:00
< input type = "text" id = "createNewPublicName" maxlength = "50" >
2019-05-13 14:02:10 -06:00
< / l a b e l >
< label > Allow Emails
< input type = "checkbox" id = "createNewAllowEmails" >
< / l a b e l >
2019-05-14 17:22:17 -06:00
< section id = "createAccountErrorMessages" > < / s e c t i o n >
2019-05-24 16:38:08 -06:00
< button id = "createAccountSubmit" class = "button" > Create Account < / b u t t o n >
2019-05-13 14:02:10 -06:00
< / d i v >
< / d i v >
< / s e c t i o n >
< / d i v > ` ;
document . body . appendChild ( loginModal ) ;
setupLoginModal ( loginModal ) ;
2019-05-17 12:23:40 -06:00
}
2019-05-24 15:37:15 -06:00
export function renderMakePublic ( ) {
const editSettingsTab = document . getElementById ( 'editSettingsTab' ) ;
2019-05-28 17:01:29 -06:00
const { isPublic } = window . currentDictionary . settings ;
2019-05-24 15:37:15 -06:00
const editSettingsTabHTML = ` <label>Make Public
2019-05-28 17:01:29 -06:00
< input type = "checkbox" id = "editIsPublic" $ { isPublic ? ' checked' : '' } > < br >
2019-05-24 15:37:15 -06:00
< small > Checking this box will make this public via a link you can share with others . < / s m a l l >
< / l a b e l >
2019-05-28 17:01:29 -06:00
< p id = "publicLinkDisplay" style = "${!isPublic ? 'display:none;': ''}margin-left:20px;" >
< strong > Public Link : < / s t r o n g > < b r >
< input readonly id = "publicLink" value = "${window.location.href + window.currentDictionary.externalID.toString()}" >
< a class = "small button" id = "publicLinkCopy" > Copy < / a >
< / p >
2019-05-24 15:37:15 -06:00
` ;
editSettingsTab . innerHTML += editSettingsTabHTML ;
2019-05-28 17:01:29 -06:00
setupMakePublic ( ) ;
2019-05-24 15:37:15 -06:00
}
2019-05-17 12:23:40 -06:00
export function renderAccountSettings ( ) {
const accountSettingsColumn = document . getElementById ( 'accountSettings' ) ;
const accountSettingsHTML = ` <h3>Account Settings</h3>
2019-05-23 17:00:13 -06:00
< label > Email Address < br > < input id = "accountSettingsEmail" required maxlength = "100" value = "${window.account.email}" > < / l a b e l >
< label > Public Name < br > < input id = "accountSettingsPublicName" placeholder = "Someone" maxlength = "50" value = "${window.account.publicName}" > < / l a b e l >
2019-05-23 18:25:52 -06:00
< label > Allow Emails < input type = "checkbox" id = "accountSettingsAllowEmails" $ { window . account . allowEmails ? ' checked' : '' } > < / l a b e l >
< label > New Password < small > Only fill if changing ! < / s m a l l > < b r > < i n p u t t y p e = " p a s s w o r d " i d = " a c c o u n t S e t t i n g s N e w P a s s w o r d " p l a c e h o l d e r = " L e a v e B l a n k t o P r e v e n t C h a n g e " > < / l a b e l >
` ;
2019-05-23 17:30:34 -06:00
accountSettingsColumn . innerHTML = accountSettingsHTML ;
}
export function renderAccountActions ( ) {
const accountActionsColumn = document . getElementById ( 'accountActions' ) ;
const accountActionsHTML = ` <h3>Account Actions</h3>
2019-05-17 12:23:40 -06:00
< label > Change Dictionary < br > < select id = "accountSettingsChangeDictionary" > < / s e l e c t > < / l a b e l >
2019-05-23 17:32:31 -06:00
< p > < a class = "button" id = "accountSettingsCreateNewDictionary" > Create New Dictionary < / a > < / p >
2019-05-17 12:23:40 -06:00
< h4 > Request Your Data < / h 4 >
< p >
Per your < a href = "https://www.eugdpr.org/" target = "_blank" > GDPR < / a > r i g h t s i n A r t i c l e s 1 3 – 1 5 a n d 2 0 , w e a l l o w y o u t o r e q u e s t a n y a n d a l l d a t a w e h a v e s t o r e d a b o u t y o u . T h e o n l y d a t a w e h a v e a b o u t y o u p e r s o n a l l y i s y o u r e m a i l a d d r e s s a n d y o u r P u b l i c N a m e , i f y o u d e c i d e d t o s e t o n e . A l l o t h e r d a t a ( y o u r D i c t i o n a r y d a t a ) i s v i s i b l e a n d a c c e s s i b l e v i a t h e E x p o r t b u t t o n u n d e r y o u r D i c t i o n a r y ' s S e t t i n g s . S e n d a n e m a i l t o h e l p @ l e x i c o n . g a t o r e q u e s t y o u r i n f o r m a t i o n .
< / p >
< h4 > Delete Your Account < / h 4 >
< p >
Per your < a href = "https://www.eugdpr.org/" target = "_blank" > GDPR < / a > r i g h t s i n A r t i c l e s 1 7 , i f y o u w i s h f o r y o u r a c c o u n t t o b e d e l e t e d , p l e a s e c o n t a c t u s a t h e l p @ l e x i c o n . g a , a n d w e w i l l d e l e t e y o u r a c c o u n t a n d a l l a s s o c i a t e d d i c t i o n a r i e s a n d w o r d s a s q u i c k l y a s p o s s i b l e . N o t e t h a t y o u c a n d e l e t e d i c t i o n a r i e s y o u r s e l f v i a y o u r D i c t i o n a r y ' s S e t t i n g s .
< / p >
< p >
Anything that is deleted from our system is permanently and irretrievably removed from our system and cannot be restored , though search engines or internet archives may retain a cached version of your content ( there is nothing we can do about this , and you will need to seek out removal of that information by directly contacting the services that are caching your data ) .
< / p >
` ;
2019-05-23 17:30:34 -06:00
accountActionsColumn . innerHTML = accountActionsHTML ;
2019-05-23 17:00:13 -06:00
renderChangeDictionaryOptions ( ) ;
2019-05-23 17:32:31 -06:00
setupCreateNewDictionary ( ) ;
2019-05-23 17:00:13 -06:00
}
export function renderChangeDictionaryOptions ( ) {
request ( {
action : 'get-all-dictionary-names' ,
} , dictionaries => {
const changeDictionarySelect = document . getElementById ( 'accountSettingsChangeDictionary' ) ;
const optionsHTML = dictionaries . map ( dictionary => ` <option value=" ${ dictionary . id } "> ${ dictionary . name } </option> ` ) . join ( '' ) ;
changeDictionarySelect . innerHTML = optionsHTML ;
changeDictionarySelect . value = window . currentDictionary . externalID ;
setupChangeDictionary ( ) ;
} , error => console . error ( error ) ) ;
2019-05-23 19:56:45 -06:00
}
export function renderDeletedDictionaryChangeModal ( deletedId ) {
const changeDictionarySelect = document . getElementById ( 'accountSettingsChangeDictionary' ) ;
const lazyFilterOptions = changeDictionarySelect . querySelectorAll ( ` option:not([value=" ${ deletedId } "]) ` ) ;
const lazyFilter = document . createElement ( 'select' ) ;
lazyFilter . innerHTML = '<option></option>' ;
lazyFilterOptions . forEach ( option => {
lazyFilter . appendChild ( option ) ;
} ) ;
const otherDictionariesHTML = lazyFilter . innerHTML ;
const modal = document . createElement ( 'section' ) ;
modal . classList . add ( 'modal' ) ;
modal . innerHTML = ` <div class="modal-background"></div>
< div class = "modal-content" >
< section class = "info-modal" >
< h2 > Dictionary Deleted < / h 2 >
$ { lazyFilterOptions . length < 1 ? ''
: ` <label>Select dictionary to load<br>
< select id = "selectDictionaryToLoad" > $ { otherDictionariesHTML } < / s e l e c t >
< / l a b e l >
< p > OR < / p > ` }
< p > < a class = "button" id = "createNewDictionaryAfterDelete" > Create a New Dictionary < / a > < / p >
< / s e c t i o n >
< / d i v > ` ;
document . body . appendChild ( modal ) ;
setupDeletedDictionaryChangeModal ( ) ;
2019-05-13 14:02:10 -06:00
}