From a95e0e174c48b7c5242b8969aef99838a52c41ee Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 21 Oct 2005 08:12:23 -0400
Subject: [PATCH] Improved support for UTF-8 and other charsets

---
 program/js/app.js |   45 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index fb0c455..1e70c42 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1,4 +1,4 @@
-/*
+/*
  +-----------------------------------------------------------------------+
  | RoundCube Webmail Client Script                                       |
  |                                                                       |
@@ -6,7 +6,7 @@
  | Copyright (C) 2005, RoundCube Dev, - Switzerland                      |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
- | Modified: 2005/10/13 (tbr)                                            |
+ | Modified: 2005/10/21 (roundcube)                                      |
  |                                                                       |
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
@@ -31,6 +31,7 @@
   // webmail client settings
   this.dblclick_time = 600;
   this.message_time = 5000;
+  this.request_timeout = 120000;
   this.mbox_expression = new RegExp('[^0-9a-z\-_]', 'gi');
   this.env.blank_img = 'skins/default/images/blank.gif';
   
@@ -76,8 +77,7 @@
     this.task = this.env.task;
     
     // check browser
-    if (!(bw.dom && ((bw.ie && bw.vendver>=5.5 && !bw.opera) || (bw.mz && bw.vendver>=1) || (bw.safari && bw.vendver>=125) ||
-                     (bw.opera && bw.vendver>=8) || (bw.konq && bw.vendver>=3.4))))
+    if (!bw.dom || !bw.xmlhttp_test())
       {
       location.href = this.env.comm_path+'&_action=error&_code=0x199';
       return;
@@ -204,7 +204,7 @@
 
     // flag object as complete
     this.loaded = true;
-      
+          
     // show message
     if (this.pending_message)
       this.display_message(this.pending_message[0], this.pending_message[1]);
@@ -732,6 +732,7 @@
     };
 
 
+  // lock/unlock interface
   this.set_busy = function(a, message)
     {
     if (a && message)
@@ -744,6 +745,14 @@
     
     if (this.gui_objects.editform)
       this.lock_form(this.gui_objects.editform, a);
+      
+    // clear pending timer
+    if (this.request_timer)
+      clearTimeout(this.request_timer);
+
+    // set timer for requests
+    if (a && this.request_timeout)
+      this.request_timer = setTimeout(this.ref+'.request_timed_out()', this.request_timeout);
     };
 
 
@@ -763,6 +772,14 @@
       url = this.env.comm_path;
 
     return url.replace(/_task=[a-z]+/, '_task='+task);
+    };
+    
+  
+  // called when a request timed out
+  this.request_timed_out = function()
+    {
+    this.set_busy(false);
+    this.display_message('Request timed out!', 'error');
     };
 
 
@@ -1006,6 +1023,7 @@
     if (!page && mbox != this.env.mailbox)
       {
       page = 1;
+      add_url += '&_refresh=1';
       this.env.current_page = page;
       this.clear_selection();
       }
@@ -1016,14 +1034,14 @@
     // load message list remotely
     if (this.gui_objects.messagelist)
       {
-      this.list_mailbox_remote(mbox, page);
+      this.list_mailbox_remote(mbox, page, add_url);
       return;
       }
     
     if (this.env.contentframe && window.frames && window.frames[this.env.contentframe])
       {
       target = window.frames[this.env.contentframe];
-      add_url = '&_framed=1';
+      add_url += '&_framed=1';
       }
 
     // load message list to target frame/window
@@ -1036,7 +1054,7 @@
 
 
   // send remote request to load message list
-  this.list_mailbox_remote = function(mbox, page)
+  this.list_mailbox_remote = function(mbox, page, add_url)
     {
     // clear message list
     var table = this.gui_objects.messagelist;
@@ -1050,7 +1068,7 @@
     // send request to server
     var url = '_mbox='+escape(mbox)+(page ? '&_page='+page : '');
     this.set_busy(true, 'loading');
-    this.http_request('list', url);
+    this.http_request('list', url+add_url);
     };
 
 
@@ -1967,9 +1985,13 @@
     var cont = msg;
     if (type)
       cont = '<div class="'+type+'">'+cont+'</div>';
-      
+
+    this.gui_objects.message._rcube = this;
     this.gui_objects.message.innerHTML = cont;
     this.gui_objects.message.style.display = 'block';
+    
+    if (type!='loading')
+      this.gui_objects.message.onmousedown = function(){ this._rcube.hide_message(); return true; };
     
     if (!hold)
       this.message_timer = setTimeout(this.ref+'.hide_message()', this.message_time);
@@ -1980,7 +2002,10 @@
   this.hide_message = function()
     {
     if (this.gui_objects.message)
+      {
       this.gui_objects.message.style.display = 'none';
+      this.gui_objects.message.onmousedown = null;
+      }
     };
 
 

--
Gitblit v1.9.1