Mercurial > laserkard
view awesome_js/robert.js @ 81:6adb5da55d18 laserkard
getting color select working
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 25 Jul 2010 05:45:56 -0400 |
parents | 343dc947f999 |
children |
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 }79 function smallRedraw(style,field)80 {82 var JSONtext = document.getElementById('formValues').innerHTML;83 var hash = new Object();84 hash = eval('(' + JSONtext + ')');86 var content = eval("hash."+field);88 content = unescape(content);91 contentRedraw(style,field, content);92 }96 function contentRedraw(style,field, content)97 {99 //var color = color;104 posx = 10;105 posy = 10;106 center = 0;107 font = 10;108 face = 700;109 weirdFlip = 0;110 resize = 1;111 width = 450;113 getPosition(style, field);118 target = "d_" + field;121 var whatev = eval("typeof " + target + " != 'undefined'")123 if (whatev){eval ("{" + target + ".remove();}");}125 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );128 var sizzle = eval(target+".getBBox().width;");130 document.getElementById('output').innerHTML = sizzle;133 if (resize == 1)135 {140 //base case141 if ((sizzle) > width)142 {144 mul = .9;147 mul = (width/sizzle);150 font = font * mul;152 //eval( target + ".scale(mul,mul)" );154 eval ( target + ".remove();");155 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );158 }162 }165 var targetFont = 2.3 *font/385.16 + 2.3*0.311;167 if (font <25)168 {170 targetFont = targetFont * 0.75;172 }175 eval ( target +".attr('stroke-width', targetFont);");176 //eval ( target +".attr('stroke-width', font/385.16 + 0.311);");178 var sizzle = eval(target+".getBBox().width;");180 document.getElementById('output').innerHTML = sizzle;182 eval ( target +".attr('stroke', '#" + color + "');");183 //eval ( target +".attr('stroke', '#fbafcd');");185 eval ( target +".attr('fill', '#" + color + "');");190 if (center == 1)191 {192 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);");193 }196 if (weirdFlip == 1)197 {198 eval("var c = "+target+".getBBox().width;");199 eval(target+ ".translate((317 - c)/2,0);");200 eval(target+".translate(0, -490);");201 eval(target+".rotate(90,0,0);");202 }206 prevVal = content;210 }212 function clearAll()213 {214 if(typeof d_Name != 'undefined' ){d_Name.remove();}215 if(typeof d_Company != 'undefined' ){d_Company.remove();}216 if(typeof d_Email != 'undefined' ){d_Email.remove();}217 if(typeof d_Occupation != 'undefined' ){d_Occupation.remove();}218 if(typeof d_Phone != 'undefined' ){d_Phone.remove();}219 if(typeof d_Website != 'undefined' ){d_Website.remove();}221 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}222 }225 function lineDraw(style, color)226 {232 if (style == "bold")233 {return;}237 if (style == "arrow")238 {239 d_lineArt = raphe.path("M 4 272 L 258 272");240 d_lineArt.attr('stroke', "#" + color);241 return;242 }245 if (style == "classic")246 {return;}249 if (style == "direct")250 {251 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");252 d_lineArt.attr('stroke', "#" + color);253 return;254 }256 }260 function redraw(style)261 {266 if (style == "bold")267 {269 clearAll();270 smallRedraw("bold","Name");271 smallRedraw("bold","Email");275 }278 if (style == "arrow")279 {281 clearAll();283 smallRedraw("arrow","Name");284 smallRedraw("arrow","Email");285 smallRedraw("arrow","Occupation");286 smallRedraw("arrow","Company");289 }292 if (style == "classic")293 {295 clearAll();297 smallRedraw("classic","Name");298 smallRedraw("classic","Email");299 smallRedraw("classic","Occupation");300 smallRedraw("classic","Company");301 smallRedraw("classic","Phone");302 smallRedraw("classic","Website");303 }306 if (style == "direct")307 {309 clearAll();311 smallRedraw("direct","Name");312 smallRedraw("direct","Email");313 smallRedraw("direct","Occupation");314 smallRedraw("direct","Company");315 smallRedraw("direct","Phone");316 smallRedraw("direct","Website");319 }321 lineDraw(style, "fefefe");325 }