From 6649b1f0a5db6160d197a13ca79cfd67fbb02d77 Mon Sep 17 00:00:00 2001 From: svncommit <devs@roundcube.net> Date: Sat, 23 Sep 2006 19:37:29 -0400 Subject: [PATCH] added TinyMCE spellchecker plugin, configured to use GoogleSpell --- program/js/common.js | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 105 insertions(+), 3 deletions(-) diff --git a/program/js/common.js b/program/js/common.js index 2d2c2e9..b0dc556 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -6,11 +6,11 @@ | Copyright (C) 2005, RoundCube Dev, - Switzerland | | Licensed under the GNU GPL | | | - | Modified: 19.08.2005 (tbr) | - | | +-----------------------------------------------------------------------+ | Author: Thomas Bruederli <roundcube@gmail.com> | +-----------------------------------------------------------------------+ + + $Id$ */ @@ -81,6 +81,14 @@ (this.ie && this.win && this.vendver>=5.5) || this.safari); this.opacity = (this.mz || (this.ie && this.vendver>=5.5 && !this.opera) || (this.safari && this.vendver>=100)); this.cookies = navigator.cookieEnabled; + + // test for XMLHTTP support + this.xmlhttp_test = function() + { + var activeX_test = new Function("try{var o=new ActiveXObject('Microsoft.XMLHTTP');return true;}catch(err){return false;}"); + this.xmlhttp = (window.XMLHttpRequest || (window.ActiveXObject && activeX_test())) ? true : false; + return this.xmlhttp; + } } @@ -255,7 +263,63 @@ } } +// check if input is a valid email address +// By Cal Henderson <cal@iamcal.com> +// http://code.iamcal.com/php/rfc822/ +function rcube_check_email(input, inline) + { + if (input && window.RegExp) + { + var no_ws_ctl = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]"; + var alpha = "[\\x41-\\x5a\\x61-\\x7a]"; + var digit = "[\\x30-\\x39]"; + var cr = "\\x0d"; + var lf = "\\x0a"; + var crlf = "(" + cr + lf + ")"; + var obs_char = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]"; + var obs_text = "("+lf+"*"+cr+"*("+obs_char+lf+"*"+cr+"*)*)"; + var text = "([\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|"+obs_text+")"; + var obs_qp = "(\\x5c[\\x00-\\x7f])"; + var quoted_pair = "(\\x5c"+text+"|"+obs_qp+")"; + + var wsp = "[\\x20\\x09]"; + var obs_fws = "("+wsp+"+("+crlf+wsp+"+)*)"; + var fws = "((("+wsp+"*"+crlf+")?"+wsp+"+)|"+obs_fws+")"; + var ctext = "("+no_ws_ctl+"|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])"; + var ccontent = "("+ctext+"|"+quoted_pair+")"; + var comment = "(\\x28("+fws+"?"+ccontent+")*"+fws+"?\\x29)"; + var cfws = "(("+fws+"?"+comment+")*("+fws+"?"+comment+"|"+fws+"))"; + var cfws = fws+"*"; + + var atext = "("+alpha+"|"+digit+"|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2e\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])"; + var atom = "("+cfws+"?"+atext+"+"+cfws+"?)"; + + var qtext = "("+no_ws_ctl+"|[\\x21\\x23-\\x5b\\x5d-\\x7e])"; + var qcontent = "("+qtext+"|"+quoted_pair+")"; + var quoted_string = "("+cfws+"?\\x22("+fws+"?"+qcontent+")*"+fws+"?\\x22"+cfws+"?)"; + var word = "("+atom+"|"+quoted_string+")"; + + var obs_local_part = "("+word+"(\\x2e"+word+")*)"; + var obs_domain = "("+atom+"(\\x2e"+atom+")*)"; + + var dot_atom_text = "("+atext+"+(\\x2e"+atext+"+)*)"; + var dot_atom = "("+cfws+"?"+dot_atom_text+cfws+"?)"; + + var dtext = "("+no_ws_ctl+"|[\\x21-\\x5a\\x5e-\\x7e])"; + var dcontent = "("+dtext+"|"+quoted_pair+")"; + var domain_literal = "("+cfws+"?\\x5b("+fws+"?"+dcontent+")*"+fws+"?\\x5d"+cfws+"?)"; + + var local_part = "("+dot_atom+"|"+quoted_string+"|"+obs_local_part+")"; + var domain = "("+dot_atom+"|"+domain_literal+"|"+obs_domain+")"; + var addr_spec = "("+local_part+"\\x40"+domain+")"; + + var reg1 = inline ? new RegExp(addr_spec, 'i') : new RegExp('^'+addr_spec+'$', 'i'); + return reg1.test(input) ? true : false; + } + return false; + } + // find a value in a specific array and returns the index function find_in_array() @@ -277,6 +341,13 @@ return -1; } + + +// make a string URL safe +function urlencode(str) +{ + return window.encodeURI ? encodeURI(str).replace(/&/g, '%26') : escape(str); +} // get any type of html objects by id/name @@ -342,5 +413,36 @@ return {x:iX, y:iY}; } + -var bw = new roundcube_browser(); \ No newline at end of file +// cookie functions by GoogieSpell +function setCookie(name, value, expires, path, domain, secure) + { + var curCookie = name + "=" + escape(value) + + (expires ? "; expires=" + expires.toGMTString() : "") + + (path ? "; path=" + path : "") + + (domain ? "; domain=" + domain : "") + + (secure ? "; secure" : ""); + document.cookie = curCookie; + } + +function getCookie(name) + { + var dc = document.cookie; + var prefix = name + "="; + var begin = dc.indexOf("; " + prefix); + if (begin == -1) + { + begin = dc.indexOf(prefix); + if (begin != 0) return null; + } + else + begin += 2; + var end = document.cookie.indexOf(";", begin); + if (end == -1) + end = dc.length; + return unescape(dc.substring(begin + prefix.length, end)); + } + + +var bw = new roundcube_browser(); -- Gitblit v1.9.1