var colTypes = new Array('st', 'sub', 'date', 'from', 'to'); var msgSortGetData = [ '(x.status == "N") ? 2 : ((x.status == "r") ? 1 : 0)', 'x.subject.toLowerCase()', 'x.moment', 'x.from.toLowerCase()', 'x.to.toLowerCase()' ]; var folders = new Array(); var fpBuilding = false; var flUpdate; var page; var vFolder; var pCompose; var udFolder; var udFList; var msgtt; function emptyCB(data) { } function Folder(t, i, n, nc, mc) { this.type = t; this.id = i; this.name = n; this.nCount = nc; this.mCount = mc; this.messages = new Array(); this.settings = new Array(); this.threadOrder = new Array(); this.selAll = false; this.selected = false; this.deleteMessage = Folder_deleteMessage; this.prepareThreading = Folder_prepareThreading; } function Folder_deleteMessage(idm) {with(this) { var i; for (i=0;i 64) errors[1] = 2; else errors[1] = 0; if (cText == "") errors[2] = 1; else errors[2] = 0; return (errors[0] == 0 && errors[1] == 0 && errors[2] == 0); }} function makeSortFunction(type,dir) { var str = 'function(a,b){var x,s1,s2,i,rv=0,l=msgSortGetData.length;' + 'for(i=0;is2)?1:0));}return rv;}'; return str; } function initMessages() { // Initialise sort functions var i,j; for (i=0;iHelp'; } //-------------------- // COMPOSE MESSAGE //-------------------- function composeNew() { page = "Compose"; setParametersCompose(new Array("","","")); drawMainMenu(); } function messageTo(t,n) { page = "Compose"; setParametersCompose(new Array(t.toString(),n.toString(),"")); drawMainMenu(); } function composeReply(t,n,r) { page = "Compose"; setParametersCompose(new Array(t.toString(),n.toString(),r)); drawMainMenu(); } function setParametersCompose(p) { var tt, tid, trp; tt = p[0] ? p[0] : "p"; tid = p[1] ? p[1] : -1; trp = p[2] ? p[2] : -1; pCompose = new ComposeParameters(tt, tid, trp); if (tid != -1) { x_getTargetName(tt, tid, targetNameReceived); setTimeout('checkComposeReady()', 500); } else { pCompose.ready = true; buildComposePage(); } } function targetNameReceived(data) { pCompose.tText = data; if (pCompose.rId != -1) x_getMessageText(pCompose.rId, gotOriginalMessage); else pCompose.ready = true; } function gotOriginalMessage(data) { var a = data.split('\n'); a.shift(); if (a[0].indexOf('Re:') == 0) pCompose.sText = a.shift(); else pCompose.sText = 'Re: ' + a.shift(); if (a.length > 0) pCompose.rText = a.join('\n'); pCompose.ready = true; } function checkComposeReady() { if (pCompose.ready) buildComposePage(); else setTimeout('checkComposeReady()', 500); } function buildComposePage() { drawComposePage(); document.getElementById('mcmsg').value = pCompose.cText; } function composePageStatus(s) { var allids = new Array('mcmtype', 'mcmto', 'mcmsub', 'mcmsg', 'mcmsend'); var i; for (i=0;i0) { if (udFList) clearTimeout(udFList); x_updateFolders(parseFolderList); } if (i>0||fpBuilding) { fpBuilding = false; buildMessageDisplay(); } } function buildMessageDisplay() {with(folders[vFolder]){ var mcl = messages.length, mcm = mcl % settings[0]; if (mcl == 0) { drawEmptyFolder(); return; } var smet = 'messages.sort(ms_' + settings[1] + '_' + (settings[2] ? "asc" : "desc") + ')'; eval(smet); if (settings[3]) prepareThreading(); var npg = (mcl - mcm) / settings[0] + (mcm > 0 ? 1 : 0); if (settings[4] >= npg) settings[4] = npg - 1; drawPageSelector(npg, settings[4]); drawListHeader(); drawList(); updateControls(); udFolder = setTimeout('getMessageList()', 30000); }} function drawListHeader() {with(folders[vFolder]){ var i, str = ''; str += ''; str += ''; for (i=0;i'; if (settings[1] == t) str += ''; str += colTitles[i]; if (settings[1] == t) { str += '' + (settings[2] ? ' + messages[i].status + ''; str += ''; str += ''; str += ''; str += ''; str += ''; if (messages[i].isopen && messages[i].message != "") { if (messages[i].status == 'N') { messages[i].status = 'r'; nCount--; crc = true; } str += ''; } str += '
 '; if (settings[3]) { var k; for (k=0;k'+messages[i].subject+''; if (messages[i].status == 'N') str += ''; str += '' + formatDate(messages[i].moment) + ''; if (messages[i].slink != "") str += ''; str += messages[i].from; if (messages[i].slink != "") str += ''; str += ''; if (messages[i].rlink != "") str += ''; str += messages[i].to; if (messages[i].rlink != "") str += ''; str += ' 
 

'; str += messages[i].message + '

'; if (messages[i].replink) { str += '[ '; str += replyText + ' ]'; } str += '
 
'; } str += ''; document.getElementById('msglist2').innerHTML = str; if (crc) { drawMainMenu(); updateHeader(); } }} function switchSort(t) {with(folders[vFolder]){ if (settings[1] != t) settings[1] = t; settings[2] = !settings[2]; x_setSortParameters(type, id, settings[1], settings[2] ? "1" : "0", emptyCB); buildMessageDisplay(); }} function setMsgPerPage() {with(folders[vFolder]){ var sel = document.getElementById('fcmpp'), si = sel.selectedIndex; settings[0] = parseInt(sel.options[si].value, 10) * 10; x_setMessagesPerPage(type, id, sel.options[si].value, emptyCB); buildMessageDisplay(); }} function switchThreaded() {with(folders[vFolder]){ settings[3] = !settings[3]; x_switchThreaded(type, id, emptyCB); buildMessageDisplay(); }} function changePage() {with(folders[vFolder]){ var sel = document.getElementById('pgs'), si = sel.selectedIndex; settings[4] = parseInt(sel.options[si].value, 10); buildMessageDisplay(); }} function switchOpen(i) {with(folders[vFolder]){ messages[i].isopen = !messages[i].isopen; if (messages[i].isopen && messages[i].message == "") x_getMessageText(messages[i].id, gotMessageText); else drawList(); }} function gotMessageText(data) { var i, a = data.split('\n'); var mId = a[0].split('#'); if (mId.length == 1) return; idx = findFolder(mId[0], mId[1]); if (idx == -1) return; with (folders[idx]) { for (i=0;i 2) { a.shift(); a.shift(); messages[i].message = a.join('\n'); } else messages[i].message = msgNotFound; } drawList(); } function switchSelection(idx) {with(folders[vFolder]){ messages[idx].selected = !messages[idx].selected; if (!messages[idx].selected && selAll) { selAll = false; document.getElementById('mlsa').checked = false; } updateControls(); }} function switchSelAll() {with(folders[vFolder]){ var i,j=settings[0]*settings[4]; selAll = !selAll; for (i=0;i 0) drawSFControls(fs, cd); else document.getElementById('chgfld').innerHTML = ' '; } function renameFolder(fid) { var i = findFolder("CUS", fid); if (i == -1) return; var nn = ""; while (nn == "") { nn = promptRename(folders[i].name); if (typeof nn == 'object' && !nn) return; if (nn == "") alertFolderName(0); else if (nn.length > 32) { alertFolderName(1); nn = ""; } } if (udFList) clearTimeout(udFList); x_renameFolder(fid, nn, parseFolderList); } function addFolder() { var n = document.getElementById('adfldn').value; if (n == "") { alertFolderName(0); return; } else if (n.length > 32) { alertFolderName(1); return; } if (udFList) clearTimeout(udFList); x_addFolder(n, parseFolderList); } function deleteFolders() { var i, a = new Array(), tm = 0; for (i=0;i 0 && !confirmFDelete(a.length, tm)) return; x_deleteFolders(a.join('#'), parseFolderList); } function flushFolders() { var i, a = new Array(), tm = 0; for (i=0;i