1;(function($) { 2 3 var ns = 'simpleCaptcha'; 4 5 $.fn.simpleCaptcha = function(o) { 6 var n = $(this); 7 var c; 8 o = (o)?o:{}; 9 10 if (n.length === 1 && n.hasClass(ns) && n.data(ns) && o && o.length) { 11 c = n.data(ns); 12 if (c && o === 'refresh') { 13 c.refresh(); 14 15 } else if (c) { 16 return c[o]; 17 } 18 19 } else if (!o.node && n.length) { 20 o.node = n.filter(':first'); 21 } 22 23 if (!c && o.node) { 24 c = new $.jk.SimpleCaptcha(o); 25 c.loadImageData(function(d) { if (d) { c.addImagesToUI(); } }); 26 } 27 28 if (!c) { n.trigger('error.'+ns, ['No node provided for the simpleCaptcha UI']); } 29 30 return n; 31 }; 32 33 34 if (!$.jk) { $.jk = {}; } 35 $.jk.SimpleCaptcha = function(o) { 36 var t = this; 37 o = (o)?o:{}; 38 t.data = {}; 39 40 if (o.numImages && (!Number(o.numImages) || o.numImages < 1)) { o.numImages = t.numImages; } 41 $.extend(t, ((o)?o:{})); 42 t.allowRefresh = !!t.allowRefresh; 43 44 var n; 45 t.node = $( ((o.node)?o.node:null) ); 46 if (t.node && t.node.length === 1){ 47 n = t.node; 48 } else { 49 return t; 50 } 51 52 n.addClass(ns) 53 .html('') 54 .append( 55 "<div class='"+t.introClass+"'>"+t.introText+"</div>"+ 56 "<div class='"+t.imageBoxClass+"'></div>"+ 57 "<input class='"+ns+"Input' name='"+t.inputName+"' type='hidden' value='' />"+ 58 "<input name='captcha_id' type='hidden' value='"+ t.id+"'/>" 59 ) 60 .data(ns, t) 61 .find('.'+t.imageBoxClass) 62 .on('click', 'img.'+t.imageClass, function(e) { 63 e.preventDefault(); 64 n.find('img.'+t.imageClass).removeClass(ns+'Selected'); 65 var hash = $(this).addClass(ns+'Selected').attr('data-hash'); 66 n.find('.'+ns+"Input").val(hash); 67 68 n.trigger('select.'+ns, [t, hash]); 69 return false; 70 }) 71 .on('keyup', 'img.'+t.imageClass, function(e) { 72 if (e.which == 13 || e.which == 32) { 73 $(this).click(); 74 } 75 }); 76 77 if (t.allowRefresh) { 78 var b = $(t.refreshButton); 79 n.find('.'+t.introClass) 80 .after("<div class='"+t.refreshClass+"' />") 81 .siblings('.'+t.refreshClass) 82 .append(b); 83 b.on('click', function(e) { 84 e.preventDefault(); 85 t.refresh(); 86 return false; 87 }); 88 } 89 90 n.trigger('init.'+ns, [t]); 91 }; 92 93 $.extend($.jk.SimpleCaptcha.prototype, { 94 allowRefresh: true, 95 scriptPath: '/plugins/p_simplacaptcha/init.php', 96 numImages: 5, 97 introText: "<p>To make sure you are a human, we need you to click on the <span class='captchaText'></span>.</p>", 98 refreshButton: "<img src='/plugins/p_simplacaptcha/img/refresh.png' class='refreshButton' alt='Refresh' title='Refresh captcha' />", 99 refreshClass: 'refreshCaptcha', 100 inputName: 'code', 101 introClass: 'captchaIntro', 102 textClass: 'captchaText', 103 imageBoxClass: 'captchaImages', 104 imageClass: 'captchaImage', 105 node: null 106 }); 107 108 $.extend($.jk.SimpleCaptcha.prototype, { 109 110 loadImageData: function(cb) { 111 var t = this; 112 cb = ($.isFunction(cb))?cb:(function(){}); 113 $.ajax({ 114 url: t.scriptPath, 115 data: { numImages: t.numImages, captcha_id: t.id}, 116 type: 'post', 117 dataType: 'json', 118 success: function(d, s) { 119 if (d && d.images && d.text) { 120 t.data = d; 121 t.node.trigger('dataload.'+ns, [d]); 122 cb(d); 123 } else { 124 t.node.trigger('error.'+ns, ['Invalid data was returned from the server.']); 125 cb(null); 126 } 127 }, 128 error: function(xhr, s) { 129 cb(null); 130 t.node.trigger('error.'+ns, ['There was a serious problem: '+xhr.status]); 131 } 132 }); 133 }, 134 addImagesToUI: function() { 135 var t = this; 136 t.node.find('.'+t.textClass).text(t.data.text); 137 var h = ""; 138 for (var i=0; i<t.data.images.length; ++i) { 139 h += "<img class='"+t.imageClass+"' src='"+t.scriptPath+'?hash='+t.data.images[i]+"&captcha_id="+ t.id+"' alt='' data-hash='"+t.data.images[i]+"' />"; 140 } 141 t.node.find('.'+t.imageBoxClass).html(h); 142 t.node.trigger('ready.'+ns, [t]); 143 }, 144 refresh: function() { 145 var t = this; 146 t.node.trigger('refresh.'+ns, [t]); 147 t.loadImageData(function(d) { 148 if (d) { t.addImagesToUI(); } 149 }); 150 } 151 }); 152})(jQuery);
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.