Mercurial > laserkard
diff 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 diff
1.1 --- a/awesome_js/robert.js Thu Jan 28 00:32:54 2010 -0500 1.2 +++ b/awesome_js/robert.js Thu Jan 28 04:10:44 2010 -0500 1.3 @@ -1,5 +1,3 @@ 1.4 - 1.5 - 1.6 1.7 function defaults() 1.8 { 1.9 @@ -13,55 +11,125 @@ 1.10 } 1.11 1.12 1.13 -function drawElement(obj) 1.14 + 1.15 +function stabForm(ID) 1.16 { 1.17 +var JSONtext = document.getElementById('formValues').innerHTML; 1.18 +var hash = new Object(); 1.19 +hash = eval('(' + JSONtext + ')'); 1.20 + 1.21 +propertyValue = document.getElementById(ID).value; 1.22 +propertyName = ID; 1.23 +propertyValue = escape(propertyValue); 1.24 + 1.25 +eval("hash."+propertyName+"='"+propertyValue+"'"); 1.26 1.27 +var JSONtext = document.getElementById('formValues').innerHTML = JSON.stringify(hash); 1.28 +} 1.29 + 1.30 + 1.31 + 1.32 +function getPosition(style, field) 1.33 +{ 1.34 + 1.35 +var cardType = eval ("laserkard." + style); 1.36 + 1.37 + 1.38 +if ( eval("typeof cardType." + field + " != 'undefined'")) //shouldn't ever really matter 1.39 +{ 1.40 +values = eval("cardType." + field); 1.41 + 1.42 +if (typeof values.posx != 'undefined'){posx = values.posx;} 1.43 +if (typeof values.posy != 'undefined'){posy = values.posy;} 1.44 +if (typeof values.center != 'undefined'){center = values.center;} 1.45 +if (typeof values.font != 'undefined'){font = values.font;} 1.46 +if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;} 1.47 +} 1.48 + 1.49 + 1.50 +} 1.51 + 1.52 + 1.53 + 1.54 + 1.55 +function smallRedraw(style,field) 1.56 +{ 1.57 + 1.58 +var JSONtext = document.getElementById('formValues').innerHTML; 1.59 +var hash = new Object(); 1.60 +hash = eval('(' + JSONtext + ')'); 1.61 + 1.62 +var content = eval("hash."+field); 1.63 + 1.64 + content = unescape(content); 1.65 + 1.66 +posx = 10; 1.67 +posy = 10; 1.68 +center = 0; 1.69 +font = 10; 1.70 +face = 700; 1.71 +weirdFlip = 0; 1.72 + 1.73 +getPosition(style, field); 1.74 + 1.75 +target = "d_" + field; 1.76 + 1.77 + 1.78 +var whatev = eval("typeof " + target + " != 'undefined'") 1.79 + 1.80 +if (whatev){eval ("{" + target + ".remove();}");} 1.81 + 1.82 +eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" ); 1.83 + 1.84 + 1.85 +eval ( target +".attr('stroke', '#6a6a6a');"); 1.86 +eval ( target +".attr('fill', 'none');"); 1.87 + 1.88 + 1.89 +if (center == 1) 1.90 +{ 1.91 +eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);"); 1.92 +} 1.93 + 1.94 + 1.95 +if (weirdFlip == 1) 1.96 +{ 1.97 +eval("var c = "+target+".getBBox().width;"); 1.98 +eval(target+ ".translate((317 - c)/2,0);"); 1.99 +eval(target+".translate(0, -490);"); 1.100 +eval(target+".rotate(90,0,0);"); 1.101 +} 1.102 + 1.103 + 1.104 + 1.105 + 1.106 + 1.107 +} 1.108 + 1.109 +function clearAll() 1.110 +{ 1.111 +if(typeof d_Name != 'undefined' ){d_Name.remove();} 1.112 +if(typeof d_Company != 'undefined' ){d_Company.remove();} 1.113 +if(typeof d_Email != 'undefined' ){d_Email.remove();} 1.114 +if(typeof d_Occupation != 'undefined' ){d_Occupation.remove();} 1.115 +if(typeof d_Phone != 'undefined' ){d_Phone.remove();} 1.116 +if(typeof d_Website != 'undefined' ){d_Website.remove();} 1.117 + 1.118 +if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();} 1.119 } 1.120 1.121 function redraw(style) 1.122 { 1.123 1.124 1.125 -var JSONtext = document.getElementById('formValues').innerHTML; 1.126 -var hash = new Object(); 1.127 -hash = eval('(' + JSONtext + ')'); 1.128 1.129 -if(hash.Name){alias = hash.Name;} 1.130 -if(hash.Email){email = hash.Email;} 1.131 -if(hash.Occupation){occupation = hash.Occupation;} 1.132 -if(hash.Company){company = hash.Company;} 1.133 -if(hash.Phone){phone = hash.Phone;} 1.134 -if(hash.website){website = Website;} 1.135 1.136 if (style == "bold") 1.137 { 1.138 1.139 - 1.140 - 1.141 -if(typeof d_alias != 'undefined' ){d_alias.remove();} 1.142 -if(typeof d_email != 'undefined' ){d_email.remove();} 1.143 -if(typeof d_occupation != 'undefined' ){d_occupation.remove();} 1.144 -if(typeof d_company != 'undefined' ){d_company.remove();} 1.145 -if(typeof d_phone != 'undefined' ){d_phone.remove();} 1.146 -if(typeof d_website != 'undefined' ){d_website.remove();} 1.147 -if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();} 1.148 - 1.149 - 1.150 - 1.151 - 1.152 -d_alias = raphe.print(10, 160, alias, raphe.getFont('HelveticaNeue', 700), 60); 1.153 -d_alias.attr('stroke', '#6a6a6a'); 1.154 -d_alias.attr('fill', 'none') 1.155 -var c = d_alias.getBBox().width; 1.156 -d_alias.translate((485 - c)/2,0); 1.157 - 1.158 - 1.159 - 1.160 - 1.161 -d_email = raphe.print(280, 270, email, raphe.getFont("HelveticaNeue", 700), 25); 1.162 -d_email.attr('stroke', '#6a6a6a'); 1.163 -d_email.attr('fill', 'TRANSPARENT'); 1.164 - 1.165 +clearAll(); 1.166 +smallRedraw("bold","Name"); 1.167 +smallRedraw("bold","Email"); 1.168 1.169 1.170 1.171 @@ -71,32 +139,14 @@ 1.172 if (style == "arrow") 1.173 { 1.174 1.175 -if(typeof d_alias != 'undefined' ){d_alias.remove();} 1.176 -if(typeof d_email != 'undefined' ){d_email.remove();} 1.177 -if(typeof d_occupation != 'undefined' ){d_occupation.remove();} 1.178 -if(typeof d_company != 'undefined' ){d_company.remove();} 1.179 -if(typeof d_phone != 'undefined' ){d_phone.remove();} 1.180 -if(typeof d_website != 'undefined' ){d_website.remove();} 1.181 -if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();} 1.182 +clearAll(); 1.183 1.184 +smallRedraw("arrow","Name"); 1.185 +smallRedraw("arrow","Email"); 1.186 +smallRedraw("arrow","Occupation"); 1.187 +smallRedraw("arrow","Company"); 1.188 1.189 1.190 -d_alias = raphe.print(40, 110, alias, raphe.getFont('HelveticaNeue', 700), 55); 1.191 -d_alias.attr('stroke', '#6a6a6a'); 1.192 -d_alias.attr('fill', 'none') 1.193 - 1.194 -d_company = raphe.print(40, 155, company, raphe.getFont("HelveticaNeue", 700), 27); 1.195 -d_company.attr('stroke', '#6a6a6a'); 1.196 -d_company.attr('fill', 'TRANSPARENT'); 1.197 - 1.198 -d_occupation = raphe.print(40, 190, occupation, raphe.getFont("HelveticaNeue", 700), 27); 1.199 -d_occupation.attr('stroke', '#6a6a6a'); 1.200 -d_occupation.attr('fill', 'TRANSPARENT'); 1.201 - 1.202 -d_email = raphe.print(280, 270, email, raphe.getFont("HelveticaNeue", 700), 25); 1.203 -d_email.attr('stroke', '#6a6a6a'); 1.204 -d_email.attr('fill', 'TRANSPARENT'); 1.205 - 1.206 d_lineArt = raphe.path("M 2 272 L 258 272"); 1.207 d_lineArt.attr('stroke', '#6a6a6a'); 1.208 1.209 @@ -105,113 +155,29 @@ 1.210 1.211 if (style == "classic") 1.212 { 1.213 - 1.214 -if(typeof d_alias != 'undefined' ){d_alias.remove();} 1.215 -if(typeof d_email != 'undefined' ){d_email.remove();} 1.216 -if(typeof d_occupation != 'undefined' ){d_occupation.remove();} 1.217 -if(typeof d_company != 'undefined' ){d_company.remove();} 1.218 -if(typeof d_phone != 'undefined' ){d_phone.remove();} 1.219 -if(typeof d_website != 'undefined' ){d_website.remove();} 1.220 -if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();} 1.221 1.222 +clearAll(); 1.223 1.224 -d_email = raphe.print(0, 42, email, raphe.getFont("HelveticaNeue", 700), 29); 1.225 -d_email.attr('stroke', '#6a6a6a'); 1.226 -d_email.attr('fill', 'TRANSPARENT'); 1.227 -var c = d_email.getBBox().width; 1.228 -d_email.translate((510 - c)/2,0); 1.229 - 1.230 - 1.231 - 1.232 -d_phone = raphe.print(0, 75, phone, raphe.getFont("HelveticaNeue", 700), 27); 1.233 -d_phone.attr('stroke', '#6a6a6a'); 1.234 -d_phone.attr('fill', 'TRANSPARENT'); 1.235 -var c = d_phone.getBBox().width; 1.236 -d_phone.translate((510 - c)/2,0); 1.237 - 1.238 - 1.239 -d_alias = raphe.print(0, 164, alias, raphe.getFont('HelveticaNeue', 800), 47); 1.240 -d_alias.attr('stroke', '#6a6a6a'); 1.241 -d_alias.attr('fill', 'none') 1.242 -var c = d_alias.getBBox().width; 1.243 -d_alias.translate((510 - c)/2,0); 1.244 - 1.245 - 1.246 -d_company = raphe.print(0, 247, company, raphe.getFont("HelveticaNeue", 700), 27); 1.247 -d_company.attr('stroke', '#6a6a6a'); 1.248 -d_company.attr('fill', 'TRANSPARENT'); 1.249 -var c = d_company.getBBox().width; 1.250 -d_company.translate((510 - c)/2,0); 1.251 - 1.252 - 1.253 - 1.254 -d_occupation = raphe.print(0, 278, occupation, raphe.getFont("HelveticaNeue", 700), 27); 1.255 -d_occupation.attr('stroke', '#6a6a6a'); 1.256 -d_occupation.attr('fill', 'TRANSPARENT'); 1.257 -var c = d_occupation.getBBox().width; 1.258 -d_occupation.translate((510 - c)/2,0); 1.259 - 1.260 - 1.261 -d_website = raphe.print(0, 0, website, raphe.getFont("HelveticaNeue", 700), 21); 1.262 -d_website.attr('stroke', '#6a6a6a'); 1.263 -d_website.attr('fill', 'TRANSPARENT'); 1.264 - 1.265 -var c = d_website.getBBox().width; 1.266 -d_website.translate((317 - c)/2,0); 1.267 - 1.268 -d_website.translate(0, -490); 1.269 -d_website.rotate(90,0,0); 1.270 +smallRedraw("classic","Name"); 1.271 +smallRedraw("classic","Email"); 1.272 +smallRedraw("classic","Occupation"); 1.273 +smallRedraw("classic","Company"); 1.274 +smallRedraw("classic","Phone"); 1.275 +smallRedraw("classic","Website"); 1.276 } 1.277 1.278 1.279 if (style == "direct") 1.280 { 1.281 1.282 -if(typeof d_alias != 'undefined' ){d_alias.remove();} 1.283 -if(typeof d_email != 'undefined' ){d_email.remove();} 1.284 -if(typeof d_occupation != 'undefined' ){d_occupation.remove();} 1.285 -if(typeof d_company != 'undefined' ){d_company.remove();} 1.286 -if(typeof d_phone != 'undefined' ){d_phone.remove();} 1.287 -if(typeof d_website != 'undefined' ){d_website.remove();} 1.288 -if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();} 1.289 +clearAll(); 1.290 1.291 - 1.292 - 1.293 - 1.294 -d_alias = raphe.print(37, 70, alias, raphe.getFont('HelveticaNeue', 700), 55); 1.295 -d_alias.attr('stroke', '#6a6a6a'); 1.296 -d_alias.attr('fill', 'none') 1.297 - 1.298 - 1.299 - 1.300 -d_occupation = raphe.print(37, 120, occupation, raphe.getFont("HelveticaNeue", 700), 27); 1.301 -d_occupation.attr('stroke', '#6a6a6a'); 1.302 -d_occupation.attr('fill', 'TRANSPARENT'); 1.303 - 1.304 - 1.305 - 1.306 -d_company = raphe.print(37, 178, company, raphe.getFont("HelveticaNeue", 700), 27); 1.307 -d_company.attr('stroke', '#6a6a6a'); 1.308 -d_company.attr('fill', 'TRANSPARENT'); 1.309 - 1.310 - 1.311 - 1.312 -d_phone = raphe.print(37, 210, phone, raphe.getFont("HelveticaNeue", 700), 27); 1.313 -d_phone.attr('stroke', '#6a6a6a'); 1.314 -d_phone.attr('fill', 'TRANSPARENT'); 1.315 - 1.316 - 1.317 - 1.318 -d_email = raphe.print(37, 240, email, raphe.getFont("HelveticaNeue", 700), 27); 1.319 -d_email.attr('stroke', '#6a6a6a'); 1.320 -d_email.attr('fill', 'TRANSPARENT'); 1.321 - 1.322 - 1.323 - 1.324 - 1.325 -d_website = raphe.print(37, 270, website, raphe.getFont("HelveticaNeue", 700), 27); 1.326 -d_website.attr('stroke', '#6a6a6a'); 1.327 -d_website.attr('fill', 'TRANSPARENT'); 1.328 +smallRedraw("direct","Name"); 1.329 +smallRedraw("direct","Email"); 1.330 +smallRedraw("direct","Occupation"); 1.331 +smallRedraw("direct","Company"); 1.332 +smallRedraw("direct","Phone"); 1.333 +smallRedraw("direct","Website"); 1.334 1.335 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"); 1.336 d_lineArt.attr('stroke', '#6a6a6a');