4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @author Behrooz shabani (everplays) - <behrooz@rock.com>
20 * @copyright 2009-2010 Behrooz shabani
21 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
26 $.fn.isRTL = function(str){
27 if(typeof str != typeof "" || str.length<1)
29 var cc = str.charCodeAt(0);
30 if(cc>=1536 && cc<=1791) // arabic, persian, ...
32 if(cc>=65136 && cc<=65279) // arabic peresent 2
34 if(cc>=64336 && cc<=65023) // arabic peresent 1
36 if(cc>=1424 && cc<=1535) // hebrew
38 if(cc>=64256 && cc<=64335) // hebrew peresent
40 if(cc>=1792 && cc<=1871) // Syriac
42 if(cc>=1920 && cc<=1983) // Thaana
44 if(cc>=1984 && cc<=2047) // NKo
46 if(cc>=11568 && cc<=11647) // Tifinagh
50 $(document).ready(function(){
51 var tArea = $("#notice_data-text");
52 var tCleaner = new RegExp('@[^ ]+|![^ ]+|#[^ ]+|^RT[: ]{1}| RT | RT: |^RD[: ]{1}| RD | RD: |[♺♻:]+', 'g')
53 tArea.keyup(function(){
54 var cleaned = tArea.val().replace(tCleaner, '').replace(/^[ ]+/, '');
55 if($().isRTL(cleaned))
56 tArea.css('direction', 'rtl');
58 tArea.css('direction', 'ltr');