-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutlook.htm
More file actions
388 lines (341 loc) · 9.26 KB
/
outlook.htm
File metadata and controls
388 lines (341 loc) · 9.26 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<html>
<head>
<script language="javascript" src="mootools.js"></script>
<script language="javascript" type="text/javascript">
var slidrs = {};
var msgsScroll;
var messagesslidr;
var scrollslidr;
//the width and height of a little preview box
var previewWidth = 200;
var previewHeight = 80;
//the current location of the items slider
var msgsloc = -1;
//the total number of items in the current directory
var msgslen = 0;
//the number of currently-displayed preview boxen
var msgsboxes = 0;
//the current directory of messages
var msgsdir;
var previews = {};
var scrollenable = true;
var resizing = false;
var loading = 0;
//initialize the panes on document load
window.addEvent('domready', function(){
var firstajax = new Ajax("Outlook.GetNames", {method: 'get', onSuccess: LoadFirst});
firstajax.request();
new SmoothScroll();
//create the slide-in effect for the messages subview
messagesslidr = new Fx.Style($("messagespane"), 'width', {duration: 300, transition: Fx.Transitions.quadInOut});
scrollslidr = new Fx.Style($("messagesknob"), 'height', {duration: 300, transition: Fx.Transitions.quadInOut, onComplete: function() {
//create the vertical scroll slider for messages
msgsloc = 0;
if (msgsScroll)
msgsScroll.setOptions({onChange: function(pos) {}});
msgsScroll = new Slider($("messagesscroll"), $("messagesknob"), {
steps: Math.max(msgslen - Math.floor(window.getHeight()/previewHeight), 0),
mode: "vertical",
onChange: doscroll
}).set(0);
doscroll(0);
}});
doresize();
messagesslidr.start(0);
scrollslidr.set(window.getHeight());
});
window.addEvent('resize', doresize);
//waits until scrolling is complete
function delayScroll(val) {
if (val == msgsloc) {
//console.log("scrolling to pos %x", msgsloc);
loaditems();
}
}
function doscroll(pos) {
//a bit hackish: Sliders have shadow copies lying around
if (pos >= 0 && pos < Math.max(msgslen - Math.floor(window.getHeight()/previewHeight), 0))
if (msgsloc != pos && scrollenable) {
msgsloc = pos;
setTimeout("delayScroll(" + pos + ")",50);
//console.log("pos = %x", msgsloc);
}
}
//perform updates to size and message items divs when the window is resized
function doresize() {
//only allow one concurrent resize
if (resizing)
return;
else
resizing = true;
//transition for scrollbar size
scrollslidr.stop();
//find the height of the scrollbar
var height;
if (msgslen * previewHeight <= window.getHeight())
height = window.getHeight();
else
height = Math.max(window.getHeight() * window.getHeight() / (msgslen * previewHeight), 50)
mp = $("messagespane");
mp.setHTML("");
msgsboxes = Math.min(msgslen, Math.floor(window.getHeight()/previewHeight));
//build the message/item divs
for (var x = 0; x < msgsboxes; ++x) {
new Element("div").
setProperties({"id": "item" + x, "class": "previewbox"}).
setStyles({ "width": previewWidth+"px",
"height": previewHeight+"px",
"left": "0px",
"top": "0px" }).
addEvent("click", function() {
//load the message content
var jax = new Ajax("Outlook.GetItemContentsOnPath?lst=" + msgsdir + "&dex=" + this.getProperty("absdex"),
{method: "get", onSuccess: function(str) {
carea = $("msgcontent")
carea.setHTML(str);
carea.setStyle("height", window.getHeight());
}});
jax.request();
}).
addEvent("mouseover", function() {this.setStyle("background-color", "#758E9F");}).
addEvent("mouseout", function() {this.setStyle("background-color", "#647D8F");}).
injectInside(mp);
}
scrollslidr.start(height);
resizing = false;
}
//set the contents of the _dex_th (reference in Folder.Items) item preview box
function setpreview(dex, str) {
box = $("item" + (dex - msgsloc));
//console.log(dex-msgsloc);
box.setProperty("absdex", dex);
box.setHTML(str);
}
//Load a set of preview items
function loaditems() {
//if for some reason an ajax load failed, make loading done after 1 second regardless
setTimeout(function() {loading = 0;}, 1000);
//only allow for one concurrent load batch
if (loading > 0)
return;
else
loading = msgsboxes;
//loop through each preview box and either fetch the content from the server or load cached content
for (var x = 0; x < msgsboxes; ++x) {
if (!previews[msgsloc + x]) {
//the preview hasn't been loaded yet... send an ajax request.
var jax = new Ajax("Outlook.GetItemPreviewOnPath?lst=" + msgsdir + "&dex=" + (msgsloc + x),
{method: "get", onSuccess: function(str) {
previews[this.dex] = str;
setpreview(this.dex, previews[this.dex]);
--loading;
if (loading <= 0)
setScrollEnable(true);
}});
jax.dex = msgsloc + x;
jax.request();
}
else {
//inject a previously-loaded preview item.
setpreview(msgsloc + x, previews[msgsloc+x]);
--loading;
if (loading <= 0)
setScrollEnable(true);
}
}
}
//enable or disable the items scroll bar
function setScrollEnable(b) {
if (b) {
$("messagesscroll").effects().start({"width":20});
$("messagesknob").effects().start({"width":20});
scrollenable = true;
}
else {
$("messagesscroll").effects().start({"width":0});
$("messagesknob").effects().start({"width":0});
scrollenable = false;
}
}
//perform associated loading for an item in the folder hierarchy
function LoadInner(e) {
//prevent events from bubbling down to parent folders
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
mid = this.getProperty("id");
//Dynamically construct next set of nodes in subtree
if (!this.getProperty("loaded")) {
var jax = new Ajax("Outlook.GetNamesOnPath?lst=" + mid,
{method: "get", onSuccess: function(str) {
if (str.length == 0)
return;
subm = this.submitter;
subm.setProperties({"loaded": "true"});
subl = new Element("ul").setProperties({"class": "mitem"});
names = str.split(",");
for (var x = 0; x < names.length; ++x) {
new Element("li").
setProperties({"id": subm.getProperty("id") + "," + x, "class":"msubitem"}).
setHTML(names[x]).
addEvent("click", LoadInner).
addEvent("mouseover", function() {this.setStyle("margin-left",-15);}).
addEvent("mouseout", function() {this.setStyle("margin-left",-20);}).
injectInside(subl);
}
subl.injectInside(subm);
//show the recently-loaded contents
slidrs[mid] = new Fx.Slide(subl, {duration: 500, onComplete: function() {RefreshParentage(mid);} });
slidrs[mid].hide();
slidrs[mid].toggle();
}});
jax.submitter = this;
jax.request();
}
else {
slidrs[mid].toggle();
}
//update the items list
new Ajax("Outlook.GetLenItemsOnPath?lst=" + mid,
{method: 'get', onSuccess: function(str) {
msgsdir = mid;
msgslen = parseInt(str);
messagesslidr.stop();
doresize();
if (msgslen > 0) {
//there are some messages here - load them!
previews = {};
messagesslidr.start(previewWidth);
loaditems();
setScrollEnable(true);
}
else {
messagesslidr.start(0);
setScrollEnable(false);
}
}}).request();
messagesslidr.start(0);
}
//Fix a bug wherein sliders don't resize their parent containers appropriately
function RefreshParentage(id) {
subids = id.split(",");
for (var x = 1; x < subids.length; ++x) {
//name of subid to refresh
s = subids.slice(0, x).join(",");
slidrs[s].slideIn();
}
}
//Load the root folders
function LoadFirst(str) {
var carea = $("mcontent");
carea.setHTML("");
names = str.split(",");
for (var x = 0; x < names.length; ++x) {
new Element("li").
setProperties({"id": x},{"class":"msubitem"}).
setHTML(names[x]).
addEvent("click", LoadInner).
injectInside(carea);
}
}
</script>
<style type="text/css">
/*
lt gray: #647D8F
dk gray: #596F80
lt blue: #CFDCE6
dk blue: #6096BF
*/
html, body {
height: 100%;
}
body, h1, h3, p {
padding: 0;
margin: 0;
}
body {
font: 11px/1.6 Lucida Grande, Tahoma, Arial, sans-serif;
background-color: #596F80;
overflow: hidden;
}
.vpane {
margin: 0 auto;
min-height: 100%;
height: auto !important;
height: 100%;
}
.mitem {
background-color: #CFDCE6;
font-weight:bold;
}
.msubitem {
padding-left: 2px;
background-color: #CFDCE6;
padding-right: 10px;
margin-left:-20px;
padding-left: -20px;
}
.previewbox {
position: relative;
border-bottom: 1px solid #CFDCE6;
padding-top: 5px;
padding-left: 5px;
padding-right: 5px;
background-color: #647D8F;
}
.preview {
font-size:12px;
line-height:15px;
}
.subject {font-weight: bold; height:30px; overflow:hidden;}
.sender {font-style: italic;}
.date {}
#folderspane {
float:left;
background-color:#647D8F;
}
#messagespane {
float:left;
overflow:hidden;
background-color:#647D8F;
}
#messagesscroll {
float:left;
width:0px;
background-color:#999999;
}
#messagesknob {
height:0px;
width:0px;
cursor:pointer;
background-color:#333333;
}
#itempane {
background-color:#9999AA;
}
#msgcontent {
overflow:auto;
background-color: #FFFFFF;
padding-left: 20px;
padding-right: 20px;
}
</style>
</head>
<body>
<div class="vpane" id="folderspane">
<ul id="mcontent" class="mitem">
loading...
</ul>
</div>
<div class="vpane" id="messagespane">
<button id="but" onClick="alert($('mcontent').innerHTML)">asdf</button>
</div>
<div class="vpane" id="messagesscroll">
<div id="messagesknob"></div>
</div>
<div class="vpane" id="itempane">
<div id="msgcontent">
</div>
</div>
</body>
</html>