-
-
+
@@ -1493,6 +1493,7 @@
childList: true,
})
target.addEventListener('input', checkEntry)
+ target.addEventListener('paste', checkEntry)
}
})
getRef('article_wrapper').addEventListener("focusout", e => {
@@ -1501,6 +1502,7 @@
normalizeText(e.target.closest('.content__area'))
document.removeEventListener('selectionchange', detectFormatting)
target.removeEventListener('input', checkEntry)
+ target.removeEventListener('paste', checkEntry)
const selection = window.getSelection()
if (!e.relatedTarget?.closest('#text_toolbar')) {
getRef('text_toolbar').classList.add('hide-completely')
@@ -1540,12 +1542,9 @@
}
function updateScore() {
const newScore = parseFloat(getRef('update_score_field').value)
- scores[floGlobals.versionHistory.currentEntry] = newScore
+ updateGenData(floGlobals.versionHistory.currentEntry, { score: newScore })
document.querySelectorAll(`[data-vector-clock="${floGlobals.versionHistory.currentEntry}"] .content__score`).forEach(scoreElem => scoreElem.textContent = newScore)
- const mark = {
- [floGlobals.versionHistory.currentEntry]: newScore
- }
- floCloudAPI.markApplicationData(mark).then(res => {
+ floCloudAPI.tagApplicationData(floGlobals.versionHistory.currentEntry, newScore).then(res => {
notify('Score updated', 'success')
hidePopup()
}).catch(err => notify(err, 'error'))
@@ -1766,17 +1765,25 @@
}
function getGenData(vectorClock) {
- const { message: { section, origin, plainText, html, hash }, senderID, time } = floGlobals.generalData[`${floGlobals.currentArticle.id}_gd|${floGlobals.adminID}|${floGlobals.application}`][vectorClock]
+ const { message: { section, origin, html, hash }, senderID, time, tag } = floGlobals.generalData[`${floGlobals.currentArticle.id}_gd|${floGlobals.adminID}|${floGlobals.application}`][vectorClock]
+ // convert html to innerText
+ const tempDiv = createElement('div', {
+ innerHTML: html
+ })
+ console.log(tempDiv.innerText)
return {
- plainText,
+ plainText: tempDiv.innerText,
html,
editor: senderID,
hash,
- score: getScore(vectorClock),
+ score: tag ? tag : 0,
timestamp: time,
vectorClock,
}
}
+ function updateGenData(vectorClock, propsToUpdate = {}) {
+ floGlobals.generalData[`${floGlobals.currentArticle.id}_gd|${floGlobals.adminID}|${floGlobals.application}`][vectorClock] = { ...floGlobals.generalData[`${floGlobals.currentArticle.id}_gd|${floGlobals.adminID}|${floGlobals.application}`][vectorClock], ...propsToUpdate }
+ }
const checkEntry = debounce(e => {
const contentCard = e.target.closest('.content-card')
@@ -1825,7 +1832,6 @@
const entry = {
section: sectionID,
origin: isUniqueEntry ? floCrypto.randString(16, true) : uid,
- plainText,
html: cleanHTML,
hash
}
@@ -1833,18 +1839,14 @@
submitButton.disabled = true
floCloudAPI.sendGeneralData(entry, `${floGlobals.currentArticle.id}_gd`)
.then((res) => {
- let genDataVC
// Add result to general data
- for (genDataVC in res) {
- floGlobals.generalData[`${floGlobals.currentArticle.id}_gd|${floGlobals.adminID}|${floGlobals.application}`][genDataVC] = res[genDataVC]
- }
-
+ floGlobals.generalData[`${floGlobals.currentArticle.id}_gd|${floGlobals.adminID}|${floGlobals.application}`][res.vectorClock] = { ...res, message: entry }
submitButton.classList.add('hide-completely')
notify('Content submitted', 'success')
if (isUniqueEntry) {
contentArea.innerHTML = ''
floGlobals.currentArticle.sections[sectionID].uniqueEntries.push(entry.origin)
- floGlobals.currentArticle.uniqueEntries[entry.origin] = { iterations: [genDataVC] }
+ floGlobals.currentArticle.uniqueEntries[entry.origin] = { iterations: [res.vectorClock] }
// Insert new content card based on set filter
const newCard = render.contentCard(entry.origin)
if (getRef('sort_content_list').value === 'time') {
@@ -1887,7 +1889,7 @@
if (noOfContributors < 2 && !contributors.hasOwnProperty(myFloID)) {
contentCard.querySelector('.content__author').textContent = `${myFloID} and 1 more`
}
- floGlobals.currentArticle.uniqueEntries[entry.origin].iterations.push(genDataVC)
+ floGlobals.currentArticle.uniqueEntries[entry.origin].iterations.push(res.vectorClock)
}
})
.catch(err => console.log(err))
@@ -2032,14 +2034,6 @@
}
- const scores = {}
- function getScore(vc) {
- if (!scores[vc])
- scores[vc] = floCrypto.randInt(0, 100)
- return scores[vc]
- }
-
-
let currentOptionsPanel = ''
function toggleOptionsPanel(type) {
const animInOptions = {
@@ -2349,8 +2343,6 @@
}
}
- const splitAt = (string, index) => [string.slice(0, index), string.slice(index)]
-
function normalizeText(target) {
if (target) {
for (const child of target.children) {
@@ -2378,9 +2370,10 @@
} else {
const pos = selection.getRangeAt(0).getBoundingClientRect()
const leftOffset = pos.left + 200 < window.innerWidth ? pos.left : pos.left - 220 + window.innerWidth - pos.left
- getRef('text_toolbar').style.transform = `translate(${leftOffset}px, calc(${pos.bottom + window.pageYOffset}px + 1rem))`
+ const topOffeset = (pos.bottom + window.pageYOffset + 64) > window.innerHeight ? pos.top + window.pageYOffset - 56 : pos.bottom + window.pageYOffset
+ getRef('text_toolbar').style.transform = `translate(${leftOffset}px, calc(${topOffeset}px + 1rem))`
getRef('text_toolbar').classList.remove('hide-completely')
- getRef('text_toolbar').style.transform = `translate(${leftOffset}px, calc(${pos.bottom + window.pageYOffset}px + 0.3rem))`
+ getRef('text_toolbar').style.transform = `translate(${leftOffset}px, calc(${topOffeset}px + 0.3rem))`
}
getRef('formatting_options').classList.remove('hide-completely')
getRef('link_panel').classList.add('hide-completely')
@@ -2599,69 +2592,27 @@
}).catch(error => console.error(error))
}
-
-
-
+
-