1var captcha_bg_color = "rgb(191, 157, 94)"; 2var captcha_text_color = "rgb(93, 93, 93)"; 3function DrawPixel(canvas, ctx, color, x, y) 4{ 5 ctx.fillStyle = color; 6 ctx.fillRect( x, y, 1, 1 ); 7} 8function GetRandomCode(chars_count) 9{ 10 var code = ""; 11 //var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 12 var possible = "0123456789"; 13 14 for (var i = 0; i < chars_count; i++) 15 { 16 code += possible.charAt(Math.floor(Math.random() * possible.length)); 17 } 18 19 return code; 20} 21function init_all_captch() 22{ 23 $(".captcha_image_canvas").each(function(index, element) 24 { 25 var canvas = element; 26 var ctx = canvas.getContext("2d"); 27 28 var code = GetRandomCode(6); 29 30 var canvas_w = canvas.width; 31 var canvas_h = canvas.height; 32 //alert("canvas_h: " + canvas_h) 33 34 var canvas_w_vw = ConvertPx2Vw_fixed(canvas_w,1025); 35 var canvas_h_vw = ConvertPx2Vw_fixed(canvas_h,1025); 36 //alert("canvas_h_vw: " + canvas_h_vw) 37 38 var site_width = window.innerWidth; 39 var new_canvas_w = canvas_w_vw * (site_width / 100); 40 var new_canvas_h = canvas_h_vw * (site_width / 100); 41 //alert("new_canvas_h: " + new_canvas_h) 42 43 canvas_w = canvas.width = new_canvas_w; 44 canvas_h = canvas.height = new_canvas_h; 45 46 var total_pixels = canvas_w * canvas_h; 47 var pixels2draw = Math.floor(total_pixels / 2); 48 49 var pixels_locations = []; 50 for(var i = 0; i < pixels2draw; i++) 51 { 52 var random_x = Math.floor(Math.random() * canvas_w); 53 var random_y = Math.floor(Math.random() * canvas_h); 54 var str_location = random_x + "," + random_y; 55 56 while(pixels_locations.indexOf(str_location) >= 0) 57 { 58 var random_x = Math.floor(Math.random() * canvas_w); 59 var random_y = Math.floor(Math.random() * canvas_h); 60 var str_location = random_x + "," + random_y; 61 } 62 63 pixels_locations.push(str_location); 64 65 DrawPixel(canvas, ctx, captcha_bg_color, random_x, random_y); 66 } 67 68 var font_size = canvas_h/2; 69 70 ctx.fillStyle = captcha_text_color; 71 ctx.font = font_size + 'pt arial'; 72 ctx.textAlign = 'center'; 73 ctx.textBaseline = "middle"; 74 ctx.fillText(code, canvas_w/2, canvas_h/2); 75 76 setCookie(cookie_name_captcha + "_" + canvas.id,code,1); 77 78 }); 79}
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.