-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskpane.html
More file actions
295 lines (253 loc) · 6.98 KB
/
taskpane.html
File metadata and controls
295 lines (253 loc) · 6.98 KB
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>HashFix - Email Hashtag Fixer</title>
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #333;
padding: 20px;
min-height: 100vh;
}
.container {
background: white;
border-radius: 12px;
padding: 24px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
h1 {
color: #667eea;
font-size: 24px;
margin-bottom: 8px;
display: flex;
align-items: center;
gap: 8px;
}
.subtitle {
color: #666;
font-size: 14px;
margin-bottom: 24px;
}
.status-card {
background: #f8f9fa;
border-left: 4px solid #667eea;
padding: 16px;
border-radius: 8px;
margin-bottom: 24px;
}
.status-card h2 {
font-size: 16px;
color: #333;
margin-bottom: 8px;
}
.status-card p {
color: #666;
font-size: 14px;
line-height: 1.5;
}
.stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-bottom: 24px;
}
.stat-box {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 16px;
border-radius: 8px;
text-align: center;
}
.stat-number {
font-size: 32px;
font-weight: bold;
margin-bottom: 4px;
}
.stat-label {
font-size: 12px;
opacity: 0.9;
}
.logs-section {
margin-top: 24px;
}
.logs-section h3 {
font-size: 16px;
color: #333;
margin-bottom: 12px;
}
.log-entry {
background: #f8f9fa;
padding: 12px;
border-radius: 6px;
margin-bottom: 8px;
font-size: 13px;
}
.log-time {
color: #667eea;
font-weight: 600;
}
.log-detail {
color: #666;
margin-top: 4px;
}
.no-logs {
text-align: center;
color: #999;
padding: 24px;
font-style: italic;
}
.info-box {
background: #e7f3ff;
border: 1px solid #b3d9ff;
padding: 16px;
border-radius: 8px;
margin-top: 24px;
}
.info-box h3 {
color: #0066cc;
font-size: 14px;
margin-bottom: 8px;
}
.info-box ul {
margin-left: 20px;
color: #333;
font-size: 13px;
}
.info-box li {
margin-bottom: 4px;
}
.refresh-btn {
background: #667eea;
color: white;
border: none;
padding: 10px 20px;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
font-weight: 600;
width: 100%;
margin-top: 16px;
transition: background 0.3s;
}
.refresh-btn:hover {
background: #5568d3;
}
.emoji {
font-size: 24px;
}
</style>
</head>
<body>
<div class="container">
<h1>
<span class="emoji">#</span>
HashFix
</h1>
<p class="subtitle">Automatic hashtag formatting for your emails</p>
<div class="status-card">
<h2>Status: Active</h2>
<p>HashFix automatically converts "Data#3" to "Data<sup>#</sup>3" (with superscript #) when you send emails.</p>
</div>
<button class="refresh-btn" onclick="fixCurrentEmail()" style="margin-bottom: 24px;">Fix Data#3 in Current Email</button>
<div class="stats">
<div class="stat-box">
<div class="stat-number" id="totalFixes">0</div>
<div class="stat-label">Total Fixes</div>
</div>
<div class="stat-box">
<div class="stat-number" id="sessionFixes">0</div>
<div class="stat-label">This Session</div>
</div>
</div>
<div class="logs-section">
<h3>Recent Activity</h3>
<div id="logsList"></div>
</div>
<button class="refresh-btn" onclick="refreshLogs()">Refresh Activity</button>
<div class="info-box">
<h3>What HashFix Does:</h3>
<ul>
<li>Automatically formats "Data#3" with superscript #</li>
<li>Converts: Data#3 → Data<sup>#</sup>3</li>
<li>Runs automatically when you send emails</li>
<li>Or click button above to fix current email manually</li>
<li>Preserves all other email formatting</li>
</ul>
</div>
</div>
<script>
let totalFixesCount = 0;
Office.onReady(() => {
loadLogs();
// Refresh logs every 5 seconds
setInterval(loadLogs, 5000);
});
function loadLogs() {
try {
const logs = JSON.parse(sessionStorage.getItem('hashfixLogs') || '[]');
const logsList = document.getElementById('logsList');
const totalFixes = document.getElementById('totalFixes');
const sessionFixes = document.getElementById('sessionFixes');
if (logs.length === 0) {
logsList.innerHTML = '<div class="no-logs">No hashtag fixes yet. Send an email with "# tag" to see HashFix in action!</div>';
totalFixes.textContent = '0';
sessionFixes.textContent = '0';
return;
}
// Calculate total fixes
const totalCount = logs.reduce((sum, log) => sum + log.fixesApplied, 0);
totalFixesCount = totalCount;
// Update stats
totalFixes.textContent = totalCount;
sessionFixes.textContent = logs.length;
// Display recent logs (last 10)
const recentLogs = logs.slice(-10).reverse();
logsList.innerHTML = recentLogs.map(log => {
const date = new Date(log.timestamp);
const timeStr = date.toLocaleTimeString();
return `
<div class="log-entry">
<div class="log-time">${timeStr}</div>
<div class="log-detail">Fixed ${log.fixesApplied} hashtag${log.fixesApplied !== 1 ? 's' : ''}</div>
</div>
`;
}).join('');
} catch (error) {
console.error('Error loading logs:', error);
}
}
function refreshLogs() {
loadLogs();
}
function fixCurrentEmail() {
Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, function(result) {
if (result.status === Office.AsyncResultStatus.Failed) {
alert('Failed to get email content');
return;
}
const originalHtml = result.value;
const fixedHtml = originalHtml.replace(/Data#3(?!<\/sup>)/gi, 'Data<sup>#</sup>3');
if (fixedHtml !== originalHtml) {
Office.context.mailbox.item.body.setAsync(fixedHtml, { coercionType: Office.CoercionType.Html }, function(setResult) {
if (setResult.status === Office.AsyncResultStatus.Succeeded) {
alert('✓ Data#3 formatted with superscript #');
} else {
alert('Failed to update email');
}
});
} else {
alert('No Data#3 found in this email');
}
});
}
</script>
</body>
</html>