1/* CAPTCHA */ 2var data ={ 3 "icons" : 4 [ 5 { 6 "id": "1", 7 "name": "car", 8 "properties": { 9 "class": "fa-car", 10 "spanish": "carro", 11 "english": "car", 12 "deutch": "auto", 13 "french": "voiture", 14 "genre_es":"el", 15 "genre_en":"the", 16 "genre_fr":"la ", 17 "genre_de":"das" 18 } 19 }, 20 { 21 "id": "2", 22 "name": "scissors", 23 "properties": { 24 "class": "fa-scissors", 25 "spanish": "tijeras", 26 "english": "scissors", 27 "deutch": "schere", 28 "french": "ciseaux", 29 "genre_es":"las", 30 "genre_en":"the", 31 "genre_fr":"les ", 32 "genre_de":"die" 33 } 34 }, 35 { 36 "id": "3", 37 "name": "calculator", 38 "properties": { 39 "class": "fa-calculator", 40 "spanish": "calculadora", 41 "english": "calculator", 42 "deutch": "taschenrechner", 43 "french": "calculatrice", 44 "genre_es":"la", 45 "genre_en":"the", 46 "genre_fr":"la ", 47 "genre_de":"der" 48 } 49 }, 50 { 51 "id": "4", 52 "name": "bomb", 53 "properties": { 54 "class": "fa-bomb", 55 "spanish": "bomba", 56 "english": "bomb", 57 "deutch": "bombe", 58 "french": "bombe", 59 "genre_es":"la", 60 "genre_en":"the", 61 "genre_fr":"la ", 62 "genre_de":"die" 63 } 64 }, 65 { 66 "id": "5", 67 "name": "book", 68 "properties": { 69 "class": "fa-book", 70 "spanish": "libro", 71 "english": "book", 72 "deutch": "buch", 73 "french": "livre", 74 "genre_es":"el", 75 "genre_en":"the", 76 "genre_fr":"le ", 77 "genre_de":"das" 78 } 79 }, 80 { 81 "id": "6", 82 "name": "cake", 83 "properties": { 84 "class": "fa-birthday-cake", 85 "spanish": "pastel", 86 "english": "cake", 87 "deutch": "kuchen", 88 "french": "gâteau", 89 "genre_es":"el", 90 "genre_en":"the", 91 "genre_fr":"le ", 92 "genre_de":"der" 93 } 94 }, 95 { 96 "id": "7", 97 "name": "coffee", 98 "properties": { 99 "class": "fa-coffee", 100 "spanish": "cafe", 101 "english": "coffee", 102 "deutch": "kaffee", 103 "french": "café", 104 "genre_es":"el", 105 "genre_en":"the", 106 "genre_fr":"le ", 107 "genre_de":"der" 108 } 109 }, 110 { 111 "id": "8", 112 "name": "cloud", 113 "properties": { 114 "class": "fa-cloud", 115 "spanish": "nube", 116 "english": "cloud", 117 "deutch": "Wolke", 118 "french": "nuage", 119 "genre_es":"la", 120 "genre_en":"the", 121 "genre_fr":"le ", 122 "genre_de":"die" 123 } 124 }, 125 { 126 "id": "9", 127 "name": "diamond", 128 "properties": { 129 "class": "fa-diamond", 130 "spanish": "diamante", 131 "english": "diamond", 132 "deutch": "diamant", 133 "french": "diamant", 134 "genre_es":"el", 135 "genre_en":"the", 136 "genre_fr":"le ", 137 "genre_de":"der" 138 } 139 }, 140 { 141 "id": "10", 142 "name": "female", 143 "properties": { 144 "class": "fa-female", 145 "spanish": "mujer", 146 "english": "woman", 147 "deutch": "frau", 148 "french": "femme", 149 "genre_es":"la", 150 "genre_en":"the", 151 "genre_fr":"la ", 152 "genre_de":"die" 153 } 154 }, 155 { 156 "id": "11", 157 "name": "male", 158 "properties": { 159 "class": "fa-male", 160 "spanish": "hombre", 161 "english": "male", 162 "deutch": "mann", 163 "french": "homme", 164 "genre_es":"el", 165 "genre_en":"the", 166 "genre_fr":"l'", 167 "genre_de":"der" 168 } 169 }, 170 { 171 "id": "12", 172 "name": "futbol", 173 "properties": { 174 "class": "fa-futbol", 175 "spanish": "balon", 176 "english": "ball", 177 "deutch": "ball", 178 "french": "balle", 179 "genre_es":"el", 180 "genre_en":"the", 181 "genre_fr":"la ", 182 "genre_de":"den" 183 } 184 }, 185 { 186 "id": "13", 187 "name": "gamepad", 188 "properties": { 189 "class": "fa-gamepad", 190 "spanish": "control", 191 "english": "gamepad", 192 "deutch": "Gamepad", 193 "french": "manette", 194 "genre_es":"el", 195 "genre_en":"the", 196 "genre_fr":"la ", 197 "genre_de":"das" 198 } 199 }, 200 { 201 "id": "14", 202 "name": "home", 203 "properties": { 204 "class": "fa-home", 205 "spanish": "casa", 206 "english": "home", 207 "deutch": "haus", 208 "french": "maison", 209 "genre_es":"la", 210 "genre_en":"the", 211 "genre_fr":"la ", 212 "genre_de":"das" 213 } 214 }, 215 { 216 "id": "15", 217 "name": "mobile", 218 "properties": { 219 "class": "fa-mobile", 220 "spanish": "celular", 221 "english": "mobile", 222 "deutch": "mobile", 223 "french": "portable", 224 "genre_es":"el", 225 "genre_en":"the", 226 "genre_fr":"le ", 227 "genre_de":"das" 228 } 229 }, 230 { 231 "id": "16", 232 "name": "tree", 233 "properties": { 234 "class": "fa-tree", 235 "spanish": "arbol", 236 "english": "tree", 237 "deutch": "baum", 238 "french": "arbre", 239 "genre_es":"el", 240 "genre_en":"the", 241 "genre_fr":"l'", 242 "genre_de":"der" 243 } 244 }, 245 { 246 "id": "17", 247 "name": "trophy", 248 "properties": { 249 "class": "fa-trophy", 250 "spanish": "trofeo", 251 "english": "trophy", 252 "deutch": "trophäe", 253 "french": "trophée", 254 "genre_es":"el", 255 "genre_en":"the", 256 "genre_fr":"le ", 257 "genre_de":"die" 258 } 259 }, 260 { 261 "id": "18", 262 "name": "umbrella", 263 "properties": { 264 "class": "fa-umbrella", 265 "spanish": "sombrilla", 266 "english": "umbrella", 267 "deutch": "regenschirm", 268 "french": "parapluie", 269 "genre_es":"la", 270 "genre_en":"the", 271 "genre_fr":"le ", 272 "genre_de":"der" 273 } 274 }, 275 { 276 "id": "19", 277 "name": "university", 278 "properties": { 279 "class": "fa-university", 280 "spanish": "universidad", 281 "english": "university", 282 "deutch": "universität", 283 "french": "université", 284 "genre_es":"la", 285 "genre_en":"the", 286 "genre_fr":"l'", 287 "genre_de":"die" 288 } 289 }, 290 { 291 "id": "20", 292 "name": "video-camera", 293 "properties": { 294 "class": "fa-video-camera", 295 "spanish": "camara", 296 "english": "camera", 297 "deutch": "kamera", 298 "french": "caméra", 299 "genre_es":"la", 300 "genre_en":"the", 301 "genre_fr":"la ", 302 "genre_de":"die" 303 } 304 }, 305 { 306 "id": "21", 307 "name": "ambulance", 308 "properties": { 309 "class": "fa-ambulance", 310 "spanish": "ambulancia", 311 "english": "ambulance", 312 "deutch": "krankenwagen", 313 "french": "ambulance", 314 "genre_es":"la", 315 "genre_en":"the", 316 "genre_fr":"l'", 317 "genre_de":"der" 318 } 319 }, 320 { 321 "id": "22", 322 "name": "plane", 323 "properties": { 324 "class": "fa-plane", 325 "spanish": "avion", 326 "english": "plane", 327 "deutch": "flugzeug", 328 "french": "avion", 329 "genre_es":"el", 330 "genre_en":"the", 331 "genre_fr":"l'", 332 "genre_de":"das" 333 } 334 }, 335 { 336 "id": "23", 337 "name": "subway", 338 "properties": { 339 "class": "fa-subway", 340 "spanish": "tren", 341 "english": "subway", 342 "deutch": "zug", 343 "french": "métro", 344 "genre_es":"el", 345 "genre_en":"the", 346 "genre_fr":"le ", 347 "genre_de":"der" 348 } 349 }, 350 { 351 "id": "24", 352 "name": "bicycle", 353 "properties": { 354 "class": "fa-bicycle", 355 "spanish": "bicicleta", 356 "english": "bicycle", 357 "deutch": "fahrrad", 358 "french": "vélo", 359 "genre_es":"la", 360 "genre_en":"the", 361 "genre_fr":"le ", 362 "genre_de":"das" 363 } 364 }, 365 { 366 "id": "25", 367 "name": "truck", 368 "properties": { 369 "class": "fa-truck", 370 "spanish": "camion", 371 "english": "truck", 372 "deutch": "LKW", 373 "french": "camion", 374 "genre_es":"el", 375 "genre_en":"the", 376 "genre_fr":"le ", 377 "genre_de":"der" 378 } 379 }, 380 { 381 "id": "26", 382 "name": "heart", 383 "properties": { 384 "class": "fa-heart", 385 "spanish": "corazon", 386 "english": "heart", 387 "deutch": "herz", 388 "french": "cÅur", 389 "genre_es":"el", 390 "genre_en":"the", 391 "genre_fr":"le ", 392 "genre_de":"das" 393 } 394 } 395 ] 396}; 397 398var captchaAnswered = false;
399var captcha_icon = ''; 400var captchaAnswer = getRandomIcon(); 401 402 403$(document).ready(function() { 404 405 reloadCaptcha(true); 406 $('.reCap').on('click', function(event) { 407 event.preventDefault(); 408 $('.reCap i').addClass('fa-spin'); 409 setTimeout(function(){ 410 reloadCaptcha(true); 411 }, 1000); 412 413 }); 414 415$('.voiceCaptcha').on('click', function(event) { 416 event.preventDefault(); 417 spechToTextCaptcha($('.captchaTitle').text()); 418}); 419 420}); 421 422Array.prototype.unique=function(a){ 423 return function(){return this.filter(a)}}(function(a,b,c){return c.indexOf(a,b+1)<0 424}); 425 426function getRandomIcon() { 427 var id = getRandomId(1,25); 428 return data.icons[parseInt(id)]; 429} 430 431function getRandomId(min,max){ 432 return Math.floor(Math.random() * (max - min + 1)) + min; 433} 434 435 436function getRandomsByArray(arr,icon){ 437 var addToArray = false; 438 for (var i = 0; i < arr.length; i++) { 439 if(icon === arr[i]){ 440 addToArray = false; 441 break; 442 } 443 else { 444 addToArray = true; 445 } 446 } 447 return addToArray; 448} 449 450function loadPictures(answerId){ 451 var arr = new Array(); 452 arr.push(answerId); 453 for (var i = 0; i < 5; i++) { 454 var aux = getRandomIcon(); 455 if(getRandomsByArray(arr,aux)) 456 { 457 arr.push(aux); 458 } 459 else { 460 i--; 461 } 462 } 463 arr.unique(); 464 shuffle(arr); 465 for (var i = 0; i < arr.length; i++) { 466 $('.capchaIcons').append(' <a data-id="'+ arr[i].id +'" class="captchaIconSingle fa ' + arr[i].properties.class + '" ></a> '); 467 } 468 469 console.log(arr); 470} 471 472function clearCaptcha(){ 473 474} 475 476function shuffle(array) { 477 var currentIndex = array.length, temporaryValue, randomIndex ; 478 479 // While there remain elements to shuffle... 480 while (0 !== currentIndex) { 481 482 // Pick a remaining element... 483 randomIndex = Math.floor(Math.random() * currentIndex); 484 currentIndex -= 1; 485 486 // And swap it with the current element. 487 temporaryValue = array[currentIndex]; 488 array[currentIndex] = array[randomIndex]; 489 array[randomIndex] = temporaryValue; 490 } 491 492 return array; 493} 494 495function reloadCaptcha(reload){ 496 if(reload){ 497 captchaAnswer = getRandomIcon(); 498 captchaAnswered = false; 499 $('.capchaIcons').html(''); 500 $('.captchaQuestion').text(''); 501 $('.reCap i').removeClass('fa-spin'); 502 } 503 if(language==="fr"){ 504 $('.captchaQuestion').text(captchaAnswer.properties.genre_fr + captchaAnswer.properties.french); 505 } 506 else if(language==="de"){ 507 $('.captchaQuestion').text(captchaAnswer.properties.genre_de + ' ' + captchaAnswer.properties.deutch); 508 } 509 else if(language==="es"){ 510 $('.captchaQuestion').text(captchaAnswer.properties.genre_es + ' ' + captchaAnswer.properties.spanish); 511 } 512 else { 513 $('.captchaQuestion').text(captchaAnswer.properties.genre_en + ' ' + captchaAnswer.properties.english ); 514 } 515 loadPictures(captchaAnswer); 516 517 $('.capchaIcons a').on('click', function(event) { 518 event.preventDefault(); 519 $('.capchaIcons a').removeClass('selectedIconCaptcha'); 520 captchaAnswered = false; 521 $(this).addClass('selectedIconCaptcha'); 522 if($(this).data('id') == captchaAnswer.id){ 523 captchaAnswered = true; 524 captcha_icon = $(this).attr('class'); 525 } 526 else { 527 captchaAnswered = false; 528 } 529 }); 530} 531 532function spechToTextCaptcha(text){ 533 var msg = new SpeechSynthesisUtterance(); 534 var voices = window.speechSynthesis.getVoices(); 535 msg.text = text; 536 if(language == 'fr'){ 537 msg.lang = 'fr-FR'; 538 } 539 else if(language == 'de'){ 540 msg.lang = 'de-DE'; 541 } 542 else if(language == 'es'){ 543 msg.lang = 'es-ES'; 544 } 545 else { 546 msg.lang = 'en-US'; 547 } 548 549 msg.onend = function(e) { 550 console.log('Finished in ' + event.elapsedTime + ' seconds.'); 551 }; 552 speechSynthesis.speak(msg); 553}
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.