1/* 2 * jQuery $.greyScale Plugin 0.1 3 * Written by Andrew Pryde (www.pryde-design.co.uk) 4 * Date: Mon 1 Aug 2011 5 */ 6 7(function($){ 8 9 $.fn.greyScale = function(args) { 10 $options = $.extend({ 11 fadeTime: 400 12 }, args); 13 function greyScale(image, width, height) { 14 can = $('<canvas>') 15 .css({ 16 'display' : 'none', 17 'left' : '0', 18 'position' : 'absolute', 19 'top' : '0' 20 }) 21 .attr({ 22 'width': width, 23 'height': height 24 }) 25 .addClass('gsCanvas'); 26 ctx = can[0].getContext('2d'); 27 ctx.drawImage(image, 0, 0, width, height); 28 29 imageData = ctx.getImageData(0, 0, width, height); 30 px = imageData.data; 31 for (i = 0; i < px.length; i+= 4) { 32 grey = px[i] * .3 + px[i+1] * .59 + px[i+2] * .11; 33 px[i] = px[i+1] = px[i+2] = grey; 34 } 35 ctx.putImageData(imageData, 0, 0); 36 return can; 37 } 38 if ($.browser.msie) { 39 // IE doesn't support Canvas so use it's horrible filter syntax instead 40 this.each(function(){ 41 $(this).css({ 42 'filter': 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)', 43 'zoom': '1' 44 }); 45 $(this).hover(function() { 46 $(this).css({ 47 'filter': 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=0)' 48 }); 49 }, function() { 50 $(this).css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)'); 51 }); 52 }); 53 } else { 54 this.each(function(index) { 55 $(this).wrap('<div class="gsWrapper">'); 56 gsWrapper = $(this).parent(); 57 gsWrapper.css({ 58 'position' : 'relative', 59 'display' : 'inline-block' 60 }); 61 if (window.location.hostname !== this.src.split('/')[2]) { 62 // if the image is on a different url proxy the request 63 $.getImageData({ 64 url: $(this).attr('src'), 65 success: $.proxy(function(image) { 66 can = greyScale(image, image.width, image.height); 67 can.appendTo(this).fadeIn($options.fadeTime); 68 }, gsWrapper), 69 error: function(xhr, text_status){ 70 // silently fail on error 71 } 72 }); 73 } else { // if the url isn't local don't proxy the request 74 can = greyScale($(this)[0], $(this).width(), $(this).height()); 75 can.appendTo(gsWrapper).fadeIn($options.fadeTime); 76 } 77 }); 78 79 $(this).parent().delegate('.gsCanvas', 'mouseover mouseout', function(event) { 80 (event.type == 'mouseover') && $(this).stop().animate({'opacity': '0'}, $options.fadeTime); 81 (event.type == 'mouseout') && $(this).stop().animate({'opacity': '1'}, $options.fadeTime); 82 }); 83 } 84 }; 85})( jQuery ); 86 87/* 88 * 89 * jQuery $.getImageData Plugin 0.3 90 * http://www.maxnov.com/getimagedata 91 * 92 * Written by Max Novakovic (http://www.maxnov.com/) 93 * Date: Thu Jan 13 2011 94 * 95 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 96 * 97 * Includes jQuery JSONP Core Plugin 2.1.4 98 * http://code.google.com/p/jquery-jsonp/ 99 * Copyright 2010, Julian Aubourg 100 * Released under the MIT License. 101 * 102 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 103 * 104 * Copyright 2011, Max Novakovic 105 * Dual licensed under the MIT or GPL Version 2 licenses. 106 * http://www.maxnov.com/getimagedata/#license 107 * 108 */ 109(function(c,g){function n(){}function o(a){s=[a]}function e(a,j,k){return a&&a.apply(j.context||j,k)}function h(a){function j(b){!l++&&g(function(){p();q&&(t[d]={s:[b]});z&&(b=z.apply(a,[b]));e(a.success,a,[b,A]);e(B,a,[a,A])},0)}function k(b){!l++&&g(function(){p();q&&b!=C&&(t[d]=b);e(a.error,a,[a,b]);e(B,a,[a,b])},0)}a=c.extend({},D,a);var B=a.complete,z=a.dataFilter,E=a.callbackParameter,F=a.callback,R=a.cache,q=a.pageCache,G=a.charset,d=a.url,f=a.data,H=a.timeout,r,l=0,p=n;a.abort=function(){!l++&& 110p()};if(e(a.beforeSend,a,[a])===false||l)return a;d=d||u;f=f?typeof f=="string"?f:c.param(f,a.traditional):u;d+=f?(/\?/.test(d)?"&":"?")+f:u;E&&(d+=(/\?/.test(d)?"&":"?")+encodeURIComponent(E)+"=?");!R&&!q&&(d+=(/\?/.test(d)?"&":"?")+"_"+(new Date).getTime()+"=");d=d.replace(/=\?(&|$)/,"="+F+"$1");q&&(r=t[d])?r.s?j(r.s[0]):k(r):g(function(b,m,v){if(!l){v=H>0&&g(function(){k(C)},H);p=function(){v&&clearTimeout(v);b[I]=b[w]=b[J]=b[x]=null;i[K](b);m&&i[K](m)};window[F]=o;b=c(L)[0];b.id=M+S++;if(G)b[T]= 111G;var O=function(y){(b[w]||n)();y=s;s=undefined;y?j(y[0]):k(N)};if(P.msie){b.event=w;b.htmlFor=b.id;b[I]=function(){/loaded|complete/.test(b.readyState)&&O()}}else{b[x]=b[J]=O;P.opera?(m=c(L)[0]).text="jQuery('#"+b.id+"')[0]."+x+"()":b[Q]=Q}b.src=d;i.insertBefore(b,i.firstChild);m&&i.insertBefore(m,i.firstChild)}},0);return a}var Q="async",T="charset",u="",N="error",M="_jqjsp",w="onclick",x="on"+N,J="onload",I="onreadystatechange",K="removeChild",L="<script/>",A="success",C="timeout",P=c.browser, 112i=c("head")[0]||document.documentElement,t={},S=0,s,D={callback:M,url:location.href};h.setup=function(a){c.extend(D,a)};c.jsonp=h})(jQuery,setTimeout); 113(function(c){c.getImageData=function(a){var f=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;if(a.url){var g=location.protocol==="https:",e="";e=a.server&&f.test(a.server)&&a.server.indexOf("https:")&&(g||a.url.indexOf("https:"))?a.server:"http://img-to-json.appspot.com/?callback=?";c.jsonp({url:e,data:{url:escape(a.url)}
113,dataType:"jsonp",timeout:1E4,success:function(b){var d=new Image;c(d).load(function(){this.width=b.width;this.height=b.height;typeof a.success==typeof Function&& a.success(this)}).attr("src",b.data)},error:function(b,d){typeof a.error==typeof Function&&a.error(b,d)}})}else typeof a.error==typeof Function&&a.error(null,"no_url")}})(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.