From 390959bb323679f7611ee1585d8e1f55007c7773 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 22 Apr 2012 13:24:06 -0400
Subject: [PATCH] - Small code improvements

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

diff --git a/program/js/app.js b/program/js/app.js
index 038a3c7..9521fb9 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3266,20 +3266,11 @@
   this.compose_field_hash = function(save)
   {
     // check input fields
-    var ed, str = '',
-      value_to = $("[name='_to']").val(),
-      value_cc = $("[name='_cc']").val(),
-      value_bcc = $("[name='_bcc']").val(),
-      value_subject = $("[name='_subject']").val();
+    var ed, i, val, str = '', hash_fields = ['to', 'cc', 'bcc', 'subject'];
 
-    if (value_to)
-      str += value_to+':';
-    if (value_cc)
-      str += value_cc+':';
-    if (value_bcc)
-      str += value_bcc+':';
-    if (value_subject)
-      str += value_subject+':';
+    for (i=0; i<hash_fields.length; i++)
+      if (val = $('[name="_' + hash_fields[i] + '"]').val())
+        str += val + ':';
 
     if (window.tinyMCE && (ed = tinyMCE.get(this.env.composebody)))
       str += ed.getContent();
@@ -6233,12 +6224,15 @@
   // starts interval for keep-alive/check-recent signal
   this.start_keepalive = function()
   {
+    if (!this.env.keep_alive || this.env.framed)
+      return;
+
     if (this._int)
       clearInterval(this._int);
 
-    if (this.env.keep_alive && !this.env.framed && this.task == 'mail' && this.gui_objects.mailboxlist)
+    if (this.task == 'mail' && this.gui_objects.mailboxlist)
       this._int = setInterval(function(){ ref.check_for_recent(false); }, this.env.keep_alive * 1000);
-    else if (this.env.keep_alive && !this.env.framed && this.task != 'login' && this.env.action != 'print')
+    else if (this.task != 'login' && this.env.action != 'print')
       this._int = setInterval(function(){ ref.keep_alive(); }, this.env.keep_alive * 1000);
   };
 
@@ -6299,7 +6293,7 @@
       return obj.selectionEnd;
     else if (document.selection && document.selection.createRange) {
       var range = document.selection.createRange();
-      if (range.parentElement()!=obj)
+      if (range.parentElement() != obj)
         return 0;
 
       var gm = range.duplicate();

--
Gitblit v1.9.1