forked from blockchain/unused-My-Wallet
-
Notifications
You must be signed in to change notification settings - Fork 2
/
chrome.js
116 lines (92 loc) · 2.82 KB
/
chrome.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
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
isExtension = true;
APP_NAME = 'javascript_chrome';
$(document).ready(function() {
var body = $(document.body);
var data_root = body.data('root');
if (data_root)
root = data_root;
var data_resource = body.data('resource');
if (data_resource)
resource = data_resource;
//Chrome should automatically grant notification permissions
MyWallet.setHTML5Notifications(true);
$('body').css('padding-bottom', '0px').css('-webkit-user-select', 'text');
$('html').css('overflow-y', 'auto');
$('head').append('<style type="text/css"> .modal-backdrop { background-color : rgb(245, 245, 245) }</style>');
$('.quickstart').css('background-image', 'linear-gradient(rgb(255, 255, 255), rgb(245, 245, 245))').find('.container:first-child').css('padding-top', '0px');
$('#large-summary').prepend('<img id="refresh" src="'+resource+'refresh-black-32.png" style="padding-bottom:4px" />');
});
/*
MyWallet.makeNotice = function(type, id, msg, timeout) {
if (msg == null || msg.length == 0)
return;
MyWallet.showNotification({
title : type == 'success' ? 'Success' : 'Error',
body : msg,
iconUrl : resource + 'cube48.png'
});
}*/
var superSetLanguage = MyWallet.setLanguage;
MyWallet.setLanguage = function(language) {
if (MyWallet.getLanguage()) {
superSetLanguage(language);
MyWallet.makeNotice('success', 'misc-success', 'Changing Language ' + language + '. Please Wait...');
setTimeout(function() {
chrome.runtime.reload();
});
} else {
superSetLanguage(language);
}
}
MyWallet.logout = function() {
$.ajax({
type: "GET",
url: root + 'wallet/logout',
data : {format : 'plain'},
success: function(data) {
chrome.app.window.current().close();
},
error : function() {
chrome.app.window.current().close();
}
});
}
MyStore = new function() {
this.put = function(key, value) {
var obj = {};
obj[key] = value;
try {
chrome.storage.local.set(obj);
} catch(e) {
console.log(e);
}
}
this.get = function(key, callback) {
try {
chrome.storage.local.get(key, function(result) {
try {
callback(result[key]);
} catch (e) {
console.log(e);
}
});
} catch(e) {
console.log(e);
callback();
}
}
this.remove = function(key) {
try {
chrome.storage.local.remove(key);
} catch(e) {
console.log(e);
}
}
this.clear = function() {
try {
chrome.storage.local.clear();
} catch(e) {
console.log(e);
}
}
}