mirror of
https://github.com/status-im/codimd.git
synced 2025-02-02 18:53:26 +00:00
refactor: fix lint warning on public/js/cover.js
Signed-off-by: BoHong Li <a60814billy@gmail.com>
This commit is contained in:
parent
d387cac690
commit
e564c40b4d
@ -1,37 +1,37 @@
|
|||||||
/* eslint-env browser, jquery */
|
/* eslint-env browser, jquery */
|
||||||
/* global moment, serverurl */
|
/* global moment, serverurl */
|
||||||
|
|
||||||
require('./locale')
|
|
||||||
|
|
||||||
require('../css/cover.css')
|
|
||||||
require('../css/site.css')
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
checkIfAuth,
|
checkIfAuth,
|
||||||
clearLoginState,
|
clearLoginState,
|
||||||
getLoginState,
|
getLoginState,
|
||||||
resetCheckAuth,
|
resetCheckAuth,
|
||||||
setloginStateChangeEvent
|
setloginStateChangeEvent
|
||||||
} from './lib/common/login'
|
} from './lib/common/login'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
clearDuplicatedHistory,
|
clearDuplicatedHistory,
|
||||||
deleteServerHistory,
|
deleteServerHistory,
|
||||||
getHistory,
|
getHistory,
|
||||||
getStorageHistory,
|
getStorageHistory,
|
||||||
parseHistory,
|
parseHistory,
|
||||||
parseServerToHistory,
|
parseServerToHistory,
|
||||||
parseStorageToHistory,
|
parseStorageToHistory,
|
||||||
postHistoryToServer,
|
postHistoryToServer,
|
||||||
removeHistory,
|
removeHistory,
|
||||||
saveHistory,
|
saveHistory,
|
||||||
saveStorageHistoryToServer
|
saveStorageHistoryToServer
|
||||||
} from './history'
|
} from './history'
|
||||||
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import List from 'list.js'
|
import List from 'list.js'
|
||||||
import unescapeHTML from 'lodash/unescape'
|
import unescapeHTML from 'lodash/unescape'
|
||||||
|
|
||||||
|
require('./locale')
|
||||||
|
|
||||||
|
require('../css/cover.css')
|
||||||
|
require('../css/site.css')
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
valueNames: ['id', 'text', 'timestamp', 'fromNow', 'time', 'tags', 'pinned'],
|
valueNames: ['id', 'text', 'timestamp', 'fromNow', 'time', 'tags', 'pinned'],
|
||||||
item: `<li class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
|
item: `<li class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
|
||||||
@ -67,27 +67,27 @@ pageInit()
|
|||||||
|
|
||||||
function pageInit () {
|
function pageInit () {
|
||||||
checkIfAuth(
|
checkIfAuth(
|
||||||
data => {
|
data => {
|
||||||
$('.ui-signin').hide()
|
$('.ui-signin').hide()
|
||||||
$('.ui-or').hide()
|
$('.ui-or').hide()
|
||||||
$('.ui-welcome').show()
|
$('.ui-welcome').show()
|
||||||
if (data.photo) $('.ui-avatar').prop('src', data.photo).show()
|
if (data.photo) $('.ui-avatar').prop('src', data.photo).show()
|
||||||
else $('.ui-avatar').prop('src', '').hide()
|
else $('.ui-avatar').prop('src', '').hide()
|
||||||
$('.ui-name').html(data.name)
|
$('.ui-name').html(data.name)
|
||||||
$('.ui-signout').show()
|
$('.ui-signout').show()
|
||||||
$('.ui-history').click()
|
$('.ui-history').click()
|
||||||
parseServerToHistory(historyList, parseHistoryCallback)
|
parseServerToHistory(historyList, parseHistoryCallback)
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
$('.ui-signin').show()
|
$('.ui-signin').show()
|
||||||
$('.ui-or').show()
|
$('.ui-or').show()
|
||||||
$('.ui-welcome').hide()
|
$('.ui-welcome').hide()
|
||||||
$('.ui-avatar').prop('src', '').hide()
|
$('.ui-avatar').prop('src', '').hide()
|
||||||
$('.ui-name').html('')
|
$('.ui-name').html('')
|
||||||
$('.ui-signout').hide()
|
$('.ui-signout').hide()
|
||||||
parseStorageToHistory(historyList, parseHistoryCallback)
|
parseStorageToHistory(historyList, parseHistoryCallback)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.masthead-nav li').click(function () {
|
$('.masthead-nav li').click(function () {
|
||||||
@ -132,7 +132,7 @@ function checkHistoryList () {
|
|||||||
|
|
||||||
function parseHistoryCallback (list, notehistory) {
|
function parseHistoryCallback (list, notehistory) {
|
||||||
checkHistoryList()
|
checkHistoryList()
|
||||||
// sort by pinned then timestamp
|
// sort by pinned then timestamp
|
||||||
list.sort('', {
|
list.sort('', {
|
||||||
sortFunction (a, b) {
|
sortFunction (a, b) {
|
||||||
const notea = a.values()
|
const notea = a.values()
|
||||||
@ -152,13 +152,13 @@ function parseHistoryCallback (list, notehistory) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// parse filter tags
|
// parse filter tags
|
||||||
const filtertags = []
|
const filtertags = []
|
||||||
for (let i = 0, l = list.items.length; i < l; i++) {
|
for (let i = 0, l = list.items.length; i < l; i++) {
|
||||||
const tags = list.items[i]._values.tags
|
const tags = list.items[i]._values.tags
|
||||||
if (tags && tags.length > 0) {
|
if (tags && tags.length > 0) {
|
||||||
for (let j = 0; j < tags.length; j++) {
|
for (let j = 0; j < tags.length; j++) {
|
||||||
// push info filtertags if not found
|
// push info filtertags if not found
|
||||||
let found = false
|
let found = false
|
||||||
if (filtertags.includes(tags[j])) { found = true }
|
if (filtertags.includes(tags[j])) { found = true }
|
||||||
if (!found) { filtertags.push(tags[j]) }
|
if (!found) { filtertags.push(tags[j]) }
|
||||||
@ -178,20 +178,20 @@ historyList.on('updated', e => {
|
|||||||
const a = itemEl.find('a')
|
const a = itemEl.find('a')
|
||||||
const pin = itemEl.find('.ui-history-pin')
|
const pin = itemEl.find('.ui-history-pin')
|
||||||
const tagsEl = itemEl.find('.tags')
|
const tagsEl = itemEl.find('.tags')
|
||||||
// parse link to element a
|
// parse link to element a
|
||||||
a.attr('href', `${serverurl}/${values.id}`)
|
a.attr('href', `${serverurl}/${values.id}`)
|
||||||
// parse pinned
|
// parse pinned
|
||||||
if (values.pinned) {
|
if (values.pinned) {
|
||||||
pin.addClass('active')
|
pin.addClass('active')
|
||||||
} else {
|
} else {
|
||||||
pin.removeClass('active')
|
pin.removeClass('active')
|
||||||
}
|
}
|
||||||
// parse tags
|
// parse tags
|
||||||
const tags = values.tags
|
const tags = values.tags
|
||||||
if (tags && tags.length > 0 && tagsEl.children().length <= 0) {
|
if (tags && tags.length > 0 && tagsEl.children().length <= 0) {
|
||||||
const labels = []
|
const labels = []
|
||||||
for (let j = 0; j < tags.length; j++) {
|
for (let j = 0; j < tags.length; j++) {
|
||||||
// push into the item label
|
// push into the item label
|
||||||
labels.push(`<span class='label label-default'>${tags[j]}</span>`)
|
labels.push(`<span class='label label-default'>${tags[j]}</span>`)
|
||||||
}
|
}
|
||||||
tagsEl.html(labels.join(' '))
|
tagsEl.html(labels.join(' '))
|
||||||
@ -328,7 +328,7 @@ $('.ui-open-history').bind('change', e => {
|
|||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
const notehistory = JSON.parse(reader.result)
|
const notehistory = JSON.parse(reader.result)
|
||||||
// console.log(notehistory);
|
// console.log(notehistory);
|
||||||
if (!reader.result) return
|
if (!reader.result) return
|
||||||
getHistory(data => {
|
getHistory(data => {
|
||||||
let mergedata = data.concat(notehistory)
|
let mergedata = data.concat(notehistory)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user