FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScriptButtons/src/util/datastore.js at master · Chhabi/JavaScriptButtons · GitHub
Chhabi
JavaScriptButtons
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScriptButtons
/
src
/
util
/
datastore.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
84 lines (56 loc) · 1.66 KB
Breadcrumbs
JavaScriptButtons
/
src
/
util
/
datastore.js
Copy path
File metadata and controls
84 lines (56 loc) · 1.66 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict'
;
var
constants
=
require
(
'../constants'
)
;
function
DataStore
(
)
{
this
.
items
=
{
}
;
}
DataStore
.
prototype
.
add
=
function
addData
(
key
,
val
)
{
// Remap nice values
key
=
constants
.
PRETTY_PARAMS
[
key
]
||
key
;
// Wrap strings in the value object
if
(
typeof
val
===
'string'
)
{
val
=
{
value
:
val
}
;
}
this
.
items
[
key
]
=
{
label
:
val
.
label
||
''
,
value
:
val
.
value
||
''
,
editable
:
!
!
val
.
editable
}
;
}
;
DataStore
.
prototype
.
get
=
function
getData
(
key
)
{
var
item
=
this
.
items
[
key
]
;
return
item
&&
item
.
value
;
}
;
DataStore
.
prototype
.
remove
=
function
removeData
(
key
)
{
delete
this
.
items
[
key
]
;
}
;
DataStore
.
prototype
.
pluck
=
function
pluckData
(
key
)
{
var
val
=
this
.
get
(
key
)
;
this
.
remove
(
key
)
;
return
val
;
}
;
DataStore
.
prototype
.
parse
=
function
parseData
(
el
)
{
var
attrs
,
attr
,
matches
,
key
,
label
,
value
,
editable
,
len
,
i
;
if
(
(
attrs
=
el
.
attributes
)
)
{
for
(
i
=
0
,
len
=
attrs
.
length
;
i
<
len
;
i
++
)
{
attr
=
attrs
[
i
]
;
if
(
(
matches
=
attr
.
name
.
match
(
/
^
d
a
t
a
-
(
[
a
-
z
0
-
9
_
]
+
)
(
-
e
d
i
t
a
b
l
e
)
?
/
i
)
)
)
{
key
=
matches
[
1
]
;
editable
=
!
!
matches
[
2
]
;
value
=
attr
.
value
;
if
(
key
.
indexOf
(
'option'
)
===
0
)
{
value
=
value
.
split
(
'='
)
;
label
=
value
[
0
]
;
value
=
value
[
1
]
.
split
(
','
)
;
}
this
.
add
(
key
,
{
label
:
label
,
value
:
value
,
editable
:
editable
}
)
;
}
}
}
}
;
module
.
exports
=
DataStore
;
Back
|
FazBrowse Home
|
New Git URL