FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mist/interface/client/mistAPIBackend.js at develop · HelloCodeWorld/mist · GitHub
HelloCodeWorld
/
mist
Public
forked from
ethereum/mist
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
mist
/
interface
/
client
/
mistAPIBackend.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
144 lines (112 loc) · 4 KB
Breadcrumbs
mist
/
interface
/
client
/
mistAPIBackend.js
Copy path
File metadata and controls
144 lines (112 loc) · 4 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/**
@module
MistAPI Backend
*/
var
allowedBrowserBarStyles
=
[
'transparent'
]
;
/**
Filters a id the id to only contain a-z A-Z 0-9 _ -.
@method
filterId
*/
var
filterId
=
function
(
str
)
{
var
newStr
=
''
;
var
i
;
for
(
i
=
0
;
i
<
str
.
length
;
i
+=
1
)
{
if
(
/
[
a
-
z
A
-
Z
0
-
9
_
-
]
/
.
test
(
str
.
charAt
(
i
)
)
)
{
newStr
+=
str
.
charAt
(
i
)
;
}
}
return
newStr
;
}
;
var
sound
=
document
.
createElement
(
'audio'
)
;
/**
The backend side of the mist API.
@method
mistAPIBackend
*/
mistAPIBackend
=
function
(
event
)
{
var
template
=
this
.
template
;
var
webview
=
this
.
webview
;
var
arg
=
event
.
args
[
0
]
;
// console.trace('mistAPIBackend event', event);
if
(
event
.
channel
===
'setWebviewId'
)
{
Tabs
.
update
(
template
.
data
.
_id
,
{
$set
:
{
webviewId
:
webview
.
getWebContents
(
)
.
id
}
}
)
;
}
// Send TEST DATA
if
(
event
.
channel
===
'sendTestData'
)
{
var
tests
=
Tabs
.
findOne
(
'tests'
)
;
if
(
tests
)
{
web3
.
eth
.
getCoinbase
(
function
(
e
,
coinbase
)
{
webview
.
send
(
'uiAction_sendTestData'
,
tests
.
permissions
,
coinbase
)
;
}
)
;
}
}
// SET FAVICON
if
(
event
.
channel
===
'favicon'
)
{
Tabs
.
update
(
template
.
data
.
_id
,
{
$set
:
{
icon
:
Blaze
.
_escape
(
arg
||
''
)
,
}
}
)
;
}
// SET APPBAR
if
(
event
.
channel
===
'appBar'
)
{
var
appBarClass
=
Blaze
.
_escape
(
arg
||
''
)
;
Tabs
.
update
(
template
.
data
.
_id
,
{
$set
:
{
appBar
:
(
_
.
contains
(
allowedBrowserBarStyles
,
appBarClass
)
?
appBarClass
:
null
)
}
}
)
;
}
if
(
event
.
channel
===
'mistAPI_sound'
)
{
sound
.
pause
(
)
;
sound
.
src
=
Blaze
.
_escape
(
'file://'
+
dirname
+
'/sounds/'
+
arg
+
'.mp3'
)
;
sound
.
play
(
)
;
}
// STOP HERE, IF BROWSER
if
(
template
.
data
.
_id
===
'browser'
)
{
return
;
}
// Actions: --------
if
(
event
.
channel
===
'mistAPI_setBadge'
)
{
Tabs
.
update
(
template
.
data
.
_id
,
{
$set
:
{
badge
:
arg
,
}
}
)
;
}
if
(
event
.
channel
===
'mistAPI_menuChanges'
&&
arg
instanceof
Array
)
{
arg
.
forEach
(
function
(
eventArg
)
{
var
query
;
if
(
eventArg
.
action
===
'addMenu'
)
{
// filter ID
if
(
eventArg
.
entry
&&
eventArg
.
entry
.
id
)
{
eventArg
.
entry
.
id
=
filterId
(
eventArg
.
entry
.
id
)
;
}
query
=
{
$set
:
{
}
}
;
if
(
eventArg
.
entry
.
id
)
{
query
.
$set
[
'menu.'
+
eventArg
.
entry
.
id
+
'.id'
]
=
eventArg
.
entry
.
id
;
}
query
.
$set
[
'menu.'
+
eventArg
.
entry
.
id
+
'.selected'
]
=
!
!
eventArg
.
entry
.
selected
;
if
(
!
_
.
isUndefined
(
eventArg
.
entry
.
position
)
)
{
query
.
$set
[
'menu.'
+
eventArg
.
entry
.
id
+
'.position'
]
=
eventArg
.
entry
.
position
;
}
if
(
!
_
.
isUndefined
(
eventArg
.
entry
.
name
)
)
{
query
.
$set
[
'menu.'
+
eventArg
.
entry
.
id
+
'.name'
]
=
eventArg
.
entry
.
name
;
}
if
(
!
_
.
isUndefined
(
eventArg
.
entry
.
badge
)
)
{
query
.
$set
[
'menu.'
+
eventArg
.
entry
.
id
+
'.badge'
]
=
eventArg
.
entry
.
badge
;
}
Tabs
.
update
(
template
.
data
.
_id
,
query
)
;
}
if
(
eventArg
.
action
===
'selectMenu'
)
{
var
tab
=
Tabs
.
findOne
(
template
.
data
.
_id
)
;
for
(
var
e
in
tab
.
menu
)
{
if
(
{
}
.
hasOwnProperty
.
call
(
tab
.
menu
,
e
)
)
{
tab
.
menu
[
e
]
.
selected
=
(
e
===
eventArg
.
id
)
;
}
}
Tabs
.
update
(
template
.
data
.
_id
,
{
$set
:
{
menu
:
tab
.
menu
}
}
)
;
}
if
(
eventArg
.
action
===
'removeMenu'
)
{
var
removeQuery
=
{
$unset
:
{
}
}
;
removeQuery
.
$unset
[
'menu.'
+
eventArg
.
id
]
=
''
;
Tabs
.
update
(
template
.
data
.
_id
,
removeQuery
)
;
}
if
(
eventArg
.
action
===
'clearMenu'
)
{
Tabs
.
update
(
template
.
data
.
_id
,
{
$set
:
{
menu
:
{
}
}
}
)
;
}
}
)
;
}
}
;
Back
|
FazBrowse Home
|
New Git URL