From bfbffd1d5a97eef8f67f43a718d5742e30aef1df Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 13 Feb 2005 02:22:54 +0000 Subject: [PATCH] implemented async read/unread marking git-svn-id: http://svn.opengroupware.org/SOGo/trunk@551 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/Mailer/ChangeLog | 3 ++ SOGo/UI/Mailer/UIxMailListView.m | 34 +++++++++++++ SOGo/UI/Mailer/UIxMailListView.wox | 4 +- SOGo/UI/Mailer/Version | 2 +- SOGo/UI/Mailer/mailer.js | 80 ++++++++++++++++-------------- 5 files changed, 83 insertions(+), 40 deletions(-) diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 092e698c..0a2cd6e2 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,8 @@ 2005-02-13 Helge Hess + * UIxMailListView.wox: added mark read/unread without page refresh + using XMLHttpRequest (v0.9.103) + * product.plist, UIxMailListView.wox, mailer.js: added bulk reply/replyall/forward (v0.9.102) diff --git a/SOGo/UI/Mailer/UIxMailListView.m b/SOGo/UI/Mailer/UIxMailListView.m index 08b0341b..85683e80 100644 --- a/SOGo/UI/Mailer/UIxMailListView.m +++ b/SOGo/UI/Mailer/UIxMailListView.m @@ -340,10 +340,14 @@ static int attachmentFlagSize = 8096; return [NSString stringWithFormat:@"clickedUid(this, '%@'); return false", [self messageUidString]]; } + +// the following are unused? - (NSString *)dblClickedMsgJS { return [NSString stringWithFormat:@"doubleClickedUid(this, '%@')", [self messageUidString]]; } + +// the following are unused? - (NSString *)highlightRowJS { return [NSString stringWithFormat:@"highlightUid(this, '%@')", [self messageUidString]]; @@ -353,6 +357,19 @@ static int attachmentFlagSize = 8096; [self messageUidString]]; } +- (NSString *)markUnreadJS { + return [NSString stringWithFormat: + @"mailListMarkMessage(this, 'markMessageUnread', " + @"'%@', false)", + [self messageUidString]]; +} +- (NSString *)markReadJS { + return [NSString stringWithFormat: + @"mailListMarkMessage(this, 'markMessageRead', " + @"'%@', true)", + [self messageUidString]]; +} + - (NSString *)jsCode { static NSString *script = \ @"var rowSelectionCount = 0;\n" @@ -421,12 +438,26 @@ static int attachmentFlagSize = 8096; return self; } +- (BOOL)isJavaScriptRequest { + return [[[[self context] request] formValueForKey:@"jsonly"] boolValue]; +} +- (id)javaScriptOK { + WOResponse *r; + + r = [[self context] response]; + [r setStatus:200 /* OK */]; + return r; +} + - (id)markMessageUnreadAction { NSException *error; if ((error = [[self lookupActiveMessage] removeFlags:@"seen"]) != nil) // TODO: improve error handling return error; + + if ([self isJavaScriptRequest]) + return [self javaScriptOK]; return [self redirectToLocation:@"view"]; } @@ -437,6 +468,9 @@ static int attachmentFlagSize = 8096; // TODO: improve error handling return error; + if ([self isJavaScriptRequest]) + return [self javaScriptOK]; + return [self redirectToLocation:@"view"]; } diff --git a/SOGo/UI/Mailer/UIxMailListView.wox b/SOGo/UI/Mailer/UIxMailListView.wox index 16abefd0..e82c07fd 100644 --- a/SOGo/UI/Mailer/UIxMailListView.wox +++ b/SOGo/UI/Mailer/UIxMailListView.wox @@ -132,13 +132,13 @@
-
-
diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index ceaa66e5..c230851e 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=102 +SUBMINOR_VERSION:=103 # v0.9.100 requires libNGMime v4.5.213 # v0.9.99 requires libNGMime v4.5.212 diff --git a/SOGo/UI/Mailer/mailer.js b/SOGo/UI/Mailer/mailer.js index a01927a9..0a4f06cc 100644 --- a/SOGo/UI/Mailer/mailer.js +++ b/SOGo/UI/Mailer/mailer.js @@ -32,36 +32,6 @@ function doubleClickedUid(sender, msguid) { return false; } -function highlightUid(sender, msguid) { - // var row = document.getElementById(msguid); - // row.className="mailer_readmailsubject_high"; - return true; -} -function lowlightUid(sender, msguid) { - // var row = document.getElementById(msguid); - // row.className="mailer_readmailsubject"; - return true; -} - -function singleClickedTableRow(clickEvent, sender) { - var rowid = sender.id; - var field; - - field = document.forms['pageform'].elements[rowid]; - if (field.value == "1") { - field.value = "0"; - sender.className = "tableview"; - } - else { - field.value = "1"; - sender.className = "tableview_selected"; - } -} -function doubleClickedTableRow(clickEvent, sender) { - var rowid = sender.id; - resetSelection(window); -} - function toggleMailSelect(sender) { var row; row = document.getElementById(sender.name); @@ -203,7 +173,7 @@ function clickedNewFilter(sender) { /* generic stuff */ -function getHTTPClient() { +function createHTTPClient() { // http://developer.apple.com/internet/webcontent/xmlhttpreq.html if (typeof XMLHttpRequest != "undefined") return new XMLHttpRequest(); @@ -267,23 +237,35 @@ function triggerOpenerCallback() { /* mail list DOM changes */ -function markMailReadInWindow(win, msguid) { +function markMailInWindow(win, msguid, markread) { var msgDiv; msgDiv = win.document.getElementById("div_" + msguid); if (msgDiv) { - msgDiv.className = "mailer_readmailsubject"; + if (markread) { + msgDiv.className = "mailer_readmailsubject"; - msgDiv = win.document.getElementById("unreaddiv_" + msguid); - if (msgDiv) msgDiv.style.display = "none"; - msgDiv = win.document.getElementById("readdiv_" + msguid); - if (msgDiv) msgDiv.style.display = "block"; + msgDiv = win.document.getElementById("unreaddiv_" + msguid); + if (msgDiv) msgDiv.style.display = "none"; + msgDiv = win.document.getElementById("readdiv_" + msguid); + if (msgDiv) msgDiv.style.display = "block"; + } + else { + msgDiv.className = "mailer_unreadmailsubject"; + msgDiv = win.document.getElementById("readdiv_" + msguid); + if (msgDiv) msgDiv.style.display = "none"; + msgDiv = win.document.getElementById("unreaddiv_" + msguid); + if (msgDiv) msgDiv.style.display = "block"; + } return true; } else return false; } +function markMailReadInWindow(win, msguid) { + return markMailInWindow(win, msguid, true); +} /* main window */ @@ -313,3 +295,27 @@ function openMessageWindowsForSelection(sender, action) { for (var i = 0; i < rows.length; i++) win = openMessageWindow(sender, rows[i], rows[i] + "/" + action); } + +function mailListMarkMessage(sender, action, msguid, markread) { + var url; + var http = createHTTPClient(); + + url = action + "?uid=" + msguid; + + if (http) { + // TODO: add parameter to signal that we are only interested in OK + http.open("GET", url + "&jsonly=1", false); + http.send(null); + if (http.status != 200) { + // TODO: refresh page? + alert("Message Mark Failed: " + http.statusText); + window.opener.location.reload(); + } + else { + markMailInWindow(window, msguid, markread); + } + } + else { + window.opener.location.href = url; + } +} -- 2.39.5