-
Notifications
You must be signed in to change notification settings - Fork 6
/
popup.html
173 lines (147 loc) · 4.28 KB
/
popup.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!--
* Filename: popup.html
* More info, see: gpme.js
*
* Web: http://huyz.us/google-plus-me/
* Source: https://github.com/huyz/google-plus-me
* Author: Huy Z http://huyz.us/
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style>
body {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif !important;
font-size: 14px;
line-height: 21px;
color: #333;
}
code, pre, textarea, tt {
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif !important;
font-size: 12px;
line-height: 18px;
color: black;
white-space: pre-wrap;
word-wrap: break-word;
}
a { text-decoration: underline; color: #537d7b }
a:visited { text-decoration: underline; color: #537d7b }
a:hover { text-decoration: underline; color: #a34d32 }
.header {
background-color: #2D2D2D;
color: white;
font-weight: bold;
padding: 3px 5px;
text-align: center;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.container {
margin: 10px 15px;
}
.author {
font-weight: normal;
font-size: 12px;
display: inline-block;
width: 100%;
text-align: right;
}
.options {
width: 200px;
margin: 5px;
}
.actions {
margin: 5px;
}
#status {
margin: 5px;
height: 20px;
color: green;
}
</style>
<script type="text/javascript" charset="utf-8">
// Saves options to localStorage.
function saveOptions() {
var mode = 'expanded';
var radios = document.getElementsByName('gpme_options_mode');
for (var radio in radios) {
if (radios[radio].checked) {
mode = radios[radio].value;
break;
}
}
localStorage.setItem('gpme_options_mode', mode);
// Send update to all tabs
broadcast({action: 'gpmeModeOptionUpdated', mode: mode});
notifyUser("Option saved.");
}
// Restores select box state to saved value from localStorage, after
// filling in localStorage from content script
function restoreOptions() {
var mode = localStorage.getItem('gpme_options_mode');
var radios = document.getElementsByName('gpme_options_mode');
for (var radio in radios) {
radios[radio].checked = mode == radios[radio].value;
}
}
function resetAll() {
// Clear our localStorage
for (var i in localStorage) {
if (i.indexOf('gpme_') == 0)
localStorage.removeItem(i);
}
// Re-default to expanded, as in background.js
localStorage.setItem('gpme_options_mode', 'expanded');
restoreOptions();
// Clear the content scripts' localStorage
broadcast({action: 'gpmeResetAll'});
notifyUser('Resetting G+me.');
}
function notifyUser(msg) {
// Update status to let user know options were saved.
var status = document.getElementById('status');
status.innerHTML = msg;
setTimeout(function() {
status.innerHTML = '';
}, 1000);
}
// Broadcast message to all tabs
function broadcast(request, callback) {
chrome.windows.getAll({populate: true}, function(windows) {
windows.forEach(function(w) {
w.tabs.forEach(function(tab) {
if (tab.url.match(/^https?:\/\/plus\.google\.com\//))
chrome.tabs.sendRequest(tab.id, request, callback);
});
});
});
}
</script>
</head>
<body onload="restoreOptions()">
<div class="header">
G+me<br/>
<span class="author">by <a href="http://huyz.us/" target=_blank>Huy Z</a></span>
</div>
<div class="container">
<div class="options">
Show posts in: <br />
<input id="gpme_options_mode_expanded" type="radio" name="gpme_options_mode" value="expanded" / >expanded mode<br />
<input id="gpme_options_mode_list" type="radio" name="gpme_options_mode" value="list" / >list mode (max. 1 open)<br />
<button onclick="saveOptions()" style="margin-top: 5px">Save</button>
</div>
<div class="actions">
<a href="#" onclick="resetAll();">Reset G+me</a>
</div>
<pre id="status">
</pre>
</div>
</body>
</html>
<!-- Local Variables: -->
<!-- coding: utf-8 -->
<!-- End: -->
<!-- vim:set ai et sts=4 sw=4 tw=0: -->