Mercurial > laserkard
view awesome_js/robert.js @ 72:83b0419c7979 laserkard
implemented temporary buy page in clojure
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 23 Jun 2010 01:01:40 -0400 |
parents | 14271eedf004 |
children | 781127893010 |
line wrap: on
line source
2 descHash = new Object();4 prevVal = "";8 descHash.classic_acrylic_clear =9 "<h1>The Classic LaserKard.</h1>Balanced and Complete. The original LaserKard. For those that wish to leave no stone unturned. It's all there.";11 descHash.big_acrylic_clear =12 "<h1>The Bold Kard.</h1>Austere and Iconic. For those that wish to leave an impression with the power of their name accompanied only by their main method of contact. Bold, period.";14 descHash.basic_acrylic_clear =15 "<h1>The Arrow Kard.</h1>Precise and Straightforward. For those that seek to make a statement while being clear and concise. Straight as an arrow.";17 descHash.lines_acrylic_clear =18 "<h1>The Direct Kard.</h1>Thorough and Distinct. For those that aim to demonstrate their professionalism with style. Push the envelope. Be Direct.";20 color = 'fefefe';25 function pokedex(target)26 {29 var description = eval ("descHash." + target);31 document.getElementById('pokedex').innerHTML = description;33 }37 function stabForm(ID)38 {39 var JSONtext = document.getElementById('formValues').innerHTML;40 var hash = new Object();41 hash = eval('(' + JSONtext + ')');43 propertyValue = document.getElementById(ID).value;44 propertyName = ID;45 propertyValue = escape(propertyValue);47 eval("hash."+propertyName+"='"+propertyValue+"'");49 var JSONtext = document.getElementById('formValues').innerHTML = JSON.stringify(hash);50 }54 function getPosition(style, field)55 {57 var cardType = eval ("laserkard." + style);60 if ( eval("typeof cardType." + field + " != 'undefined'")) //shouldn't ever really matter61 {62 values = eval("cardType." + field);64 if (typeof values.posx != 'undefined'){posx = values.posx;}65 if (typeof values.posy != 'undefined'){posy = values.posy;}66 if (typeof values.center != 'undefined'){center = values.center;}67 if (typeof values.font != 'undefined'){font = values.font;}68 if (typeof values.face != 'undefined'){face = values.face;}69 if (typeof values.width != 'undefined'){width = values.width;}70 if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;}71 if (typeof values.resize != 'undefined'){resize = values.resize;}72 }75 }77 //~ function smallRedraw(style,field)78 //~ {79 //~ //smallRedraw(style,field,"fefefe");80 //~ sRedraw(style,field,'fefefe');81 //~ }84 function smallRedraw(style,field)85 {87 var JSONtext = document.getElementById('formValues').innerHTML;88 var hash = new Object();89 hash = eval('(' + JSONtext + ')');91 var content = eval("hash."+field);93 content = unescape(content);95 //if (prevVal == content){return;}97 contentRedraw(style,field, content);100 }104 function contentRedraw(style,field, content)105 {107 //var color = color;112 posx = 10;113 posy = 10;114 center = 0;115 font = 10;116 face = 700;117 weirdFlip = 0;118 resize = 1;119 width = 450;121 getPosition(style, field);126 target = "d_" + field;129 var whatev = eval("typeof " + target + " != 'undefined'")131 if (whatev){eval ("{" + target + ".remove();}");}133 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );136 var sizzle = eval(target+".getBBox().width;");138 document.getElementById('output').innerHTML = sizzle;141 if (resize == 1)143 {148 //base case149 if ((sizzle) > width)150 {152 mul = .9;155 mul = (width/sizzle);158 font = font * mul;160 //eval( target + ".scale(mul,mul)" );162 eval ( target + ".remove();");163 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );166 }170 }173 var targetFont = 2.3 *font/385.16 + 2.3*0.311;175 if (font <25)176 {178 targetFont = targetFont * 0.75;180 }183 eval ( target +".attr('stroke-width', targetFont);");184 //eval ( target +".attr('stroke-width', font/385.16 + 0.311);");186 var sizzle = eval(target+".getBBox().width;");188 document.getElementById('output').innerHTML = sizzle;190 eval ( target +".attr('stroke', '#" + color + "');");191 //eval ( target +".attr('stroke', '#fbafcd');");193 eval ( target +".attr('fill', 'none');");198 if (center == 1)199 {200 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);");201 }204 if (weirdFlip == 1)205 {206 eval("var c = "+target+".getBBox().width;");207 eval(target+ ".translate((317 - c)/2,0);");208 eval(target+".translate(0, -490);");209 eval(target+".rotate(90,0,0);");210 }214 prevVal = content;218 }220 function clearAll()221 {222 if(typeof d_Name != 'undefined' ){d_Name.remove();}223 if(typeof d_Company != 'undefined' ){d_Company.remove();}224 if(typeof d_Email != 'undefined' ){d_Email.remove();}225 if(typeof d_Occupation != 'undefined' ){d_Occupation.remove();}226 if(typeof d_Phone != 'undefined' ){d_Phone.remove();}227 if(typeof d_Website != 'undefined' ){d_Website.remove();}229 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}230 }233 function lineDraw(style, color)234 {240 if (style == "bold")241 {return;}245 if (style == "arrow")246 {247 d_lineArt = raphe.path("M 4 272 L 258 272");248 d_lineArt.attr('stroke', "#" + color);249 return;250 }253 if (style == "classic")254 {return;}257 if (style == "direct")258 {259 d_lineArt = raphe.path("M 350 165 L 512 165 M 350 173 L 512 173 M 350 181 L 512 181 M 350 189 L 512 189 M 350 197 L 512 197 M 350 213 L 512 213 M 350 205 L 512 205 M 350 221 L 512 221");260 d_lineArt.attr('stroke', "#" + color);261 return;262 }264 }268 function redraw(style)269 {274 if (style == "bold")275 {277 clearAll();278 smallRedraw("bold","Name");279 smallRedraw("bold","Email");283 }286 if (style == "arrow")287 {289 clearAll();291 smallRedraw("arrow","Name");292 smallRedraw("arrow","Email");293 smallRedraw("arrow","Occupation");294 smallRedraw("arrow","Company");297 }300 if (style == "classic")301 {303 clearAll();305 smallRedraw("classic","Name");306 smallRedraw("classic","Email");307 smallRedraw("classic","Occupation");308 smallRedraw("classic","Company");309 smallRedraw("classic","Phone");310 smallRedraw("classic","Website");311 }314 if (style == "direct")315 {317 clearAll();319 smallRedraw("direct","Name");320 smallRedraw("direct","Email");321 smallRedraw("direct","Occupation");322 smallRedraw("direct","Company");323 smallRedraw("direct","Phone");324 smallRedraw("direct","Website");327 }329 lineDraw(style, "fefefe");333 }