Fixed page routing for preview link sharing

This commit is contained in:
sairaj mote 2022-01-02 17:54:26 +05:30
parent ee26712514
commit 66ed2bd489
4 changed files with 97 additions and 142 deletions

View File

@ -537,13 +537,18 @@ sm-copy {
padding: 1.5rem 0; padding: 1.5rem 0;
} }
#landing > section { #landing > section {
-webkit-box-align: start; -webkit-box-align: center;
-ms-flex-align: start; -ms-flex-align: center;
align-items: flex-start; align-items: center;
margin-top: 6rem;
height: 100%;
text-align: center; text-align: center;
} }
#landing h1 {
margin-top: -2ch;
font-size: clamp(2rem,5vw,5rem);
}
#landing p {
max-width: 100%;
}
#sign_in, #sign_in,
#sign_up { #sign_up {
@ -1164,6 +1169,12 @@ sm-copy {
display: none; display: none;
} }
} }
@supports (-webkit-text-stroke: 1px black) {
#landing h1 {
-webkit-text-stroke: 1px rgba(var(--text-color), 1);
-webkit-text-fill-color: rgba(var(--background-color), 1);
}
}
@media screen and (min-width: 40rem) { @media screen and (min-width: 40rem) {
sm-popup { sm-popup {
--width: 24rem; --width: 24rem;
@ -1202,6 +1213,10 @@ sm-copy {
display: none; display: none;
} }
#landing h1 {
-webkit-text-stroke-width: 0.1rem;
}
#main_header { #main_header {
padding: 1rem 1.5rem; padding: 1rem 1.5rem;
grid-template-columns: auto 1fr auto auto; grid-template-columns: auto 1fr auto auto;

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -464,11 +464,16 @@ sm-copy {
padding: 1.5rem 0; padding: 1.5rem 0;
} }
& > section { & > section {
align-items: flex-start; align-items: center;
margin-top: 6rem;
height: 100%;
text-align: center; text-align: center;
} }
h1{
margin-top: -2ch;
font-size: clamp(2rem,5vw,5rem);
}
p{
max-width: 100%;
}
} }
#sign_in, #sign_in,
@ -1009,6 +1014,12 @@ sm-copy {
display: none; display: none;
} }
} }
@supports (-webkit-text-stroke: 1px black) {
#landing h1 {
-webkit-text-stroke: 1px rgba(var(--text-color), 1);
-webkit-text-fill-color: rgba(var(--background-color), 1);
}
}
@media screen and (min-width: 40rem) { @media screen and (min-width: 40rem) {
sm-popup { sm-popup {
--width: 24rem; --width: 24rem;
@ -1041,6 +1052,9 @@ sm-copy {
.hide-on-desktop { .hide-on-desktop {
display: none; display: none;
} }
#landing h1 {
-webkit-text-stroke-width: .1rem;
}
#main_header { #main_header {
padding: 1rem 1.5rem; padding: 1rem 1.5rem;
grid-template-columns: auto 1fr auto auto; grid-template-columns: auto 1fr auto auto;
@ -1150,4 +1164,4 @@ sm-copy {
opacity: 1; opacity: 1;
} }
} }
} }

View File

@ -79,7 +79,7 @@
<section class="grid justify-center"> <section class="grid justify-center">
<div class="grid gap-0-5"> <div class="grid gap-0-5">
<h1 class="h1">Create. Collaborate. <br>Publish.</h1> <h1 class="h1">Create. Collaborate. <br>Publish.</h1>
<p>Write content with collaboration </p> <p>Write something great... <strong>Together</strong>.</p>
</div> </div>
</section> </section>
</article> </article>
@ -932,7 +932,7 @@
} }
async function showPage(targetPage, options = {}) { async function showPage(targetPage, options = {}) {
const { firstLoad, hashChange } = options const { firstLoad, hashChange, isPreview } = options
let pageId let pageId
let params = {} let params = {}
let searchParams let searchParams
@ -959,6 +959,9 @@
pageId = targetPage pageId = targetPage
} }
} }
if (isPreview) {
floGlobals.preview = location.hash;
}
if (typeof myFloID === "undefined" && !(['sign_up', 'sign_in', 'loading', 'landing'].includes(pageId))) return if (typeof myFloID === "undefined" && !(['sign_up', 'sign_in', 'loading', 'landing'].includes(pageId))) return
if (searchParams) { if (searchParams) {
const urlSearchParams = new URLSearchParams('?' + searchParams); const urlSearchParams = new URLSearchParams('?' + searchParams);
@ -1206,7 +1209,7 @@
] ]
const cc = { const cc = {
createNewArticle() { createNewArticle() {
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
const title = getRef('get_article_title').value.trim() const title = getRef('get_article_title').value.trim()
const setDefault = getRef('set_default_checkbox').checked const setDefault = getRef('set_default_checkbox').checked
const sectionTitles = getRef('get_section_titles').value.trim() const sectionTitles = getRef('get_section_titles').value.trim()
@ -1249,7 +1252,7 @@
} }
function setDefaultArticle() { function setDefaultArticle() {
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
getConfirmation('Set as default article?').then(res => { getConfirmation('Set as default article?').then(res => {
if (res) { if (res) {
floGlobals.appObjects.cc['defaultArticle'] = floGlobals.currentArticle.id floGlobals.appObjects.cc['defaultArticle'] = floGlobals.currentArticle.id
@ -1274,7 +1277,6 @@
contentCard.querySelector('.submit-entry').classList.add('hide-completely') contentCard.querySelector('.submit-entry').classList.add('hide-completely')
} else { } else {
const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'] }) const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'] })
.replace(/b>/gi, 'strong>').replace(/i>/gi, 'em>')
const hash = Crypto.SHA256(clean) const hash = Crypto.SHA256(clean)
let previousHash let previousHash
if (!isUniqueEntry) { if (!isUniqueEntry) {
@ -1304,7 +1306,6 @@
const parentSection = contentCard.closest('.article-section') const parentSection = contentCard.closest('.article-section')
const sectionID = parentSection.dataset.sectionId const sectionID = parentSection.dataset.sectionId
const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'] }) const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'] })
.replace(/b>/gi, 'strong>').replace(/i>/gi, 'em>')
if (clean === '') return if (clean === '') return
const hash = Crypto.SHA256(clean) const hash = Crypto.SHA256(clean)
let previousVersion, previousHash let previousVersion, previousHash
@ -1429,14 +1430,14 @@
}) })
floGlobals.currentArticle.sections[sectionID].expanded = true floGlobals.currentArticle.sections[sectionID].expanded = true
} }
} else if (e.target.closest('.score-button') && isSubAdmin) { } else if (e.target.closest('.score-button') && floGlobals.isSubAdmin) {
floGlobals.versionHistory.currentEntry = e.target.closest('.content-card').dataset.vectorClock floGlobals.versionHistory.currentEntry = e.target.closest('.content-card').dataset.vectorClock
getRef('update_score_field').value = e.target.closest('.score-button').children[1].textContent getRef('update_score_field').value = e.target.closest('.score-button').children[1].textContent
showPopup('scoring_popup') showPopup('scoring_popup')
} }
}) })
getRef('version_timeline').addEventListener('click', e => { getRef('version_timeline').addEventListener('click', e => {
if (e.target.closest('.score-button') && isSubAdmin) { if (e.target.closest('.score-button') && floGlobals.isSubAdmin) {
floGlobals.versionHistory.currentEntry = e.target.closest('.history-entry').dataset.vectorClock floGlobals.versionHistory.currentEntry = e.target.closest('.history-entry').dataset.vectorClock
getRef('update_score_field').value = e.target.closest('.score-button').children[1].textContent getRef('update_score_field').value = e.target.closest('.score-button').children[1].textContent
showPopup('scoring_popup') showPopup('scoring_popup')
@ -1459,7 +1460,7 @@
const contentCard = e.target.closest('.content-card') const contentCard = e.target.closest('.content-card')
const contentID = contentCard.dataset.uid const contentID = contentCard.dataset.uid
contentCard.classList.toggle('selected') contentCard.classList.toggle('selected')
if (!isSubAdmin) if (!floGlobals.isSubAdmin)
contentCard.querySelector('.content__area').toggleAttribute('contenteditable') contentCard.querySelector('.content__area').toggleAttribute('contenteditable')
if (selectedContent.has(contentID)) { if (selectedContent.has(contentID)) {
selectedContent.delete(contentID) selectedContent.delete(contentID)
@ -1619,7 +1620,7 @@
bodyTemplate.querySelector('#reading_time').textContent = `${readingTime} min read` bodyTemplate.querySelector('#reading_time').textContent = `${readingTime} min read`
let bodyAttributes = '' let bodyAttributes = ''
let extraScripts = '' let extraScripts = ''
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
bodyAttributes = `data-article-id="${floGlobals.currentArticle.id}" onload="onLoadStartUp()"` bodyAttributes = `data-article-id="${floGlobals.currentArticle.id}" onload="onLoadStartUp()"`
// copy script already present in this file instead of storing a duplicate // copy script already present in this file instead of storing a duplicate
extraScripts = ` extraScripts = `
@ -1658,7 +1659,7 @@
window.location.hash = `#/home?articleID=${pagesData.params.articleID}` window.location.hash = `#/home?articleID=${pagesData.params.articleID}`
} }
function sharePreview() { function sharePreview() {
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
let allContributors = new Set() let allContributors = new Set()
selectedContent.forEach(({ contributors }) => { selectedContent.forEach(({ contributors }) => {
contributors.forEach(id => allContributors.add(id)) contributors.forEach(id => allContributors.add(id))
@ -1694,7 +1695,7 @@
} }
function publishArticle() { function publishArticle() {
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
const category = getRef('published_article_category').value const category = getRef('published_article_category').value
const tags = getRef('article_tags').value const tags = getRef('article_tags').value
console.log(category, tags) console.log(category, tags)
@ -1830,8 +1831,6 @@
hidePopup() hidePopup()
}).catch(err => notify(err, 'error')) }).catch(err => notify(err, 'error'))
} }
</script>
<script>
floGlobals.currentArticle = {} floGlobals.currentArticle = {}
const sectionIntersectionObserver = new IntersectionObserver((entries, observer) => { const sectionIntersectionObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => { entries.forEach(entry => {
@ -1839,7 +1838,7 @@
const section = entry.target.parentNode const section = entry.target.parentNode
const frag = document.createDocumentFragment(); const frag = document.createDocumentFragment();
const arrayOfElements = floGlobals.currentArticle.sections[section.dataset.sectionId].uniqueEntries const arrayOfElements = floGlobals.currentArticle.sections[section.dataset.sectionId].uniqueEntries
const startIndex = isSubAdmin ? section.children.length : section.children.length - 1 const startIndex = floGlobals.isSubAdmin ? section.children.length : section.children.length - 1
arrayOfElements.slice(startIndex, startIndex + 5).forEach(elem => frag.append(render.contentCard(elem))) arrayOfElements.slice(startIndex, startIndex + 5).forEach(elem => frag.append(render.contentCard(elem)))
entry.target.parentNode.append(frag) entry.target.parentNode.append(frag)
} }
@ -1872,7 +1871,7 @@
handleMobileChange(mobileQuery) handleMobileChange(mobileQuery)
function getScoreElement(score) { function getScoreElement(score) {
let scoreElement let scoreElement
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
scoreElement = createElement('button', { scoreElement = createElement('button', {
className: 'score-button', className: 'score-button',
attributes: { 'title': 'Score this content' } attributes: { 'title': 'Score this content' }
@ -1904,7 +1903,7 @@
frag.append(render.section(sectionID, sections[sectionID], index)) frag.append(render.section(sectionID, sections[sectionID], index))
index += 1 index += 1
} }
if (!isSubAdmin) { if (!floGlobals.isSubAdmin) {
getRef('current_article_title').setAttribute('disabled', '') getRef('current_article_title').setAttribute('disabled', '')
} }
getRef('current_article_title').value = title getRef('current_article_title').value = title
@ -1940,7 +1939,7 @@
const clone = getRef('content_card_template').content.cloneNode(true).firstElementChild; const clone = getRef('content_card_template').content.cloneNode(true).firstElementChild;
clone.dataset.uid = id clone.dataset.uid = id
clone.dataset.vectorClock = vectorClock clone.dataset.vectorClock = vectorClock
if (!isSubAdmin) { if (!floGlobals.isSubAdmin) {
clone.querySelector('.content__area').setAttribute('contentEditable', true) clone.querySelector('.content__area').setAttribute('contentEditable', true)
} }
clone.querySelector('.content__area').innerHTML = DOMPurify.sanitize(data) clone.querySelector('.content__area').innerHTML = DOMPurify.sanitize(data)
@ -2002,7 +2001,7 @@
section.children[0].dataset.index = index section.children[0].dataset.index = index
section.children[0].dataset.sectionId = sectionID section.children[0].dataset.sectionId = sectionID
section.children[1].dataset.sectionId = sectionID section.children[1].dataset.sectionId = sectionID
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
section.querySelector('.content-card--empty').remove() section.querySelector('.content-card--empty').remove()
} else { } else {
section.querySelector('text-field').setAttribute('disabled', '') section.querySelector('text-field').setAttribute('disabled', '')
@ -2184,7 +2183,7 @@
allContentCards[card.dataset.uid] = card.cloneNode(true) allContentCards[card.dataset.uid] = card.cloneNode(true)
}) })
let emptyCard let emptyCard
if (!isSubAdmin) if (!floGlobals.isSubAdmin)
emptyCard = section.firstElementChild.cloneNode(true) emptyCard = section.firstElementChild.cloneNode(true)
section.innerHTML = '' section.innerHTML = ''
const frag = document.createDocumentFragment() const frag = document.createDocumentFragment()
@ -2196,7 +2195,7 @@
toRender.forEach((entry, index) => { toRender.forEach((entry, index) => {
frag.append(allContentCards[entry] || render.contentCard(entry)) frag.append(allContentCards[entry] || render.contentCard(entry))
}) })
if (!isSubAdmin) if (!floGlobals.isSubAdmin)
section.append(emptyCard) section.append(emptyCard)
section.append(frag) section.append(frag)
} }
@ -2204,7 +2203,7 @@
} }
getRef('sort_content_list').addEventListener('change', sortSectionEntries) getRef('sort_content_list').addEventListener('change', sortSectionEntries)
function renderSectionList() { function renderSectionList() {
if (!isSubAdmin) return if (!floGlobals.isSubAdmin) return
const frag = document.createDocumentFragment() const frag = document.createDocumentFragment()
floGlobals.appObjects[floGlobals.currentArticle.id].sections.forEach(section => { floGlobals.appObjects[floGlobals.currentArticle.id].sections.forEach(section => {
frag.append(render.sectionCard(section)) frag.append(render.sectionCard(section))
@ -2236,7 +2235,7 @@
}) })
function saveSectionEdit() { function saveSectionEdit() {
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
const newSections = [] const newSections = []
getRef('section_list_container').querySelectorAll('.section-card--new').forEach(section => { getRef('section_list_container').querySelectorAll('.section-card--new').forEach(section => {
const title = section.querySelector('input').value.trim() const title = section.querySelector('input').value.trim()
@ -2497,110 +2496,18 @@
} }
} }
const replaceBetween = (origin, startIndex, endIndex, insertion) =>
`${origin.substring(0, startIndex)}${insertion}${origin.substring(endIndex)}`;
const make = {
bold() {
replaceSelectedText(createElement('strong'))
},
italic() {
document.execCommand('italic')
},
underlined() {
replaceSelectedText(createElement('u'))
},
link() {
replaceSelectedText(createElement('a', {
attributes: { href: 'google.com' }
}))
}
}
function replaceSelectedText(node) { function replaceSelectedText(node) {
const selection = window.getSelection(); const selection = window.getSelection();
if (!selection.isCollapsed && selection.rangeCount) { if (!selection.isCollapsed && selection.rangeCount) {
const range = selection.getRangeAt(0); const range = selection.getRangeAt(0);
const originalText = range.toString() const originalText = range.toString()
const { isBold, isItalic, isUnderlined } = getSelectionFormatting() range.deleteContents()
if (isBold || isItalic || isUnderlined) { node.textContent = originalText
if (range.cloneContents().firstElementChild) { range.insertNode(node);
range.deleteContents()
const textNode = document.createTextNode(originalText)
range.insertNode(textNode);
} else {
const temp = document.createTextNode(originalText)
const textNode = document.createTextNode(originalText)
range.insertNode(temp);
temp.parentNode.after(textNode)
temp.parentNode.remove()
}
normalizeText(selection.anchorNode.parentNode.closest('.content__area'))
} else {
range.deleteContents()
node.textContent = originalText
range.insertNode(node);
}
selection.anchorNode.parentNode.closest('.content__area')?.focus() selection.anchorNode.parentNode.closest('.content__area')?.focus()
} }
} }
function getSelectionFormatting() {
const sel = window.getSelection();
const raw_html = getSelectionAsHtml();
// This is if nothing is selected
if (raw_html === "") return false;
const tempDiv = document.createElement('div');
tempDiv.innerHTML = raw_html;
const areBoldNodes = []
const areItalicNodes = []
const areUnderlinedNodes = []
for (let node of tempDiv.childNodes) {
let tags = [node.nodeName.toLowerCase()];
while (tags.includes("#text")) {
let start_tag = sel.anchorNode.parentNode.nodeName.toLowerCase();
let end_tag = sel.focusNode.parentNode.nodeName.toLowerCase();
tags = [start_tag, end_tag]
}
areBoldNodes.push(containsOnly(['strong'], tags));
areItalicNodes.push(containsOnly(['em'], tags));
areUnderlinedNodes.push(containsOnly(['u'], tags));
}
return {
isBold: !areBoldNodes.includes(false),
isItalic: !areItalicNodes.includes(false),
isUnderlined: !areUnderlinedNodes.includes(false),
}
}
function getSelectionAsHtml() {
let html = "";
if (typeof window.getSelection != "undefined") {
let sel = window.getSelection();
if (sel.rangeCount) {
let container = document.createElement("div");
for (let i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents());
}
html = container.innerHTML;
}
} else if (typeof document.selection != "undefined") {
if (document.selection.type == "Text") {
html = document.selection.createRange().htmlText;
}
}
return html;
}
function containsOnly(array1, array2) {
return !array2.some(elem => !array1.includes(elem))
}
function insertNode(node) { function insertNode(node) {
const selection = window.getSelection(); const selection = window.getSelection();
if (selection.rangeCount) { if (selection.rangeCount) {
@ -2618,12 +2525,22 @@
function insertBlockquote() { function insertBlockquote() {
insertNode(createQuote()) insertNode(createQuote())
} }
function getRelativeCount(count) {
if (count < 1000)
return count
else if (count < 1000000)
return parseFloat((count / 1000).toFixed(1)) + 'K'
else if (count < 1000000000)
return parseFloat((count / 1000000).toFixed(1)) + 'M'
}
function getSignedIn() { function getSignedIn() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (window.location.hash.includes('sign_in') || window.location.hash.includes('sign_up')) { if (window.location.hash.includes('sign_in') || window.location.hash.includes('sign_up')) {
showPage(window.location.hash) showPage(window.location.hash)
} else { } else {
showPage('landing') showPage('landing', { isPreview: location.hash.includes('preview') })
} }
getRef('sign_in_button').onclick = () => { getRef('sign_in_button').onclick = () => {
resolve(getRef('private_key_field').value.trim()) resolve(getRef('private_key_field').value.trim())
@ -2648,7 +2565,7 @@
} }
</script> </script>
<script id="onLoadStartUp"> <script id="onLoadStartUp">
let isSubAdmin = false floGlobals.isSubAdmin = false
let maxCardsPerSection let maxCardsPerSection
function onLoadStartUp() { function onLoadStartUp() {
@ -2659,9 +2576,9 @@
floDapps.launchStartUp().then(async result => { floDapps.launchStartUp().then(async result => {
getRef('user_flo_id').value = myFloID getRef('user_flo_id').value = myFloID
isSubAdmin = floGlobals.subAdmins.includes(myFloID) floGlobals.isSubAdmin = floGlobals.subAdmins.includes(myFloID)
maxCardsPerSection = isSubAdmin ? 3 : 2 maxCardsPerSection = floGlobals.isSubAdmin ? 3 : 2
if (isSubAdmin) { if (floGlobals.isSubAdmin) {
document.querySelectorAll('.admin-option').forEach(elem => elem.classList.remove('hide-completely')) document.querySelectorAll('.admin-option').forEach(elem => elem.classList.remove('hide-completely'))
} else { } else {
document.querySelectorAll('.admin-option').forEach(elem => elem.classList.add('hide-completely')) document.querySelectorAll('.admin-option').forEach(elem => elem.classList.add('hide-completely'))
@ -2670,7 +2587,7 @@
floCloudAPI.requestObjectData('cc'), floCloudAPI.requestObjectData('cc'),
]) ])
getRef('preview_options').innerHTML = ` getRef('preview_options').innerHTML = `
${isSubAdmin ? ` ${floGlobals.isSubAdmin ? `
<button class="icon-only" title="Share preview" onclick="sharePreview()"> <button class="icon-only" title="Share preview" onclick="sharePreview()">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <g> <rect fill="none" height="24" width="24" /> </g> <g> <path d="M16,5l-1.42,1.42l-1.59-1.59V16h-1.98V4.83L9.42,6.42L8,5l4-4L16,5z M20,10v11c0,1.1-0.9,2-2,2H6c-1.11,0-2-0.9-2-2V10 c0-1.11,0.89-2,2-2h3v2H6v11h12V10h-3V8h3C19.1,8,20,8.89,20,10z" /> </g> </svg> <svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <g> <rect fill="none" height="24" width="24" /> </g> <g> <path d="M16,5l-1.42,1.42l-1.59-1.59V16h-1.98V4.83L9.42,6.42L8,5l4-4L16,5z M20,10v11c0,1.1-0.9,2-2,2H6c-1.11,0-2-0.9-2-2V10 c0-1.11,0.89-2,2-2h3v2H6v11h12V10h-3V8h3C19.1,8,20,8.89,20,10z" /> </g> </svg>
</button> </button>
@ -2678,8 +2595,8 @@
<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <g> <rect fill="none" height="24" width="24" /> </g> <g> <path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z" /> </g> </svg> <svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <g> <rect fill="none" height="24" width="24" /> </g> <g> <path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z" /> </g> </svg>
</button> </button>
`: ''} `: ''}
<sm-button variant="primary" onclick="${isSubAdmin ? "showPopup('publish_article_popup')" : 'exportSelection()'}"> <sm-button variant="primary" onclick="${floGlobals.isSubAdmin ? "showPopup('publish_article_popup')" : 'exportSelection()'}">
${isSubAdmin ? ` ${floGlobals.isSubAdmin ? `
<svg class="icon button__icon--left" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <path d="M0 0h24v24H0V0z" fill="none" /> <path d="M5 4h14v2H5zm0 10h4v6h6v-6h4l-7-7-7 7zm8-2v6h-2v-6H9.83L12 9.83 14.17 12H13z" /> </svg> <svg class="icon button__icon--left" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <path d="M0 0h24v24H0V0z" fill="none" /> <path d="M5 4h14v2H5zm0 10h4v6h6v-6h4l-7-7-7 7zm8-2v6h-2v-6H9.83L12 9.83 14.17 12H13z" /> </svg>
Publish Publish
`: ` `: `
@ -2689,7 +2606,8 @@
</sm-button> </sm-button>
` `
if (window.location.hash.includes('sign_in') || window.location.hash.includes('sign_up')) { if (window.location.hash.includes('sign_in') || window.location.hash.includes('sign_up')) {
history.replaceState(null, null, ' ') const hash = floGlobals.preview ? floGlobals.preview : ' '
history.replaceState(null, null, hash)
} }
showPage(window.location.hash, { firstLoad: true }) showPage(window.location.hash, { firstLoad: true })
console.log(result) console.log(result)
@ -13184,11 +13102,11 @@
} }
const tempCount = document.createElement('div') const tempCount = document.createElement('div')
tempCount.classList.add('temp-count') tempCount.classList.add('temp-count')
tempCount.textContent = totalVotes tempCount.textContent = getRelativeCount(totalVotes)
getRef('like_count').after(tempCount) getRef('like_count').after(tempCount)
tempCount.animate(slideInUp, animOptions) tempCount.animate(slideInUp, animOptions)
.onfinish = () => { .onfinish = () => {
getRef('like_count').textContent = totalVotes getRef('like_count').textContent = getRelativeCount(totalVotes)
tempCount.remove() tempCount.remove()
} }
} }
@ -13291,6 +13209,14 @@
animateTo(getRef('sign_up'), slideInLeft, animOptions) animateTo(getRef('sign_up'), slideInLeft, animOptions)
} }
} }
function getRelativeCount(count) {
if (count < 1000)
return count
else if (count < 1000000)
return parseFloat((count / 1000).toFixed(1)) + 'K'
else if (count < 1000000000)
return parseFloat((count / 1000000).toFixed(1)) + 'M'
}
function goToSignIn() { function goToSignIn() {
const animOptions = { const animOptions = {
fill: 'forwards', fill: 'forwards',
@ -13316,7 +13242,7 @@
</script> </script>
<script id="onLoadStartUp"> <script id="onLoadStartUp">
let isSubAdmin = false floGlobals.isSubAdmin = false
let isLoggedIn = false let isLoggedIn = false
let totalVotes = 0 let totalVotes = 0
function onLoadStartUp() { function onLoadStartUp() {
@ -13336,7 +13262,7 @@
totalVotes++ totalVotes++
} }
} }
getRef('like_count').textContent = totalVotes getRef('like_count').textContent = getRelativeCount(totalVotes)
} else { } else {
animateLikeCount() animateLikeCount()
} }
@ -13362,7 +13288,7 @@
floDapps.launchStartUp().then(async result => { floDapps.launchStartUp().then(async result => {
isLoggedIn = true isLoggedIn = true
isSubAdmin = floGlobals.subAdmins.includes(myFloID) floGlobals.isSubAdmin = floGlobals.subAdmins.includes(myFloID)
getRef('user_flo_id').value = myFloID getRef('user_flo_id').value = myFloID
getRef('user_button').classList.remove('hide-completely') getRef('user_button').classList.remove('hide-completely')