1
1
/* eslint-env browser, jquery */
2
2
/* global moment, serverurl */
3
3
4
- require ( './locale' )
5
-
6
- require ( '../css/cover.css' )
7
- require ( '../css/site.css' )
8
-
9
4
import {
10
- checkIfAuth ,
11
- clearLoginState ,
12
- getLoginState ,
13
- resetCheckAuth ,
14
- setloginStateChangeEvent
5
+ checkIfAuth ,
6
+ clearLoginState ,
7
+ getLoginState ,
8
+ resetCheckAuth ,
9
+ setloginStateChangeEvent
15
10
} from './lib/common/login'
16
11
17
12
import {
18
- clearDuplicatedHistory ,
19
- deleteServerHistory ,
20
- getHistory ,
21
- getStorageHistory ,
22
- parseHistory ,
23
- parseServerToHistory ,
24
- parseStorageToHistory ,
25
- postHistoryToServer ,
26
- removeHistory ,
27
- saveHistory ,
28
- saveStorageHistoryToServer
13
+ clearDuplicatedHistory ,
14
+ deleteServerHistory ,
15
+ getHistory ,
16
+ getStorageHistory ,
17
+ parseHistory ,
18
+ parseServerToHistory ,
19
+ parseStorageToHistory ,
20
+ postHistoryToServer ,
21
+ removeHistory ,
22
+ saveHistory ,
23
+ saveStorageHistoryToServer
29
24
} from './history'
30
25
31
26
import { saveAs } from 'file-saver'
32
27
import List from 'list.js'
33
28
import unescapeHTML from 'lodash/unescape'
34
29
30
+ require ( './locale' )
31
+
32
+ require ( '../css/cover.css' )
33
+ require ( '../css/site.css' )
34
+
35
35
const options = {
36
36
valueNames : [ 'id' , 'text' , 'timestamp' , 'fromNow' , 'time' , 'tags' , 'pinned' ] ,
37
37
item : `<li class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
@@ -67,27 +67,27 @@ pageInit()
67
67
68
68
function pageInit ( ) {
69
69
checkIfAuth (
70
- data => {
71
- $ ( '.ui-signin' ) . hide ( )
72
- $ ( '.ui-or' ) . hide ( )
73
- $ ( '.ui-welcome' ) . show ( )
74
- if ( data . photo ) $ ( '.ui-avatar' ) . prop ( 'src' , data . photo ) . show ( )
75
- else $ ( '.ui-avatar' ) . prop ( 'src' , '' ) . hide ( )
76
- $ ( '.ui-name' ) . html ( data . name )
77
- $ ( '.ui-signout' ) . show ( )
78
- $ ( '.ui-history' ) . click ( )
79
- parseServerToHistory ( historyList , parseHistoryCallback )
80
- } ,
81
- ( ) => {
82
- $ ( '.ui-signin' ) . show ( )
83
- $ ( '.ui-or' ) . show ( )
84
- $ ( '.ui-welcome' ) . hide ( )
85
- $ ( '.ui-avatar' ) . prop ( 'src' , '' ) . hide ( )
86
- $ ( '.ui-name' ) . html ( '' )
87
- $ ( '.ui-signout' ) . hide ( )
88
- parseStorageToHistory ( historyList , parseHistoryCallback )
89
- }
90
- )
70
+ data => {
71
+ $ ( '.ui-signin' ) . hide ( )
72
+ $ ( '.ui-or' ) . hide ( )
73
+ $ ( '.ui-welcome' ) . show ( )
74
+ if ( data . photo ) $ ( '.ui-avatar' ) . prop ( 'src' , data . photo ) . show ( )
75
+ else $ ( '.ui-avatar' ) . prop ( 'src' , '' ) . hide ( )
76
+ $ ( '.ui-name' ) . html ( data . name )
77
+ $ ( '.ui-signout' ) . show ( )
78
+ $ ( '.ui-history' ) . click ( )
79
+ parseServerToHistory ( historyList , parseHistoryCallback )
80
+ } ,
81
+ ( ) => {
82
+ $ ( '.ui-signin' ) . show ( )
83
+ $ ( '.ui-or' ) . show ( )
84
+ $ ( '.ui-welcome' ) . hide ( )
85
+ $ ( '.ui-avatar' ) . prop ( 'src' , '' ) . hide ( )
86
+ $ ( '.ui-name' ) . html ( '' )
87
+ $ ( '.ui-signout' ) . hide ( )
88
+ parseStorageToHistory ( historyList , parseHistoryCallback )
89
+ }
90
+ )
91
91
}
92
92
93
93
$ ( '.masthead-nav li' ) . click ( function ( ) {
@@ -132,7 +132,7 @@ function checkHistoryList () {
132
132
133
133
function parseHistoryCallback ( list , notehistory ) {
134
134
checkHistoryList ( )
135
- // sort by pinned then timestamp
135
+ // sort by pinned then timestamp
136
136
list . sort ( '' , {
137
137
sortFunction ( a , b ) {
138
138
const notea = a . values ( )
@@ -152,13 +152,13 @@ function parseHistoryCallback (list, notehistory) {
152
152
}
153
153
}
154
154
} )
155
- // parse filter tags
155
+ // parse filter tags
156
156
const filtertags = [ ]
157
157
for ( let i = 0 , l = list . items . length ; i < l ; i ++ ) {
158
158
const tags = list . items [ i ] . _values . tags
159
159
if ( tags && tags . length > 0 ) {
160
160
for ( let j = 0 ; j < tags . length ; j ++ ) {
161
- // push info filtertags if not found
161
+ // push info filtertags if not found
162
162
let found = false
163
163
if ( filtertags . includes ( tags [ j ] ) ) { found = true }
164
164
if ( ! found ) { filtertags . push ( tags [ j ] ) }
@@ -178,20 +178,20 @@ historyList.on('updated', e => {
178
178
const a = itemEl . find ( 'a' )
179
179
const pin = itemEl . find ( '.ui-history-pin' )
180
180
const tagsEl = itemEl . find ( '.tags' )
181
- // parse link to element a
181
+ // parse link to element a
182
182
a . attr ( 'href' , `${ serverurl } /${ values . id } ` )
183
- // parse pinned
183
+ // parse pinned
184
184
if ( values . pinned ) {
185
185
pin . addClass ( 'active' )
186
186
} else {
187
187
pin . removeClass ( 'active' )
188
188
}
189
- // parse tags
189
+ // parse tags
190
190
const tags = values . tags
191
191
if ( tags && tags . length > 0 && tagsEl . children ( ) . length <= 0 ) {
192
192
const labels = [ ]
193
193
for ( let j = 0 ; j < tags . length ; j ++ ) {
194
- // push into the item label
194
+ // push into the item label
195
195
labels . push ( `<span class='label label-default'>${ tags [ j ] } </span>` )
196
196
}
197
197
tagsEl . html ( labels . join ( ' ' ) )
@@ -328,7 +328,7 @@ $('.ui-open-history').bind('change', e => {
328
328
const reader = new FileReader ( )
329
329
reader . onload = ( ) => {
330
330
const notehistory = JSON . parse ( reader . result )
331
- // console.log(notehistory);
331
+ // console.log(notehistory);
332
332
if ( ! reader . result ) return
333
333
getHistory ( data => {
334
334
let mergedata = data . concat ( notehistory )
0 commit comments