1/******************************************************************************* 2 Filename : shared.lib.js 3 4 Created : 08.07.2014 5 Created by : Michael Hagi 6 7 Last Updated : 08.07.2014 8 Updated by : Michael Hagi 9 10 Comments : Verschiedene global genutzte JS-Funktionen 11*******************************************************************************/ 12 13 14/* 15 BESTAETIGUNGSDIALOG MIT WEITERLEITUNG 16 Ausgabemeldung anzeigen und bei Bestaetigung auf url weiterleiten 17 @param: msg = Ausgabemeldung/Hinweis 18 @param: url = Pfad/URI 19*/ 20 21function fns_confirmMessage(msg,url) { 22 if (url && msg) { 23 tmp = confirm(msg); 24 if (tmp == true) { 25 location.replace(url); 26 } 27 } 28} 29 30function fns_confirmMessageAsync(msg,url,imgID) { 31 if (url && msg) { 32 tmp = confirm(msg); 33 if (tmp == true) { 34 35 $.ajax({ 36 url: url, 37 type: 'GET', 38 success: function(res) { 39 $('.'+ imgID ).hide(); 40 } 41 }); 42 43 } 44 } 45} 46 47/* 48 DECODEEMAIL 49 Entschluesselt mit fns_base64 codierte Werte (E-Mail-Adressen). Schutz vor Spam-Bots 50 @param: base64string 51 @param: option = link|blank (leer) 52 @call: <a href="javascript:fns_base64_decodeEmail('base64string','option');"><?php echo base64_decode('base64string-from-php');?></a> 53*/ 54 55function fns_base64_decodeEmail(base64string,option) { 56 /* --- Entschluesselung des gelieferten Strings --- */ 57 decodedValue = fns_base64.decode(base64string); 58 /* --- Search & Replace (at) to @ um E-Mails wirklich versenden zu koennen --- */ 59 Search = new Array("(at)"); 60 Replace = new Array ("@"); 61 if (option == "link") 62 { 63 for (var i = 0; i <= Search.length-1; i++) 64 { 65 for (var j = 0; j <= decodedValue.length; j++) 66 { 67 decodedValue = decodedValue.replace(Search[i],Replace[i]); 68 } 69 } 70 location.href='mailto:' + decodedValue; 71 } 72 else 73 { 74 return decodedValue; 75 } 76} 77 78function fns_decodeM(name,subject,body,domain) { 79 loc = 'mailto:' + name + '@' + domain + '?subject=' + subject; 80 if (body) { 81 loc = loc + '&body=' + body; 82 } 83 location.href = loc; 84} 85 86/* 87 fns_base64 ENCODE/DECODE 88 Verschluesselt in fns_base64 und entschluesselt fns_base64 89 @param: @call = encode|decode 90 @call: fns_base64.encode('Werte') | fns_base64.decode('Wert)' 91*/ 92 93var fns_base64 = { 94 95 // private property 96 _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 97 98 // public method for encoding 99 encode : function (input) { 100 var output = ""; 101 var chr1, chr2, chr3, enc1, enc2, enc3, enc4; 102 var i = 0; 103 104 input = fns_base64._utf8_encode(input); 105 106 while (i < input.length) { 107 108 chr1 = input.charCodeAt(i++); 109 chr2 = input.charCodeAt(i++); 110 chr3 = input.charCodeAt(i++); 111 112 enc1 = chr1 >> 2; 113 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 114 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 115 enc4 = chr3 & 63; 116 117 if (isNaN(chr2)) { 118 enc3 = enc4 = 64; 119 } else if (isNaN(chr3)) { 120 enc4 = 64; 121 } 122 123 output = output + 124 this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + 125 this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); 126 127 } 128 129 return output; 130 }, 131 132 // public method for decoding 133 decode : function (input) { 134 var output = ""; 135 var chr1, chr2, chr3; 136 var enc1, enc2, enc3, enc4; 137 var i = 0; 138 139 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 140 141 while (i < input.length) { 142 143 enc1 = this._keyStr.indexOf(input.charAt(i++)); 144 enc2 = this._keyStr.indexOf(input.charAt(i++)); 145 enc3 = this._keyStr.indexOf(input.charAt(i++)); 146 enc4 = this._keyStr.indexOf(input.charAt(i++)); 147 148 chr1 = (enc1 << 2) | (enc2 >> 4); 149 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 150 chr3 = ((enc3 & 3) << 6) | enc4; 151 152 output = output + String.fromCharCode(chr1); 153 154 if (enc3 != 64) { 155 output = output + String.fromCharCode(chr2); 156 } 157 if (enc4 != 64) { 158 output = output + String.fromCharCode(chr3); 159 } 160 161 } 162 163 output = fns_base64._utf8_decode(output); 164 165 return output; 166 167 }, 168 169 // private method for UTF-8 encoding 170 _utf8_encode : function (string) {
171 string = string.replace(/\r\n/g,"\n"); 172 var utftext = ""; 173 174 for (var n = 0; n < string.length; n++) { 175 176 var c = string.charCodeAt(n); 177 178 if (c < 128) { 179 utftext += String.fromCharCode(c); 180 } 181 else if((c > 127) && (c < 2048)) { 182 utftext += String.fromCharCode((c >> 6) | 192); 183 utftext += String.fromCharCode((c & 63) | 128); 184 } 185 else { 186 utftext += String.fromCharCode((c >> 12) | 224); 187 utftext += String.fromCharCode(((c >> 6) & 63) | 128); 188 utftext += String.fromCharCode((c & 63) | 128); 189 } 190 191 } 192 193 return utftext; 194 }, 195 196 // private method for UTF-8 decoding 197 _utf8_decode : function (utftext) { 198 var string = ""; 199 var i = 0; 200 var c = c1 = c2 = 0; 201 202 while ( i < utftext.length ) { 203 204 c = utftext.charCodeAt(i); 205 206 if (c < 128) { 207 string += String.fromCharCode(c); 208 i++; 209 } 210 else if((c > 191) && (c < 224)) { 211 c2 = utftext.charCodeAt(i+1); 212 string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); 213 i += 2; 214 } 215 else { 216 c2 = utftext.charCodeAt(i+1); 217 c3 = utftext.charCodeAt(i+2); 218 string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); 219 i += 3; 220 } 221 222 } 223 224 return string; 225 } 226 227} 228 229fns_OpenPrintPreview = function(width, height, name){ 230 231 var name = name || 'printpreview'; 232 233 /* ANPASSUNG FÃR SOURCE PRETTY URLs */ 234 var url = ''; 235 if (/[0-9]+_.*/.test(location.href) && !/.php/.test(location.href)) { 236 url = location.href.replace(/#.*/, '') + '&viewmode=print'; 237 } else { 238 url = location.href.indexOf('?') == -1 ? location.href.replace(/#.*/, '') + '?viewmode=print' : location.href.replace(/#.*/, '') + '&viewmode=print'; 239 } 240 options = ',location=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,status=no'; 241 242 wOpenPopupURL(url, width, height, name, options); 243};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.