-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchExtention.js
73 lines (72 loc) · 1.38 KB
/
chExtention.js
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
/* create DOM handler to init app */
var node = document.createElement("DIV");
node.id = 'bC_app';
document.getElementsByTagName("BODY")[0].appendChild(node);
const bC_app_feed = {
el: '#bC_app',
mixins : [
appData,
manager,
itemsList,
contractMethods,
contractApi,
generators
],
template: `
<div id="bC_app">
<component-app/>
</div>
`,
created: function () {
/* get app main data from storage */
chrome.storage.local.get([
'app',
// 'user',
'documents',
'variables',
], this.initApplication);
},
methods: {
initApplication(data){
if(data.app){
this.app = data.app;
}
// if(data.user){
// this.user = data.user;
// }
if(data.documents){
this.documents = data.documents;
}
if(data.variables){
this.variables = data.variables;
}
},
},
watch: {
app: {
handler(val){
chrome.storage.local.set({app: val}, function () {/* success */});
},
deep: true
},
// user: {
// handler(val){
// chrome.storage.local.set({user: val}, function () {/* success */});
// },
// deep: true
// },
documents: {
handler(val){
chrome.storage.local.set({documents: val}, function () {/* success */});
},
deep: true
},
variables: {
handler(val){
chrome.storage.local.set({variables: val}, function () {/* success */});
},
deep: true
},
}
}
var bC_app = new Vue(bC_app_feed);