annotate awesome_js/robert.js @ 76:781127893010 laserkard

made card text filled in
author Robert McIntyre <rlm@mit.edu>
date Wed, 14 Jul 2010 13:44:42 -0400
parents 14271eedf004
children 343dc947f999
rev   line source
rlm@29 1
rlm@47 2 descHash = new Object();
rlm@47 3
rlm@48 4 prevVal = "";
rlm@47 5
rlm@47 6
rlm@47 7
rlm@47 8 descHash.classic_acrylic_clear =
rlm@47 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.";
rlm@47 10
rlm@47 11 descHash.big_acrylic_clear =
rlm@47 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.";
rlm@47 13
rlm@47 14 descHash.basic_acrylic_clear =
rlm@47 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.";
rlm@47 16
rlm@47 17 descHash.lines_acrylic_clear =
rlm@47 18 "<h1>The Direct Kard.</h1>Thorough and Distinct. For those that aim to demonstrate their professionalism with style. Push the envelope. Be Direct.";
rlm@47 19
rlm@51 20 color = 'fefefe';
rlm@47 21
rlm@47 22
rlm@47 23
rlm@47 24
rlm@47 25 function pokedex(target)
rlm@47 26 {
rlm@47 27
rlm@47 28
rlm@47 29 var description = eval ("descHash." + target);
rlm@47 30
rlm@47 31 document.getElementById('pokedex').innerHTML = description;
rlm@47 32
rlm@47 33 }
rlm@29 34
rlm@29 35
rlm@44 36
rlm@44 37 function stabForm(ID)
rlm@42 38 {
rlm@44 39 var JSONtext = document.getElementById('formValues').innerHTML;
rlm@44 40 var hash = new Object();
rlm@44 41 hash = eval('(' + JSONtext + ')');
rlm@44 42
rlm@44 43 propertyValue = document.getElementById(ID).value;
rlm@44 44 propertyName = ID;
rlm@44 45 propertyValue = escape(propertyValue);
rlm@44 46
rlm@44 47 eval("hash."+propertyName+"='"+propertyValue+"'");
rlm@42 48
rlm@44 49 var JSONtext = document.getElementById('formValues').innerHTML = JSON.stringify(hash);
rlm@44 50 }
rlm@44 51
rlm@44 52
rlm@44 53
rlm@44 54 function getPosition(style, field)
rlm@44 55 {
rlm@44 56
rlm@44 57 var cardType = eval ("laserkard." + style);
rlm@44 58
rlm@44 59
rlm@44 60 if ( eval("typeof cardType." + field + " != 'undefined'")) //shouldn't ever really matter
rlm@44 61 {
rlm@44 62 values = eval("cardType." + field);
rlm@44 63
rlm@44 64 if (typeof values.posx != 'undefined'){posx = values.posx;}
rlm@44 65 if (typeof values.posy != 'undefined'){posy = values.posy;}
rlm@44 66 if (typeof values.center != 'undefined'){center = values.center;}
rlm@44 67 if (typeof values.font != 'undefined'){font = values.font;}
rlm@48 68 if (typeof values.face != 'undefined'){face = values.face;}
rlm@48 69 if (typeof values.width != 'undefined'){width = values.width;}
rlm@44 70 if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;}
rlm@48 71 if (typeof values.resize != 'undefined'){resize = values.resize;}
rlm@44 72 }
rlm@44 73
rlm@44 74
rlm@44 75 }
rlm@44 76
rlm@51 77 //~ function smallRedraw(style,field)
rlm@51 78 //~ {
rlm@51 79 //~ //smallRedraw(style,field,"fefefe");
rlm@51 80 //~ sRedraw(style,field,'fefefe');
rlm@51 81 //~ }
rlm@44 82
rlm@44 83
rlm@44 84 function smallRedraw(style,field)
rlm@44 85 {
rlm@51 86
rlm@44 87 var JSONtext = document.getElementById('formValues').innerHTML;
rlm@44 88 var hash = new Object();
rlm@44 89 hash = eval('(' + JSONtext + ')');
rlm@44 90
rlm@44 91 var content = eval("hash."+field);
rlm@44 92
rlm@44 93 content = unescape(content);
rlm@44 94
rlm@51 95 //if (prevVal == content){return;}
rlm@51 96
rlm@51 97 contentRedraw(style,field, content);
rlm@51 98
rlm@51 99
rlm@51 100 }
rlm@51 101
rlm@51 102
rlm@51 103
rlm@51 104 function contentRedraw(style,field, content)
rlm@51 105 {
rlm@51 106
rlm@51 107 //var color = color;
rlm@51 108
rlm@51 109
rlm@51 110
rlm@48 111
rlm@44 112 posx = 10;
rlm@44 113 posy = 10;
rlm@44 114 center = 0;
rlm@44 115 font = 10;
rlm@44 116 face = 700;
rlm@44 117 weirdFlip = 0;
rlm@48 118 resize = 1;
rlm@48 119 width = 450;
rlm@44 120
rlm@44 121 getPosition(style, field);
rlm@44 122
rlm@48 123
rlm@48 124
rlm@48 125
rlm@44 126 target = "d_" + field;
rlm@44 127
rlm@44 128
rlm@44 129 var whatev = eval("typeof " + target + " != 'undefined'")
rlm@44 130
rlm@44 131 if (whatev){eval ("{" + target + ".remove();}");}
rlm@44 132
rlm@44 133 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );
rlm@44 134
rlm@48 135
rlm@48 136 var sizzle = eval(target+".getBBox().width;");
rlm@48 137
rlm@48 138 document.getElementById('output').innerHTML = sizzle;
rlm@48 139
rlm@48 140
rlm@48 141 if (resize == 1)
rlm@48 142
rlm@48 143 {
rlm@48 144
rlm@48 145
rlm@48 146
rlm@48 147
rlm@48 148 //base case
rlm@48 149 if ((sizzle) > width)
rlm@48 150 {
rlm@48 151
rlm@48 152 mul = .9;
rlm@48 153
rlm@48 154
rlm@48 155 mul = (width/sizzle);
rlm@48 156
rlm@48 157
rlm@48 158 font = font * mul;
rlm@48 159
rlm@48 160 //eval( target + ".scale(mul,mul)" );
rlm@48 161
rlm@48 162 eval ( target + ".remove();");
rlm@56 163 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );
rlm@48 164
rlm@48 165
rlm@48 166 }
rlm@48 167
rlm@48 168
rlm@48 169
rlm@48 170 }
rlm@61 171
rlm@61 172
rlm@61 173 var targetFont = 2.3 *font/385.16 + 2.3*0.311;
rlm@61 174
rlm@61 175 if (font <25)
rlm@61 176 {
rlm@61 177
rlm@61 178 targetFont = targetFont * 0.75;
rlm@61 179
rlm@61 180 }
rlm@61 181
rlm@61 182
rlm@61 183 eval ( target +".attr('stroke-width', targetFont);");
rlm@56 184 //eval ( target +".attr('stroke-width', font/385.16 + 0.311);");
rlm@48 185
rlm@48 186 var sizzle = eval(target+".getBBox().width;");
rlm@48 187
rlm@48 188 document.getElementById('output').innerHTML = sizzle;
rlm@48 189
rlm@51 190 eval ( target +".attr('stroke', '#" + color + "');");
rlm@48 191 //eval ( target +".attr('stroke', '#fbafcd');");
rlm@48 192
rlm@76 193 eval ( target +".attr('fill', '#" + color + "');");
rlm@44 194
rlm@44 195
rlm@48 196
rlm@48 197
rlm@44 198 if (center == 1)
rlm@44 199 {
rlm@44 200 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);");
rlm@44 201 }
rlm@44 202
rlm@44 203
rlm@44 204 if (weirdFlip == 1)
rlm@44 205 {
rlm@44 206 eval("var c = "+target+".getBBox().width;");
rlm@44 207 eval(target+ ".translate((317 - c)/2,0);");
rlm@44 208 eval(target+".translate(0, -490);");
rlm@44 209 eval(target+".rotate(90,0,0);");
rlm@44 210 }
rlm@44 211
rlm@44 212
rlm@44 213
rlm@48 214 prevVal = content;
rlm@48 215
rlm@44 216
rlm@44 217
rlm@44 218 }
rlm@44 219
rlm@44 220 function clearAll()
rlm@44 221 {
rlm@44 222 if(typeof d_Name != 'undefined' ){d_Name.remove();}
rlm@44 223 if(typeof d_Company != 'undefined' ){d_Company.remove();}
rlm@44 224 if(typeof d_Email != 'undefined' ){d_Email.remove();}
rlm@44 225 if(typeof d_Occupation != 'undefined' ){d_Occupation.remove();}
rlm@44 226 if(typeof d_Phone != 'undefined' ){d_Phone.remove();}
rlm@44 227 if(typeof d_Website != 'undefined' ){d_Website.remove();}
rlm@44 228
rlm@44 229 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}
rlm@42 230 }
rlm@42 231
rlm@51 232
rlm@51 233 function lineDraw(style, color)
rlm@51 234 {
rlm@51 235
rlm@51 236
rlm@51 237
rlm@51 238
rlm@51 239
rlm@51 240 if (style == "bold")
rlm@51 241 {return;}
rlm@51 242
rlm@51 243
rlm@51 244
rlm@51 245 if (style == "arrow")
rlm@51 246 {
rlm@51 247 d_lineArt = raphe.path("M 4 272 L 258 272");
rlm@51 248 d_lineArt.attr('stroke', "#" + color);
rlm@51 249 return;
rlm@51 250 }
rlm@51 251
rlm@51 252
rlm@51 253 if (style == "classic")
rlm@51 254 {return;}
rlm@51 255
rlm@51 256
rlm@51 257 if (style == "direct")
rlm@51 258 {
rlm@51 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");
rlm@51 260 d_lineArt.attr('stroke', "#" + color);
rlm@51 261 return;
rlm@51 262 }
rlm@51 263
rlm@51 264 }
rlm@51 265
rlm@51 266
rlm@51 267
rlm@42 268 function redraw(style)
rlm@42 269 {
rlm@42 270
rlm@43 271
rlm@43 272
rlm@43 273
rlm@42 274 if (style == "bold")
rlm@42 275 {
rlm@42 276
rlm@44 277 clearAll();
rlm@44 278 smallRedraw("bold","Name");
rlm@44 279 smallRedraw("bold","Email");
rlm@42 280
rlm@42 281
rlm@42 282
rlm@42 283 }
rlm@42 284
rlm@42 285
rlm@42 286 if (style == "arrow")
rlm@42 287 {
rlm@42 288
rlm@44 289 clearAll();
rlm@42 290
rlm@44 291 smallRedraw("arrow","Name");
rlm@44 292 smallRedraw("arrow","Email");
rlm@44 293 smallRedraw("arrow","Occupation");
rlm@44 294 smallRedraw("arrow","Company");
rlm@42 295
rlm@43 296
rlm@42 297 }
rlm@42 298
rlm@42 299
rlm@42 300 if (style == "classic")
rlm@42 301 {
rlm@42 302
rlm@44 303 clearAll();
rlm@42 304
rlm@44 305 smallRedraw("classic","Name");
rlm@44 306 smallRedraw("classic","Email");
rlm@44 307 smallRedraw("classic","Occupation");
rlm@44 308 smallRedraw("classic","Company");
rlm@44 309 smallRedraw("classic","Phone");
rlm@44 310 smallRedraw("classic","Website");
rlm@42 311 }
rlm@42 312
rlm@42 313
rlm@42 314 if (style == "direct")
rlm@42 315 {
rlm@42 316
rlm@44 317 clearAll();
rlm@42 318
rlm@44 319 smallRedraw("direct","Name");
rlm@44 320 smallRedraw("direct","Email");
rlm@44 321 smallRedraw("direct","Occupation");
rlm@44 322 smallRedraw("direct","Company");
rlm@44 323 smallRedraw("direct","Phone");
rlm@44 324 smallRedraw("direct","Website");
rlm@42 325
rlm@42 326
rlm@42 327 }
rlm@42 328
rlm@51 329 lineDraw(style, "fefefe");
rlm@42 330
rlm@42 331
rlm@42 332
rlm@42 333 }
rlm@42 334
rlm@42 335