]> hackdaworld.org Git - outofuni/jsutils.git/blob - utils.js
more umlaute and sonderzeichen
[outofuni/jsutils.git] / utils.js
1 /*
2  * utils.js - utility functions
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  */
7
8 function cl(str) {
9         console.log(str);
10 }
11
12 function objdbg(obj) {
13         var msg="debug object:\n";
14         for(var k in obj) {
15                 msg=msg+"--> "+k+": "+obj[k]+"\n";
16         }
17         cl(msg);
18 }
19
20 function anddbg(obj) {
21         var msg="debug object:\n";
22         for(var k in obj) {
23                 msg=msg+"--> "+k+": "+obj[k]+"\n";
24         }
25         alert(msg);
26 }
27
28 function vert_align_text(trg) {
29         $(trg).each(function() {
30                 var lh=$(this).height();
31                 $(this).css('line-height',lh+'px');
32                 $(this).css('vertical-align','middle');
33         });
34 }
35
36 function html2ascii(str) {
37         str=str.replace(/\&Auml\;/g,"Ä");
38         str=str.replace(/\&Ouml\;/g,"Ö");
39         str=str.replace(/\&Uuml\;/g,"Ü");
40         str=str.replace(/\&auml\;/g,"ä");
41         str=str.replace(/\&ouml\;/g,"ö");
42         str=str.replace(/\&uuml\;/g,"ü");
43         str=str.replace(/\&szlig\;/g,"ß");
44         str=str.replace(/\&amp\;/g,"&");
45         return str;
46 }
47
48 function ascii2html(str) {
49         str=str.replace(/&/g,"&");
50         str=str.replace(/Ä/g,"Ä");
51         str=str.replace(/Ö/g,"Ö");
52         str=str.replace(/Ü/g,"Ü");
53         str=str.replace(/ä/g,"ä");
54         str=str.replace(/ö/g,"ö");
55         str=str.replace(/ü/g,"ü");
56         str=str.replace(/ß/g,"ß");
57         return str;
58 }
59