7f8bf077 |
1 | /***************************************************************************\r |
2 | * Copyright (C) 2003-2006 Polytechnique.org *\r |
3 | * http://opensource.polytechnique.org/ *\r |
4 | * *\r |
5 | * This program is free software; you can redistribute it and/or modify *\r |
6 | * it under the terms of the GNU General Public License as published by *\r |
7 | * the Free Software Foundation; either version 2 of the License, or *\r |
8 | * (at your option) any later version. *\r |
9 | * *\r |
10 | * This program is distributed in the hope that it will be useful, *\r |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *\r |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\r |
13 | * GNU General Public License for more details. *\r |
14 | * *\r |
15 | * You should have received a copy of the GNU General Public License *\r |
16 | * along with this program; if not, write to the Free Software *\r |
17 | * Foundation, Inc., *\r |
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *\r |
19 | ***************************************************************************/\r |
20 | \r |
21 | function send_bug() {\r |
c3f52cc3 |
22 | var h = windowHeight();\r |
23 | var y = getScrollY();\r |
24 | y += (h - 470) /2;\r |
7f8bf077 |
25 | document.getElementById('flyspray_report').style.display = 'block';\r |
c3f52cc3 |
26 | document.getElementById('flyspray_report').style.top = y+'px';\r |
7f8bf077 |
27 | return false;\r |
28 | }\r |
29 | \r |
c3f52cc3 |
30 | function getScrollY() {\r |
31 | var scrOfX = 0, scrOfY = 0;\r |
32 | if( typeof( window.pageYOffset ) == 'number' ) {\r |
33 | //Netscape compliant\r |
34 | scrOfY = window.pageYOffset;\r |
35 | } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {\r |
36 | //DOM compliant\r |
37 | scrOfY = document.body.scrollTop;\r |
38 | } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {\r |
39 | //IE6 standards compliant mode\r |
40 | scrOfY = document.documentElement.scrollTop;\r |
41 | }\r |
42 | return scrOfY;\r |
43 | }\r |
44 | function windowHeight() {\r |
45 | if( typeof( window.innerWidth ) == 'number' ) {\r |
46 | //Non-IE\r |
47 | return window.innerHeight;\r |
48 | } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {\r |
49 | return document.documentElement.clientHeight;\r |
50 | } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {\r |
51 | //IE 4 compatible\r |
52 | return document.body.clientHeight;\r |
53 | }\r |
54 | return 0;\r |
55 | }\r |
56 | \r |
7f8bf077 |
57 | function close_bug(f,send) {\r |
58 | var detail = document.getElementById('flyspray_detail');\r |
59 | detail.value = utf8(detail.value);\r |
60 | var title = document.getElementById('flyspray_title');\r |
61 | title.value = utf8(title.value);\r |
62 | if (send) {\r |
63 | f.target = '_blank';\r |
64 | f.submit();\r |
65 | }\r |
66 | f.reset();\r |
67 | document.getElementById('flyspray_report').style.display = 'none';\r |
68 | }\r |
69 | \r |
70 | function utf8(isotext)\r |
71 | {\r |
72 | var utf8text = "";\r |
73 | for ( i=0; i<isotext.length; i++ )\r |
74 | {\r |
75 | unicodchar = isotext.charCodeAt(i);\r |
76 | \r |
77 | if(unicodchar < 128){\r |
78 | utf8text += String.fromCharCode(unicodchar);\r |
79 | } else if(unicodchar < 0x800) {\r |
80 | var val1 = 0xC0 + (unicodchar & 0x7C0) / 0x40; // 0011111000000\r |
81 | var val2 = 0x80 + (unicodchar & 0x3F); // 0000000111111\r |
82 | utf8text += String.fromCharCode(val1,val2);\r |
83 | } else if(unicodchar < 0x10000) {\r |
84 | var val1 = 0xE0 + (unicodchar & 0xF000) / 0x1000; // 001111000000000000\r |
85 | var val2 = 0x80 + (unicodchar & 0xFC0) / 0x40; // 000000111111000000\r |
86 | var val3 = 0x80 + (unicodchar & 0x3F); // 000000000000111111\r |
87 | utf8text += String.fromCharCode(val1,val2, val3);\r |
88 | } else if(unicodchar < 0x200000){\r |
89 | var val4 = 0x80 + (unicodchar & 0x1C0000) / 0x40000;// 00111000000000000000000\r |
90 | var val2 = 0x80 + (unicodchar & 0x3F000) / 0x1000; // 00000111111000000000000\r |
91 | var val3 = 0x80 + (unicodchar & 0xFC0) / 0x40; // 00000000000111111000000\r |
92 | var val4 = 0x80 + (unicodchar & 0x3F); // 00000000000000000111111\r |
93 | utf8text += String.fromCharCode(val1,val2, val3, val4);\r |
94 | }\r |
95 | }\r |
96 | return utf8text;\r |
97 | }\r |