1var agTextToSpeechTexte = false; 2jQuery(document).ready(function(){ 3 agBrowserDetection(); 4// if( jQuery.browser.safari || jQuery.browser.chrome ){ 5 if( true ){ 6 7 jQuery(".agTextToSpeechBlock").each(function(i,e){ 8 var agTextToSpeechBtn = jQuery(e).find(".agTextToSpeechButton"); 9 10 var wrapper = false; 11 var parent = jQuery(e).parent(); 12 if( parent.is(".fusion-column-wrapper") ){ 13 wrapper = parent; 14 }else if( parent.is(".fusion-row") ){ 15 wrapper = parent; 16 } 17 18 if( wrapper ){ 19 var targetElement = false; 20 var h1 = wrapper.find("h1:first"); 21 var h2 = wrapper.find("h2:first"); 22 var h3 = wrapper.find("h3:first"); 23 var h4 = wrapper.find("h4:first"); 24 var h5 = wrapper.find("h5:first"); 25 var h6 = wrapper.find("h6:first"); 26 var ul = wrapper.find("ul:first"); 27 var layer = wrapper.find(".ls-wp-container"); 28 if( h1.length >= 1 && !targetElement ){ targetElement = h1; } 29 if( h2.length >= 1 && !targetElement ){ targetElement = h2; } 30 if( h3.length >= 1 && !targetElement ){ targetElement = h3; } 31 if( h4.length >= 1 && !targetElement ){ targetElement = h4; } 32 if( h5.length >= 1 && !targetElement ){ targetElement = h5; } 33 if( h6.length >= 1 && !targetElement ){ targetElement = h6; } 34 if( ul.length >= 1 && !targetElement ){ targetElement = ul; } 35 if( layer.length >= 1 && !targetElement ){ targetElement = layer; } 36 37 if( targetElement ){ 38 // targetElement.append( " " ); 39 if( targetElement.is("ul") ){ 40 jQuery(e).wrap('<li class="fusion-li-item"></li>'); 41 jQuery(e).parent().prependTo( targetElement ); 42 }else if( targetElement.is(".ls-wp-container") ){ 43 jQuery(e).addClass( 'agTextToSpeechLayer' ); 44 }else{ 45 targetElement.append( jQuery(e) ); 46 targetElement.parent().find("br").remove(); 47 } 48 jQuery(e).css("display", "inline"); 49 } 50 } 51 52 53 window.setTimeout(function(){ 54 window.setTimeout(function(){ 55 jQuery(e).animate({ 56 opacity: 1 57 }, 500); 58 }, i*500); 59 }, 1000); 60 61 agTextToSpeechBtn.click(function(){ 62 var type = jQuery(this).data("type"); 63 var text = ''; 64 65 if( typeof type == "undefined" ){ return false; } 66 67 if( type == 'read' ){ 68 var readClass = jQuery(this).data("readclass"); 69 if( typeof readClass == "undefined" ){ return false; } 70 if( jQuery("."+readClass).length >= 1 ){ 71 text = jQuery("."+readClass).clone().find("script").remove().end().find(".agTextToSpeechBlock").remove().end().find("style").remove().end(); 72 } 73 }else if( type == 'parent' ){ 74 if( targetElement ){ 75 if( wrapper.is(".fusion-column-wrapper") ){ 76 var p = jQuery(this).closest(".fusion-column-wrapper"); 77 }else if( wrapper.is(".fusion-row") ){ 78 var p = jQuery(this).closest(".fusion-row"); 79 } 80// text = p.clone().find("script").remove().end().find(".agTextToSpeechBlock").remove().end().find("style").remove().end(); 81 82 // Fallback für full, half half Inhalte 83 var bak = 0; 84 do{ 85 var emptyBlock = p.clone(); 86 emptyBlock.find(targetElement.prop('tagName')).remove(); 87 emptyBlock.find('script, .agTextToSpeechBlock, style, i').remove(); 88 89 if( jQuery.trim( emptyBlock.text() ) == '' ){ 90 p = p.parent(); 91 } 92 93 94 bak++; 95 } while( jQuery.trim( emptyBlock.text() ) == '' && bak < 50 ); 96 97 var p_clone = p.clone(); 98 p_clone.find('script, .agTextToSpeechBlock, style, i').remove(); 99 100 text = p_clone; 101 102// console.log(text.html()); 103 104// if( p_clone.find) 105 106// console.log('-----------------------------'); 107// console.log(p_clone.html()); 108// console.log('-----------------------------'); 109// console.log(p_clone.text()); 110// console.log('============================='); 111 112 }else{ 113// text = jQuery(this).parent().parent().clone().find("script").remove().end().find("style").remove().end(); 114 var content_clone = jQuery(this).parent().parent().clone(); 115 content_clone.find("script, style").remove(); 116 text = content_clone; 117 } 118 } 119 120 text = cleanHtml( text ); 121// console.log(text); 122 123// if( jQuery.browser.safari || jQuery.browser.chrome ){ 124 if( true ){ 125 126 agTextToSpeechSpeak(text); 127 128 } 129 130 }); 131 132 }); 133 134 jQuery("body").click(function(){ 135 136 if( 'speechSynthesis' in window && window.speechSynthesis.speaking && !jQuery("span[data-cmtooltip]:hover").length && !jQuery(".agTextToSpeechBlock:hover").length ){ 137 agTextToSpeechTexte = false;
138 window.speechSynthesis.cancel(); 139 } 140 }); 141 142 143 }else{ 144 jQuery(".agTextToSpeechBlock").css("display", "none"); 145 } 146 147}); 148 149 150 151if (!('speechSynthesis' in window)) { 152 console.log('No support for Speech Synthesis.'); 153} 154 155// Fetch the list of voices and populate the voice options. 156var agTextToSpeechVoices = []; 157function loadVoices() { 158 159 if( agTextToSpeechVoices.length < 1 ){ 160 161 // Fetch the available voices. 162 var voices = speechSynthesis.getVoices(); 163 164 // Loop through each of the voices. 165 voices.forEach(function(voice, i) { 166 167 if( voice.name.match(/German|german|Deutsch|deutsch|DE/) ){ 168 agTextToSpeechVoices.push( voice.name ); 169 } 170 171 }); 172 173 } 174} 175 176// Execute loadVoices. 177loadVoices(); 178 179// Chrome loads voices asynchronously. 180window.speechSynthesis.onvoiceschanged = function(e) { 181 loadVoices(); 182}; 183 184function agTextToSpeechSpeak(text) { 185 186 // Create a new instance of SpeechSynthesisUtterance. 187 var msg = new SpeechSynthesisUtterance(); 188 189 var regex = new RegExp('([.!?:])'); 190 191 if( typeof text === 'string' ){ 192 text = text.split( regex ); 193 } 194 195 if( typeof text[0] === 'undefined' ){ 196 return true; 197 } 198 199 if( text[0] === '' ){ 200 delete text[0]; 201 if( typeof text[1] !== 'undefined' ){ 202 text = text.join('').split( regex ); 203 agTextToSpeechSpeak( text ); 204 } 205 return true; 206 } 207 208 var textpart = text[0]; 209 delete text[0]; 210 211 if( typeof text[1] !== 'undefined' && inArray( text[1], ['.','!','?',':'] ) ){ 212 textpart += text[1]; 213 delete text[1]; 214 } 215 216 text = jQuery.trim( text.join('') ).split( regex ); 217 218 agTextToSpeechTexte = text; 219 220 221 if( textpart.length > 255 ){ 222 223 var longs = []; 224 var bak = 0; 225 while( textpart.length > 255 ){ 226 bak++; 227 if( bak >= 3){ break; } 228 229 var words = textpart.substr(0, 255); 230 words = words.split(' '); 231 delete words[words.length-1]; 232 words = words.join(' '); 233 var words2 = jQuery.trim( words ) + '.'; 234 longs.push( words2 ); 235 textpart = textpart.replace(words, ''); 236 } 237 longs.push( jQuery.trim(textpart) ); 238 agTextToSpeechTexte = longs.concat( agTextToSpeechTexte ); 239 agTextToSpeechSpeak(agTextToSpeechTexte); 240 return true; 241 242 } 243 244//console.log(textpart); 245 246 // Set the text. 247 msg.text = textpart; 248 249 // Set the attributes. 250 msg.volume = parseFloat(1); 251 msg.rate = parseFloat(1); 252 msg.pitch = parseFloat(1); 253 msg.lang = 'de-DE'; 254 255 // If a voice has been selected, find the voice and set the 256 // utterance instance's voice attribute. 257 258 if( agTextToSpeechVoices.length >= 1 ){ 259 msg.voice = speechSynthesis.getVoices().filter(function(voice) { return voice.name == agTextToSpeechVoices[0]; })[0]; 260 } 261 262 window.speechSynthesis.speak(msg); 263 agSpeechSynthesisWait(); 264 265} 266 267function agSpeechSynthesisWait(){ 268 269 if( agTextToSpeechTexte === false ){ 270 return true; 271 } 272 273 if ( ! window.speechSynthesis.speaking ) { 274 agTextToSpeechSpeak( agTextToSpeechTexte ); 275 return; 276 } 277 278 window.setTimeout( agSpeechSynthesisWait, 200 ); 279 280} 281 282function cleanHtml( e ){ 283 if( typeof e == "string" ){ 284 html = e; 285 }else{ 286 html = e.html(); 287 } 288 289 var htmlWrapper = '<div class="htmlWrapper">'+html+'</div>'; 290 var htmlWrapperObj = jQuery( htmlWrapper ); 291 htmlWrapperObj.find(".ls-wp-container").remove(); 292 htmlWrapperObj.find(".agCF").remove(); 293// htmlWrapperObj.find(".ls-wp-container").remove(); 294 html = htmlWrapperObj.html(); 295 296 html = html.replace(/<span data-tooltip="(.+?) class="glossaryLink(.*?)>(.+?)<\/span>/mgi, '$3'); 297 html = html.replace(/<span data-cmtooltip="(.+?) class="glossaryLink(.*?)>(.+?)<\/span>/mgi, '$3'); 298 html = html.replace(/ /gi, " ");
299 html = html.replace(/<\//gi, ". </"); 300 html = html.replace(/<span class="fusion-button-text">/gi, '<span class="fusion-button-text">Weiter zu: '); 301 302 html = html.replace(/href="#(.*?)"(.*?)>1([.]{0,1}) /gi, 'href="#$1"$2>Erstens. '); 303 html = html.replace(/href="#(.*?)"(.*?)>2([.]{0,1}) /gi, 'href="#$1"$2>Zweitens. '); 304 html = html.replace(/href="#(.*?)"(.*?)>3([.]{0,1}) /gi, 'href="#$1"$2>Drittens. '); 305 html = html.replace(/href="#(.*?)"(.*?)>4([.]{0,1}) /gi, 'href="#$1"$2>Viertens. '); 306 html = html.replace(/href="#(.*?)"(.*?)>5([.]{0,1}) /gi, 'href="#$1"$2>Fünftens. '); 307 html = html.replace(/href="#(.*?)"(.*?)>6([.]{0,1}) /gi, 'href="#$1"$2>Sechstens. '); 308 html = html.replace(/href="#(.*?)"(.*?)>7([.]{0,1}) /gi, 'href="#$1"$2>Siebtens. '); 309 html = html.replace(/href="#(.*?)"(.*?)>8([.]{0,1}) /gi, 'href="#$1"$2>Achtens. '); 310 html = html.replace(/href="#(.*?)"(.*?)>9([.]{0,1}) /gi, 'href="#$1"$2>Neuntens. '); 311 html = html.replace(/href="#(.*?)"(.*?)>10([.]{0,1}) /gi, 'href="#$1"$2>Zehntens. '); 312 html = html.replace(/href="#(.*?)"(.*?)>11([.]{0,1}) /gi, 'href="#$1"$2>Elftens. '); 313 html = html.replace(/href="#(.*?)"(.*?)>12([.]{0,1}) /gi, 'href="#$1"$2>Zwölftens. '); 314 html = html.replace(/href="#(.*?)"(.*?)>13([.]{0,1}) /gi, 'href="#$1"$2>Dreizehntens. '); 315 html = html.replace(/href="#(.*?)"(.*?)>14([.]{0,1}) /gi, 'href="#$1"$2>Vierzehntens. '); 316 html = html.replace(/href="#(.*?)"(.*?)>15([.]{0,1}) /gi, 'href="#$1"$2>Fünfzehntens. '); 317 318 html = html.replace(/<h(1|2|3|4) (.*?)>1([.]{0,1}) /gi, '<h$1 $2>Erstens. '); 319 html = html.replace(/<h(1|2|3|4) (.*?)>2([.]{0,1}) /gi, '<h$1 $2>Zweitens. '); 320 html = html.replace(/<h(1|2|3|4) (.*?)>3([.]{0,1}) /gi, '<h$1 $2>Drittens. '); 321 html = html.replace(/<h(1|2|3|4) (.*?)>4([.]{0,1}) /gi, '<h$1 $2>Viertens. '); 322 html = html.replace(/<h(1|2|3|4) (.*?)>5([.]{0,1}) /gi, '<h$1 $2>Fünftens. '); 323 html = html.replace(/<h(1|2|3|4) (.*?)>6([.]{0,1}) /gi, '<h$1 $2>Sechstens. '); 324 html = html.replace(/<h(1|2|3|4) (.*?)>7([.]{0,1}) /gi, '<h$1 $2>Siebtens. '); 325 html = html.replace(/<h(1|2|3|4) (.*?)>8([.]{0,1}) /gi, '<h$1 $2>Achtens. '); 326 html = html.replace(/<h(1|2|3|4) (.*?)>9([.]{0,1}) /gi, '<h$1 $2>Neuntens. '); 327 html = html.replace(/<h(1|2|3|4) (.*?)>10([.]{0,1}) /gi, '<h$1 $2>Zehntens. '); 328 html = html.replace(/<h(1|2|3|4) (.*?)>11([.]{0,1}) /gi, '<h$1 $2>Elftens. '); 329 html = html.replace(/<h(1|2|3|4) (.*?)>12([.]{0,1}) /gi, '<h$1 $2>Zwölftens. '); 330 html = html.replace(/<h(1|2|3|4) (.*?)>13([.]{0,1}) /gi, '<h$1 $2>Dreizehntens. '); 331 html = html.replace(/<h(1|2|3|4) (.*?)>14([.]{0,1}) /gi, '<h$1 $2>Vierzehntens. '); 332 html = html.replace(/<h(1|2|3|4) (.*?)>15([.]{0,1}) /gi, '<h$1 $2>Fünfzehntens. '); 333 334 html = strip_tags( html ); 335 html = html_entity_decode( html ); 336 337 html = html.replace(/Pelletkessel/gi, "Pellet-Kessel"); 338 html = html.replace(/pelletheizung-(infosde|infos\.de)/gi, "Pelletheizung minus Infoos Punkt De E"); 339 html = html.replace(/evtl\./gi, "eventuell"); 340 html = html.replace(/evt\./gi, "eventuell"); 341 html = html.replace(/usw\./gi, "und so weiter"); 342 html = html.replace(/z\.B\./gi, "zum Beispiel"); 343 html = html.replace(/etc\./gi, "etcetera"); 344 html = html.replace(/bzw\./gi, "beziehungsweise"); 345 html = html.replace(/d\.h\./gi, "das heiÃt"); 346 html = html.replace(/eigtl\./gi, "eigentlich"); 347 html = html.replace(/engl\./gi, "englisch"); 348 html = html.replace(/MwSt\./gi, "Mehrwertsteuer"); 349 html = html.replace(/Nr\./gi, "Nummer"); 350 html = html.replace(/u\.a\./gi, "unter anderem"); 351 html = html.replace(/uvm\./gi, "und vieles mehr"); 352 html = html.replace(/wg\./gi, "wegen"); 353 html = html.replace(/inkl\./gi, "inklusive"); 354 html = html.replace(/(ggfs\.|ggf\.)/gi, "gegebenenfalls"); 355 html = html.replace(/mind\./gi, "mindestens"); 356 html = html.replace(/max\./gi, "maximal"); 357 html = html.replace(/([^a-zA-Z0-9]{1})min\./gi, "$1minimal"); 358 html = html.replace(/ l\./g, " Liter."); 359 html = html.replace(/ l /g, " Liter "); 360 html = html.replace(/Enplus/g, "EN plus"); 361 html = html.replace(/DINplus/g, "Dien plus"); 362 html = html.replace(/kWh\/m²\/a/g, "Kilowattstunden pro Quadratmeter im Jahr"); 363 html = html.replace(/kWh\/m<sup>2<\/sup>\/a/g, "Kilowattstunden pro Quadratmeter im Jahr"); 364 html = html.replace(/Pelletierung/g, "Pelle tierung"); 365 html = html.replace(/komfortabel/g, "kom for tabel"); 366 html = html.replace(/Produktions/g, "Pro duk tions"); 367 html = html.replace(/Lieferkette/g, "Liefer kette"); 368 html = html.replace(/200.000/g, "200000"); 369 html = html.replace(/Angebote/g, "An gebote"); 370 html = html.replace(/Installationsanleitung/g, "Installations-Anleitung"); 371 html = html.replace(/Montage/g, "Montasche"); 372 html = html.replace(/Ãkofen/g, "Ãkofeen"); 373 html = html.replace(/Pelletstank/g, "Pellets tank"); 374 html = html.replace(/CO2/g, "C O 2"); 375 html = html.replace(/CO<sup>2<\/sup>/g, "C O 2"); 376 html = html.replace(/CO²/g, "C O 2"); 377 html = html.replace(/Pelletsofen/g, "Pellets ofen"); 378 html = html.replace(/Pelletskessel/g, "Pellets kessel"); 379 html = html.replace(/§/g, "Paragraph"); 380 html = html.replace(/Abs\./g, "Absatz"); 381 382 while( html.indexOf("..") >= 0 ){ 383 html = html.replace(/\.\./gi, "."); 384 } 385 while( html.indexOf(" ") >= 0 ){ 386 html = html.replace(/ /gi, " "); 387 } 388 389 html = html.replace(/\t/gi, ""); 390 html = html.replace(/([0-9]{1,}),([0-9]{1,})/g, "$1#komma#$2"); 391 html = html.replace(/,/mgi, ""); 392 html = html.replace(/([0-9]{1,})#komma#([0-9]{1,})/g, "$1,$2"); 393 394 html = html.replace(/\.([ ]{0,1})([a-zäöüÃ]{1})/mg, "$1$2"); 395 html = html.replace(/([0-9a-zA-ZäöüÃÃÃÃ]{1})\./mgi, "$1#~#"); 396 html = html.replace(/\./gi, ""); 397 html = html.replace(/#~#/gi, "."); 398 399// html = html.replace(/([a-z0-9äöü]{1})\.([ ]{0,1})([a-zäöü]{1})/mg, "$1$2$3"); 400 401 html = html.replace(/kWh\/kg/gi, "Kilowattstunden pro Kilogramm"); 402 html = html.replace(/kWh/gi, "Kilowattstunden"); 403 html = html.replace(/([0-9]{1,})\.([0-9]{3})/g, "$1$2"); 404 405 html = html.replace(/([0-9]{1,})([ ]{0,1})(-|â)([ ]{0,1})([0-9]{1,})/gi, "$1 bis $5"); 406 407 html = html.replace(/([0-9]{1,})\.([0-9]{1,})([.]{0,1})([0-9]{0,})([.]{0,1})([0-9]{0,})/gi, "$1 Punkt $2# Punkt $4## Punkt $6#."); 408 html = html.replace(/# Punkt ([0-9]{1,})#/gi, " Punkt $1"); 409 html = html.replace(/# Punkt #/gi, ""); 410 411// html = html.replace(/\(([0-9a-zA-ZäöüÃÃÃ]{1})/gi, ". Klammer auf $1"); // Responsive Voice 412// html = html.replace(/([0-9a-zA-ZäöüÃÃÃ?.!]{1})\)/gi, "$1 Klammer zu. "); // Responsive Voice 413 414 html = html.replace(/Ist/g, "ist"); 415 416// html = html.replace(/( |\n|\t|\r)/gmi, ""); 417 418 html = html.replace(/( )/gmi, " "); 419 html = html.replace(/(\n)/gmi, " "); 420 html = html.replace(/(\t)/gmi, ""); 421 html = html.replace(/(\r)/gmi, ""); 422 423 424// html = html.replace(/\./gi, ""); 425// var fulltext = html.split(" "); 426// for( i in fulltext ){ 427// fulltext[i] = jQuery.trim( fulltext[i] ); 428// } 429// html = fulltext.join(" "); 430 431 html = jQuery.trim( html ); 432 433// console.log(html); 434 435 return html; 436} 437 438 439/* --------------- PHP-JS -------------------------------- */ 440 441function strip_tags(input, allowed) { 442 // discuss at: http://phpjs.org/functions/strip_tags/ 443 // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 444 // improved by: Luke Godfrey 445 // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 446 // input by: Pul 447 // input by: Alex 448 // input by: Marc Palau 449 // input by: Brett Zamir (http://brett-zamir.me) 450 // input by: Bobby Drake 451 // input by: Evertjan Garretsen 452 // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 453 // bugfixed by: Onno Marsman 454 // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 455 // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 456 // bugfixed by: Eric Nagel 457 // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 458 // bugfixed by: Tomasz Wesolowski 459 // revised by: RafaÅ Kukawski (http://blog.kukawski.pl/) 460 // example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>'); 461 // returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>' 462 // example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>'); 463 // returns 2: '<p>Kevin van Zonneveld</p>' 464 // example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>"); 465 // returns 3: "<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>" 466 // example 4: strip_tags('1 < 5 5 > 1'); 467 // returns 4: '1 < 5 5 > 1'
vendor: 9,481 bytes, lines 468-754
468 // example 5: strip_tags('1 <br/> 1'); 469 // returns 5: '1 1' 470 // example 6: strip_tags('1 <br/> 1', '<br>'); 471 // returns 6: '1 <br/> 1' 472 // example 7: strip_tags('1 <br/> 1', '<br><br/>'); 473 // returns 7: '1 <br/> 1' 474 475 allowed = (((allowed || '') + '') 476 .toLowerCase() 477 .match(/<[a-z][a-z0-9]*>/g) || []) 478 .join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>) 479 var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi, 480 commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi; 481 return input.replace(commentsAndPhpTags, '') 482 .replace(tags, function($0, $1) { 483 return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''; 484 }); 485} 486 487function htmlentities(string, quote_style, charset, double_encode) { 488 // discuss at: http://phpjs.org/functions/htmlentities/ 489 // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 490 // revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 491 // revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 492 // improved by: nobbler 493 // improved by: Jack 494 // improved by: RafaÅ Kukawski (http://blog.kukawski.pl) 495 // improved by: Dj (http://phpjs.org/functions/htmlentities:425#comment_134018) 496 // bugfixed by: Onno Marsman 497 // bugfixed by: Brett Zamir (http://brett-zamir.me) 498 // input by: Ratheous 499 // depends on: get_html_translation_table 500 // example 1: htmlentities('Kevin & van Zonneveld'); 501 // returns 1: 'Kevin & van Zonneveld' 502 // example 2: htmlentities("foo'bar","ENT_QUOTES"); 503 // returns 2: 'foo'bar' 504 505 var hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style), 506 symbol = ''; 507 string = string == null ? '' : string + ''; 508 509 if (!hash_map) { 510 return false; 511 } 512 513 if (quote_style && quote_style === 'ENT_QUOTES') { 514 hash_map["'"] = '''; 515 } 516 517 if ( !! double_encode || double_encode == null) { 518 for (symbol in hash_map) { 519 if (hash_map.hasOwnProperty(symbol)) { 520 string = string.split(symbol) 521 .join(hash_map[symbol]); 522 } 523 } 524 } else { 525 string = string.replace(/([\s\S]*?)(&(?:#\d+|#x[\da-f]+|[a-zA-Z][\da-z]*);|$)/g, function(ignore, text, entity) { 526 for (symbol in hash_map) { 527 if (hash_map.hasOwnProperty(symbol)) { 528 text = text.split(symbol) 529 .join(hash_map[symbol]); 530 } 531 } 532 533 return text + entity; 534 }); 535 } 536 537 return string; 538} 539 540function html_entity_decode(string, quote_style) { 541 // discuss at: http://phpjs.org/functions/html_entity_decode/ 542 // original by: john (http://www.jd-tech.net) 543 // input by: ger 544 // input by: Ratheous 545 // input by: Nick Kolosov (http://sammy.ru) 546 // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 547 // improved by: marc andreu 548 // revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 549 // revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 550 // bugfixed by: Onno Marsman 551 // bugfixed by: Brett Zamir (http://brett-zamir.me) 552 // bugfixed by: Fox 553 // depends on: get_html_translation_table 554 // example 1: html_entity_decode('Kevin & van Zonneveld'); 555 // returns 1: 'Kevin & van Zonneveld' 556 // example 2: html_entity_decode('&lt;'); 557 // returns 2: '<' 558 559 var hash_map = {}, 560 symbol = '', 561 tmp_str = '', 562 entity = ''; 563 tmp_str = string.toString(); 564 565 if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) { 566 return false; 567 } 568 569 // fix & problem 570 // http://phpjs.org/functions/get_html_translation_table:416#comment_97660 571 delete(hash_map['&']); 572 hash_map['&'] = '&'; 573 574 for (symbol in hash_map) { 575 entity = hash_map[symbol]; 576 tmp_str = tmp_str.split(entity) 577 .join(symbol); 578 } 579 tmp_str = tmp_str.split(''') 580 .join("'"); 581 582 return tmp_str; 583} 584 585function get_html_translation_table(table, quote_style) { 586 // discuss at: http://phpjs.org/functions/get_html_translation_table/ 587 // original by: Philip Peterson 588 // revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 589 // bugfixed by: noname 590 // bugfixed by: Alex 591 // bugfixed by: Marco 592 // bugfixed by: madipta 593 // bugfixed by: Brett Zamir (http://brett-zamir.me) 594 // bugfixed by: T.Wild 595 // improved by: KELAN 596 // improved by: Brett Zamir (http://brett-zamir.me) 597 // input by: Frank Forte 598 // input by: Ratheous 599 // note: It has been decided that we're not going to add global 600 // note: dependencies to php.js, meaning the constants are not 601 // note: real constants, but strings instead. Integers are also supported if someone 602 // note: chooses to create the constants themselves. 603 // example 1: get_html_translation_table('HTML_SPECIALCHARS'); 604 // returns 1: {'"': '"', '&': '&', '<': '<', '>': '>'} 605 606 var entities = {}, 607 hash_map = {}, 608 decimal; 609 var constMappingTable = {}, 610 constMappingQuoteStyle = {}; 611 var useTable = {}, 612 useQuoteStyle = {}; 613 614 // Translate arguments 615 constMappingTable[0] = 'HTML_SPECIALCHARS'; 616 constMappingTable[1] = 'HTML_ENTITIES'; 617 constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; 618 constMappingQuoteStyle[2] = 'ENT_COMPAT'; 619 constMappingQuoteStyle[3] = 'ENT_QUOTES'; 620 621 useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; 622 useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 623 'ENT_COMPAT'; 624 625 if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') { 626 throw new Error('Table: ' + useTable + ' not supported'); 627 // return false; 628 } 629 630 entities['38'] = '&'; 631 if (useTable === 'HTML_ENTITIES') { 632 entities['160'] = ' '; 633 entities['161'] = '¡'; 634 entities['162'] = '¢'; 635 entities['163'] = '£'; 636 entities['164'] = '¤'; 637 entities['165'] = '¥'; 638 entities['166'] = '¦'; 639 entities['167'] = '§'; 640 entities['168'] = '¨'; 641 entities['169'] = '©'; 642 entities['170'] = 'ª'; 643 entities['171'] = '«'; 644 entities['172'] = '¬'; 645 entities['173'] = '­'; 646 entities['174'] = '®'; 647 entities['175'] = '¯'; 648 entities['176'] = '°'; 649 entities['177'] = '±'; 650 entities['178'] = '²'; 651 entities['179'] = '³'; 652 entities['180'] = '´'; 653 entities['181'] = 'µ'; 654 entities['182'] = '¶'; 655 entities['183'] = '·'; 656 entities['184'] = '¸'; 657 entities['185'] = '¹'; 658 entities['186'] = 'º'; 659 entities['187'] = '»'; 660 entities['188'] = '¼'; 661 entities['189'] = '½'; 662 entities['190'] = '¾'; 663 entities['191'] = '¿'; 664 entities['192'] = 'À'; 665 entities['193'] = 'Á'; 666 entities['194'] = 'Â'; 667 entities['195'] = 'Ã'; 668 entities['196'] = 'Ä'; 669 entities['197'] = 'Å'; 670 entities['198'] = 'Æ'; 671 entities['199'] = 'Ç'; 672 entities['200'] = 'È'; 673 entities['201'] = 'É'; 674 entities['202'] = 'Ê'; 675 entities['203'] = 'Ë'; 676 entities['204'] = 'Ì'; 677 entities['205'] = 'Í'; 678 entities['206'] = 'Î'; 679 entities['207'] = 'Ï'; 680 entities['208'] = 'Ð'; 681 entities['209'] = 'Ñ'; 682 entities['210'] = 'Ò'; 683 entities['211'] = 'Ó'; 684 entities['212'] = 'Ô'; 685 entities['213'] = 'Õ'; 686 entities['214'] = 'Ö'; 687 entities['215'] = '×'; 688 entities['216'] = 'Ø'; 689 entities['217'] = 'Ù'; 690 entities['218'] = 'Ú'; 691 entities['219'] = 'Û'; 692 entities['220'] = 'Ü'; 693 entities['221'] = 'Ý'; 694 entities['222'] = 'Þ'; 695 entities['223'] = 'ß'; 696 entities['224'] = 'à'; 697 entities['225'] = 'á'; 698 entities['226'] = 'â'; 699 entities['227'] = 'ã'; 700 entities['228'] = 'ä'; 701 entities['229'] = 'å'; 702 entities['230'] = 'æ'; 703 entities['231'] = 'ç'; 704 entities['232'] = 'è'; 705 entities['233'] = 'é'; 706 entities['234'] = 'ê'; 707 entities['235'] = 'ë'; 708 entities['236'] = 'ì'; 709 entities['237'] = 'í'; 710 entities['238'] = 'î'; 711 entities['239'] = 'ï'; 712 entities['240'] = 'ð'; 713 entities['241'] = 'ñ'; 714 entities['242'] = 'ò'; 715 entities['243'] = 'ó'; 716 entities['244'] = 'ô'; 717 entities['245'] = 'õ'; 718 entities['246'] = 'ö'; 719 entities['247'] = '÷'; 720 entities['248'] = 'ø'; 721 entities['249'] = 'ù'; 722 entities['250'] = 'ú'; 723 entities['251'] = 'û'; 724 entities['252'] = 'ü'; 725 entities['253'] = 'ý'; 726 entities['254'] = 'þ'; 727 entities['255'] = 'ÿ'; 728 } 729 730 if (useQuoteStyle !== 'ENT_NOQUOTES') { 731 entities['34'] = '"'; 732 } 733 if (useQuoteStyle === 'ENT_QUOTES') { 734 entities['39'] = '''; 735 } 736 entities['60'] = '<'; 737 entities['62'] = '>'; 738 739 // ascii decimals to real symbols 740 for (decimal in entities) { 741 if (entities.hasOwnProperty(decimal)) { 742 hash_map[String.fromCharCode(decimal)] = entities[decimal]; 743 } 744 } 745 746 return hash_map; 747} 748 749function inArray(needle, haystack) { 750 for(var i = 0; i < haystack.length; i++) { 751 if(haystack[i] == needle) return true; 752 } 753 return false; 754}
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.