Mercurial > laserkard
view awesome_js/robert.js @ 44:1045db9799e3 laserkard
[svn r45] Greatly Enhanced Responsiveness of the website.
author | rlm |
---|---|
date | Thu, 28 Jan 2010 04:10:44 -0500 |
parents | 329638a361cc |
children | 26c2b3ad21c7 |
line wrap: on
line source
2 function defaults()3 {4 alias = "Robert Mac";5 email = "rlm@mit.edu";6 occupation = "";7 company = "";8 phone = "";9 website = "";10 lineArt = "";11 }15 function stabForm(ID)16 {17 var JSONtext = document.getElementById('formValues').innerHTML;18 var hash = new Object();19 hash = eval('(' + JSONtext + ')');21 propertyValue = document.getElementById(ID).value;22 propertyName = ID;23 propertyValue = escape(propertyValue);25 eval("hash."+propertyName+"='"+propertyValue+"'");27 var JSONtext = document.getElementById('formValues').innerHTML = JSON.stringify(hash);28 }32 function getPosition(style, field)33 {35 var cardType = eval ("laserkard." + style);38 if ( eval("typeof cardType." + field + " != 'undefined'")) //shouldn't ever really matter39 {40 values = eval("cardType." + field);42 if (typeof values.posx != 'undefined'){posx = values.posx;}43 if (typeof values.posy != 'undefined'){posy = values.posy;}44 if (typeof values.center != 'undefined'){center = values.center;}45 if (typeof values.font != 'undefined'){font = values.font;}46 if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;}47 }50 }55 function smallRedraw(style,field)56 {58 var JSONtext = document.getElementById('formValues').innerHTML;59 var hash = new Object();60 hash = eval('(' + JSONtext + ')');62 var content = eval("hash."+field);64 content = unescape(content);66 posx = 10;67 posy = 10;68 center = 0;69 font = 10;70 face = 700;71 weirdFlip = 0;73 getPosition(style, field);75 target = "d_" + field;78 var whatev = eval("typeof " + target + " != 'undefined'")80 if (whatev){eval ("{" + target + ".remove();}");}82 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );85 eval ( target +".attr('stroke', '#6a6a6a');");86 eval ( target +".attr('fill', 'none');");89 if (center == 1)90 {91 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);");92 }95 if (weirdFlip == 1)96 {97 eval("var c = "+target+".getBBox().width;");98 eval(target+ ".translate((317 - c)/2,0);");99 eval(target+".translate(0, -490);");100 eval(target+".rotate(90,0,0);");101 }107 }109 function clearAll()110 {111 if(typeof d_Name != 'undefined' ){d_Name.remove();}112 if(typeof d_Company != 'undefined' ){d_Company.remove();}113 if(typeof d_Email != 'undefined' ){d_Email.remove();}114 if(typeof d_Occupation != 'undefined' ){d_Occupation.remove();}115 if(typeof d_Phone != 'undefined' ){d_Phone.remove();}116 if(typeof d_Website != 'undefined' ){d_Website.remove();}118 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}119 }121 function redraw(style)122 {127 if (style == "bold")128 {130 clearAll();131 smallRedraw("bold","Name");132 smallRedraw("bold","Email");136 }139 if (style == "arrow")140 {142 clearAll();144 smallRedraw("arrow","Name");145 smallRedraw("arrow","Email");146 smallRedraw("arrow","Occupation");147 smallRedraw("arrow","Company");150 d_lineArt = raphe.path("M 2 272 L 258 272");151 d_lineArt.attr('stroke', '#6a6a6a');153 }156 if (style == "classic")157 {159 clearAll();161 smallRedraw("classic","Name");162 smallRedraw("classic","Email");163 smallRedraw("classic","Occupation");164 smallRedraw("classic","Company");165 smallRedraw("classic","Phone");166 smallRedraw("classic","Website");167 }170 if (style == "direct")171 {173 clearAll();175 smallRedraw("direct","Name");176 smallRedraw("direct","Email");177 smallRedraw("direct","Occupation");178 smallRedraw("direct","Company");179 smallRedraw("direct","Phone");180 smallRedraw("direct","Website");182 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");183 d_lineArt.attr('stroke', '#6a6a6a');187 }193 }