small fixes from previous
[platal.git] / htdocs / javascript / flyspray.js
1 /***************************************************************************
2 * Copyright (C) 2003-2006 Polytechnique.org *
3 * http://opensource.polytechnique.org/ *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************/
20
21 function send_bug() {
22 document.getElementById('flyspray_report').style.display = 'block';
23 return false;
24 }
25
26 function close_bug(f,send) {
27 var detail = document.getElementById('flyspray_detail');
28 detail.value = utf8(detail.value);
29 var title = document.getElementById('flyspray_title');
30 title.value = utf8(title.value);
31 if (send) {
32 f.target = '_blank';
33 f.submit();
34 }
35 f.reset();
36 document.getElementById('flyspray_report').style.display = 'none';
37 }
38
39 function utf8(isotext)
40 {
41 var utf8text = "";
42 for ( i=0; i<isotext.length; i++ )
43 {
44 unicodchar = isotext.charCodeAt(i);
45
46 if(unicodchar < 128){
47 utf8text += String.fromCharCode(unicodchar);
48 } else if(unicodchar < 0x800) {
49 var val1 = 0xC0 + (unicodchar & 0x7C0) / 0x40; // 0011111000000
50 var val2 = 0x80 + (unicodchar & 0x3F); // 0000000111111
51 utf8text += String.fromCharCode(val1,val2);
52 } else if(unicodchar < 0x10000) {
53 var val1 = 0xE0 + (unicodchar & 0xF000) / 0x1000; // 001111000000000000
54 var val2 = 0x80 + (unicodchar & 0xFC0) / 0x40; // 000000111111000000
55 var val3 = 0x80 + (unicodchar & 0x3F); // 000000000000111111
56 utf8text += String.fromCharCode(val1,val2, val3);
57 } else if(unicodchar < 0x200000){
58 var val4 = 0x80 + (unicodchar & 0x1C0000) / 0x40000;// 00111000000000000000000
59 var val2 = 0x80 + (unicodchar & 0x3F000) / 0x1000; // 00000111111000000000000
60 var val3 = 0x80 + (unicodchar & 0xFC0) / 0x40; // 00000000000111111000000
61 var val4 = 0x80 + (unicodchar & 0x3F); // 00000000000000000111111
62 utf8text += String.fromCharCode(val1,val2, val3, val4);
63 }
64 }
65 return utf8text;
66 }