1/** 2 * instant.js 2.2 (05-Sep-2008) 3 * (c) by Christian Effenberger 4 * All Rights Reserved 5 * Source: instant.netzgesta.de 6 * Distributed under Netzgestade Software License Agreement 7 * http://www.netzgesta.de/cvi/LICENSE.txt 8 * License permits free of charge 9 * use on non-commercial and 10 * private web sites only 11**/ 12 13var tmp = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0; 14if(tmp) var isIE = document.namespaces ? 1 : 0; 15 16if(isIE) { 17 if(document.namespaces['v'] == null) { 18 var stl = document.createStyleSheet(); 19 stl.addRule("v\\:*", "behavior: url(#default#VML);"); 20 document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); 21 } 22} 23 24function getImages(className){ 25 var children = document.getElementsByTagName('img'); 26 var elements = new Array(); var i = 0; 27 var child; var classNames; var j = 0; 28 for (i=0;i<children.length;i++) { 29 child = children[i]; 30 classNames = child.className.split(' '); 31 for (var j = 0; j < classNames.length; j++) { 32 if (classNames[j] == className) { 33 elements.push(child); 34 break; 35 } 36 } 37 } 38 return elements; 39} 40function getClasses(classes,string){ 41 var temp = ''; 42 for (var j=0;j<classes.length;j++) { 43 if (classes[j] != string) { 44 if (temp) { 45 temp += ' ' 46 } 47 temp += classes[j]; 48 } 49 } 50 return temp; 51} 52function getClassValue(classes,string){ 53 var temp = 0; var pos = string.length; 54 for (var j=0;j<classes.length;j++) { 55 if (classes[j].indexOf(string) == 0) { 56 temp = Math.min(classes[j].substring(pos),100); 57 break; 58 } 59 } 60 return Math.max(0,temp); 61} 62function getClassColor(classes,string){ 63 var temp = 0; var str = ''; var pos = string.length; 64 for (var j=0;j<classes.length;j++) { 65 if (classes[j].indexOf(string) == 0) { 66 temp = classes[j].substring(pos); 67 str = '#' + temp.toLowerCase(); 68 break; 69 } 70 } 71 if(str.match(/^#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)) { 72 return str; 73 }else { 74 return 0; 75 } 76} 77function getClassAttribute(classes,string){ 78 var temp = 0; var pos = string.length; 79 for (var j=0;j<classes.length;j++) { 80 if (classes[j].indexOf(string) == 0) { 81 temp = 1; 82 break; 83 } 84 } 85 return temp; 86} 87function addShading(ctx,x,y,width,height,opacity) { 88 var style = ctx.createLinearGradient(0,y,0,y+height); 89 style.addColorStop(0,'rgba(0,0,0,'+(opacity/2)+')'); 90 style.addColorStop(0.3,'rgba(0,0,0,0)'); 91 style.addColorStop(0.7,'rgba(254,254,254,0)'); 92 style.addColorStop(1,'rgba(254,254,254,'+(opacity)+')'); 93 ctx.beginPath(); ctx.rect(x,y,width,height); 94 ctx.closePath(); ctx.fillStyle = style; ctx.fill(); 95} 96function addLining(ctx,x,y,width,height,opacity,inset,inner,color) { 97 var style = ctx.createLinearGradient(x,y,width,height); 98 if(inner==true) { 99 style.addColorStop(0,'rgba(192,192,192,'+opacity+')'); 100 style.addColorStop(0.7,'rgba(254,254,254,0.8)'); 101 style.addColorStop(1,'rgba(254,254,254,0.9)'); 102 }else { 103 if(color=='#f0f4ff') { 104 style.addColorStop(0,'rgba(254,254,254,0.9)'); 105 style.addColorStop(0.3,'rgba(254,254,254,0.8)'); 106 style.addColorStop(1,'rgba(192,192,192,0)'); 107 }else { 108 style.addColorStop(0,'rgba(254,254,254,0)'); 109 style.addColorStop(1,'rgba(192,192,192,0)'); 110 } 111 } 112 ctx.strokeStyle = style; ctx.lineWidth = inset; 113 ctx.beginPath(); ctx.rect(x,y,width,height); 114 ctx.closePath(); ctx.stroke(); 115} 116function addRadialStyle(ctx,x1,y1,r1,x2,y2,r2,opacity) { 117 var tmp = ctx.createRadialGradient(x1,y1,r1,x2,y2,r2); 118 var opt = Math.min(parseFloat(opacity+0.1),1.0); 119 tmp.addColorStop(0,'rgba(0,0,0,'+opt+')'); 120 tmp.addColorStop(0.25,'rgba(0,0,0,'+opacity+')'); 121 tmp.addColorStop(1,'rgba(0,0,0,0)'); 122 return tmp; 123} 124function addLinearStyle(ctx,x,y,w,h,opacity) { 125 var tmp = ctx.createLinearGradient(x,y,w,h); 126 var opt = Math.min(parseFloat(opacity+0.1),1.0); 127 tmp.addColorStop(0,'rgba(0,0,0,'+opt+')'); 128 tmp.addColorStop(0.25,'rgba(0,0,0,'+opacity+')'); 129 tmp.addColorStop(1,'rgba(0,0,0,0)'); 130 return tmp; 131} 132function tiltShadow(ctx,x,y,width,height,radius,opacity,round){ 133 var style, f=round?2.5:1.25, t=round?3.5:2.25; ctx.fillStyle="rgba(0,0,0,"+(opacity*1.2)+")"; 134 ctx.beginPath(); ctx.rect(x+radius,y+height-y-y,width-(radius*t),y); ctx.closePath(); ctx.fill(); 135 ctx.beginPath(); ctx.rect(x+width-x-x,y,radius,radius); ctx.closePath(); 136 style=addLinearStyle(ctx,x+width-x-x,y+radius,x+width-x-x,y,opacity); ctx.fillStyle=style; ctx.fill(); 137 ctx.beginPath(); ctx.rect(x,y+height-y-y,radius,radius); ctx.closePath(); 138 style=addLinearStyle(ctx,x+radius,y+height-y-y,x,y+height-y-y,opacity); ctx.fillStyle=style; ctx.fill(); 139 ctx.beginPath(); ctx.moveTo(x+width-x-x,y+radius); ctx.lineTo(x+width-x,y+radius); ctx.quadraticCurveTo(x+width-x-x,y+(height/2),x+width-x,y+height-(radius*f)); ctx.lineTo(x+width-x-x,y+height-(radius*f)); ctx.quadraticCurveTo(x+width-(x*3),y+(height/2),x+width-x-x,y+radius); ctx.closePath(); ctx.fill(); 140 ctx.beginPath(); ctx.rect(x,y+height-radius,radius,radius); ctx.closePath(); 141 style=addRadialStyle(ctx,x+radius,y+height-radius,radius-x,x+radius,y+height-radius,radius,opacity); 142 ctx.fillStyle=style; ctx.fill(); 143 ctx.beginPath(); ctx.rect(x+radius,y+height-y,width-(radius*t),y); ctx.closePath(); 144 style=addLinearStyle(ctx,x+radius,y+height-y,x+radius,y+height,opacity); 145 ctx.fillStyle=style; ctx.fill(); 146 ctx.beginPath(); ctx.rect(x+width-(radius*f),y+height-(radius*f),radius*f,radius*f); ctx.closePath(); 147 style=addRadialStyle(ctx,x+width-(radius*f),y+height-(radius*f),Math.max(0,(radius*f)-1.5-x),x+width-(radius*f),y+height-(radius*f),radius*f,o
147pacity); 148 ctx.fillStyle=style; ctx.fill(); 149 ctx.beginPath(); ctx.moveTo(x+width-x,y+radius); ctx.lineTo(x+width,y+radius); ctx.quadraticCurveTo(x+width-x,y+(height/2),x+width,y+height-(radius*f)); ctx.lineTo(x+width-x,y+height-(radius*f)); ctx.quadraticCurveTo(x+width-(x*2),y+(height/2),x+width-x,y+radius); ctx.closePath(); 150 style=addLinearStyle(ctx,x+width-x,y+radius,x+width,y+radius,opacity); 151 ctx.fillStyle=style; ctx.fill(); 152 ctx.beginPath(); ctx.rect(x+width-radius,y,radius,radius); ctx.closePath(); 153 style=addRadialStyle(ctx,x+width-radius,y+radius,radius-x,x+width-radius,y+radius,radius,opacity); 154 ctx.fillStyle=style; ctx.fill(); 155} 156function getRadius(radius,width,height){ 157 var part = (Math.min(width,height)/100); 158 radius = Math.max(Math.min(100,radius/part),0); 159 return radius+'%'; 160} 161function wavedRect(ctx,x,y,w,h,r,n){ 162 function rF(a,z) {return Math.random()*(z-a)+a;}; 163 var i,t,c,cx,cy,cw,ch,wa=w/16,wz=w/32,ha=h/16,hz=h/32,da=r*0.1,dz=r*0.25; if(!n) {ctx.beginPath();} ctx.moveTo(x,y); 164 cx=x; cy=y; ch=h; while(ch>0) {t=rF(ha,Math.min(ch,hz)); c=rF(1,t); ctx.quadraticCurveTo(cx+rF(da,dz),cy+c,cx,cy+t); cy+=t; ch-=t;} 165 cx=x; cy=y+h; cw=w; while(cw>0) {t=rF(wa,Math.min(cw,wz)); c=rF(1,t); ctx.quadraticCurveTo(cx+c,cy-rF(da,dz),cx+t,cy); cx+=t; cw-=t;} 166 cx=x+w; cy=y+h; ch=h; while(ch>0) {t=rF(ha,Math.min(ch,hz)); c=rF(1,t); ctx.quadraticCurveTo(cx-rF(da,dz),cy-c,cx,cy-t); cy-=t; ch-=t;} 167 cx=x+w; cy=y; cw=w; while(cw>0) {t=rF(wa,Math.min(cw,wz)); c=rF(1,t); ctx.quadraticCurveTo(cx-c,cy+rF(da,dz),cx-t,cy); cx-=t; cw-=t;} 168 if(!n) ctx.closePath(); 169} 170function wavedPath(x,y,w,h,r){ 171 function rI(a,b) {return parseInt(Math.floor(Math.random()*(b-a+1))+a);}; 172 function qC(cX,cY,CPx,CPy,aX,aY) {var z=new Array(6); z[0]=cX+2.0/3.0*(CPx-cX); z[1]=cY+2.0/3.0*(CPy-cY); z[2]=z[0]+(aX-cX)/3.0; z[3]=z[1]+(aY-cY)/3.0; z[4]=aX; z[5]=aY; return z;} 173 var p="",i,k,t,c,cx,cy,cw,ch,wa=w/16,wz=w/32,ha=h/16,hz=h/32,da=r*0.1,dz=r*0.25; 174 p+='m '+x+','+y; cx=x; cy=y; ch=h; while(ch>0) {t=rI(ha,Math.min(ch,hz)); c=rI(1,t); k=qC(cx,cy,cx+rI(da,dz),cy+c,cx,cy+t); 175 p+=' c '+parseInt(k[0])+','+Math.min(h,parseInt(k[1]))+','+parseInt(k[2])+','+Math.min(h,parseInt(k[3]))+','+parseInt(k[4])+','+Math.min(h,parseInt(k[5])); cy+=t; ch-=t;} 176 cx=x; cy=y+h; cw=w; while(cw>0) {t=rI(wa,Math.min(cw,wz)); c=rI(1,t); k=qC(cx,cy,cx+c,cy-rI(da,dz),cx+t,cy); 177 p+=' c '+Math.min(w,parseInt(k[0]))+','+parseInt(k[1])+','+Math.min(w,parseInt(k[2]))+','+parseInt(k[3])+','+Math.min(w,parseInt(k[4]))+','+parseInt(k[5]); cx+=t; cw-=t;} 178 cx=x+w; cy=y+h; ch=h; while(ch>0) {t=rI(ha,Math.min(ch,hz)); c=rI(1,t);
178 k=qC(cx,cy,cx-rI(da,dz),cy-c,cx,cy-t); 179 p+=' c '+parseInt(k[0])+','+Math.max(0,parseInt(k[1]))+','+parseInt(k[2])+','+Math.max(0,parseInt(k[3]))+','+parseInt(k[4])+','+Math.max(0,parseInt(k[5])); cy-=t; ch-=t;} 180 cx=x+w; cy=y; cw=w; while(cw>0) {t=rI(wa,Math.min(cw,wz)); c=rI(1,t); k=qC(cx,cy,cx-c,cy+rI(da,dz),cx-t,cy); 181 p+=' c '+Math.max(0,parseInt(k[0]))+','+parseInt(k[1])+','+Math.max(0,parseInt(k[2]))+','+parseInt(k[3])+','+Math.max(0,parseInt(k[4]))+','+parseInt(k[5]); cx-=t; cw-=t;} 182 return p+' x e'; 183} 184function roundedRect(ctx,x,y,width,height,radius,nopath){ 185 if (!nopath) ctx.beginPath(); 186 ctx.moveTo(x,y+radius); 187 ctx.lineTo(x,y+height-radius); 188 ctx.quadraticCurveTo(x,y+height,x+radius,y+height); 189 ctx.lineTo(x+width-radius,y+height); 190 ctx.quadraticCurveTo(x+width,y+height,x+width,y+height-radius); 191 ctx.lineTo(x+width,y+radius); 192 ctx.quadraticCurveTo(x+width,y,x+width-radius,y); 193 ctx.lineTo(x+radius,y); 194 ctx.quadraticCurveTo(x,y,x,y+radius); 195 if (!nopath) ctx.closePath(); 196} 197 198function addIEInstant() { 199 var theimages = getImages('instant'); 200 var image; var object; var vml; var display; 201 var border = 16; var offset = 8; var scale = 1; 202 var icolor = ''; var ishadow = 0; var noshading; 203 var itiltright; var itiltnone; var itiltleft; 204 var itxttitle; var itxtalt; var itxtcol; var text=""; 205 var color = ''; var tilt = 'r'; var opacity = 0; var tw; 206 var preserve, tcolor, head, foot, frame, fill, shadow, shade, txt, over, shine; 207 var classes = ''; var newClasses = ''; var path, historical, nocorner; 208 var inset = 6; var i, f, r, db, hz, flt, ww, hh, ff, yo, xo; 209 for(i=0;i<theimages.length;i++) { 210 image = theimages[i]; object = image.parentNode; historical = 0; 211 itxtalt = 0; itxttitle = 0; text=""; tcolor = '#000000'; nocorner = 0; 212 opacity = 0.33; color = '#f0f4ff'; preserve = 0; path=""; over=""; txt=""; 213 itiltright = 0; itiltnone = 0; itiltleft = 0; noshading = 0; 214 if(image.width>=64 && image.height>=64) { 215 classes = image.className.split(' '); 216 ishadow = getClassValue(classes,"ishadow"); 217 if(ishadow>0) opacity=ishadow/100; 218 icolor = getClassColor(classes,"icolor"); 219 if(icolor!=0) color = icolor; 220 itxtcol = getClassColor(classes,"itxtcol"); 221 if(itxtcol!=0) tcolor = itxtcol; 222 itxttitle = getClassAttribute(classes,"itxttitle"); 223 itxtalt = getClassAttribute(classes,"itxtalt"); 224 itiltleft = getClassAttribute(classes,"itiltleft"); 225 itiltright = getClassAttribute(classes,"itiltright"); 226 itiltnone = getClassAttribute(classes,"itiltnone"); 227 historical = getClassAttribute(classes,"historical"); 228 noshading = getClassAttribute(classes,"noshading"); 229 nocorner = getClassAttribute(classes,"nocorner"); 230 preserve = getClassAttribute(classes,"preserve"); 231 if(historical==true) nocorner = false; 232 if(itiltright==true) tilt = 'r'; 233 if(itiltnone==true) tilt = 'n'; 234 if(itiltleft==true) tilt = 'l'; 235 newClasses = getClasses(classes,"instant"); 236 width = image.width; height = image.height; 237 border = Math.round(((width+height)/2)*0.05); db=border; 238 offset = border/2; inset = parseInt(offset*.75); 239 ww=width-(border*2); hh=height-(border*2); hz=Math.round(hh/3); 240 f=(noshading==0?"t":"f"); r=nocorner?getRadius(border,width,height):0; 241 if(tilt=='r') { 242 rotation = 2.8; scale = 0.95; tilt = 'n'; 243 }else if(tilt=='n') { 244 rotation = 0; scale = 1; tilt = 'l'; 245 }else if(tilt=='l') { 246 rotation = -2.8; scale = 0.95; tilt = 'r'; 247 } 248 display = (image.currentStyle.display.toLowerCase()=='block')?'block':'inline-block'; 249 vml = document.createElement(['<var style="zoom:1;overflow:hidden;display:' + display + ';width:' + width + 'px;height:' + height + 'px;padding:0;">'].join('')); 250 flt = image.currentStyle.styleFloat.toLowerCase(); 251 display = (flt=='left'||flt=='right')?'inline':display; 252 text = image.alt!=''&&itxtalt!=0?image.alt:image.title!=''&&itxttitle!=0?image.title:''; 253 head = '<v:group style="rotation:' + rotation + '; zoom:' + scale + '; display:' + display + '; margin:-1px 0 0 -1px; padding:0; position:relative; width:'+width+'px;height:'+height+'px;" coordsize="'+width+','+height+'"><v:rect strokeweight="0" filled="f" stroked="f" fillcolor="transparent" style="zoom:1;margin: 0;padding: 0;display:block;position:absolute;top:0px;left:0px;width:'+width+'px;height:'+height+';"><v:fill opacity="0" color="#000000" /></v:rect>'; 254 shadow = '<v:roundrect arcsize="'+r+'" strokeweight="0" filled="t" stroked="f" fillcolor="#000000" style="filter:Alpha(opacity='+(opacity*100)+'), progid:dxImageTransform.Microsoft.Blur(PixelRadius='+inset+', MakeShadow=false); zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+offset+'px;left:'+offset+'px;width:'+(width-(2*offset))+'px;height:'+(height-(2*offset))+';"><v:fill color="#000000" opacity="1" /></v:roundrect>'; 255 if(historical==0) { 256 frame = '<v:roundrect arcsize="'+r+'" strokeweight="0" filled="t" stroked="f" fillcolor="'+color+'" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+(width-offset)+'px;height:'+(height-offset)+';">
256</v:roundrect>'; 257 }else {path = wavedPath(0,0,(width-offset)*10,(height-offset)*10,border*10); 258 frame = '<v:shape strokeweight="0" stroked="f" filled="t" fillcolor="'+color+'" coordorigin="0,0" coordsize="'+((width-offset)*10)+','+((height-offset)*10)+'" path="'+path+'" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+(width-offset)+'px;height:'+(height-offset)+';"></v:shape>'; 259 } 260 shine = '<v:rect strokeweight="0" filled="t" stroked="f" fillcolor="' + color + '" style="zoom:1;margin: 0;padding: 0;display:block;position:absolute;top:'+db+'px;left:'+db+'px;width:' + (width-offset-(2*border)) + 'px;height:' + (height-offset-(2*border)) + ';"><v:fill color="#000000" opacity="' + opacity + '" /></v:rect>'; 261 if(typeof check_strokeTextCapability=='function' && check_strokeTextCapability() && text!='') { 262 over = '<v:rect strokeweight="0" filled="t" stroked="f" fillcolor="'+color+'" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(border-1)+'px;top:'+(height-1-offset-(border*3))+'px;width:'+(width-offset+2-(border*2))+'px;height:'+(border*3)+'px;"></v:rect>'; 263 text = get_widthText(text,ww,border*1.5,100,100); 264 tw = get_textWidth(text,border*1.5,100,100); 265 txt = get_strokeText(text,((width-offset)-tw)/2,height-offset-(border*2.4),border*1.5,100,100,100,"sans-serif",tcolor,1,0); 266 shade = '<v:rect strokeweight="0" filled="'+f+'" stroked="f" fillcolor="transparent" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+db+'px;left:'+db+'px;width:'+(width-offset-(2*border))+'px;height:'+hz+'px;"><v:fill method="sigma" type="gradient" angle="0" color="#000000" opacity="0" color2="#000000" o:opacity2="'+(opacity/2)+'" /></v:rect><v:rect strokeweight="0" filled="'+f+'" stroked="f" fillcolor="transparent" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+(height-offset-(border*3)-hz)+'px;left:'+border+'px;width:'+(width-offset-(2*border))+'px;height:'+hz+'px;"><v:fill method="sigma" type="gradient" angle="0" color="#ffffff" opacity="'+(opacity*0.75)+'" color2="#ffffff" o:opacity2="0" /></v:rect><v:rect strokeweight="2" filled="f" stroked="t" strokecolor="'+color+'" fillcolor="transparent" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+border+'px;left:'+border+'px;width:'+(width-offset-(2*border))+'px;height:'+(height-offset-(4*border))+'px;"><v:fill color="#ffffff" opacity="0" /></v:rect>'; 267 }else { 268 shade = '<v:rect strokeweight="0" filled="'+f+'" stroked="f" fillcolor="transparent" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+db+'px;left:'+db+'px;width:'+(width-offset-(2*border))+'px;height:'+hz+'px;"><v:fill method="sigma" type="gradient" angle="0" color="#000000" opacity="0" color2="#000000" o:opacity2="'+(opacity/2)+'" /></v:rect><v:rect strokeweight="0" filled="'+f+'" stroked="f" fillcolor="transparent" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+(height-offset-border-hz)+'px;left:'+border+'px;width:'+(width-offset-(2*border))+'px;height:'+hz+'px;"><v:fill method="sigma" type="gradient" angle="0" color="#ffffff" opacity="'+(opacity*0.75)+'" color2="#ffffff" o:opacity2="0" /></v:rect><v:rect strokeweight="2" filled="f" stroked="t" strokecolor="'+color+'" fillcolor="transparent" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+border+'px;left:'+border+'px;width:'+(width-offset-(2*border))+'px;height:'+(height-offset-(2*border))+'px;"><v:fill color="#ffffff" opacity="0" /></v:rect>'; 269 } 270 if(preserve==0) { 271 fill = '<v:image src="'+image.src+'" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+db+'px;left:'+db+'px;width:'+(width-offset-(2*border))+'px;height:'+(height-offset-(2*border))+';"></v:image>'; 272 }else { 273 if(width>height) { 274 ff=(height/width); xo=0; yo=((ww*ff)-hh)/2; hh=(ww*ff); yo=(yo/(hh/100)); 275 }else if(width<height) { 276 ff=(width/height); yo=0; xo=((hh*ff)-ww)/2; ww=(hh*ff); xo=(xo/(ww/100)); 277 }else { 278 ff=1; xo=0; yo=0; 279 } 280 fill = '<v:image croptop="'+yo+'%" cropbottom="'+yo+'%" cropleft="'+xo+'%" cropright="'+xo+'%" src="'+image.src+'" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:'+db+'px;left:'+db+'px;width:'+(width-offset-(2*border))+'px;height:'+(height-offset-(2*border))+';"></v:image>'; 281 } 282 foot = '</v:group>'; 283 vml.innerHTML = head+shadow+frame+shine+fill+shade+over+txt+foot; 284 vml.className = newClasses; 285 vml.style.cssText = image.style.cssText; 286 vml.style.visibility = 'visible'; 287 vml.src = image.src; vml.alt = image.alt; 288 vml.width = image.width; vml.height = image.height; 289 if(image.id!='') vml.id = image.id;
290 if(image.title!='') vml.title = image.title; 291 if(image.getAttribute('onclick')!='') vml.setAttribute('onclick',image.getAttribute('onclick')); 292 object.replaceChild(vml,image); 293 } 294 } 295} 296 297function addInstant() { 298 var theimages = getImages('instant'); 299 var image; var object; var canvas; var context; 300 var border = 16; var offset = 8; var inset = 2; 301 var icolor = ''; var ishadow = 0; var noshading; 302 var itiltright; var itiltnone; var itiltleft; 303 var itxttitle; var itxtalt; var itxtcol; var text=""; var tw; 304 var color = ''; var tilt = 'r'; var opacity = 0; var db; 305 var classes = ''; var newClasses = ''; var style = ''; 306 var scale = 0; var xscale = 1; var yscale = 1; 307 var i, ww, hh, ff, yo, xo, tcolor, nocorner, historical, preserve; 308 for(i=0;i<theimages.length;i++) { 309 image = theimages[i]; object = image.parentNode; 310 canvas = document.createElement('canvas'); historical = 0; 311 itxtalt = 0; itxttitle = 0; text=""; tcolor = '#000000'; 312 opacity = 0.33; color = '#f0f4ff'; preserve = 0; nocorner = 0; 313 itiltright = 0; itiltnone = 0; itiltleft = 0; noshading = 0; 314 if(canvas.getContext && image.width>=64 && image.height>=64) { 315 classes = image.className.split(' '); 316 ishadow = getClassValue(classes,"ishadow"); 317 if(ishadow>0) opacity=ishadow/100; 318 icolor = getClassColor(classes,"icolor"); 319 if(icolor!=0) color = icolor; 320 itiltleft = getClassAttribute(classes,"itiltleft"); 321 itiltright = getClassAttribute(classes,"itiltright"); 322 itiltnone = getClassAttribute(classes,"itiltnone"); 323 itxtcol = getClassColor(classes,"itxtcol"); 324 if(itxtcol!=0) tcolor = itxtcol; 325 itxttitle = getClassAttribute(classes,"itxttitle"); 326 itxtalt = getClassAttribute(classes,"itxtalt"); 327 historical = getClassAttribute(classes,"historical"); 328 noshading = getClassAttribute(classes,"noshading"); 329 nocorner = getClassAttribute(classes,"nocorner"); 330 preserve = getClassAttribute(classes,"preserve"); 331 if(historical==true) nocorner = false; 332 if(itiltright==true) tilt = 'r'; 333 if(itiltnone==true) tilt = 'n'; 334 if(itiltleft==true) tilt = 'l'; 335 newClasses = getClasses(classes,"instant"); 336 canvas.className = newClasses; 337 canvas.style.cssText = image.style.cssText; 338 canvas.style.height = image.height+'px'; 339 canvas.style.width = image.width+'px'; 340 canvas.height = image.height; 341 canvas.width = image.width; 342 canvas.src = image.src; canvas.alt = image.alt; 343 if(image.id!='') canvas.id = image.id; 344 if(image.title!='') canvas.title = image.title; 345 if(image.getAttribute('onclick')!='') canvas.setAttribute('onclick',image.getAttribute('onclick')); 346 text = canvas.alt!=''&&itxtalt!=0?canvas.alt:canvas.title!=''&&itxttitle!=0?canvas.title:''; 347 border = Math.round(((canvas.width+canvas.height)/2)*0.05); db = Math.round(Math.max(canvas.width,canvas.height)*0.05); 348 offset = border/2; ww=canvas.width-(border*2); hh=canvas.height-(border*2); 349 inset = Math.floor(Math.min(Math.max(border/8,1),2)); 350 if(canvas.width>canvas.height) { 351 xscale = 0.05; yscale = xscale*(canvas.width/canvas.height); 352 }else if(canvas.width<canvas.height) { 353 yscale = 0.05; xscale = yscale*(canvas.height/canvas.width); 354 }else {xscale = 0.05; yscale = 0.05;} 355 context = canvas.getContext("2d"); 356 object.replaceChild(canvas,image); 357 context.clearRect(0,0,canvas.width,canvas.height);
358 context.save(); scale = 1.333333; 359 if(tilt=='r') { 360 context.translate(db,0); 361 context.scale(1-(scale*xscale),1-(scale*yscale)); 362 context.rotate(0.05); tilt = 'n'; 363 }else if(tilt=='n') { 364 scale = 1.5; tilt = 'l'; 365 context.scale(1-(xscale/scale),1-(yscale/scale)); 366 }else if(tilt=='l') { 367 context.translate(0,db); 368 context.scale(1-(scale*xscale),1-(scale*yscale)); 369 context.rotate(-0.05); tilt = 'r'; 370 } 371 tiltShadow(context,offset,offset,canvas.width,canvas.height,offset,opacity,nocorner); 372 if(historical==1) {wavedRect(context,0,0,canvas.width,canvas.height,border); context.clip(); }else 373 if(nocorner==1) {roundedRect(context,0,0,canvas.width,canvas.height,border); context.clip(); } 374 context.fillStyle = color; 375 context.fillRect(0,0,canvas.width,canvas.height); 376 context.fillStyle = 'rgba(0,0,0,'+opacity+')'; 377 context.fillRect(border,border,canvas.width-(border*2),canvas.height-(border*2)); 378 if(!window.opera) addLining(context,1.5,1.5,canvas.width-3,canvas.height-3,opacity,inset,false,color); 379 if(preserve==0) { 380 context.drawImage(image,border,border,canvas.width-(border*2),canvas.height-(border*2)); 381 }else { 382 if(canvas.width>canvas.height) { 383 ff=(canvas.height/canvas.width); xo=0; yo=((ww*ff)-hh)/2; hh=(ww*ff); 384 }else if(canvas.width<canvas.height) { 385 ff=(canvas.width/canvas.height); yo=0; xo=((hh*ff)-ww)/2; ww=(hh*ff); 386 }else { 387 ff=1; xo=0; yo=0; 388 } 389 context.save(); 390 context.beginPath(); 391 context.rect(border,border,ww-(2*xo),hh-(2*yo)); 392 context.closePath(); 393 context.clip(); 394 context.drawImage(image,border-xo,border-yo,ww,hh); 395 context.restore(); 396 } 397 if(typeof set_textRenderContext=='function' && text!='') { 398 set_textRenderContext(context); 399 if(check_textRenderContext(context)) { 400 context.save(); 401 context.beginPath(); context.rect(1,canvas.height-(border*3),canvas.width-2,(border*3)); context.closePath(); context.fillStyle = color; context.fill(); 402 context.restore(); 403 if(noshading==0) addShading(context,border,border,canvas.width-(border*2),canvas.height-(border*4),opacity); 404 if(!window.opera) addLining(context,border,border,canvas.width-(border*2),canvas.height-(border*4),opacity,inset,true); 405 context.strokeStyle = tcolor; text=get_widthText(text,ww,border*1.5,100,100); tw=get_textWidth(text,border*1.5,100,100); 406 context.strokeText(text,border+((ww-tw)/2),canvas.height-(border*2.4),border*1.5,100,100,100); 407 } 408 }else { 409 if(noshading==0) addShading(context,border,border,canvas.width-(border*2),canvas.height-(border*2),opacity); 410 if(!window.opera) addLining(context,border,border,canvas.width-(border*2),canvas.height-(border*2),opacity,inset,true); 411 } 412 context.restore(); 413 canvas.style.visibility = 'visible'; 414 } 415 } 416} 417 418var instantOnload = window.onload; 419window.onload = function () { if(instantOnload) instantOnload(); if(isIE){addIEInstant(); }else {addInstant();}}
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.