forked from antimatter15/surplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lite.html
190 lines (176 loc) · 5.19 KB
/
lite.html
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!doctype html>
<html>
<head>
</head>
<body>
<style>
a {
color: #36C;
cursor: pointer;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
#container > a {
text-decoration: none !important;
}
#supercontainer {
height: 450px;
overflow: auto;
}
.item {
padding: 14px 21px 14px 21px;
background: #EEF0F9;
color: #666;
border-top: 1px solid #DDDFE7;
outline: none;
min-height: 30px;
cursor: pointer;
}
.item a {
color: #666;
}
.item.unread a {
color: #36C;
}
.item.unread {
background: #fff;
color: #000;
}
.item img{
display: inline-block;
float: left;
margin-right: 10px;
vertical-align: middle;
width: 35px;
height: 35px;
}
body {
font: normal 13px arial,sans-serif;
width: 440px;
padding: 0;
margin: 0;
}
.icon {
float: right;
margin: 9px 10px 0 5px;
display: inline-block;
height: 16px;
vertical-align: middle;
width: 16px;
}
.stream {
background: no-repeat url(img/icons.png) -83px 0;
}
.circles {
background: no-repeat url(img/icons.png) -100px 0;
}
.photo {
background: no-repeat url(img/icons.png) 0 0;
}
.chevron {
background-image: url(img/chevron.png);
background-position: -64px 16px;
display: inline-block;
float: right;
margin: 10px 0;
width: 7px;
height: 13px;
vertical-align: middle;
}
#header {
padding: 18px 19px 17px 19px;
vertical-align: middle;
}
</style>
<div id="header">
<a href="javascript:updatelastreadtime()" style="float:right">Mark all read</a>
<span style="font-size:110%;font-weight:bold">Surplus Lite </span>
</div>
<div id="supercontainer">
<div id="container">
<center>Loading...</center>
</div>
</div>
<script src="parse.js"></script>
<script>
if(localStorage.slitecache){
document.getElementById('container').innerHTML = localStorage.slitecache;
}
function load_notifications(){
var xhr = new XMLHttpRequest();
xhr.open('get', 'https://plus.google.com/u/'+(localStorage.auth_user||0)+'/_/notifications/getnotificationsdata', true);
xhr.onload = function(){
try{
var json = eval(xhr.responseText.substr(5));
//TODO: use something other than EVAL to parse the malformed JSON
var n = parseNotifications(json)
}catch(err){
var n = [
{
html: "An <b>error has occurred</b> in processing your notifications. Problems which may cause this include <b>not signing in</b> on Google+ or <b>not having access</b> to Google+.", unread: true, pic: "img/64.png"
},
{
html: "Error: server returned malformed JSON or was unable to parse the JSON",
unread: false, pic: "img/64.png"
},
{
html: "Verbose Javascript Error: "+err,
unread: false, pic: "img/64.png"
}
]
}
document.getElementById('container').innerHTML = '';
var unreadCount = 0;
console.log(n);
for(var i = 0; i < n.length; i++){
(function(m){
var l = document.createElement('a');
var div = document.createElement('div');
div.className = 'item '+(m.unread?'unread':'');
if(m.unread) unreadCount++;
var img = document.createElement('img');
img.src = m.pic;
div.appendChild(img);
var chevron = document.createElement('div');
chevron.className = 'chevron';
div.appendChild(chevron);
var icon = document.createElement('span');
icon.className = 'icon ';
div.appendChild(icon);
var text = document.createElement('div');
text.innerHTML = m.html;
div.appendChild(text);
l.target = '_blank';
if(m.is_photo || /photo/.test(m.html)){
icon.className += 'photo';
if(/tagged/.test(m.html))
l.href = 'https://plus.google.com/u/'+(localStorage.auth_user||0)+'/notifications/phototags'
}else if(/added you/.test(m.html)){
l.href = 'https://plus.google.com/u/'+(localStorage.auth_user||0)+'/circles';
icon.className += 'circles'
}else{
icon.className += 'stream';
if(m.url) l.href = m.url;
}
l.appendChild(div);
document.getElementById('container').appendChild(l);
})(n[i]);
}
if(unreadCount == 1) bg.updatelastreadtime();
localStorage.slitecache = document.getElementById('container').innerHTML;
}
xhr.send();
}
function updatelastreadtime(){
bg.updatelastreadtime(function(){
load_notifications();
bg.updateCount();
})
}
var bg = chrome.extension.getBackgroundPage();
load_notifications()
</script>
</body>
</html>